wgy8283335 commented on a change in pull request #10558:
URL: https://github.com/apache/shardingsphere/pull/10558#discussion_r644397493
##########
File path:
shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
##########
@@ -121,7 +121,223 @@ unionClause
;
queryBlock
- : SELECT duplicateSpecification? projections fromClause? whereClause?
groupByClause? havingClause?
+ : withClause? SELECT duplicateSpecification? projections fromClause?
whereClause? groupByClause? havingClause?
Review comment:
The rule `duplicateSpecification` is not the same as definition in
oracle rule.

##########
File path:
shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
##########
@@ -121,7 +121,223 @@ unionClause
;
queryBlock
- : SELECT duplicateSpecification? projections fromClause? whereClause?
groupByClause? havingClause?
+ : withClause? SELECT duplicateSpecification? projections fromClause?
whereClause? groupByClause? havingClause?
Review comment:
The rule `projections` is not the same as definition in oracle rule.

##########
File path:
shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
##########
@@ -121,7 +121,223 @@ unionClause
;
queryBlock
- : SELECT duplicateSpecification? projections fromClause? whereClause?
groupByClause? havingClause?
+ : withClause? SELECT duplicateSpecification? projections fromClause?
whereClause? groupByClause? havingClause?
Review comment:
The rule `fromClause` is not the same as definition in oracle rule.

##########
File path:
shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
##########
@@ -121,7 +121,223 @@ unionClause
;
queryBlock
- : SELECT duplicateSpecification? projections fromClause? whereClause?
groupByClause? havingClause?
+ : withClause? SELECT duplicateSpecification? projections fromClause?
whereClause? groupByClause? havingClause?
Review comment:
The rules: `whereClause`, `groupByClause`, `havingClause`. They need to
be checked whether it is the same as the definition of the oracle rule.
##########
File path:
shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
##########
@@ -121,7 +121,223 @@ unionClause
;
queryBlock
- : SELECT duplicateSpecification? projections fromClause? whereClause?
groupByClause? havingClause?
+ : withClause? SELECT duplicateSpecification? projections fromClause?
whereClause? groupByClause? havingClause?
Review comment:
I agree with you.
##########
File path:
shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
##########
@@ -121,7 +121,223 @@ unionClause
;
queryBlock
- : SELECT duplicateSpecification? projections fromClause? whereClause?
groupByClause? havingClause?
+ : withClause? SELECT duplicateSpecification? projections fromClause?
whereClause? groupByClause? havingClause?
+ ;
+
+withClause
+ : WITH plsqlDeclarations? ((subqueryFactoringClause |
subavFactoringClause) (COMMA_ (subqueryFactoringClause |
subavFactoringClause))*)?
+ ;
+
+plsqlDeclarations
+ : (functionDeclaration | procedureDeclaration)+
+ ;
+
+functionDeclaration
+ : functionHeading ((DETERMINISTIC | PIPELINED | PARALLEL_ENABLE |
RESULT_CACHE)+)?
+ ;
+
+functionHeading
+ : FUNCTION functionName (LP_ parameterDeclaration (SQ_
parameterDeclaration)* RP_)? RETURN dataType
+ ;
+
+parameterDeclaration
+ : parameterName ((IN? dataType ((COLON_ EQ_ | DEFAULT) expr)?) | (IN? OUT
NOCOPY? dataType))?
+ ;
+
+procedureDeclaration
+ : procedureHeading procedureProperties
+ ;
+
+procedureHeading
+ : PROCEDURE procedureName (LP_ parameterDeclaration (SQ_
parameterDeclaration)* RP_)?
+ ;
+
+procedureProperties
+ : (accessibleByClause | defaultCollationClause | invokerRightsClause)*
+ ;
+
+accessibleByClause
+ : ACCESSIBLE BY LP_ accessor (COMMA_ accessor)* RP_
+ ;
+
+accessor
+ : unitKind? unitName
+ ;
+
+unitKind
+ : FUNCTION | PROCEDURE | PACKAGE | TRIGGER | TYPE
+ ;
+
+defaultCollationClause
+ : DEFAULT COLLATION collationOption
+ ;
+
+collationOption
+ : USING_NLS_COMP
+ ;
+
+invokerRightsClause
+ : AUTHID (CURRENT_USER | DEFINER)
+ ;
+
+subqueryFactoringClause
+ : queryName (LP_ alias (COMMA_ alias)* RP_)? AS LP_ selectSubquery RP_
searchClause? cycleClause?
+ ;
+
+searchClause
+ : SEARCH (DEPTH | BREADTH) FIRST BY (alias (ASC | DESC)? (NULLS FIRST |
NULLS LAST)?) (COMMA_ (alias (ASC | DESC)? (NULLS FIRST | NULLS LAST)?))* SET
orderingColumn
+ ;
+
+cycleClause
+ : CYCLE alias (COMMA_ alias)* SET alias TO cycleValue DEFAULT noCycleValue
+ ;
+
+subavFactoringClause
+ : subavName ANALYTIC VIEW AS LP_ subavClause RP_
+ ;
+
+subavClause
+ : USING baseAvName hierarchiesClause? filterClauses? addCalcsClause?
+ ;
+
+hierarchiesClause
+ : HIERARCHIES LP_ ((alias DOT_)? alias (COMMA_ (alias DOT_)? alias)*)? RP_
+ ;
+
+filterClauses
+ : FILTER FACT LP_ filterClause (COMMA_ filterClause)* RP_
+ ;
+
+filterClause
+ : (MEASURES | (alias DOT_)? alias) TO expr
+ ;
+
+addCalcsClause
+ : ADD MEASURES LP_ calcMeasClause (COMMA_ calcMeasClause)* RP_
+ ;
+
+calcMeasClause
+ : measName AS LP_ calcMeasExpression RP_
+ ;
+
+calcMeasExpression
+ : avExpression | expr
+ ;
+
+avExpression
+ : avMeasExpression | avHierExpression
+ ;
+
+avMeasExpression
+ : leadLagExpression | windowExpression | rankExpression |
shareOfExpression | qdrExpression
+ ;
+
+leadLagExpression
+ : leadLagFunctionName LP_ calcMeasExpression RP_ OVER LP_ leadLagClause RP_
+ ;
+
+leadLagFunctionName
+ : LAG | LAG_DIFF | LAG_DIF_PERCENT | LEAD | LEAD_DIFF | LEAD_DIFF_PERCENT
+ ;
+
+leadLagClause
+ : HIERARCHY hierarchyRef OFFSET offsetExpr ((WITHIN (LEVEL | PARENT)) |
(ACROSS ANCESTOR AT LEVEL levelRef (POSITION FROM (BEGINNING | END))?))?
+ ;
+
+hierarchyRef
+ : (alias DOT_)? alias
+ ;
+
Review comment:
I've checked the rule `alias`.
Could you put the below rule into the BaseRule.g4?
```
alias
: identifier | STRING_
;
```
##########
File path:
shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
##########
@@ -121,7 +121,223 @@ unionClause
;
queryBlock
- : SELECT duplicateSpecification? projections fromClause? whereClause?
groupByClause? havingClause?
+ : withClause? SELECT duplicateSpecification? projections fromClause?
whereClause? groupByClause? havingClause?
+ ;
+
+withClause
+ : WITH plsqlDeclarations? ((subqueryFactoringClause |
subavFactoringClause) (COMMA_ (subqueryFactoringClause |
subavFactoringClause))*)?
+ ;
+
+plsqlDeclarations
+ : (functionDeclaration | procedureDeclaration)+
+ ;
+
+functionDeclaration
+ : functionHeading ((DETERMINISTIC | PIPELINED | PARALLEL_ENABLE |
RESULT_CACHE)+)?
+ ;
+
+functionHeading
+ : FUNCTION functionName (LP_ parameterDeclaration (SQ_
parameterDeclaration)* RP_)? RETURN dataType
+ ;
+
+parameterDeclaration
+ : parameterName ((IN? dataType ((COLON_ EQ_ | DEFAULT) expr)?) | (IN? OUT
NOCOPY? dataType))?
+ ;
+
+procedureDeclaration
+ : procedureHeading procedureProperties
+ ;
+
+procedureHeading
+ : PROCEDURE procedureName (LP_ parameterDeclaration (SQ_
parameterDeclaration)* RP_)?
+ ;
+
+procedureProperties
+ : (accessibleByClause | defaultCollationClause | invokerRightsClause)*
+ ;
+
+accessibleByClause
+ : ACCESSIBLE BY LP_ accessor (COMMA_ accessor)* RP_
+ ;
+
+accessor
+ : unitKind? unitName
+ ;
+
+unitKind
+ : FUNCTION | PROCEDURE | PACKAGE | TRIGGER | TYPE
+ ;
+
+defaultCollationClause
+ : DEFAULT COLLATION collationOption
+ ;
+
+collationOption
+ : USING_NLS_COMP
+ ;
+
+invokerRightsClause
+ : AUTHID (CURRENT_USER | DEFINER)
+ ;
+
+subqueryFactoringClause
+ : queryName (LP_ alias (COMMA_ alias)* RP_)? AS LP_ selectSubquery RP_
searchClause? cycleClause?
+ ;
+
+searchClause
+ : SEARCH (DEPTH | BREADTH) FIRST BY (alias (ASC | DESC)? (NULLS FIRST |
NULLS LAST)?) (COMMA_ (alias (ASC | DESC)? (NULLS FIRST | NULLS LAST)?))* SET
orderingColumn
+ ;
+
+cycleClause
Review comment:

##########
File path:
shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
##########
@@ -121,7 +121,223 @@ unionClause
;
queryBlock
- : SELECT duplicateSpecification? projections fromClause? whereClause?
groupByClause? havingClause?
+ : withClause? SELECT duplicateSpecification? projections fromClause?
whereClause? groupByClause? havingClause?
+ ;
+
+withClause
+ : WITH plsqlDeclarations? ((subqueryFactoringClause |
subavFactoringClause) (COMMA_ (subqueryFactoringClause |
subavFactoringClause))*)?
+ ;
+
+plsqlDeclarations
+ : (functionDeclaration | procedureDeclaration)+
+ ;
+
+functionDeclaration
+ : functionHeading ((DETERMINISTIC | PIPELINED | PARALLEL_ENABLE |
RESULT_CACHE)+)?
+ ;
+
+functionHeading
+ : FUNCTION functionName (LP_ parameterDeclaration (SQ_
parameterDeclaration)* RP_)? RETURN dataType
+ ;
+
+parameterDeclaration
+ : parameterName ((IN? dataType ((COLON_ EQ_ | DEFAULT) expr)?) | (IN? OUT
NOCOPY? dataType))?
+ ;
+
+procedureDeclaration
+ : procedureHeading procedureProperties
+ ;
+
+procedureHeading
+ : PROCEDURE procedureName (LP_ parameterDeclaration (SQ_
parameterDeclaration)* RP_)?
+ ;
+
+procedureProperties
+ : (accessibleByClause | defaultCollationClause | invokerRightsClause)*
+ ;
+
+accessibleByClause
+ : ACCESSIBLE BY LP_ accessor (COMMA_ accessor)* RP_
+ ;
+
+accessor
+ : unitKind? unitName
+ ;
+
+unitKind
+ : FUNCTION | PROCEDURE | PACKAGE | TRIGGER | TYPE
+ ;
+
+defaultCollationClause
+ : DEFAULT COLLATION collationOption
+ ;
+
+collationOption
+ : USING_NLS_COMP
+ ;
+
+invokerRightsClause
+ : AUTHID (CURRENT_USER | DEFINER)
+ ;
+
+subqueryFactoringClause
+ : queryName (LP_ alias (COMMA_ alias)* RP_)? AS LP_ selectSubquery RP_
searchClause? cycleClause?
+ ;
+
+searchClause
+ : SEARCH (DEPTH | BREADTH) FIRST BY (alias (ASC | DESC)? (NULLS FIRST |
NULLS LAST)?) (COMMA_ (alias (ASC | DESC)? (NULLS FIRST | NULLS LAST)?))* SET
orderingColumn
+ ;
+
+cycleClause
+ : CYCLE alias (COMMA_ alias)* SET alias TO cycleValue DEFAULT noCycleValue
+ ;
+
+subavFactoringClause
+ : subavName ANALYTIC VIEW AS LP_ subavClause RP_
+ ;
+
+subavClause
+ : USING baseAvName hierarchiesClause? filterClauses? addCalcsClause?
+ ;
+
+hierarchiesClause
Review comment:
![Uploading image.png…]()
##########
File path:
shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
##########
@@ -121,7 +121,223 @@ unionClause
;
queryBlock
- : SELECT duplicateSpecification? projections fromClause? whereClause?
groupByClause? havingClause?
+ : withClause? SELECT duplicateSpecification? projections fromClause?
whereClause? groupByClause? havingClause?
+ ;
+
+withClause
+ : WITH plsqlDeclarations? ((subqueryFactoringClause |
subavFactoringClause) (COMMA_ (subqueryFactoringClause |
subavFactoringClause))*)?
+ ;
+
+plsqlDeclarations
+ : (functionDeclaration | procedureDeclaration)+
+ ;
+
+functionDeclaration
+ : functionHeading ((DETERMINISTIC | PIPELINED | PARALLEL_ENABLE |
RESULT_CACHE)+)?
+ ;
+
+functionHeading
+ : FUNCTION functionName (LP_ parameterDeclaration (SQ_
parameterDeclaration)* RP_)? RETURN dataType
+ ;
+
+parameterDeclaration
+ : parameterName ((IN? dataType ((COLON_ EQ_ | DEFAULT) expr)?) | (IN? OUT
NOCOPY? dataType))?
+ ;
+
+procedureDeclaration
+ : procedureHeading procedureProperties
+ ;
+
+procedureHeading
+ : PROCEDURE procedureName (LP_ parameterDeclaration (SQ_
parameterDeclaration)* RP_)?
+ ;
+
+procedureProperties
+ : (accessibleByClause | defaultCollationClause | invokerRightsClause)*
+ ;
+
+accessibleByClause
+ : ACCESSIBLE BY LP_ accessor (COMMA_ accessor)* RP_
+ ;
+
+accessor
+ : unitKind? unitName
+ ;
+
+unitKind
+ : FUNCTION | PROCEDURE | PACKAGE | TRIGGER | TYPE
+ ;
+
+defaultCollationClause
+ : DEFAULT COLLATION collationOption
+ ;
+
+collationOption
+ : USING_NLS_COMP
+ ;
+
+invokerRightsClause
+ : AUTHID (CURRENT_USER | DEFINER)
+ ;
+
+subqueryFactoringClause
+ : queryName (LP_ alias (COMMA_ alias)* RP_)? AS LP_ selectSubquery RP_
searchClause? cycleClause?
+ ;
+
+searchClause
+ : SEARCH (DEPTH | BREADTH) FIRST BY (alias (ASC | DESC)? (NULLS FIRST |
NULLS LAST)?) (COMMA_ (alias (ASC | DESC)? (NULLS FIRST | NULLS LAST)?))* SET
orderingColumn
+ ;
+
+cycleClause
+ : CYCLE alias (COMMA_ alias)* SET alias TO cycleValue DEFAULT noCycleValue
+ ;
+
+subavFactoringClause
+ : subavName ANALYTIC VIEW AS LP_ subavClause RP_
+ ;
+
+subavClause
+ : USING baseAvName hierarchiesClause? filterClauses? addCalcsClause?
+ ;
+
+hierarchiesClause
Review comment:

##########
File path:
shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
##########
@@ -121,7 +121,223 @@ unionClause
;
queryBlock
- : SELECT duplicateSpecification? projections fromClause? whereClause?
groupByClause? havingClause?
+ : withClause? SELECT duplicateSpecification? projections fromClause?
whereClause? groupByClause? havingClause?
+ ;
+
+withClause
+ : WITH plsqlDeclarations? ((subqueryFactoringClause |
subavFactoringClause) (COMMA_ (subqueryFactoringClause |
subavFactoringClause))*)?
+ ;
+
+plsqlDeclarations
+ : (functionDeclaration | procedureDeclaration)+
+ ;
+
+functionDeclaration
+ : functionHeading ((DETERMINISTIC | PIPELINED | PARALLEL_ENABLE |
RESULT_CACHE)+)?
+ ;
+
+functionHeading
+ : FUNCTION functionName (LP_ parameterDeclaration (SQ_
parameterDeclaration)* RP_)? RETURN dataType
+ ;
+
+parameterDeclaration
+ : parameterName ((IN? dataType ((COLON_ EQ_ | DEFAULT) expr)?) | (IN? OUT
NOCOPY? dataType))?
+ ;
+
+procedureDeclaration
+ : procedureHeading procedureProperties
+ ;
+
+procedureHeading
+ : PROCEDURE procedureName (LP_ parameterDeclaration (SQ_
parameterDeclaration)* RP_)?
+ ;
+
+procedureProperties
+ : (accessibleByClause | defaultCollationClause | invokerRightsClause)*
+ ;
+
+accessibleByClause
+ : ACCESSIBLE BY LP_ accessor (COMMA_ accessor)* RP_
+ ;
+
+accessor
+ : unitKind? unitName
+ ;
+
+unitKind
+ : FUNCTION | PROCEDURE | PACKAGE | TRIGGER | TYPE
+ ;
+
+defaultCollationClause
+ : DEFAULT COLLATION collationOption
+ ;
+
+collationOption
+ : USING_NLS_COMP
+ ;
+
+invokerRightsClause
+ : AUTHID (CURRENT_USER | DEFINER)
+ ;
+
+subqueryFactoringClause
+ : queryName (LP_ alias (COMMA_ alias)* RP_)? AS LP_ selectSubquery RP_
searchClause? cycleClause?
+ ;
+
+searchClause
+ : SEARCH (DEPTH | BREADTH) FIRST BY (alias (ASC | DESC)? (NULLS FIRST |
NULLS LAST)?) (COMMA_ (alias (ASC | DESC)? (NULLS FIRST | NULLS LAST)?))* SET
orderingColumn
+ ;
+
+cycleClause
+ : CYCLE alias (COMMA_ alias)* SET alias TO cycleValue DEFAULT noCycleValue
+ ;
+
+subavFactoringClause
+ : subavName ANALYTIC VIEW AS LP_ subavClause RP_
+ ;
+
+subavClause
+ : USING baseAvName hierarchiesClause? filterClauses? addCalcsClause?
+ ;
+
+hierarchiesClause
+ : HIERARCHIES LP_ ((alias DOT_)? alias (COMMA_ (alias DOT_)? alias)*)? RP_
+ ;
+
+filterClauses
+ : FILTER FACT LP_ filterClause (COMMA_ filterClause)* RP_
+ ;
+
+filterClause
Review comment:

##########
File path:
shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
##########
@@ -121,7 +121,223 @@ unionClause
;
queryBlock
- : SELECT duplicateSpecification? projections fromClause? whereClause?
groupByClause? havingClause?
+ : withClause? SELECT duplicateSpecification? projections fromClause?
whereClause? groupByClause? havingClause?
+ ;
+
+withClause
+ : WITH plsqlDeclarations? ((subqueryFactoringClause |
subavFactoringClause) (COMMA_ (subqueryFactoringClause |
subavFactoringClause))*)?
+ ;
+
+plsqlDeclarations
+ : (functionDeclaration | procedureDeclaration)+
+ ;
+
+functionDeclaration
+ : functionHeading ((DETERMINISTIC | PIPELINED | PARALLEL_ENABLE |
RESULT_CACHE)+)?
+ ;
+
+functionHeading
+ : FUNCTION functionName (LP_ parameterDeclaration (SQ_
parameterDeclaration)* RP_)? RETURN dataType
+ ;
+
+parameterDeclaration
+ : parameterName ((IN? dataType ((COLON_ EQ_ | DEFAULT) expr)?) | (IN? OUT
NOCOPY? dataType))?
+ ;
+
+procedureDeclaration
+ : procedureHeading procedureProperties
+ ;
+
+procedureHeading
+ : PROCEDURE procedureName (LP_ parameterDeclaration (SQ_
parameterDeclaration)* RP_)?
+ ;
+
+procedureProperties
+ : (accessibleByClause | defaultCollationClause | invokerRightsClause)*
+ ;
+
+accessibleByClause
+ : ACCESSIBLE BY LP_ accessor (COMMA_ accessor)* RP_
+ ;
+
+accessor
+ : unitKind? unitName
+ ;
+
+unitKind
+ : FUNCTION | PROCEDURE | PACKAGE | TRIGGER | TYPE
+ ;
+
+defaultCollationClause
+ : DEFAULT COLLATION collationOption
+ ;
+
+collationOption
+ : USING_NLS_COMP
+ ;
+
+invokerRightsClause
+ : AUTHID (CURRENT_USER | DEFINER)
+ ;
+
+subqueryFactoringClause
+ : queryName (LP_ alias (COMMA_ alias)* RP_)? AS LP_ selectSubquery RP_
searchClause? cycleClause?
+ ;
+
+searchClause
+ : SEARCH (DEPTH | BREADTH) FIRST BY (alias (ASC | DESC)? (NULLS FIRST |
NULLS LAST)?) (COMMA_ (alias (ASC | DESC)? (NULLS FIRST | NULLS LAST)?))* SET
orderingColumn
+ ;
+
+cycleClause
+ : CYCLE alias (COMMA_ alias)* SET alias TO cycleValue DEFAULT noCycleValue
+ ;
+
+subavFactoringClause
+ : subavName ANALYTIC VIEW AS LP_ subavClause RP_
+ ;
+
+subavClause
+ : USING baseAvName hierarchiesClause? filterClauses? addCalcsClause?
+ ;
+
+hierarchiesClause
+ : HIERARCHIES LP_ ((alias DOT_)? alias (COMMA_ (alias DOT_)? alias)*)? RP_
+ ;
+
+filterClauses
+ : FILTER FACT LP_ filterClause (COMMA_ filterClause)* RP_
+ ;
+
+filterClause
+ : (MEASURES | (alias DOT_)? alias) TO expr
+ ;
+
+addCalcsClause
+ : ADD MEASURES LP_ calcMeasClause (COMMA_ calcMeasClause)* RP_
+ ;
+
+calcMeasClause
Review comment:
Could you put a reference link of the rule `calcMeasClause`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]