Skip to content

Commit

Permalink
[Doc] MV docs minor fix (#34109)
Browse files Browse the repository at this point in the history
(cherry picked from commit e6f6f60)

# Conflicts:
#	docs/sql-reference/sql-statements/data-definition/CREATE_MATERIALIZED_VIEW.md
#	docs/sql-reference/sql-statements/data-definition/CREATE_TABLE.md
  • Loading branch information
EsoragotoSpirit authored and mergify[bot] committed Nov 1, 2023
1 parent 91f7d12 commit 1b22f29
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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**
>
Expand All @@ -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

Expand Down
65 changes: 65 additions & 0 deletions docs/sql-reference/sql-statements/data-definition/CREATE_TABLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" = "<unique_key>[, ...]",
"foreign_key_constraints" = "
(<child_column>[, ...])
REFERENCES
[catalog_name].[database_name].<parent_table_name>(<parent_column>[, ...])
[;...]
"
)
```

- `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" = "<string_value>",
"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
Expand Down

0 comments on commit 1b22f29

Please sign in to comment.