From 1b22f29b9bd2555b09f1bf2ef4c62ec644da9722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B5=B5=E7=A9=BA=E4=BA=8B=E3=82=B9=E3=83=94=E3=83=AA?= =?UTF-8?q?=E3=83=83=E3=83=88?= Date: Wed, 1 Nov 2023 14:57:44 +0800 Subject: [PATCH] [Doc] MV docs minor fix (#34109) (cherry picked from commit e6f6f60310a7ebad6bfd0d9364bce3a553cc310d) # Conflicts: # docs/sql-reference/sql-statements/data-definition/CREATE_MATERIALIZED_VIEW.md # docs/sql-reference/sql-statements/data-definition/CREATE_TABLE.md --- .../CREATE_MATERIALIZED_VIEW.md | 55 ++++++---------- .../data-definition/CREATE_TABLE.md | 65 +++++++++++++++++++ 2 files changed, 85 insertions(+), 35 deletions(-) diff --git a/docs/sql-reference/sql-statements/data-definition/CREATE_MATERIALIZED_VIEW.md b/docs/sql-reference/sql-statements/data-definition/CREATE_MATERIALIZED_VIEW.md index 060526ab134b0..17bc738f37c80 100644 --- a/docs/sql-reference/sql-statements/data-definition/CREATE_MATERIALIZED_VIEW.md +++ b/docs/sql-reference/sql-statements/data-definition/CREATE_MATERIALIZED_VIEW.md @@ -237,6 +237,7 @@ See [Asynchronous materialized view - Rewrite queries with the asynchronous mat - Asynchronous materialized views created based on the StarRocks default catalog support the following data types: +<<<<<<< HEAD - DATE - DATETIME - CHAR @@ -255,6 +256,13 @@ See [Asynchronous materialized view - Rewrite queries with the asynchronous mat - BITMAP - HLL - PERCENTILE +======= + - **Date**: DATE, DATETIME + - **String**: CHAR, VARCHAR + - **Numeric**: BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DECIMAL, PERCENTILE + - **Semi-structured**: ARRAY, JSON, MAP (from v3.1 onwards), STRUCT (from v3.1 onwards) + - **Other**: BITMAP, HLL +>>>>>>> e6f6f60310 ([Doc] MV docs minor fix (#34109)) > **NOTE** > @@ -264,47 +272,24 @@ See [Asynchronous materialized view - Rewrite queries with the asynchronous mat - Hive Catalog - - INT/INTEGER - - BIGINT - - TIMESTAMP - - STRING - - VARCHAR - - CHAR - - DOUBLE - - FLOAT - - DECIMAL - - ARRAY + - **Numeric**: INT/INTEGER, BIGINT, DOUBLE, FLOAT, DECIMAL + - **Date**: TIMESTAMP + - **String**: STRING, VARCHAR, CHAR + - **Semi-structured**: ARRAY - Hudi Catalog - - BOOLEAN - - INT - - DATE - - TimeMillis/TimeMicros - - TimestampMillis/TimestampMicros - - LONG - - FLOAT - - DOUBLE - - STRING - - ARRAY - - DECIMAL + - **Numeric**: BOOLEAN, INT, LONG, FLOAT, DOUBLE, DECIMAL + - **Date**: DATE, TimeMillis/TimeMicros, TimestampMillis/TimestampMicros + - **String**: STRING + - **Semi-structured**: ARRAY - Iceberg Catalog - - BOOLEAN - - INT - - LONG - - FLOAT - - DOUBLE - - DECIMAL(P, S) - - DATE - - TIME - - TIMESTAMP - - STRING - - UUID - - FIXED(L) - - BINARY - - LIST + - **Numeric**: BOOLEAN, INT, LONG, FLOAT, DOUBLE, DECIMAL(P, S) + - **Date**: DATE, TIME, TIMESTAMP + - **String**: STRING, UUID, FIXED(L), BINARY + - **Semi-structured**: LIST ## Usage notes diff --git a/docs/sql-reference/sql-statements/data-definition/CREATE_TABLE.md b/docs/sql-reference/sql-statements/data-definition/CREATE_TABLE.md index ed9bfb64487bb..90fb030624972 100644 --- a/docs/sql-reference/sql-statements/data-definition/CREATE_TABLE.md +++ b/docs/sql-reference/sql-statements/data-definition/CREATE_TABLE.md @@ -470,6 +470,71 @@ ROLLUP (rollup_name (column_name1, column_name2, ...) [PROPERTIES ("key"="value", ...)],...) ``` +<<<<<<< HEAD +======= +#### Define Unique Key constraints and Foreign Key constraints for View Delta Join query rewrite + +To enable query rewrite in the View Delta Join scenario, you must define the Unique Key constraints `unique_constraints` and Foreign Key constraints `foreign_key_constraints` for the table to be joined in the Delta Join. See [Asynchronous materialized view - Rewrite queries in View Delta Join scenario](../../../using_starrocks/query_rewrite_with_materialized_views.md#query-delta-join-rewrite) for further information. + +```SQL +PROPERTIES ( + "unique_constraints" = "[, ...]", + "foreign_key_constraints" = " + ([, ...]) + REFERENCES + [catalog_name].[database_name].([, ...]) + [;...] + " +) +``` + +- `child_column`: the Foreign Key of the table. You can define multiple `child_column`. +- `catalog_name`: the name of the catalog where the table to join resides. The default catalog is used if this parameter is not specified. +- `database_name`: the name of the database where the table to join resides. The current database is used if this parameter is not specified. +- `parent_table_name`: the name of the table to join. +- `parent_column`: the column to be joined. They must be the Primary Keys or Unique Keys of the corresponding tables. + +> **CAUTION** +> +> - `unique_constraints` and `foreign_key_constraints` are only used for query rewrite. Foreign Key constraints checks are not guaranteed when data is loaded into the table. You must ensure the data loaded into the table meets the constraints. +> - The primary keys of a Primary Key table or the unique keys of a Unique Key table are, by default, the corresponding `unique_constraints`. You do not need to set it manually. +> - The `child_column` in a table's `foreign_key_constraints` must be referenced to a `unique_key` in another table's `unique_constraints`. +> - The number of `child_column` and `parent_column` must agree. +> - The data types of the `child_column` and the corresponding `parent_column` must match. + +#### Create cloud-native tables for StarRocks Shared-data cluster + +To [use your StarRocks Shared-data cluster](../../../deployment/shared_data/s3.md#use-your-shared-data-starrocks-cluster), you must create cloud-native tables with the following properties: + +```SQL +PROPERTIES ( + "datacache.enable" = "{ true | false }", + "datacache.partition_duration" = "", + "enable_async_write_back" = "{ true | false }" +) +``` + +- `datacache.enable`: Whether to enable the local disk cache. Default: `true`. + + - When this property is set to `true`, the data to be loaded is simultaneously written into the object storage and the local disk (as the cache for query acceleration). + - When this property is set to `false`, the data is loaded only into the object storage. + + > **NOTE** + > + > To enable the local disk cache, you must specify the directory of the disk in the BE configuration item `storage_root_path`. For more information, see [BE Configuration items](../../../administration/Configuration.md#be-configuration-items). + +- `datacache.partition_duration`: The validity duration of the hot data. When the local disk cache is enabled, all data is loaded into the cache. When the cache is full, StarRocks deletes the less recently used data from the cache. When a query needs to scan the deleted data, StarRocks checks if the data is within the duration of validity. If the data is within the duration, StarRocks loads the data into the cache again. If the data is not within the duration, StarRocks does not load it into the cache. This property is a string value that can be specified with the following units: `YEAR`, `MONTH`, `DAY`, and `HOUR`, for example, `7 DAY` and `12 HOUR`. If it is not specified, all data is cached as the hot data. + + > **NOTE** + > + > This property is available only when `datacache.enable` is set to `true`. + +- `enable_async_write_back`: Whether to allow data to be written into object storage asynchronously. Default: `false`. + + - When this property is set to `true`, the load task returns success as soon as the data is written into the local disk cache, and the data is written into the object storage asynchronously. This allows better loading performance, but it also risks data reliability under potential system failures. + - When this property is set to `false`, the load task returns success only after the data is written into both object storage and the local disk cache. This guarantees higher availability but leads to lower loading performance. + +>>>>>>> e6f6f60310 ([Doc] MV docs minor fix (#34109)) ## Examples ### Create an Aggregate table that uses Hash bucketing and columnar storage