Commit Graph

167 Commits

Author SHA1 Message Date
Frank
d1c2920f80
Feat/spark sql auxiliary syntax (#165)
* feat: supplement SparkSQL add syntax unit test

* chore: recompile spark listener & visitor

---------

Co-authored-by: dilu <dilu@dtstack.com>
2023-10-09 09:49:22 +08:00
Frank
05da14d007
Feat/spark g4 (#168)
* feat: spark g4 test

* fix: fixed build lint

---------

Co-authored-by: liuyi <liuyi@dtstack.com>
Co-authored-by: dilu <dilu@dtstack.com>
2023-10-08 14:23:06 +08:00
XCynthia
0a9a7d15d3
test: hive complete data types' check and unit tests (#160)
* feat: add Authorization SQL and update syntax file

* test: hive complete data types' check and unit tests

* feat: hive add syntax complete automaticlly

* feat: update hive's syntax complete

feat:update hive's syntax complete

---------

Co-authored-by: zhaoge <>
2023-10-08 14:14:03 +08:00
hayden
b8c47d0ac9 feat: declare copyright ownership 2023-09-27 17:54:46 +08:00
琉易
623a004cd1
refactor: spark sql grammar (#163)
* feat: import apache spark g4

* feat: optimize parser g4

* feat: replace KW_

* fix: remove useless rules

---------

Co-authored-by: liuyi <liuyi@dtstack.com>
2023-09-27 09:54:13 +08:00
XCynthia
2ec03f1770
feat: hive Authorization syntax and unit tests (#159)
Co-authored-by: zhaoge <>
2023-09-12 20:10:43 +08:00
XCynthia
97ab76af76
Feat check hive create syntax (#157)
* check and update abort and alter sql

* delete superfluous space

* update grammar lib after change alter parser

* update alter parser to be compatible

* check create sql

---------

Co-authored-by: zhaoge <>
2023-09-06 16:42:04 +08:00
Hayden
885b85e842
Test/hive dml (#155)
* feat: add showIndex parser rule

* test: uncomment show index test cases

* test: add unit tests about DML syntax to HiveSQL

* test: add unit tests about export and import syntax to HiveSQL

* refactor: recompile hive grammar

* test: correct description of HiveSQL unit tests
2023-09-06 15:15:04 +08:00
XCynthia
6dad62ddf4
check alter sql and syntax (#156)
* check and update abort and alter sql

* delete superfluous space

* update grammar lib after change alter parser

* update alter parser to be compatible

---------

Co-authored-by: zhaoge <>
2023-09-06 11:46:46 +08:00
Hayden
ded9f28e36
feat: improve hive keywords rule (#154) 2023-09-05 14:27:21 +08:00
Hayden
af1d71c576
Feat/hive ddl (#150)
* test: test cases about Alter Either Table or Partition

* feat: support alter protection and correct alter compact

* feat: improve keyword rules

* feat: recompile hive grammar
2023-08-30 17:58:20 +08:00
hayden
13b58b2dec feat: support DT_ADD_CONFIG_FILE syntax 2023-08-28 13:04:28 +08:00
hayden
82d097b034 fix: allow ROW and ROWS as function name 2023-08-28 12:48:18 +08:00
hayden
ebd9a1ed85 feat: hiveSQL support create/drop/alter index grammar 2023-07-07 14:52:59 +08:00
hayden
e97e0b2ef6 feat: recomplie hive sql grammar and fix parser about 2023-07-07 14:48:44 +08:00
hayden
1d890e58fe feat: format hive grammar files name 2023-07-07 14:48:44 +08:00
Yu Chen
f413a29fac fix: flinkSqlParser should not import src 2023-07-07 14:47:36 +08:00
Hayden
9cf79064de
refactor: optimize basic parser interface (#121)
* feat: set all internal method to protected

* feat: public createLexer and createParser method

* feat: remove error listeners of parser when get suggestion
2023-06-16 16:14:53 +08:00
Hayden
e34a9f6128
Fix/basic suggestion (#119)
* fix: correct suggetion logic in multiple sql case

* test: add multiple sql test case of suggestion

* feat: export SyntaxContextType as enum
2023-06-12 15:21:27 +08:00
Hayden
1b02ff5d75
feat: FlinkSQL supports auto complete (#115)
* feat: add antlr4-c3 dependencies

* feat: distinguish table, catalog and database from uid

* feat: move semicolon from sqlStatements to sqlStatement

* chore: move antlr4ts-cli to devDependencies

* feat: improve basic parser and support suggestions of token and syntax

* feat: implement suggest method in sql parsers

* test: flink sql suggestion test cases

* feat: optimize ts defination of suggestion

* feat: add split listener and optimize performance of auto-completion

* test: supplementary flink suggestion unit tests
2023-06-09 11:22:53 +08:00
Ziv
34f64e6bea
refactor: migrate antlr4 v4.12.0 to antlr4ts(4.9.0) (#106)
* build: ignore gen folder

* refactor: remove useless code

* fix: correct the Javascript usage in grammar

* refactor: move to antlr4ts

* fix: remove useless

* fix: update grammars for javascript target

* refactor: migrate to antlr4ts

* refactor: migrate to antlr4ts

* refactor: implements ParserErrorListener

* fix: rename the  start reserved word

* refactor: remove unused import

* refactor: migrate to antlr4ts

* test: update the expects of test cases

* refactor: migrate hive to antlr4ts

* refactor: update the incompatible syntax for antlr4ts

* refactor: migrate pgsql grammar to antlr4ts, increasing tests

* refactor: migrate the plsql to antlr4ts

* build: remove unused config

* build: migrate to antlr4ts

* build: migrate ts-jest to @swc/jest

* refactor: migrate to anltr4ts

* build: migrate ts-jest to @swc/jest
2023-05-30 14:44:03 +08:00
Hayden
793ff6ef0e
feat: replace fliePath with slashText to resolve conflict between filePath and arithmetic (#112) 2023-05-30 10:19:13 +08:00
Ziv
76d7ee5e70
fix: rename TrinoSqlVisitor 2023-05-25 11:35:00 +08:00
Ziv
1442ad66d7
fix: update the exports path of trino 2023-05-25 11:29:48 +08:00
wewoor
99ee6c0998 Merge branch 'master' of github.com:DTStack/dt-sql-parser 2023-05-25 10:53:40 +08:00
wewoor
8084c7919a fix: rename TrinoSqlParser to TrinoSql 2023-05-25 10:53:03 +08:00
Hayden
3509964afc
test: add flink template test cases (#111)
* feat: rebuild flink sql parser

* test: add sqls templates in stream app test cases
2023-05-25 09:24:24 +08:00
wewoor
46a8a7ab12 fix: rename to TrinoSqlParser 2023-05-24 18:11:50 +08:00
Ziv
eeb111b5c5
fix: correct the grammar usage, especially in the parts targeting javascript (#109)
* build: ignore gen folder

* fix: correct the grammar when targeting Typescript

* fix: move base Lexer and fix javascript syntax

* fix: correct the usage of Javascript in grammar
2023-05-24 15:07:53 +08:00
mumiao
9c82a5d248
feat: support trino(presto) sql language (#105)
* feat(trino): intergrate prestoGrammar to dt-sql-parser

* feat(trino): add trinoSQl test framework

* feat(trino): intergrate test files for trinoSQL

* test(trino): support alterStatement test

* test(trino): support alter table set authorization statement

* feat(trino): complete trinosql alter unit tests

* test(trino): complete dropStatement unit cases for trinosql

* test(trino): complete create statement unit cases for trinoSQL

* test(trino): complete insertStatement unit cases for trinoSQl

* test(trino): dropStatement test files changed to short line split

* test(trino): complete selectStatement unit cases and grammar check

* test(trino): complete commentStatement unit case for trinoSQL

* test(trino): complete analyze commit and call clause unit case

* test(trino): complete delete deny and describe statement unit case

* test(trino): complete explain execute and grant statement unit case

* feat(trino): improve GRANT Role grammar

* test(trino): complete show statement unit case

* test(trino): complete truncateTable startTransaction update and values  statement unit case

* test(trino): improve update statement test cases

* test(trino): complete revoke revoke roles  and rollback statement unit case

* test(trino): add set statement test case

* feat: generator new trino parser and lexer file

* feat(trino): improve alter statement grammar

* test(trino): complete alter statement unit cases

* feat(trino): support case-insensitive lexers

* fix(trino): rm unless gen files

* test(trino): complete merge and reset session statement unit cases

* test(trino): complete merge anduse statement unit cases

* test(trino): complete prepare and refresh materialized view statement unit cases

* test(trino): improve statement unit cases

* test(trino): complete match recognize statement unit cases

* test(trino): complete window with row pattern recognition statement unit cases
2023-05-24 15:07:02 +08:00
Hayden
0924acf730
feat: update the builtin funcs of flinksql (#102)
* style: put evrry branch on a single line

* feat: support ASYMMETRIC and SYMMETRIC for between and

* feat: support SIMILAR TO predicate

* feat: support nested boolean expression

* feat: support escape to like and similar in flink sql

* test: add where clause test cases

* feat: add reservedKeywordsUsedAsFunctionName rule

* feat: add timepointLiteral rule and improve function call grammar
2023-05-24 15:03:08 +08:00
mumiao
c409b80ee1
feat(flink): support insert multipe tables statement for FlinkSQL 1.15(#104)
* feat(flink): support insert multipe tables statement for FlinkSQL 1.15

* test: recover jest.config info

* fix(flink): correct typo

* fix(flinksql): resolve conflicts
2023-05-23 14:40:52 +08:00
野迂迂
4b824fb500
feat(flink): support NOT NULL syntax (#103)
* feat(flink): support NOT NULL syntax

* feat(flinksql): support NULL
2023-05-23 10:12:05 +08:00
Hayden
40c911597b
refactor: improve keywords definations (#100)
* feat: improve keywords definations and add prefix named KW_

* test: capitalize keywords in alter sql test cases

* test: capitalize keywords in create sql test cases

* feat: merge interval rule and timeIntervalExpression rule in flinksql grammar

* test: put keywords in quotation marks around insert sql test cases

* test: put keywords in quotation marks around select sql test cases

* feat: improve uid rule

* test: rename sum to _sum because it is a reserved keyword

* docs: improve comments in flinkSqlLexer
2023-05-19 14:28:25 +08:00
Hayden
a026ae0592
feat: complete Query statements of FlinkSQL (#93)
* feat: add inlineDataValueClasue rule

* test: update tests of select statements

* feat: support flinksql window TVF grammar

* test: flink sql windown TVF statement test

* feat: support grouping sets grammar

* test: window TVF Aggregation and Group Window Aggregation tests

* test: supplemental selectAggregation with test cases

* test: add Having statement test case

* feat: support flinkSql over aggregation grammar

* test: add over aggregation grammar test cases

* test: flink sql join statement test cases

* test: flink sql set Operations grammar test cases

* test: flink sql limit clause test case

* feat: remove allPlusUid and replace with uid

* feat: support flink sql pattern recognition grammar

* test: flink sql pattern recognition tests

* feat: add flink sql with clause rule

* test: flink sql with clasue select tests

* feat: rebuild flink sql parser
2023-05-17 10:30:25 +08:00
Ziv
fbee70cde5
feat: update alter and drop statements (#94)
* feat: add UNIQUE keyword

* feat: support ifExist, addConstraint, dropConstraint and addUnique of alter table statement

* feat: support ifExist, addConstraint, dropConstraint and addUnique of alter table statement

* tests: add tests of alter statements

* docs: add comments for sql syntax

* build: optimize promote of build/antlr4

* ci: add max_old_space_size

* ci: add max_old_space_size

* ci: update tests script
2023-05-17 10:00:35 +08:00
mumiao
dc417e1381
feat: improve flinksql insertStatement
* feat: feat: improve flinksql insertStatement

* feat: complete insertFromSelectQueries syntax unit tests

* feat: complete insertValuesIntoTable syntax unit tests

* feat: improve insertValuesIntoTable sql case data

* feat: complete insertMultipeTables unit cases

* feat: depracate insertMulStatement grammar for 1.1.4

* fix: depracate unless files

* test: recover jest.config info

* feat:  improve  insertMultipleTable.sql  test case

* feat: build new flinksql parser and lexer

* feat: generator new flink parser and lexer file

* test: improve readSQL logic

* test: fix insertMultipleTable sql error

* test:  recover jest.config.js info
2023-05-12 09:31:54 +08:00
野迂迂
370cccf8d9
feat: improve flinksql createStatement (#91)
* feat: improve flinksql createStatement

* feat: complete CREATE syntax unit tests

* feat: complete CREATA TABLE syntax tests

* feat: develop flinkSQL grammar

* feat: improve tableConstraint

* fix: convert TIMESTAMP_LTZ

* test: improve tests

* feat: build new flinksql parser and lexer

* test: add CREATE TEMPLATE TABLE test
2023-05-11 17:41:34 +08:00
Ziv
c1c72def30
feat: upgrade antlr4 to 4.12.0 (#88) 2023-05-04 10:13:05 +08:00
nankaNULL
c0842b3e07
Feat/flink dt sql (#75)
* feat: dt self develop grammar

* feat: dt self develop grammar
2023-03-21 09:53:25 +08:00
nankaNULL
4f02f9aca0
Feat/flink grammar (#73)
* feat: complete flink sql insert statement

* feat: complete flink sql drop statement

* feat: complete flink sql alert statement

* feat: complete flink sql create statement, remove console log

* feat: complete flink sql describe, show, explain, use statement

* feat(flinksql): add statement, such as set, load

* fix(flinksql): fix insert, add temporary table
2023-02-27 19:03:32 +08:00
Ziv
14c2534de7
fix: remove space character in line comment rule (#69)
* fix: remove space character in line comment rule

* build: recompile grammars

* test: add cases for line comment
2023-01-09 11:01:10 +08:00
nankaNULL
0c9a831585
fix: fix flinksql create table grammar, add test (#65)
* fix: fix flinksql create table grammar, add test

* feat: add cross join, left outer join and time temporal join

* test: supplement flinksql join test

* fix: fix catalog table grammar, add test

* fix: fix flinksql data type, add test

* fix: delete console

* feat: add query with clause, add test
2022-12-28 14:20:33 +08:00
nankanull
e446fc0435 fix: fix bracket match 2022-12-25 13:30:43 +08:00
Salvatore Ravidà
ae767d5815 convert base to es5 - code clean 2022-12-16 15:13:56 +08:00
Salvatore Ravidà
ea0f061ff9 Added tests - restore target es6 - transpile base into es5 2022-12-16 15:13:56 +08:00
Salvatore Ravidà
f79202a5b7 Rename root to program 2022-12-16 15:13:56 +08:00
Salvatore Ravidà
a15da8e275 Added pgSQL support 2022-12-16 15:13:56 +08:00
xiaowei
eae322c0a3 build: update the SQL libs 2021-09-10 17:50:58 +08:00
xiaowei
bb6e8ac025 feat: tokenizer for the function arugments 2021-09-10 17:50:58 +08:00
xiaowei
b1ae454ae4 feat: add Bracket, Comma, and FunctionArguments tokens 2021-09-10 17:50:58 +08:00
xiaowei
df18e6cb21 feat: support custom variables ${} 2021-09-10 17:50:58 +08:00
Ziv
ca85be9696
build: add the basic type declaration (#30) 2021-05-11 14:20:07 +08:00
xiaowei
5f5af0a4ab fix: lexer for comment 2021-05-11 13:40:52 +08:00
Ziv
dc49697302
fix: clean sql white spaces #21 2021-05-11 13:39:42 +08:00
Ziv
bff1618742
Revert "fix: clea sql white spaces \n fix #21 (#26)" (#28)
This reverts commit b632f62678.
2021-05-11 13:37:34 +08:00
Ziv
b632f62678
fix: clea sql white spaces \n fix #21 (#26) 2021-05-11 13:35:45 +08:00
xiaowei
dc9974bbff refactor(spark): extract spark export into src index 2021-01-05 17:57:33 +08:00
xiaowei
221482cc7c refactor(plsql): extract plsql export into src index 2021-01-05 17:49:34 +08:00
xiaowei
57aba357ab refactor(hive): extract hive export into src index 2021-01-05 17:45:54 +08:00
xiaowei
ca44962acc refactor: update flinkSQL and genericSQL exporting location 2021-01-05 17:40:34 +08:00
xiaowei
1ac760e01a refactor: rename BasicParser.ts to basicParser.ts 2021-01-05 15:27:43 +08:00
xigua
1c8d020826 modify parser export 2020-12-17 17:43:12 +08:00
xigua
084efe1aab modify sparkSql grammar 2020-12-17 16:35:49 +08:00
xigua
8418c42c26 Merge branch 'dev' into feat_sparkSql 2020-12-17 14:59:52 +08:00
xigua
edbc87e8f1 update sql parser name 2020-12-17 11:44:45 +08:00
Erindcl
e6ee2ff411 Merge branch 'dev' into feat_flinkSql 2020-12-14 14:03:28 +08:00
Erindcl
771b562c78 fix(flink): clear useless comments 2020-12-14 11:48:08 +08:00
Erindcl
7d6c753d82 feat(utils): add cleanSql、splitSql、lexer func and test 2020-12-09 17:59:24 +08:00
Erindcl
a9b1e90d73 feat(flink): update grammar to match special columnName 2020-12-09 11:08:56 +08:00
Erindcl
e67f991ede feat(flink): modify grammar to match keywords 2020-12-08 16:04:56 +08:00
Erindcl
c9d88d00a6 feat(flink): update flinkSql grammar and add some test 2020-12-03 20:03:25 +08:00
Erindcl
04c4c40397 feat(flink): update flink SQL grammar 2020-12-03 16:25:43 +08:00
Erindcl
0ef80696f4 feat(flink): add describe/explain/use/show statement and some test 2020-11-26 11:20:57 +08:00
Erindcl
d1259b46a0 feat(flink): update createTable grammar 2020-11-25 19:48:06 +08:00
chenfeng
2aab4b6ca7 refactor: listener and visitor entrance 2020-11-25 16:57:53 +08:00
chenfeng
e7e0c15b0d fix: adjust import path 2020-11-25 15:03:16 +08:00
chenfeng
ec41432ee3 feat: create hive lexer and hive parser 2020-11-25 14:55:51 +08:00
chenfeng
557e9a3246 feat: refactoring hive SQL lexer 2020-11-25 14:49:33 +08:00
Erindcl
1b9efdccd5 feat(flink): perfect query statement 2020-11-24 16:49:45 +08:00
Erindcl
afef8e6d72 feat(flink): add grammar rules that pass the test 2020-11-20 17:08:17 +08:00
Erindcl
da9660c6fe feat(flink): adjust lexer position to fix test error 2020-11-19 19:52:59 +08:00
Erindcl
0735269f4e feat(flink): merge parser and lexer in order to java test 2020-11-18 20:05:49 +08:00
Erindcl
d7d32a3824 feat(fink): refactoring selectStatement 2020-11-17 19:57:12 +08:00
Erindcl
a5ea7be606 feat: add some query grammar 2020-11-11 19:58:14 +08:00
xigua
0d47b7debc modify grammar, add syntax test 2020-11-05 20:37:07 +08:00
Erindcl
ba29949359 feat(flink): add queryStatement 2020-11-05 20:00:20 +08:00
Erindcl
9fc91a572a feat(flink): add drop/alter test add add part of queryStatement 2020-11-04 18:03:41 +08:00
xigua
bfe055be71 add sparkSql base grammar 2020-10-28 21:34:13 +08:00
Erindcl
158e235b01 feat(flink): add inset\drop\alter grammar 2020-10-28 16:15:41 +08:00
Erindcl
6082c2b151 feat(flinksql): add some lexer 2020-10-23 17:52:43 +08:00
Erindcl
b7df08f012 feat(flink): add createTable grammar 2020-10-22 19:57:13 +08:00
xiaowei
654d96028c refactor: update parser root statement 2020-09-17 20:54:45 +08:00
xiaowei
be863e1acb build: update parser lib 2020-09-11 18:47:53 +08:00
xiaowei
f85163892a feat: add generic and plsql basic parser file 2020-09-11 17:39:10 +08:00
xiaowei
68800312d3 build: add antlr4 compile script 2020-09-09 14:11:04 +08:00
xiaowei
c069f9f714 refactor: unify the parser generator to antlr4 2020-08-28 13:29:11 +08:00
HSunboy
3bf241408c fix insert rowValuesList syntax 2020-03-26 13:06:16 +08:00
HSunboy
0c5f6164f4 fix hive insert syntax 2020-03-26 11:47:47 +08:00
HSunboy
364dc5fcae fix impala create table as select column bug 2020-01-10 17:00:09 +08:00