-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jialan
committed
Jan 3, 2025
1 parent
c1b619c
commit 631a479
Showing
16 changed files
with
1,071 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import type { CompletionSnippetOption } from 'src/monaco.contribution'; | ||
|
||
export const flinkSnippets: CompletionSnippetOption[] = [ | ||
{ | ||
label: 'create-source-table', | ||
prefix: 'CREATE-SOURCE-TABLE', | ||
body: [ | ||
'CREATE TABLE ${1:source_table} (', | ||
'\tid STRING,', | ||
'\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'format' = 'json',", | ||
"\t'scan.startup.mode' = 'earliest-offset'", | ||
');' | ||
] | ||
}, | ||
{ | ||
label: 'create-sink-table', | ||
prefix: 'CREATE-SINK-TABLE', | ||
body: [ | ||
'CREATE TABLE ${1:sink_table} (', | ||
'\tid STRING,', | ||
'\tcnt BIGINT', | ||
') WITH (', | ||
"\t'connector' = 'jdbc',", | ||
"\t'url' = 'jdbc:mysql://localhost:3306/test',", | ||
"\t'table-name' = 'output_table',", | ||
"\t'username' = 'root',", | ||
"\t'password' = 'password'", | ||
');' | ||
] | ||
}, | ||
{ | ||
label: 'tumble-window', | ||
prefix: 'TUMBLE-WINDOW', | ||
body: [ | ||
'SELECT', | ||
'\twindow_start,', | ||
'\twindow_end,', | ||
'\tSUM(price) as total_price', | ||
'FROM', | ||
'\tTABLE(TUMBLE(TABLE table_name2,', | ||
'\tDESCRIPTOR(create_time),', | ||
"\tINTERVAL '1' MINUTE))", | ||
'GROUP BY', | ||
'\twindow_start,', | ||
'\twindow_end;' | ||
] | ||
}, | ||
{ | ||
label: 'hop-window', | ||
prefix: 'HOP-WINDOW', | ||
body: [ | ||
'SELECT', | ||
'\twindow_start,', | ||
'\twindow_end,', | ||
'\tSUM(price) as total_price', | ||
'FROM', | ||
'\tTABLE(HOP(TABLE table_name2,', | ||
'\tDESCRIPTOR(create_time),', | ||
"\tINTERVAL '30' SECONDS,", | ||
"\tINTERVAL '1' MINUTE))", | ||
'GROUP BY', | ||
'\twindow_start,', | ||
'\twindow_end;' | ||
] | ||
}, | ||
{ | ||
label: 'comulate-window', | ||
prefix: 'CUMULATE-WINDOW', | ||
body: [ | ||
'SELECT', | ||
'\twindow_start,', | ||
'\twindow_end,', | ||
'\tSUM(price) as total_price', | ||
'FROM', | ||
'\tTABLE(CUMULATE(TABLE table_name2,', | ||
'\tDESCRIPTOR(create_time),', | ||
"\tINTERVAL '30' SECONDS,", | ||
"\tINTERVAL '1' MINUTE))", | ||
'GROUP BY', | ||
'\twindow_start,', | ||
'\twindow_end;' | ||
] | ||
}, | ||
{ | ||
label: 'session-window', | ||
prefix: 'SESSION-WINDOW', | ||
body: [ | ||
'SELECT', | ||
"\tSESSION_START(create_time, INTERVAL '10' SECOND) AS session_beg,", | ||
"\tSESSION_ROWTIME(create_time, INTERVAL '10' SECOND) AS session_end,", | ||
'\tSUM(price) AS total_price', | ||
'FROM', | ||
'\ttable_name', | ||
'GROUP BY', | ||
"\tSESSION(create_time, INTERVAL '10' SECOND);" | ||
] | ||
}, | ||
{ | ||
label: 'insert-into-select', | ||
prefix: 'INSERT-INTO-SELECT', | ||
body: [ | ||
'INSERT INTO ${1:table_name}', | ||
'SELECT ${2:column1}, ${3:column2}', | ||
'FROM ${4:source_table}', | ||
'WHERE ${5:conditions};\n$6' | ||
] | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
import type { CompletionSnippetOption } from 'src/monaco.contribution'; | ||
|
||
export const hiveSnippets: CompletionSnippetOption[] = [ | ||
{ | ||
label: 'select', | ||
prefix: 'SELECT', | ||
body: ['SELECT ${2:column1}, ${3:column2} FROM ${1:table_name};\n$4'] | ||
}, | ||
{ | ||
label: 'select-join', | ||
prefix: 'SELECT-JOIN', | ||
body: [ | ||
'SELECT ${8:column1} FROM ${1:table_name} ${2:t1}', | ||
'${3:LEFT} JOIN ${4:table2} ${5:t2} ON ${2:t1}.${6:column1} = ${5:t2}.${7:column2};\n$9' | ||
] | ||
}, | ||
{ | ||
label: 'select-order-by', | ||
prefix: 'SELECT-ORDERBY', | ||
body: [ | ||
'SELECT ${2:column1}, ${3:column2} FROM ${1:table_name} ORDER BY ${4:column1} ${5:desc};\n$6' | ||
] | ||
}, | ||
{ | ||
label: 'insert', | ||
prefix: 'INSERT-INTO', | ||
body: [ | ||
'INSERT INTO ${1:table_name} (${2:column1}, ${3:column2}) VALUES (${4:value1}, ${5:value2});\n$6' | ||
] | ||
}, | ||
{ | ||
label: 'insert-into-select', | ||
prefix: 'INSERT-INTO-SELECT', | ||
body: [ | ||
'INSERT INTO TABLE ${1:table_name}', | ||
'SELECT ${3:column1}, ${4:column2}', | ||
'FROM ${2:source_table}', | ||
'WHERE ${5:conditions};\n$6' | ||
] | ||
}, | ||
{ | ||
label: 'insert-overwrite-table', | ||
prefix: 'INSERT-OVERWRITE-TABLE', | ||
body: [ | ||
'INSERT OVERWRITE TABLE ${1:table_name}', | ||
'SELECT ${3:column1}, ${4:column2}', | ||
'FROM ${2:source_table}', | ||
'WHERE ${5:conditions};\n$6' | ||
] | ||
}, | ||
{ | ||
label: 'update', | ||
prefix: 'UPDATE', | ||
body: [ | ||
'UPDATE ${1:table_name}', | ||
'SET ${2:column1} = ${3:value1}', | ||
'WHERE ${4:column2} = ${5:value2};\n$6' | ||
] | ||
}, | ||
{ | ||
label: 'delete', | ||
prefix: 'DELETE', | ||
body: ['DELETE FROM ${1:table_name}', 'WHERE ${2:column1} = ${3:value1};\n$4'] | ||
}, | ||
{ | ||
label: 'create-table', | ||
prefix: 'CREATE-TABLE', | ||
body: [ | ||
'CREATE TABLE IF NOT EXISTS ${1:table_name} (', | ||
'\t${2:column1} ${3:STRING},', | ||
'\t${4:column2} ${5:STRING}', | ||
')', | ||
"COMMENT '${6:table_comment}'", | ||
'ROW FORMAT ${7:DELIMITED}', | ||
"FIELDS TERMINATED BY '${8:\\t}'", | ||
'STORED AS ${9:PARQUET};\n$10' | ||
] | ||
}, | ||
{ | ||
label: 'create-table-as-select', | ||
prefix: 'CREATE-TABLE-AS-SELECT', | ||
body: [ | ||
'CREATE TABLE IF NOT EXISTS ${1:table_name}', | ||
'AS', | ||
'SELECT ${2:column1}, ${3:column2}', | ||
'FROM ${4:source_table}', | ||
'WHERE ${5:conditions};\n$6' | ||
] | ||
}, | ||
{ | ||
label: 'create-partition-table', | ||
prefix: 'CREATE-PARTITION-TABLE', | ||
body: [ | ||
'CREATE TABLE IF NOT EXISTS ${1:table_name} (', | ||
'\t${2:column1} ${3:STRING},', | ||
'\t${4:column2} ${5:STRING}', | ||
')', | ||
"COMMENT '${6:table_comment}'", | ||
'PARTITIONED BY (${7:part_column_name} STRING)', | ||
'ROW FORMAT ${8:DELIMITED}', | ||
"FIELDS TERMINATED BY '${9:\\t}'", | ||
'STORED AS ${10:PARQUET};\n$11' | ||
] | ||
}, | ||
{ | ||
label: 'create-bucket-table', | ||
prefix: 'CREATE-BUCKET-TABLE', | ||
body: [ | ||
'CREATE TABLE IF NOT EXISTS ${1:table_name} (', | ||
'\t${2:column1} ${3:STRING},', | ||
'\t${4:column2} ${5:STRING}', | ||
')', | ||
"COMMENT '${6:table_comment}'", | ||
'PARTITIONED BY (${7:part_column_name} STRING)', | ||
'CLUSTERED BY (${8:bucket_column_name}) INTO ${9:1} BUCKETS', | ||
'ROW FORMAT ${10:DELIMITED}', | ||
"FIELDS TERMINATED BY '${11:\\t}'", | ||
'STORED AS ${12:PARQUET};\n$13' | ||
] | ||
}, | ||
{ | ||
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" | ||
] | ||
}, | ||
{ | ||
label: 'alter-table-properties', | ||
prefix: 'ALTER-TABLE-PROPERTIES', | ||
body: [ | ||
"ALTER TABLE ${1:table_name} SET TBLPROPERTIES ('${2:property_name}'='${3:property_value}');\n$4" | ||
] | ||
}, | ||
{ | ||
label: 'alter-table-columns', | ||
prefix: 'ALTER-TABLE-COLUMNS', | ||
body: [ | ||
'ALTER TABLE ${1:table_name} ADD COLUMNS (', | ||
"\t${2:column_name} ${3:STRING} COMMENT '${4:desc}'", | ||
');\n$5' | ||
] | ||
} | ||
]; |
Oops, something went wrong.