22.8. Reading Metadata #
- 22.8.1. Retrieving a Snapshot
- 22.8.2. Retrieving Analytical Tables
- 22.8.3. Retrieving Columns of an Analytical Table
- 22.8.4. Retrieving Filtered Parquet Files
- 22.8.5. Retrieving Analytical Table Statistics
- 22.8.6. Retrieving Analytical Table Column Statistics
- 22.8.7. Retrieving Analytical Table Statistics for a Specific Time Interval
- 22.8.2. Retrieving Analytical Tables
This section describes how to read metadata by querying metadata tables.
22.8.1. Retrieving a Snapshot #
Execute the following command on the server with the metadata catalog:
SELECT * FROM axe_catalog.axe_snapshot WHERE snapshot_id = snapshot_ID;
Where snapshot_ID is the ID of the snapshot that must be retrieved, from the axe_snapshot metadata table.
To retrieve the latest snapshot, execute the following command on the server with the metadata catalog:
SELECT * FROM axe_catalog.axe_snapshot WHERE snapshot_id = (SELECT max(snapshot_id) FROM axe_catalog.axe_snapshot);
22.8.2. Retrieving Analytical Tables #
Execute the following command on the server with the metadata catalog:
SELECT table_id, table_name FROM axe_catalog.axe_table WHERE schema_id =schema_IDANDsnapshot_ID>= begin_snapshot AND (snapshot_ID< end_snapshot OR end_snapshot IS NULL);
Where:
schema_ID: The ID of the schema containing the analytical tables that must be retrieved, from theaxe_schemametadata table.snapshot_ID: The ID of the snapshot associated with the required time period, from theaxe_snapshotmetadata table.
22.8.3. Retrieving Columns of an Analytical Table #
Execute the following command on the server with the metadata catalog:
SELECT column_id, column_name, column_type
FROM axe_catalog.axe_column
WHERE
table_id = table_ID AND
snapshot_ID >= begin_snapshot AND
(snapshot_ID < end_snapshot OR end_snapshot IS NULL)
ORDER BY column_order;
Where:
table_ID: The ID of the analytical table containing the column that must be retrieved, from theaxe_tablemetadata table.snapshot_ID: The ID of the snapshot associated with the required time period, from theaxe_snapshotmetadata table.
22.8.4. Retrieving Filtered Parquet Files #
You can retrieve Parquet files after retrieving columns of an analytical table. The files can be filtered using statistics from the axe_file_column_stats metadata table.
Execute the following command on the server with the metadata catalog:
SELECT data_file_id
FROM axe_catalog.axe_file_column_stats
WHERE
table_id = table_ID AND
column_id = column_ID AND
(scalar_value >= min_value OR min_value IS NULL) AND
(scalar_value <= max_value OR max_value IS NULL);
Where:
table_ID: The ID of the analytical table containing the Parquet files that must be retrieved, from theaxe_tablemetadata table.column_ID: The ID of the column whose values are used for filtering the Parquet files, from theaxe_columnmetadata table.scalar_value: The value used for filtering the Parquet files. Only Parquet files whose range of column values includes this value are retrieved.
You can filter column values using different conditions, such as "greater than (>)", by updating the command accordingly. The minimum and maximum column values are stored as strings, so they must be converted to the data type of the filtered column before comparison.
22.8.5. Retrieving Analytical Table Statistics #
Execute the following command on the server with the metadata catalog:
SELECT s1.record_count, s1.file_size_bytes FROM axe_catalog.axe_table_stats s1, axe_catalog.axe_table t1 WHERE s1.table_id = t1.table_id
AND t1.table_name='table_name';
Where table_name is the name of the analytical table for which the statistics must be retrieved, from the axe_table metadata table.
22.8.6. Retrieving Analytical Table Column Statistics #
Execute the following command on the server with the metadata catalog:
SELECT c1.column_name, s1.contains_null, s1.min_value, s1.max_value
FROM axe_catalog.axe_column c1, axe_catalog.axe_table_column_stats s1, axe_catalog.axe_table t1
WHERE c1.table_id = t1.table_id AND t1.table_name = 'table_name' AND s1.column_id = c1.column_id;
Where table_name is the name of the analytical table for which the column statistics must be retrieved, from the axe_table metadata table.
22.8.7. Retrieving Analytical Table Statistics for a Specific Time Interval #
On the server with the metadata catalog, retrieve paths to the Parquet files added to the analytical table within a specific time interval:
SELECT array_agg(t1.path) FROM axe_catalog.axe_data_file t1, axe_catalog.axe_table t2, axe_catalog.axe_snapshot t3 WHERE t1.end_snapshot IS NULL AND t1.table_id = t2.table_id AND t2.end_snapshot IS NULL AND t2.table_name = '
table_name' AND t1.begin_snapshot = t3.snapshot_id AND t3.snapshot_time > timestamptz 'start_date_and_time' AND t3.snapshot_time < timestamptz 'end_date_and_time';Where:
table_name: The name of the analytical table for which the Parquet files must be retrieved, from theaxe_tablemetadata table.start_date_and_timeandend_date_and_time: The start and end date and time for retrieving the Parquet files.
On the Postgres Pro AXE server, query the retrieved Parquet files to calculate the analytical table statistics:
SELECT COUNT(*) FROM read_parquet(['
path_to_file_1', 'path_to_file_N']);Where
path_to_file_1andpath_to_file_Nare paths to the retrieved Parquet files.