apache / apache/shardingsphere

Duplicate definition of data type in PostgreSQL/openGauss BaseRule.g4

Open
#23,466 0 comments 0 reactions 0 assignees View on GitHub
in: SQL parse type: refactor
Dominant language
Java
Stars
20.8k
Forks
6.9k
Avg merge
9h 55m
Merged PRs (30d)
311

Description

## Refactor

The `dataType` was custom:
https://github.com/apache/shardingsphere/blob/795d3721d648c1ede9f839273b80ee14d89d6ff9/sql-parser/dialect/postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4#L1464-L1477

The `typeName` was the same as PostgreSQL's grammar:
https://github.com/apache/shardingsphere/blob/795d3721d648c1ede9f839273b80ee14d89d6ff9/sql-parser/dialect/postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4#L1075-L1220

https://github.com/postgres/postgres/blob/d952373a987bad331c0e499463159dd142ced1ef/src/backend/parser/gram.y#L13907-L14363

These definitions were used in different syntax. Maybe we should consider unifying the definition of data type?

Contributor guide

Open the contributing guide

Research direction

Compare the custom dataType rule and the existing typeName rule in sql-parser/dialect/postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4 with the corresponding PostgreSQL grammar in gram.y. Trace where each rule is used, then determine whether they can be unified without changing the distinct syntax they currently support; done means the duplicate definition is resolved and parser behavior remains covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, sql
Domain
compilers, databases
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.