Improve format-sql for views and timestamp functions (#528)
This commit is contained in:
Родитель
9468f997ab
Коммит
ce28624b74
|
@ -29,13 +29,24 @@ const tokenizerCfg = {
|
|||
'PRECEDING', 'PROTO', 'RANGE', 'RECURSIVE', 'REPLACE', 'RESPECT', 'RIGHT',
|
||||
'ROLLUP', 'ROWS', 'SELECT', 'SET', 'SOME', 'STRUCT', 'TABLESAMPLE', 'TEMP',
|
||||
'TEMPORARY', 'THEN', 'TO', 'TREAT', 'TRUE', 'UNBOUNDED', 'UNION', 'UNNEST',
|
||||
'USING', 'WHEN', 'WHERE', 'WINDOW', 'WITH', 'WITHIN',
|
||||
'USING', 'WHEN', 'WHERE', 'WINDOW', 'WITHIN',
|
||||
// EXTRACT DATE/TIMESTAMP part
|
||||
'MICROSECOND FROM', 'MILLISECOND FROM', 'MILLISECOND FROM', 'MINUTE FROM',
|
||||
'HOUR FROM', 'DAYOFWEEK FROM', 'DAY FROM', 'DAYOFYEAR FROM', 'WEEK FROM',
|
||||
'ISOWEEK FROM', 'MONTH FROM', 'QUARTER FROM', 'YEAR FROM', 'ISOYEAR FROM',
|
||||
'DATE FROM', 'DATETIME FROM', 'TIME FROM',
|
||||
// DATE/TIMESTAMP part
|
||||
'MICROSECOND', 'MILLISECOND', 'MILLISECOND', 'MINUTE', 'HOUR', 'DAYOFWEEK',
|
||||
'DAY', 'DAYOFYEAR', 'WEEK', 'ISOWEEK', 'MONTH', 'QUARTER', 'YEAR',
|
||||
'ISOYEAR', 'DATE', 'DATETIME', 'TIME',
|
||||
],
|
||||
// These words get their own line followed by increased indent
|
||||
reservedToplevelWords: [
|
||||
// DDL
|
||||
'ALTER TABLE IF EXISTS', 'ALTER TABLE', 'CREATE OR REPLACE TABLE',
|
||||
'CREATE TABLE IF NOT EXISTS', 'CREATE TABLE', 'DROP TABLE', 'DROP VIEW',
|
||||
'ALTER TABLE IF EXISTS', 'ALTER TABLE', 'CLUSTER BY',
|
||||
'CREATE OR REPLACE TABLE', 'CREATE OR REPLACE VIEW',
|
||||
'CREATE TABLE IF NOT EXISTS', 'CREATE TABLE', 'CREATE VIEW IF NOT EXISTS',
|
||||
'CREATE VIEW', 'DROP TABLE', 'DROP VIEW',
|
||||
// DML
|
||||
'DELETE FROM', 'DELETE', 'INSERT INTO', 'INSERT', 'MERGE INTO', 'MERGE',
|
||||
'UPDATE',
|
||||
|
@ -44,7 +55,9 @@ const tokenizerCfg = {
|
|||
'INNER JOIN', 'INTERSECT', 'JOIN', 'LEFT JOIN', 'LEFT OUTER JOIN', 'LIMIT',
|
||||
'ORDER BY', 'OUTER JOIN', 'PARTITION BY', 'RIGHT JOIN', 'RIGHT OUTER JOIN',
|
||||
'ROWS BETWEEN', 'ROWS', 'SELECT AS STRUCT', 'SELECT AS VALUE', 'SELECT',
|
||||
'SET', 'UNION ALL', 'UNION', 'USING', 'VALUES', 'WHERE',
|
||||
'SET', 'UNION ALL', 'UNION', 'USING', 'VALUES', 'WHERE', 'WITH',
|
||||
// UDF
|
||||
'CREATE TEMP FUNCTION', 'CREATE TEMPORARY FUNCTION', 'RETURNS', 'LANGUAGE',
|
||||
],
|
||||
// These words start a new line at the current indent
|
||||
reservedNewlineWords: ['AND', 'BETWEEN', 'ELSE', 'OR', 'WHEN', 'XOR'],
|
||||
|
|
Загрузка…
Ссылка в новой задаче