Skip to content

Commit

Permalink
fix: fix snippets syntax error
Browse files Browse the repository at this point in the history
  • Loading branch information
jialan committed Nov 25, 2024
1 parent 752576b commit 1475738
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 72 deletions.
36 changes: 18 additions & 18 deletions src/languages/flink/flink.snippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ import type { CompletionSnippetOption } from 'src/monaco.contribution';

export const flinkSnippets: CompletionSnippetOption[] = [
{
prefix: 'create source table',
label: 'CREATE-SOURCE-TABLE',
label: 'create source table',
prefix: 'CREATE-SOURCE-TABLE',
body: [
'CREATE TABLE ${1:source_table} (',
'\tid STRING,',
'\tvalue BIGINT,',
'\tval BIGINT,',
'\tts TIMESTAMP(3),',
"\tWATERMARK FOR ts AS ts - INTERVAL '5' SECOND",
') WITH (',
"\t'connector' = 'kafka',",
"\t'topic' = 'input_topic',",
"\t'properties.bootstrap.servers' = 'localhost:9092'",
"\t'properties.bootstrap.servers' = 'localhost:9092',",
"\t'format' = 'json',",
"\t'scan.startup.mode' = 'earliest-offset'",
');'
]
},
{
prefix: 'create sink table',
label: 'CREATE-SINK-TABLE',
label: 'create sink table',
prefix: 'CREATE-SINK-TABLE',
body: [
'CREATE TABLE ${1:sink_table} (',
'\tid STRING,',
Expand All @@ -36,8 +36,8 @@ export const flinkSnippets: CompletionSnippetOption[] = [
]
},
{
prefix: 'tumble window',
label: 'TUMBLE-WINDOW',
label: 'tumble window',
prefix: 'TUMBLE-WINDOW',
body: [
'SELECT',
'\twindow_start,',
Expand All @@ -53,15 +53,15 @@ export const flinkSnippets: CompletionSnippetOption[] = [
]
},
{
prefix: 'comulate window',
label: 'CUMULATE-WINDOW',
label: 'hop window',
prefix: 'HOP-WINDOW',
body: [
'SELECT',
'\twindow_start,',
'\twindow_end,',
'\tSUM(price) as total_price',
'FROM',
'\tTABLE(CUMULATE(TABLE table_name2,',
'\tTABLE(HOP(TABLE table_name2,',
'\tDESCRIPTOR(create_time),',
"\tINTERVAL '30' SECONDS,",
"\tINTERVAL '1' MINUTE))",
Expand All @@ -71,8 +71,8 @@ export const flinkSnippets: CompletionSnippetOption[] = [
]
},
{
prefix: 'comulate window',
label: 'CUMULATE-WINDOW',
label: 'comulate window',
prefix: 'CUMULATE-WINDOW',
body: [
'SELECT',
'\twindow_start,',
Expand All @@ -89,8 +89,8 @@ export const flinkSnippets: CompletionSnippetOption[] = [
]
},
{
prefix: 'session window',
label: 'SESSION-WINDOW',
label: 'session window',
prefix: 'SESSION-WINDOW',
body: [
'SELECT',
"\tSESSION_START(create_time, INTERVAL '10' SECOND) AS session_beg,",
Expand All @@ -103,10 +103,10 @@ export const flinkSnippets: CompletionSnippetOption[] = [
]
},
{
prefix: 'INSERT INTO',
label: 'INSERT-INTO-SELECT',
label: 'insert into',
prefix: 'INSERT-INTO-SELECT',
body: [
'INSERT INTO TABLE ${1:table_name}',
'INSERT INTO ${1:table_name}',
'SELECT ${2:column1}, ${3:column2}',
'FROM ${4:source_table}',
'WHERE ${5:conditions};\n$6'
Expand Down
10 changes: 6 additions & 4 deletions src/languages/hive/hive.snippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export const hiveSnippets: CompletionSnippetOption[] = [
prefix: 'INSERT-INTO-SELECT',
body: [
'INSERT INTO TABLE ${1:table_name}',
'SELECT ${2:column1}, ${3:column2}',
'FROM ${4:source_table}',
'SELECT ${3:column1}, ${4:column2}',
'FROM ${2:source_table}',
'WHERE ${5:conditions};\n$6'
]
},
Expand Down Expand Up @@ -71,7 +71,7 @@ export const hiveSnippets: CompletionSnippetOption[] = [
'\t${4:column2} ${5:STRING}',
')',
"COMMENT '${6:table_comment}'",
'ROW FORMAT ${7:DELIMITE}',
'ROW FORMAT ${7:DELIMITED}',
"FIELDS TERMINATED BY '${8:\\t}'",
'STORED AS ${9:PARQUET};\n$10'
]
Expand Down Expand Up @@ -136,7 +136,9 @@ export const hiveSnippets: CompletionSnippetOption[] = [
label: 'alter table columns',
prefix: 'ALTER-TABLE-COLUMNS',
body: [
"ALTER TABLE ${1:table_name} ADD ${2:column_name} ${3:STRING} COMMENT '${4:desc}';\n$5"
'ALTER TABLE ${1:table_name} ADD COLUMNS (',
"\t${2:column_name} ${3:STRING} COMMENT '${4:desc}'",
');\n$5'
]
}
];
26 changes: 13 additions & 13 deletions src/languages/impala/impala.snippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export const impalaSnippets: CompletionSnippetOption[] = [
label: 'insert into select',
prefix: 'INSERT-INTO-SELECT',
body: [
'INSERT INTO TABLE ${1:table_name}',
'SELECT ${2:column1}, ${3:column2}',
'FROM ${4:source_table}',
'INSERT INTO ${1:table_name}',
'SELECT ${3:column1}, ${4:column2}',
'FROM ${2:source_table}',
'WHERE ${5:conditions};\n$6'
]
},
Expand Down Expand Up @@ -80,8 +80,8 @@ export const impalaSnippets: CompletionSnippetOption[] = [
body: [
'CREATE TABLE IF NOT EXISTS ${1:table_name}',
'AS',
'SELECT ${2:column1}, ${3:column2}',
'FROM ${4:source_table}',
'SELECT ${3:column1}, ${4:column2}',
'FROM ${2:source_table}',
'WHERE ${5:conditions};\n$6'
]
},
Expand All @@ -93,30 +93,30 @@ export const impalaSnippets: CompletionSnippetOption[] = [
'\t${2:column1} ${3:STRING},',
'\t${4:column2} ${5:STRING}',
')',
"COMMENT '${6:table_comment}'",
'PARTITIONED BY (${7:part_column_name} STRING)',
'STORED AS ${8:PARQUET};\n$9'
'PARTITIONED BY (${6:part_column_name} ${7:STRING})',
"COMMENT '${8:table_comment}'",
'STORED AS ${9:PARQUET};\n$10'
]
},
{
label: 'alter table partition',
prefix: 'ALTER-TABLE-PARTITION',
body: [
"ALTER TABLE ${1:table_name} ${2:ADD} PARTITION (${3:part_column}='${4:part_value}');\n$5"
"ALTER TABLE ${1:table_name} ${2:ADD} PARTITION (${3:part_column} = '${4:part_value}');\n$5"
]
},
{
label: 'alter table properties',
prefix: 'ALTER-TABLE-PROPERTIES',
body: [
"ALTER TABLE ${1:table_name} SET TBLPROPERTIES ('${2:property_name}'='${3:property_value}');\n$4"
"ALTER TABLE ${1:table_name} SET TBLPROPERTIES ('${2:property_name}' = '${3:property_value}');\n$4"
]
},
{
label: 'alter table columns',
prefix: 'ALTER-TABLE-COLUMNS',
label: 'alter table column',
prefix: 'ALTER-TABLE-COLUMN',
body: [
"ALTER TABLE ${1:table_name} ADD ${2:column_name} ${3:STRING} COMMENT '${4:desc}';\n$5"
"ALTER TABLE ${1:table_name} ADD COLUMN ${2:column_name} ${3:STRING} COMMENT '${4:desc}';\n$5"
]
}
];
20 changes: 10 additions & 10 deletions src/languages/mysql/mysql.snippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export const mysqlSnippets: CompletionSnippetOption[] = [
label: 'insert into select',
prefix: 'INSERT-INTO-SELECT',
body: [
'INSERT INTO TABLE ${1:table_name}',
'SELECT ${2:column1}, ${3:column2}',
'FROM ${4:source_table}',
'INSERT INTO ${1:table_name}',
'SELECT ${3:column1}, ${4:column2}',
'FROM ${2:source_table}',
'WHERE ${5:conditions};\n$6'
]
},
Expand Down Expand Up @@ -64,12 +64,12 @@ export const mysqlSnippets: CompletionSnippetOption[] = [
label: 'create table',
prefix: 'CREATE-TABLE',
body: [
'CREATE TABLE ${1:table_name} (',
'CREATE TABLE ${1:table_name} (',
'\t${2:column1} ${3:INT},',
'\t${4:column2} ${5:INT}',
'\t${4:column2} ${5:INT},',
'\tPRIMARY KEY (${2:column1})',
')',
"COMMENT '${6:table_comment}'"
"COMMENT '${6:table_comment}';\n$7"
]
},
{
Expand All @@ -89,7 +89,7 @@ export const mysqlSnippets: CompletionSnippetOption[] = [
body: [
'CREATE TABLE ${1:table_name} (',
'\t${2:column1} ${3:INT},',
'\t${4:column2} ${5:INT}',
'\t${4:column2} ${5:INT},',
'\tPRIMARY KEY (${2:column1})',
')',
'PARTITION BY RANGE (${2:column1}) (',
Expand All @@ -103,7 +103,7 @@ export const mysqlSnippets: CompletionSnippetOption[] = [
body: [
'CREATE TABLE ${1:table_name} (',
'\t${2:column1} ${3:INT},',
'\t${4:column2} ${5:INT}',
'\t${4:column2} ${5:INT},',
'\tPRIMARY KEY (${2:column1})',
')',
'PARTITION BY LIST (${2:column1}) (',
Expand All @@ -117,7 +117,7 @@ export const mysqlSnippets: CompletionSnippetOption[] = [
body: [
'CREATE TABLE ${1:table_name} (',
'\t${2:column1} ${3:INT},',
'\t${4:column2} ${5:INT}',
'\t${4:column2} ${5:INT},',
'\tPRIMARY KEY (${2:column1})',
')',
'PARTITION BY HASH (${2:column1})',
Expand All @@ -130,7 +130,7 @@ export const mysqlSnippets: CompletionSnippetOption[] = [
body: [
'CREATE TABLE ${1:table_name} (',
'\t${2:column1} ${3:INT},',
'\t${4:column2} ${5:INT}',
'\t${4:column2} ${5:INT},',
'\tPRIMARY KEY (${2:column1})',
')',
'PARTITION BY KEY (${2:column1})',
Expand Down
23 changes: 11 additions & 12 deletions src/languages/pgsql/pgsql.snippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export const pgsqlSnippets: CompletionSnippetOption[] = [
label: 'insert into select',
prefix: 'INSERT-INTO-SELECT',
body: [
'INSERT INTO TABLE ${1:table_name}',
'SELECT ${2:column1}, ${3:column2}',
'FROM ${4:source_table}',
'INSERT INTO ${1:table_name}',
'SELECT ${3:column1}, ${4:column2}',
'FROM ${2:source_table}',
'WHERE ${5:conditions};\n$6'
]
},
Expand All @@ -58,10 +58,9 @@ export const pgsqlSnippets: CompletionSnippetOption[] = [
body: [
'CREATE TABLE ${1:table_name} (',
'\t${2:column1} ${3:INT},',
'\t${4:column2} ${5:INT}',
'\t${4:column2} ${5:INT},',
'\tPRIMARY KEY (${2:column1})',
')',
"COMMENT '${6:table_comment}'"
');\n$6'
]
},
{
Expand All @@ -70,8 +69,8 @@ export const pgsqlSnippets: CompletionSnippetOption[] = [
body: [
'CREATE TABLE ${1:table_name}',
'AS',
'SELECT ${2:column1}, ${3:column2}',
'FROM ${4:source_table}',
'SELECT ${3:column1}, ${4:column2}',
'FROM ${2:source_table}',
'WHERE ${5:conditions};\n$6'
]
},
Expand All @@ -83,7 +82,7 @@ export const pgsqlSnippets: CompletionSnippetOption[] = [
'\t${2:column1} ${3:INT},',
'\t${4:column2} ${5:INT}',
')',
'PARTITION BY RANGE (${2:column1});\n\n',
'PARTITION BY RANGE (${2:column1});\n',
'CREATE TABLE ${6:p0} PARTITION OF ${1:table_name}',
'\tFOR VALUES FROM (${7:start_value}) TO (${8:end_value});\n$9'
]
Expand All @@ -96,7 +95,7 @@ export const pgsqlSnippets: CompletionSnippetOption[] = [
'\t${2:column1} ${3:INT},',
'\t${4:column2} ${5:INT}',
')',
'PARTITION BY LIST (${2:column1});\n\n',
'PARTITION BY LIST (${2:column1});\n',
'CREATE TABLE ${6:p0} PARTITION OF ${1:table_name}',
'\tFOR VALUES IN (${7:range_values});\n$8'
]
Expand All @@ -109,15 +108,15 @@ export const pgsqlSnippets: CompletionSnippetOption[] = [
'\t${2:column1} ${3:INT},',
'\t${4:column2} ${5:INT}',
')',
'PARTITION BY HASH (${2:column1});\n\n',
'PARTITION BY HASH (${2:column1});\n',
'CREATE TABLE ${6:p0} PARTITION OF ${1:table_name}',
'\tFOR VALUES WITH (MODULUS ${7:4}, REMAINDER ${8:0});\n$9'
]
},
{
label: 'alter table add column',
prefix: 'ALTER-TABLE-ADD-COLUMN',
body: ["ALTER TABLE ${1:table_name} ADD ${2:column_name} ${3:INT} COMMENT '${4:desc}';\n$5"]
body: ['ALTER TABLE ${1:table_name} ADD COLUMN ${2:column_name} ${3:INT};\n$4']
},
{
label: 'alter table add primary key',
Expand Down
18 changes: 9 additions & 9 deletions src/languages/spark/spark.snippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const sparkSnippets: CompletionSnippetOption[] = [
label: 'insert into select',
prefix: 'INSERT-INTO-SELECT',
body: [
'INSERT INTO TABLE ${1:table_name}',
'INSERT INTO ${1:table_name}',
'SELECT ${2:column1}, ${3:column2}',
'FROM ${4:source_table}',
'WHERE ${5:conditions};\n$6'
Expand Down Expand Up @@ -70,8 +70,8 @@ export const sparkSnippets: CompletionSnippetOption[] = [
'\t${2:column1} ${3:STRING},',
'\t${4:column2} ${5:STRING}',
')',
"COMMENT '${6:table_comment}'",
'USING ${7:parquet};\n$8'
'USING ${6:parquet}',
"COMMENT '${7:table_comment}';\n$8"
]
},
{
Expand All @@ -93,9 +93,9 @@ export const sparkSnippets: CompletionSnippetOption[] = [
'\t${2:column1} ${3:STRING},',
'\t${4:column2} ${5:STRING}',
')',
"COMMENT '${6:table_comment}'",
'USING ${6:parquet}',
'PARTITIONED BY (${7:part_column_name} ${8:STRING})',
'USING ${9:parquet};\n$10'
"COMMENT '${9:table_comment}';\n$10"
]
},
{
Expand All @@ -106,9 +106,9 @@ export const sparkSnippets: CompletionSnippetOption[] = [
'\t${2:column1} ${3:STRING},',
'\t${4:column2} ${5:STRING}',
')',
"COMMENT '${6:table_comment}'",
'CLUSTERED BY (${7:bucket_column) INTO ${8:1} BUCKETS',
'USING ${9:parquet};\n$10'
'USING ${6:parquet}',
'CLUSTERED BY (${7:bucket_column}) INTO ${8:1} BUCKETS',
"COMMENT '${9:table_comment}';\n$10"
]
},
{
Expand All @@ -129,7 +129,7 @@ export const sparkSnippets: CompletionSnippetOption[] = [
label: 'alter table columns',
prefix: 'ALTER-TABLE-COLUMNS',
body: [
"ALTER TABLE ${1:table_name} ADD ${2:column_name} ${3:STRING} COMMENT '${4:desc}';\n$5"
"ALTER TABLE ${1:table_name} ADD COLUMN ${2:column_name} ${3:STRING} COMMENT '${4:desc}';\n$5"
]
}
];
Loading

0 comments on commit 1475738

Please sign in to comment.