diff --git a/docs/content/concepts/append-table/append-queue-table.md b/docs/content/concepts/append-table/append-queue-table.md index c2aa0cdd7fcad..37860b774f60c 100644 --- a/docs/content/concepts/append-table/append-queue-table.md +++ b/docs/content/concepts/append-table/append-queue-table.md @@ -96,7 +96,7 @@ For streaming reads, records are produced in the following order: You can define watermark for reading Paimon tables: ```sql -CREATE TABLE T ( +CREATE TABLE t ( `user` BIGINT, product STRING, order_time TIMESTAMP(3), @@ -105,7 +105,7 @@ CREATE TABLE T ( -- launch a bounded streaming job to read paimon_table SELECT window_start, window_end, COUNT(`user`) FROM TABLE( - TUMBLE(TABLE T, DESCRIPTOR(order_time), INTERVAL '10' MINUTES)) GROUP BY window_start, window_end; + TUMBLE(TABLE t, DESCRIPTOR(order_time), INTERVAL '10' MINUTES)) GROUP BY window_start, window_end; ``` You can also enable [Flink Watermark alignment](https://nightlies.apache.org/flink/flink-docs-stable/docs/dev/datastream/event-time/generating_watermarks/#watermark-alignment-_beta_), @@ -168,7 +168,7 @@ The following is an example of creating the Append table and specifying the buck {{< tab "Flink" >}} ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( product_id BIGINT, price DOUBLE, sales BIGINT diff --git a/docs/content/concepts/append-table/append-scalable-table.md b/docs/content/concepts/append-table/append-scalable-table.md index 21c1636ff8a5b..f83f1cd6792db 100644 --- a/docs/content/concepts/append-table/append-scalable-table.md +++ b/docs/content/concepts/append-table/append-scalable-table.md @@ -101,7 +101,7 @@ The following is an example of creating the Append table and specifying the buck {{< tab "Flink" >}} ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( product_id BIGINT, price DOUBLE, sales BIGINT diff --git a/docs/content/concepts/primary-key-table/merge-engine.md b/docs/content/concepts/primary-key-table/merge-engine.md index daa455507a25a..1f29275d818bd 100644 --- a/docs/content/concepts/primary-key-table/merge-engine.md +++ b/docs/content/concepts/primary-key-table/merge-engine.md @@ -76,7 +76,7 @@ So we introduce sequence group mechanism for partial-update tables. It can solve See example: ```sql -CREATE TABLE T ( +CREATE TABLE t ( k INT, a INT, b INT, @@ -91,17 +91,17 @@ CREATE TABLE T ( 'fields.g_2.sequence-group'='c,d' ); -INSERT INTO T VALUES (1, 1, 1, 1, 1, 1, 1); +INSERT INTO t VALUES (1, 1, 1, 1, 1, 1, 1); -- g_2 is null, c, d should not be updated -INSERT INTO T VALUES (1, 2, 2, 2, 2, 2, CAST(NULL AS INT)); +INSERT INTO t VALUES (1, 2, 2, 2, 2, 2, CAST(NULL AS INT)); -SELECT * FROM T; -- output 1, 2, 2, 2, 1, 1, 1 +SELECT * FROM t; -- output 1, 2, 2, 2, 1, 1, 1 -- g_1 is smaller, a, b should not be updated -INSERT INTO T VALUES (1, 3, 3, 1, 3, 3, 3); +INSERT INTO t VALUES (1, 3, 3, 1, 3, 3, 3); -SELECT * FROM T; -- output 1, 2, 2, 2, 3, 3, 3 +SELECT * FROM t; -- output 1, 2, 2, 2, 3, 3, 3 ``` For `fields..sequence-group`, valid comparative data types include: DECIMAL, TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, DATE, TIME, TIMESTAMP, and TIMESTAMP_LTZ. @@ -113,7 +113,7 @@ You can specify aggregation function for the input field, all the functions in t See example: ```sql -CREATE TABLE T ( +CREATE TABLE t ( k INT, a INT, b INT, @@ -127,13 +127,13 @@ CREATE TABLE T ( 'fields.c.sequence-group' = 'd', 'fields.d.aggregate-function' = 'sum' ); -INSERT INTO T VALUES (1, 1, 1, CAST(NULL AS INT), CAST(NULL AS INT)); -INSERT INTO T VALUES (1, CAST(NULL AS INT), CAST(NULL AS INT), 1, 1); -INSERT INTO T VALUES (1, 2, 2, CAST(NULL AS INT), CAST(NULL AS INT)); -INSERT INTO T VALUES (1, CAST(NULL AS INT), CAST(NULL AS INT), 2, 2); +INSERT INTO t VALUES (1, 1, 1, CAST(NULL AS INT), CAST(NULL AS INT)); +INSERT INTO t VALUES (1, CAST(NULL AS INT), CAST(NULL AS INT), 1, 1); +INSERT INTO t VALUES (1, 2, 2, CAST(NULL AS INT), CAST(NULL AS INT)); +INSERT INTO t VALUES (1, CAST(NULL AS INT), CAST(NULL AS INT), 2, 2); -SELECT * FROM T; -- output 1, 2, 1, 2, 3 +SELECT * FROM t; -- output 1, 2, 1, 2, 3 ``` ## Aggregation @@ -151,7 +151,7 @@ Each field not part of the primary keys can be given an aggregate function, spec {{< tab "Flink" >}} ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( product_id BIGINT, price DOUBLE, sales BIGINT, diff --git a/docs/content/concepts/primary-key-table/sequence-rowkind.md b/docs/content/concepts/primary-key-table/sequence-rowkind.md index 8333424a2140f..fd50155d58df7 100644 --- a/docs/content/concepts/primary-key-table/sequence-rowkind.md +++ b/docs/content/concepts/primary-key-table/sequence-rowkind.md @@ -37,7 +37,7 @@ there will be some cases that lead to data disorder. At this time, you can use a {{< tabs "sequence.field" >}} {{< tab "Flink" >}} ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( pk BIGINT PRIMARY KEY NOT ENFORCED, v1 DOUBLE, v2 BIGINT, diff --git a/docs/content/how-to/altering-tables.md b/docs/content/how-to/altering-tables.md index 573fb41f473ee..ce9ca73d79917 100644 --- a/docs/content/how-to/altering-tables.md +++ b/docs/content/how-to/altering-tables.md @@ -280,11 +280,11 @@ The following SQL drops the partitions of the paimon table. For flink sql, you can specify the partial columns of partition columns, and you can also specify multiple partition values at the same time. ```sql -ALTER TABLE MyTable DROP PARTITION (`id` = 1); +ALTER TABLE my_table DROP PARTITION (`id` = 1); -ALTER TABLE MyTable DROP PARTITION (`id` = 1, `name` = 'paimon'); +ALTER TABLE my_table DROP PARTITION (`id` = 1, `name` = 'paimon'); -ALTER TABLE MyTable DROP PARTITION (`id` = 1), PARTITION (`id` = 2); +ALTER TABLE my_table DROP PARTITION (`id` = 1), PARTITION (`id` = 2); ``` @@ -295,7 +295,7 @@ ALTER TABLE MyTable DROP PARTITION (`id` = 1), PARTITION (`id` = 2); For spark sql, you need to specify all the partition columns. ```sql -ALTER TABLE MyTable DROP PARTITION (`id` = 1, `name` = 'paimon'); +ALTER TABLE my_table DROP PARTITION (`id` = 1, `name` = 'paimon'); ``` {{< /tab >}} diff --git a/docs/content/how-to/creating-tables.md b/docs/content/how-to/creating-tables.md index ed7e71c04bd5d..0a01662a07218 100644 --- a/docs/content/how-to/creating-tables.md +++ b/docs/content/how-to/creating-tables.md @@ -30,14 +30,14 @@ under the License. Tables created in Paimon [catalogs]({{< ref "how-to/creating-catalogs" >}}) are managed by the catalog. When the table is dropped from catalog, its table files will also be deleted. -The following SQL assumes that you have registered and are using a Paimon catalog. It creates a managed table named `MyTable` with five columns in the catalog's `default` database, where `dt`, `hh` and `user_id` are the primary keys. +The following SQL assumes that you have registered and are using a Paimon catalog. It creates a managed table named `my_table` with five columns in the catalog's `default` database, where `dt`, `hh` and `user_id` are the primary keys. {{< tabs "primary-keys-example" >}} {{< tab "Flink" >}} ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT, behavior STRING, @@ -52,7 +52,7 @@ CREATE TABLE MyTable ( {{< tab "Spark3" >}} ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT, behavior STRING, @@ -70,7 +70,7 @@ CREATE TABLE MyTable ( ```sql SET hive.metastore.warehouse.dir=warehouse_path; -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT, behavior STRING, @@ -88,7 +88,7 @@ TBLPROPERTIES ( {{< tab "Trino" >}} ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT, behavior VARCHAR, @@ -104,7 +104,7 @@ CREATE TABLE MyTable ( {{< tab "Presto" >}} ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT, behavior VARCHAR, @@ -125,14 +125,14 @@ Inserting jobs on the table should be stopped prior to dropping tables, or table ### Partitioned Tables -The following SQL creates a table named `MyTable` with five columns partitioned by `dt` and `hh`, where `dt`, `hh` and `user_id` are the primary keys. +The following SQL creates a table named `my_table` with five columns partitioned by `dt` and `hh`, where `dt`, `hh` and `user_id` are the primary keys. {{< tabs "partitions-example" >}} {{< tab "Flink" >}} ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT, behavior STRING, @@ -147,7 +147,7 @@ CREATE TABLE MyTable ( {{< tab "Spark3" >}} ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT, behavior STRING, @@ -165,7 +165,7 @@ CREATE TABLE MyTable ( ```sql SET hive.metastore.warehouse.dir=warehouse_path; -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT, behavior STRING @@ -184,7 +184,7 @@ TBLPROPERTIES ( {{< tab "Trino" >}} ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT, behavior VARCHAR, @@ -201,7 +201,7 @@ CREATE TABLE MyTable ( {{< tab "Presto" >}} ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT, behavior VARCHAR, @@ -258,7 +258,7 @@ note that partition fields and primary key fields can not be specified. {{< tab "Flink" >}} ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT, behavior STRING, @@ -276,7 +276,7 @@ with( {{< tab "Spark3" >}} ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT, behavior STRING, @@ -295,7 +295,7 @@ CREATE TABLE MyTable ( ```sql SET hive.metastore.warehouse.dir=warehouse_path; -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT, behavior STRING, @@ -331,31 +331,31 @@ We can specify the primary key or partition when use `CREATE TABLE AS SELECT`, f /* For streaming mode, you need to enable the checkpoint. */ -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT ); -CREATE TABLE MyTableAs AS SELECT * FROM MyTable; +CREATE TABLE my_table As AS SELECT * FROM my_table; /* partitioned table */ -CREATE TABLE MyTablePartition ( +CREATE TABLE my_table_partition ( user_id BIGINT, item_id BIGINT, behavior STRING, dt STRING, hh STRING ) PARTITIONED BY (dt, hh); -CREATE TABLE MyTablePartitionAs WITH ('partition' = 'dt') AS SELECT * FROM MyTablePartition; +CREATE TABLE my_table_partition As WITH ('partition' = 'dt') AS SELECT * FROM my_table_partition; /* change options */ -CREATE TABLE MyTableOptions ( +CREATE TABLE my_table_options ( user_id BIGINT, item_id BIGINT ) WITH ('file.format' = 'orc'); -CREATE TABLE MyTableOptionsAs WITH ('file.format' = 'parquet') AS SELECT * FROM MyTableOptions; +CREATE TABLE my_table_options As WITH ('file.format' = 'parquet') AS SELECT * FROM my_table_options; /* primary key */ -CREATE TABLE MyTablePk ( +CREATE TABLE my_table_pk ( user_id BIGINT, item_id BIGINT, behavior STRING, @@ -363,11 +363,11 @@ CREATE TABLE MyTablePk ( hh STRING, PRIMARY KEY (dt, hh, user_id) NOT ENFORCED ); -CREATE TABLE MyTablePkAs WITH ('primary-key' = 'dt,hh') AS SELECT * FROM MyTablePk; +CREATE TABLE my_table_pk As WITH ('primary-key' = 'dt,hh') AS SELECT * FROM my_table_pk; /* primary key + partition */ -CREATE TABLE MyTableAll ( +CREATE TABLE my_table_all ( user_id BIGINT, item_id BIGINT, behavior STRING, @@ -375,7 +375,7 @@ CREATE TABLE MyTableAll ( hh STRING, PRIMARY KEY (dt, hh, user_id) NOT ENFORCED ) PARTITIONED BY (dt, hh); -CREATE TABLE MyTableAllAs WITH ('primary-key' = 'dt,hh', 'partition' = 'dt') AS SELECT * FROM MyTableAll; +CREATE TABLE my_table_all As WITH ('primary-key' = 'dt,hh', 'partition' = 'dt') AS SELECT * FROM my_table_all; ``` {{< /tab >}} @@ -383,32 +383,32 @@ CREATE TABLE MyTableAllAs WITH ('primary-key' = 'dt,hh', 'partition' = 'dt') AS {{< tab "Spark3" >}} ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT ); -CREATE TABLE MyTableAs AS SELECT * FROM MyTable; +CREATE TABLE my_table As AS SELECT * FROM my_table; /* partitioned table*/ -CREATE TABLE MyTablePartition ( +CREATE TABLE my_table_partition ( user_id BIGINT, item_id BIGINT, behavior STRING, dt STRING, hh STRING ) PARTITIONED BY (dt, hh); -CREATE TABLE MyTablePartitionAs PARTITIONED BY (dt) AS SELECT * FROM MyTablePartition; +CREATE TABLE my_table_partition As PARTITIONED BY (dt) AS SELECT * FROM my_table_partition; /* change TBLPROPERTIES */ -CREATE TABLE MyTableOptions ( +CREATE TABLE my_table_options ( user_id BIGINT, item_id BIGINT ) TBLPROPERTIES ('file.format' = 'orc'); -CREATE TABLE MyTableOptionsAs TBLPROPERTIES ('file.format' = 'parquet') AS SELECT * FROM MyTableOptions; +CREATE TABLE my_table_options As TBLPROPERTIES ('file.format' = 'parquet') AS SELECT * FROM my_table_options; /* primary key */ -CREATE TABLE MyTablePk ( +CREATE TABLE my_table_pk ( user_id BIGINT, item_id BIGINT, behavior STRING, @@ -417,10 +417,10 @@ CREATE TABLE MyTablePk ( ) TBLPROPERTIES ( 'primary-key' = 'dt,hh,user_id' ); -CREATE TABLE MyTablePkAs TBLPROPERTIES ('primary-key' = 'dt') AS SELECT * FROM MyTablePk; +CREATE TABLE my_table_pk As TBLPROPERTIES ('primary-key' = 'dt') AS SELECT * FROM my_table_pk; /* primary key + partition */ -CREATE TABLE MyTableAll ( +CREATE TABLE my_table_all ( user_id BIGINT, item_id BIGINT, behavior STRING, @@ -429,7 +429,7 @@ CREATE TABLE MyTableAll ( ) PARTITIONED BY (dt, hh) TBLPROPERTIES ( 'primary-key' = 'dt,hh,user_id' ); -CREATE TABLE MyTableAllAs PARTITIONED BY (dt) TBLPROPERTIES ('primary-key' = 'dt,hh') AS SELECT * FROM MyTableAll; +CREATE TABLE my_table_all As PARTITIONED BY (dt) TBLPROPERTIES ('primary-key' = 'dt,hh') AS SELECT * FROM my_table_all; ``` {{< /tab >}} @@ -446,7 +446,7 @@ CREATE TABLE MyTableAllAs PARTITIONED BY (dt) TBLPROPERTIES ('primary-key' = 'dt To create a table with the same schema, partition, and table properties as another table, use CREATE TABLE LIKE. ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT, behavior STRING, @@ -455,10 +455,10 @@ CREATE TABLE MyTable ( PRIMARY KEY (dt, hh, user_id) NOT ENFORCED ); -CREATE TABLE MyTableLike LIKE MyTable; +CREATE TABLE my_table_like LIKE my_table; -- Create Paimon Table like other connector table -CREATE TABLE MyTableLike WITH ('connector' = 'paimon') LIKE MyTable; +CREATE TABLE my_table_like WITH ('connector' = 'paimon') LIKE my_table; ``` {{< /tab >}} @@ -469,14 +469,14 @@ CREATE TABLE MyTableLike WITH ('connector' = 'paimon') LIKE MyTable; Users can specify table properties to enable features or improve performance of Paimon. For a complete list of such properties, see [configurations]({{< ref "maintenance/configurations" >}}). -The following SQL creates a table named `MyTable` with five columns partitioned by `dt` and `hh`, where `dt`, `hh` and `user_id` are the primary keys. This table has two properties: `'bucket' = '2'` and `'bucket-key' = 'user_id'`. +The following SQL creates a table named `my_table` with five columns partitioned by `dt` and `hh`, where `dt`, `hh` and `user_id` are the primary keys. This table has two properties: `'bucket' = '2'` and `'bucket-key' = 'user_id'`. {{< tabs "table-properties-example" >}} {{< tab "Flink" >}} ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT, behavior STRING, @@ -494,7 +494,7 @@ CREATE TABLE MyTable ( {{< tab "Spark3" >}} ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT, behavior STRING, @@ -512,7 +512,7 @@ CREATE TABLE MyTable ( {{< tab "Hive" >}} ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT, behavior STRING, @@ -533,7 +533,7 @@ TBLPROPERTIES ( {{< tab "Trino" >}} ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT, behavior VARCHAR, @@ -552,7 +552,7 @@ CREATE TABLE MyTable ( {{< tab "Presto" >}} ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT, behavior VARCHAR, @@ -588,10 +588,10 @@ Paimon external tables can be used in any catalog. If you do not want to create Please **DO NOT** use this mode. We recommend using the Paimon Catalog way. The current reservation is only for compatibility. {{< /hint >}} -Flink SQL supports reading and writing an external table. External Paimon tables are created by specifying the `connector` and `path` table properties. The following SQL creates an external table named `MyTable` with five columns, where the base path of table files is `hdfs:///path/to/table`. +Flink SQL supports reading and writing an external table. External Paimon tables are created by specifying the `connector` and `path` table properties. The following SQL creates an external table named `my_table` with five columns, where the base path of table files is `hdfs:///path/to/table`. ```sql -CREATE TABLE MyTable ( +CREATE TABLE my_table ( user_id BIGINT, item_id BIGINT, behavior STRING, diff --git a/docs/content/how-to/lookup-joins.md b/docs/content/how-to/lookup-joins.md index 34973bdc167f1..e0dba4c591aae 100644 --- a/docs/content/how-to/lookup-joins.md +++ b/docs/content/how-to/lookup-joins.md @@ -55,7 +55,7 @@ CREATE TABLE customers ( INSERT INTO customers ... -- Create a temporary left table, like from kafka -CREATE TEMPORARY TABLE Orders ( +CREATE TEMPORARY TABLE orders ( order_id INT, total INT, customer_id INT, @@ -76,7 +76,7 @@ You can now use `customers` in a lookup join query. ```sql -- enrich each order with customer information SELECT o.order_id, o.total, c.country, c.zip -FROM Orders AS o +FROM orders AS o JOIN customers FOR SYSTEM_TIME AS OF o.proc_time AS c ON o.customer_id = c.id; @@ -84,7 +84,7 @@ ON o.customer_id = c.id; ## Retry Lookup -If the records of `Orders` (main table) join missing because the corresponding data of `customers` (lookup table) is not ready. +If the records of `orders` (main table) join missing because the corresponding data of `customers` (lookup table) is not ready. You can consider using Flink's [Delayed Retry Strategy For Lookup](https://nightlies.apache.org/flink/flink-docs-stable/docs/dev/table/sql/queries/hints/#3-enable-delayed-retry-strategy-for-lookup). Only for Flink 1.16+. @@ -92,7 +92,7 @@ Only for Flink 1.16+. -- enrich each order with customer information SELECT /*+ LOOKUP('table'='c', 'retry-predicate'='lookup_miss', 'retry-strategy'='fixed_delay', 'fixed-delay'='1s', 'max-attempts'='600') */ o.order_id, o.total, c.country, c.zip -FROM Orders AS o +FROM orders AS o JOIN customers FOR SYSTEM_TIME AS OF o.proc_time AS c ON o.customer_id = c.id; @@ -108,14 +108,14 @@ other records. -- enrich each order with customer information SELECT /*+ LOOKUP('table'='c', 'retry-predicate'='lookup_miss', 'output-mode'='allow_unordered', 'retry-strategy'='fixed_delay', 'fixed-delay'='1s', 'max-attempts'='600') */ o.order_id, o.total, c.country, c.zip -FROM Orders AS o +FROM orders AS o JOIN customers /*+ OPTIONS('lookup.async'='true', 'lookup.async-thread-number'='16') */ FOR SYSTEM_TIME AS OF o.proc_time AS c ON o.customer_id = c.id; ``` {{< hint info >}} -If the main table (`Orders`) is CDC stream, `allow_unordered` will be ignored by Flink SQL (only supports append stream), +If the main table (`orders`) is CDC stream, `allow_unordered` will be ignored by Flink SQL (only supports append stream), your streaming job may be blocked. You can try to use `audit_log` system table feature of Paimon to walk around (convert CDC stream to append stream). {{< /hint >}} diff --git a/docs/content/how-to/system-tables.md b/docs/content/how-to/system-tables.md index 5ee01ffcc445d..2efecf070333e 100644 --- a/docs/content/how-to/system-tables.md +++ b/docs/content/how-to/system-tables.md @@ -34,7 +34,7 @@ Currently, Flink, Spark and Trino supports querying system tables. In some cases, the table name needs to be enclosed with back quotes to avoid syntax parsing conflicts, for example triple access mode: ```sql -SELECT * FROM my_catalog.my_db.`MyTable$snapshots`; +SELECT * FROM my_catalog.my_db.`my_table$snapshots`; ``` ### Snapshots Table @@ -42,7 +42,7 @@ SELECT * FROM my_catalog.my_db.`MyTable$snapshots`; You can query the snapshot history information of the table through snapshots table, including the record count occurred in the snapshot. ```sql -SELECT * FROM MyTable$snapshots; +SELECT * FROM my_table$snapshots; /* +--------------+------------+-----------------+-------------------+--------------+-------------------------+--------------------------------+------------------------------- +--------------------------------+---------------------+---------------------+-------------------------+-------------------+--------------------+----------------+ @@ -62,7 +62,7 @@ By querying the snapshots table, you can know the commit and expiration informat You can query the historical schemas of the table through schemas table. ```sql -SELECT * FROM MyTable$schemas; +SELECT * FROM my_table$schemas; /* +-----------+--------------------------------+----------------+--------------+---------+---------+-------------------------+ @@ -80,7 +80,7 @@ You can join the snapshots table and schemas table to get the fields of given sn ```sql SELECT s.snapshot_id, t.schema_id, t.fields - FROM MyTable$snapshots s JOIN MyTable$schemas t + FROM my_table$snapshots s JOIN my_table$schemas t ON s.schema_id=t.schema_id where s.snapshot_id=100; ``` @@ -89,7 +89,7 @@ SELECT s.snapshot_id, t.schema_id, t.fields You can query the table's option information which is specified from the DDL through options table. The options not shown will be the default value. You can take reference to [Configuration]({{< ref "maintenance/configurations#coreoptions" >}}). ```sql -SELECT * FROM MyTable$options; +SELECT * FROM my_table$options; /* +------------------------+--------------------+ @@ -114,7 +114,7 @@ There are four values for `rowkind`: - `-D`: Deletion operation. ```sql -SELECT * FROM MyTable$audit_log; +SELECT * FROM my_table$audit_log; /* +------------------+-----------------+-----------------+ @@ -150,7 +150,7 @@ For append tables, as all files can be read without merging, `ro` system table acts like the normal append table. ```sql -SELECT * FROM MyTable$ro; +SELECT * FROM my_table$ro; ``` ### Files Table @@ -158,7 +158,7 @@ You can query the files of the table with specific snapshot. ```sql -- Query the files of latest snapshot -SELECT * FROM MyTable$files; +SELECT * FROM my_table$files; /* +-----------+--------+--------------------------------+-------------+-----------+-------+--------------+--------------------+---------+---------+------------------------+-------------------------+-------------------------+---------------------+---------------------+-----------------------+ @@ -175,7 +175,7 @@ SELECT * FROM MyTable$files; */ -- You can also query the files with specific snapshot -SELECT * FROM MyTable$files /*+ OPTIONS('scan.snapshot-id'='1') */; +SELECT * FROM my_table$files /*+ OPTIONS('scan.snapshot-id'='1') */; /* +-----------+--------+--------------------------------+-------------+-----------+-------+--------------+--------------------+---------+---------+------------------------+-------------------------+-------------------------+---------------------+---------------------+-----------------------+ @@ -195,7 +195,7 @@ You can query the tag history information of the table through tags table, inclu and some historical information of the snapshots. You can also get all tag names and time travel to a specific tag data by name. ```sql -SELECT * FROM MyTable$tags; +SELECT * FROM my_table$tags; /* +----------+-------------+-----------+-------------------------+--------------+--------------+ @@ -213,7 +213,7 @@ SELECT * FROM MyTable$tags; You can query all consumers which contains next snapshot. ```sql -SELECT * FROM MyTable$consumers; +SELECT * FROM my_table$consumers; /* +-------------+------------------+ @@ -232,7 +232,7 @@ You can query all manifest files contained in the latest snapshot or the specifi ```sql -- Query the manifest of latest snapshot -SELECT * FROM MyTable$manifests; +SELECT * FROM my_table$manifests; /* +--------------------------------+-------------+------------------+-------------------+---------------+ @@ -245,7 +245,7 @@ SELECT * FROM MyTable$manifests; */ -- You can also query the manifest with specified snapshot -SELECT * FROM MyTable$manifests /*+ OPTIONS('scan.snapshot-id'='1') */; +SELECT * FROM my_table$manifests /*+ OPTIONS('scan.snapshot-id'='1') */; /* +--------------------------------+-------------+------------------+-------------------+---------------+ | file_name | file_size | num_added_files | num_deleted_files | schema_id | @@ -261,7 +261,7 @@ SELECT * FROM MyTable$manifests /*+ OPTIONS('scan.snapshot-id'='1') */; You can query the historical aggregation of the table through aggregation fields table. ```sql -SELECT * FROM MyTable$aggregation_fields; +SELECT * FROM my_table$aggregation_fields; /* +------------+-----------------+--------------+--------------------------------+---------+ @@ -280,7 +280,7 @@ SELECT * FROM MyTable$aggregation_fields; You can query the partition files of the table. ```sql -SELECT * FROM MyTable$partitions; +SELECT * FROM my_table$partitions; /* +---------------+----------------+--------------------+ diff --git a/docs/content/how-to/writing-tables.md b/docs/content/how-to/writing-tables.md index d42c1ce833acb..c70ae79bd48ea 100644 --- a/docs/content/how-to/writing-tables.md +++ b/docs/content/how-to/writing-tables.md @@ -86,7 +86,7 @@ we have a column key1 in table A which is primary key, primary key cannot be nul which is nullable. If we run a sql like this: ``` sql -INSERT INTO A key1 SELECT key2 FROM B +INSERT INTO a key1 SELECT key2 FROM b ``` We will catch an exception, - In spark: "Cannot write nullable values to non-null column 'key1'." @@ -96,7 +96,7 @@ Other engines will throw respective exception to announce this. We can use funct turn a nullable column into a non-null column to escape exception: ```sql -INSERT INTO A key1 SELECT COALESCE(key2, ) FROM B; +INSERT INTO a key1 SELECT COALESCE(key2, ) FROM b; ``` ## Applying Records/Changes to Tables @@ -108,7 +108,7 @@ INSERT INTO A key1 SELECT COALESCE(key2, ) FROM B; Use `INSERT INTO` to apply records and changes to tables. ```sql -INSERT INTO MyTable SELECT ... +INSERT INTO my_table SELECT ... ``` Paimon supports shuffle data by partition and bucket in sink phase. @@ -120,7 +120,7 @@ Paimon supports shuffle data by partition and bucket in sink phase. Use `INSERT INTO` to apply records and changes to tables. ```sql -INSERT INTO MyTable SELECT ... +INSERT INTO my_table SELECT ... ``` {{< /tab >}} @@ -144,7 +144,7 @@ Use `INSERT OVERWRITE` to overwrite the whole unpartitioned table. {{< tab "Flink" >}} ```sql -INSERT OVERWRITE MyTable SELECT ... +INSERT OVERWRITE my_table SELECT ... ``` {{< /tab >}} @@ -152,7 +152,7 @@ INSERT OVERWRITE MyTable SELECT ... {{< tab "Spark" >}} ```sql -INSERT OVERWRITE MyTable SELECT ... +INSERT OVERWRITE my_table SELECT ... ``` {{< /tab >}} @@ -170,7 +170,7 @@ Use `INSERT OVERWRITE` to overwrite a partition. {{< tab "Flink" >}} ```sql -INSERT OVERWRITE MyTable PARTITION (key1 = value1, key2 = value2, ...) SELECT ... +INSERT OVERWRITE my_table PARTITION (key1 = value1, key2 = value2, ...) SELECT ... ``` {{< /tab >}} @@ -178,7 +178,7 @@ INSERT OVERWRITE MyTable PARTITION (key1 = value1, key2 = value2, ...) SELECT .. {{< tab "Spark" >}} ```sql -INSERT OVERWRITE MyTable PARTITION (key1 = value1, key2 = value2, ...) SELECT ... +INSERT OVERWRITE my_table PARTITION (key1 = value1, key2 = value2, ...) SELECT ... ``` {{< /tab >}} @@ -198,10 +198,10 @@ appear in the overwritten data). You can configure `dynamic-partition-overwrite` -- MyTable is a Partitioned Table -- Dynamic overwrite -INSERT OVERWRITE MyTable SELECT ... +INSERT OVERWRITE my_table SELECT ... -- Static overwrite (Overwrite whole table) -INSERT OVERWRITE MyTable /*+ OPTIONS('dynamic-partition-overwrite' = 'false') */ SELECT ... +INSERT OVERWRITE my_table /*+ OPTIONS('dynamic-partition-overwrite' = 'false') */ SELECT ... ``` {{< /tab >}} @@ -218,11 +218,11 @@ Spark's default overwrite mode is static partition overwrite. To enable dynamic -- MyTable is a Partitioned Table -- Static overwrite (Overwrite whole table) -INSERT OVERWRITE MyTable SELECT ... +INSERT OVERWRITE my_table SELECT ... -- Dynamic overwrite SET spark.sql.sources.partitionOverwriteMode=dynamic; -INSERT OVERWRITE MyTable SELECT ... +INSERT OVERWRITE my_table SELECT ... ``` {{< /tab >}} @@ -238,7 +238,7 @@ INSERT OVERWRITE MyTable SELECT ... You can use `INSERT OVERWRITE` to purge tables by inserting empty value. ```sql -INSERT OVERWRITE MyTable /*+ OPTIONS('dynamic-partition-overwrite'='false') */ SELECT * FROM MyTable WHERE false; +INSERT OVERWRITE my_table /*+ OPTIONS('dynamic-partition-overwrite'='false') */ SELECT * FROM my_table WHERE false; ``` {{< /tab >}} @@ -246,7 +246,7 @@ INSERT OVERWRITE MyTable /*+ OPTIONS('dynamic-partition-overwrite'='false') */ S {{< tab "Flink 1.18" >}} ```sql -TRUNCATE TABLE MyTable; +TRUNCATE TABLE my_table; ``` {{< /tab >}} @@ -254,7 +254,7 @@ TRUNCATE TABLE MyTable; {{< tab "Spark" >}} ```sql -TRUNCATE TABLE MyTable; +TRUNCATE TABLE my_table; ``` {{< /tab >}} @@ -276,24 +276,24 @@ Currently, Paimon supports two ways to purge partitions. ```sql -- Syntax -INSERT OVERWRITE MyTable /*+ OPTIONS('dynamic-partition-overwrite'='false') */ -PARTITION (key1 = value1, key2 = value2, ...) SELECT selectSpec FROM MyTable WHERE false; +INSERT OVERWRITE my_table /*+ OPTIONS('dynamic-partition-overwrite'='false') */ +PARTITION (key1 = value1, key2 = value2, ...) SELECT selectSpec FROM my_table WHERE false; -- The following SQL is an example: -- table definition -CREATE TABLE MyTable ( +CREATE TABLE my_table ( k0 INT, k1 INT, v STRING ) PARTITIONED BY (k0, k1); -- you can use -INSERT OVERWRITE MyTable /*+ OPTIONS('dynamic-partition-overwrite'='false') */ -PARTITION (k0 = 0) SELECT k1, v FROM MyTable WHERE false; +INSERT OVERWRITE my_table /*+ OPTIONS('dynamic-partition-overwrite'='false') */ +PARTITION (k0 = 0) SELECT k1, v FROM my_table WHERE false; -- or -INSERT OVERWRITE MyTable /*+ OPTIONS('dynamic-partition-overwrite'='false') */ -PARTITION (k0 = 0, k1 = 0) SELECT v FROM MyTable WHERE false; +INSERT OVERWRITE my_table /*+ OPTIONS('dynamic-partition-overwrite'='false') */ +PARTITION (k0 = 0, k1 = 0) SELECT v FROM my_table WHERE false; ``` {{< /tab >}} @@ -352,7 +352,7 @@ UPDATE table_identifier SET column1 = value1, column2 = value2, ... WHERE condit -- The following SQL is an example: -- table definition -CREATE TABLE MyTable ( +CREATE TABLE my_table ( a STRING, b INT, c INT, @@ -362,7 +362,7 @@ CREATE TABLE MyTable ( ); -- you can use -UPDATE MyTable SET b = 1, c = 2 WHERE a = 'myTable'; +UPDATE my_table SET b = 1, c = 2 WHERE a = 'myTable'; ``` {{< /tab >}} @@ -381,7 +381,7 @@ spark supports update PrimitiveType and StructType, for example: -- Syntax UPDATE table_identifier SET column1 = value1, column2 = value2, ... WHERE condition; -CREATE TABLE T ( +CREATE TABLE t ( id INT, s STRUCT, name STRING) @@ -391,8 +391,8 @@ TBLPROPERTIES ( ); -- you can use -UPDATE T SET name = 'a_new' WHERE id = 1; -UPDATE T SET s.c2 = 'a_new' WHERE s.c1 = 1; +UPDATE t SET name = 'a_new' WHERE id = 1; +UPDATE t SET s.c2 = 'a_new' WHERE s.c1 = 1; ``` {{< /tab >}} @@ -452,7 +452,7 @@ DELETE FROM table_identifier WHERE conditions; -- The following SQL is an example: -- table definition -CREATE TABLE MyTable ( +CREATE TABLE my_table ( id BIGINT NOT NULL, currency STRING, rate BIGINT, @@ -463,7 +463,7 @@ CREATE TABLE MyTable ( ); -- you can use -DELETE FROM MyTable WHERE currency = 'UNKNOWN'; +DELETE FROM my_table WHERE currency = 'UNKNOWN'; ``` {{< /tab >}} @@ -482,7 +482,7 @@ To enable delete needs these configs below: ``` ```sql -DELETE FROM MyTable WHERE currency = 'UNKNOWN'; +DELETE FROM my_table WHERE currency = 'UNKNOWN'; ``` {{< /tab >}} diff --git a/docs/content/maintenance/manage-partition.md b/docs/content/maintenance/manage-partition.md index ff1658786be57..a0359a4f20c9a 100644 --- a/docs/content/maintenance/manage-partition.md +++ b/docs/content/maintenance/manage-partition.md @@ -40,7 +40,7 @@ See [Expire Snapshots]({{< ref "/maintenance/manage-snapshots#expire-snapshots" An example for single partition field: ```sql -CREATE TABLE T (...) PARTITIONED BY (dt) WITH ( +CREATE TABLE t (...) PARTITIONED BY (dt) WITH ( 'partition.expiration-time' = '7 d', 'partition.expiration-check-interval' = '1 d', 'partition.timestamp-formatter' = 'yyyyMMdd' @@ -49,7 +49,7 @@ CREATE TABLE T (...) PARTITIONED BY (dt) WITH ( An example for multiple partition fields: ```sql -CREATE TABLE T (...) PARTITIONED BY (other_key, dt) WITH ( +CREATE TABLE t (...) PARTITIONED BY (other_key, dt) WITH ( 'partition.expiration-time' = '7 d', 'partition.expiration-check-interval' = '1 d', 'partition.timestamp-formatter' = 'yyyyMMdd', diff --git a/docs/content/maintenance/manage-tags.md b/docs/content/maintenance/manage-tags.md index 134e4f489b133..c5024c38d4da0 100644 --- a/docs/content/maintenance/manage-tags.md +++ b/docs/content/maintenance/manage-tags.md @@ -63,7 +63,7 @@ Example, configure table to create a tag at 0:10 every day, with a maximum reten ```sql -- Flink SQL -CREATE TABLE T ( +CREATE TABLE t ( k INT PRIMARY KEY NOT ENFORCED, f0 INT, ... @@ -74,18 +74,18 @@ CREATE TABLE T ( 'tag.num-retained-max' = '90' ); -INSERT INTO T SELECT ...; +INSERT INTO t SELECT ...; -- Spark SQL -- Read latest snapshot -SELECT * FROM T; +SELECT * FROM t; -- Read Tag snapshot -SELECT * FROM T VERSION AS OF '2023-07-26'; +SELECT * FROM t VERSION AS OF '2023-07-26'; -- Read Incremental between Tags -SELECT * FROM paimon_incremental_query('T', '2023-07-25', '2023-07-26'); +SELECT * FROM paimon_incremental_query('t', '2023-07-25', '2023-07-26'); ``` See [Query Tables]({{< ref "how-to/querying-tables" >}}) to see more query for engines. @@ -135,12 +135,12 @@ public class CreateTag { {{< tab "Spark" >}} Run the following sql: ```sql -CALL create_tag(table => 'test.T', tag => 'test_tag', snapshot => 2); +CALL create_tag(table => 'test.t', tag => 'test_tag', snapshot => 2); ``` To create a tag based on the latest snapshot id, run the following sql: ```sql -CALL create_tag(table => 'test.T', tag => 'test_tag'); +CALL create_tag(table => 'test.t', tag => 'test_tag'); ``` {{< /tab >}} @@ -190,7 +190,7 @@ public class DeleteTag { {{< tab "Spark" >}} Run the following sql: ```sql -CALL delete_tag(table => 'test.T', tag => 'test_tag'); +CALL delete_tag(table => 'test.t', tag => 'test_tag'); ``` {{< /tab >}} @@ -251,7 +251,7 @@ public class RollbackTo { Run the following sql: ```sql -CALL rollback(table => 'test.T', version => '2'); +CALL rollback(table => 'test.t', version => '2'); ``` {{< /tab >}} diff --git a/docs/content/migration/upsert-to-partitioned.md b/docs/content/migration/upsert-to-partitioned.md index 6c5ccd10a9724..b82bc942a6267 100644 --- a/docs/content/migration/upsert-to-partitioned.md +++ b/docs/content/migration/upsert-to-partitioned.md @@ -59,7 +59,7 @@ CREATE CATALOG my_hive WITH ( USE CATALOG my_hive; -CREATE TABLE mydb.T ( +CREATE TABLE mydb.t ( pk INT, col1 STRING, col2 STRING @@ -71,7 +71,7 @@ CREATE TABLE mydb.T ( INSERT INTO t VALUES (1, '10', '100'), (2, '20', '200'); -- create tag '2023-10-16' for snapshot 1 -CALL sys.create_tag('mydb.T', '2023-10-16', 1); +CALL sys.create_tag('mydb.t', '2023-10-16', 1); ``` {{< /tab >}} @@ -82,13 +82,13 @@ CALL sys.create_tag('mydb.T', '2023-10-16', 1); {{< tabs "Query table in Hive with Partition Pruning 1" >}} {{< tab "Hive" >}} ```sql -SHOW PARTITIONS T; +SHOW PARTITIONS t; /* OK dt=2023-10-16 */ -SELECT * FROM T WHERE dt='2023-10-16'; +SELECT * FROM t WHERE dt='2023-10-16'; /* OK 1 10 100 2023-10-16 @@ -120,7 +120,7 @@ CREATE CATALOG my_hive WITH ( USE CATALOG my_hive; -CREATE TABLE mydb.T ( +CREATE TABLE mydb.t ( pk INT, col1 STRING, col2 STRING @@ -135,7 +135,7 @@ CREATE TABLE mydb.T ( INSERT INTO t VALUES (1, '10', '100'), (2, '20', '200'); -- create tag '2023-10-16' for snapshot 1 -CALL sys.create_tag('mydb.T', '2023-10-16', 1); +CALL sys.create_tag('mydb.t', '2023-10-16', 1); -- new data in '2023-10-17' INSERT INTO t VALUES (3, '30', '300'), (4, '40', '400'); @@ -152,14 +152,14 @@ INSERT INTO t VALUES (3, '30', '300'), (4, '40', '400'); {{< tabs "Query table in Hive with Partition Pruning 2" >}} {{< tab "Hive" >}} ```sql -SHOW PARTITIONS T; +SHOW PARTITIONS t; /* OK dt=2023-10-16 dt=2023-10-17 */ -SELECT * FROM T WHERE dt='2023-10-17'; +SELECT * FROM t WHERE dt='2023-10-17'; -- preview tag '2023-10-17' /* OK