For Trino and Presto

Create Trino or Presto metadata and query-history input files that Single Origin can ingest.

Single Origin uses table metadata, column metadata, view definitions, and query logs from Trino or Presto to analyze query behavior and support optimization recommendations.

Required files

Prepare the following files for Single Origin:

FileRequiredDescription
tables.parquetYesTable-level metadata from your storage metadata source.
columns.parquetYesColumn-level metadata from your storage metadata source.
views.parquetYesView definitions and ownership metadata, when available.
query-historys.jsonYesQuery log records from the Trino or Presto query engine.

Prerequisites

  1. Identify the metadata source for the catalogs queried through Trino or Presto.
  2. Enable or locate query logging for your Trino or Presto environment.
  3. Prepare a destination where you can write the Parquet and JSON files for upload to Single Origin.

Generate tables.parquet

Export table-level metadata from the storage metadata source used by your Trino or Presto catalogs.

The file should include:

FieldTypeDescription
table_catalogstringCatalog name.
table_schemastringSchema name.
table_namestringTable name.
table_ownerstringTable owner.
row_countint64Number of rows, when available.
bytesint64Table size in bytes, when available.
commentstringTable comment.
createdint64Creation timestamp.
last_alteredint64Last altered timestamp.

Expected schema:

message TableItem {
  string table_catalog = 1;
  string table_schema = 2;
  string table_name = 3;
  string table_owner = 4;
  int64 row_count = 5;
  int64 bytes = 6;
  string comment = 7;
  int64 created = 8;
  int64 last_altered = 9;
}

Generate columns.parquet

Export column-level metadata from the storage metadata source used by your Trino or Presto catalogs.

The file should include:

FieldTypeDescription
table_catalogstringCatalog name.
table_schemastringSchema name.
table_namestringTable name.
column_namestringColumn name.
ordinal_positionint32Column position in the table.
is_nullablestringWhether the column can contain NULL.
data_typestringTrino or Presto data type.
numeric_precisionbytesNumeric precision, when applicable.
numeric_scalebytesNumeric scale, when applicable.
datetime_precisionbytesDatetime precision, when applicable.

Expected schema:

message schema {
  string table_catalog = 1;
  string table_schema = 2;
  string table_name = 3;
  string column_name = 4;
  int32 ordinal_position = 5;
  string is_nullable = 6;
  string data_type = 7;
  bytes numeric_precision = 8;
  bytes numeric_scale = 9;
  bytes datetime_precision = 10;
}

Generate views.parquet

Export view metadata from the metadata source used by your Trino or Presto catalogs.

The file should include:

FieldTypeDescription
table_catalogstringCatalog name.
table_schemastringSchema name.
table_namestringView name.
view_definitionstringSQL definition for the view.
table_ownerstringView owner.

Expected schema:

message schema {
  string table_catalog = 1;
  string table_schema = 2;
  string table_name = 3;
  string view_definition = 4;
  string table_owner = 5;
}

Generate query-historys.json

Export query-history records from your Trino or Presto query logs.

The public source page uses records from com.github.trino.querylog.QueryLogListener. Include records with query metadata, query context, user information, query ID, SQL text, query state, server details, and query URI.

Example query text from a query-history record:

select * from hive.dw1.flight where count in (10,264)

At minimum, each query-history record should preserve the fields needed to identify:

  • The user and query context.
  • The Trino or Presto server and environment.
  • The query ID.
  • The SQL query text.
  • The query state.
  • The query timestamp.

The filename query-historys.json is intentionally preserved for compatibility with the existing Single Origin import workflow.

Upload the files

After you generate the required files, upload them to Single Origin as input data files.

Before uploading, verify that:

  • The files use the expected names.
  • The exported columns match the field names and types above.
  • query-historys.json contains query records from the time window you want Single Origin to analyze.
  • Query-history records include query IDs, SQL text, user context, query state, and timestamps.