Improve format-sql for views and timestamp functions (#528)

This commit is contained in:
Daniel Thorn 2019-11-25 14:15:32 -05:00 коммит произвёл GitHub
Родитель 9468f997ab
Коммит ce28624b74
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 17 добавлений и 4 удалений

Просмотреть файл

@ -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'],