Querying Data in a Paimon Table
Batch query
Paimon's batch read returns all data from a table snapshot. By default, it returns the latest snapshot.
SELECT * FROM my_table;
Metadata Columns
Paimon supports reading hidden metadata columns.
| Metadata Column | Description |
|---|---|
| __paimon_file_path | Path of the data file where the record is located. |
| __paimon_partition | Partition value of the record. |
| __paimon_bucket | Bucket ID of the record. |
| __paimon_row_index | Row index of the record in the data file. |
SELECT *, __paimon_file_path, __paimon_partition, __paimon_bucket, __paimon_row_index FROM t;
Note: Only append-only tables or tables with deletion vectors support querying metadata columns.
Time travel
-- Query by snapshot ID SELECT * FROM t VERSION AS OF 1; -- Query by timestamp SELECT * FROM t TIMESTAMP AS OF '2023-06-01 00:00:00.123'; -- Query by tag SELECT * FROM t VERSION AS OF 'my-tag';
Incremental query
-- Read incremental data between snapshots 12 and 20.
SELECT * FROM paimon_incremental_query('tableName', 12, 20);
-- Read incremental data between two specific timestamps.
SELECT * FROM paimon_incremental_between_timestamp('tableName', '2025-03-12 00:00:00', '2025-03-12 00:08:00'); Query optimization
It is recommended to specify filter conditions for partitions and primary keys during query to accelerate data skipping. Supported filter functions include:
- =, <, <=, >, >=
- IN (...)
- LIKE 'abc%'
- IS NULL
Paimon sorts data by primary key to optimize the performance of point queries and range queries. When using composite primary keys, it is recommended to match the leftmost prefix of the primary key in the query condition to improve query efficiency.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot