Skip to content

Commit 712b3f3

Browse files
fix(SchemaTree): update create table template (#512)
1 parent b8ef0d0 commit 712b3f3

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

src/containers/Tenant/utils/queryTemplates.ts

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
11
export const createTableTemplate = (path: string) => {
2-
return `CREATE TABLE \`${path}/my_table\`
3-
(
4-
\`id\` Uint64,
5-
\`name\` String,
6-
PRIMARY KEY (\`id\`)
7-
);`;
2+
return `-- docs: https://ydb.tech/en/docs/yql/reference/syntax/create_table
3+
CREATE TABLE \`${path}/ydb_row_table\` (
4+
category_id Uint64 NOT NULL,
5+
id Uint64,
6+
expire_at Datetime,
7+
updated_on Datetime,
8+
name Text,
9+
\`binary-payload\` Bytes,
10+
attributes JsonDocument,
11+
-- uncomment to add a secondary index
12+
-- INDEX idx_row_table_id GLOBAL SYNC ON ( id ) COVER ( name, attributes ), -- Secondary indexes docs https://ydb.tech/en/docs/yql/reference/syntax/create_table#secondary_index
13+
PRIMARY KEY (category_id, id)
14+
)
15+
WITH (
16+
AUTO_PARTITIONING_BY_SIZE = ENABLED,
17+
AUTO_PARTITIONING_PARTITION_SIZE_MB = 2048,
18+
AUTO_PARTITIONING_BY_LOAD = ENABLED,
19+
AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 4,
20+
AUTO_PARTITIONING_MAX_PARTITIONS_COUNT = 1024,
21+
-- uncomment to create a table with predefined partitions
22+
-- UNIFORM_PARTITIONS = 4, -- The number of partitions for uniform initial table partitioning.
23+
-- The primary key's first column must have type Uint64 or Uint32.
24+
-- A created table is immediately divided into the specified number of partitions
25+
-- uncomment to launch read only replicas in every AZ
26+
-- READ_REPLICAS_SETTINGS = 'PER_AZ:1', -- Enable read replicas for stale read, launch one replica in every availability zone
27+
-- uncomment to enable ttl
28+
-- TTL = Interval("PT1H") ON expire_at, -- Enable background deletion of expired rows https://ydb.tech/en/docs/concepts/ttl
29+
KEY_BLOOM_FILTER = ENABLED -- With a Bloom filter, you can more efficiently determine
30+
-- if some keys are missing in a table when making multiple single queries by the primary key.
31+
)`;
832
};
933
export const alterTableTemplate = (path: string) => {
1034
return `ALTER TABLE \`${path}\`

0 commit comments

Comments
 (0)