apache / shardingsphere

Distributed SQL transaction & query engine for data sharding, scaling, encryption, and more - on any database.
Apache License 2.0
19.88k stars 6.73k forks source link

[SQL Definition Collation][SQLServer]Collate the g4 files of SQL definitions #6478

Closed jingshanglu closed 3 months ago

jingshanglu commented 4 years ago

Hi community,

This issue is to collate the SQL definitions of SQLServer. Therefore, we can support parsing more SQLs. We need your interaction! If you

  1. Be familiar with g4 file of Antlr (The grammars are RegularExpression-like)
  2. Understand the SQLServer grammars

then welcome!

Background

How is a SQL parsed? SQL definition file ->(Parse to) AST ->(Visit it)
SQLStatment

Process

  1. Compare SQL definitions in Oficial SQL Doc and ShardingSphere SQL Doc
  2. If there is any difference in ShardingSphere SQL Doc, please correct them referring to Official SQL Doc
  3. Run mvn install the current_file_module
  4. Check whether there are any exceptions. If indeed, please fix them. (Especially xxxVisitor.class)
  5. Add new corresponding SQL case in SQL Cases and expected parsed result in Expected Statment XML
  6. Run SQLParserParameterizedTest to make sure no exceptions.

Notice

1.Left recursion can not work well in Antlr4,

a
  : b
  | a b
  ;
b
  : a c
  ;
c
  : ...
  ;

you can consider the following one,

a
  : b*
  ;
b
  : a c
  ;
c
  : ...
  ;
  1. Here is a Chinese version for reference.

subtask

1、DML

2、DDL-ALTER

3、DDL-CREATE

5、DCL

6、TCL

7、DAL

dongzl commented 4 years ago

I will do it.

jingshanglu commented 4 years ago

I will do it.

@dongzl select,update,insert and delete are used more often, you can start from this subtasks.

dongzl commented 4 years ago

I will do it.

@dongzl select,update,insert and delete are used more often, you can start from this subtasks.

Hi @jingshanglu , OK, I will be familiar with the work.

tristaZero commented 4 years ago

Welcome @dongzl come back! It is long-term work, so I suggest you split a huge PR into many small ones and look forward to a flow of PRs from you. :-)

dongzl commented 4 years ago

Welcome @dongzl come back! It is long-term work, so I suggest you split a huge PR into many small ones and look forward to a flow of PRs from you. :-)

Hi @tristaZero , Thank you for your reminder, I'm not familiar with the SQL parse, I think this is a good opportunity, I will often communicate with jingshang and you about this work.

tristaZero commented 3 years ago

Hi @ThanoshanMV Welcome! Could you comment something here so I can assign to U?

ThanoshanMV commented 3 years ago

Hi @tristaZero, I'll try this one.

tristaZero commented 3 years ago

Hi @jingshanglu and @Icesource I saw your activities on this issue, and @ThanoshanMV still wan to be part of this one. Could you update which parts of this issue you are working on? So that we can take charge of the remaining ones.

Icesource commented 3 years ago

Hi @jingshanglu and @Icesource I saw your activities on this issue, and @ThanoshanMV still wan to be part of this one. Could you update which parts of this issue you are working on? So that we can take charge of the remaining ones.

@tristaZero I'm working on DDL statements. Maybe you can start with other SQL statements.

ThanoshanMV commented 3 years ago

Thank you @Icesource. First, I'll start with TCL and DAL.

ThanoshanMV commented 2 years ago

Hi @jingshanglu, @tristaZero, @Icesource

I completed TCL and DAL statements. Please refer to the submitted PRs. If there is anything to be changed, please let me know.

  1. For TCL statements:
  1. For DAL statements:

Next, I'll try to work on DCL statements.

ThanoshanMV commented 2 years ago

Hi @strongduanmu. In WITH dept_costs AS (SELECT department_name, SUM(salary) dept_total FROM departments d GROUP BY department_name) SELECT * FROM dept_costs WHERE dept_total > 304500 ORDER BY department_name SQL statement, SubquerySegment's startIndex should begin with parenthesis '(' or from the SELECT statement?

strongduanmu commented 2 years ago

Hi @ThanoshanMV, I don't think the startIndex of SubquerySegment should contain parentheses, it's just a simple wrapper around the select statement to identify the subquery.

ThanoshanMV commented 2 years ago

Hi @ThanoshanMV, I don't think the startIndex of SubquerySegment should contain parentheses, it's just a simple wrapper around the select statement to identify the subquery.

Thank you @strongduanmu.

ThanoshanMV commented 2 years ago

Sure @zrsaber.

github-actions[bot] commented 2 years ago

Hello , this issue has not received a reply for several days. This issue is supposed to be closed.

strongduanmu commented 2 years ago

This issue has not been finished, so I will reopen it.

github-actions[bot] commented 6 months ago

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.

terrymanu commented 3 months ago

Close because of staled.