apache / shardingsphere

Empowering Data Intelligence with Distributed SQL for Sharding, Scalability, and Security Across All Databases.
Apache License 2.0
19.93k stars 6.74k forks source link

Consider refactoring SQL parsing assert to reduce the workload of SQL parsing development #30454

Open strongduanmu opened 8 months ago

strongduanmu commented 8 months ago

Feature Request

Is your feature request related to a problem?

30452

Describe the feature you would like.

In pr #30452, I modify the g4 sytax of the Oracle Merge statement and tried adding an SQL parse assert xml file. Because of the complexity of the Merge statement, writing the xml file takes a lot of time.

For many beginners, writing xml assertion files is a nightmare because they need to know what the expected segment is for each segment and then understand each of their attributes. Currently, there is a large community of developers involved in SQL parsing tasks, and if we can adjust the assertion logic of SQL parsing results, it will greatly save developers time.

Now, I can think of a way to provide a tool that can automatically generate XML files based on SQLStatment, then manually check whether the XML file meets our expectations, and then add the XML assertion file to the SQL parsing test. However, this tool can also be abused, for example: people use it without any human checks, which may also hide some parsing bugs.

So, I want to hear what you think, what are your good ways, and welcome to leave a comment on the issue. In addition, we can also refer to some excellent SQL parsing engines, such as: Calcite Parser, Druid Parser, to see how they do AST testing.

github-actions[bot] commented 7 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.