From 5c70cc5a71279c9926eca701e66bcdcd59f72e11 Mon Sep 17 00:00:00 2001
From: ironman <34911091+lcfliuxi@users.noreply.github.com>
Date: Fri, 8 Nov 2024 16:10:02 +0800
Subject: [PATCH] Fix PostgreSQL and openGauss time extract function parse week
and quarter error (#33564)
* Fix PostgreSQL time extract function parse week and quarter error
* Fix openGauss time extract function parse week and quarter error
* Support time extract function parse week and quarter in openGauss
* Added support for time extract function parse week and quarter in PostgreSQL and openGauss
---
.../main/antlr4/imports/opengauss/BaseRule.g4 | 4 ++
.../antlr4/imports/postgresql/BaseRule.g4 | 4 ++
.../case/dml/select-special-function.xml | 44 +++++++++++++++++++
.../supported/dml/select-special-function.xml | 2 +
.../resources/sql/unsupported/unsupported.xml | 2 -
5 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/BaseRule.g4 b/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/BaseRule.g4
index abf4c2e63d310..610ebdda0be74 100644
--- a/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/BaseRule.g4
+++ b/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/BaseRule.g4
@@ -329,6 +329,7 @@ unreservedWord
| PROCEDURES
| PROGRAM
| PUBLICATION
+ | QUARTER
| QUOTE
| RANGE
| READ
@@ -427,6 +428,7 @@ unreservedWord
| VIEW
| VIEWS
| VOLATILE
+ | WEEK
| WHITESPACE
| WITHIN
| WITHOUT
@@ -1147,7 +1149,9 @@ extractList
extractArg
: YEAR
+ | QUARTER
| MONTH
+ | WEEK
| DAY
| HOUR
| MINUTE
diff --git a/parser/sql/dialect/postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4 b/parser/sql/dialect/postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4
index 751ca07f4e0f2..4a1910c3b99f4 100644
--- a/parser/sql/dialect/postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4
+++ b/parser/sql/dialect/postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4
@@ -330,6 +330,7 @@ unreservedWord
| PROCEDURES
| PROGRAM
| PUBLICATION
+ | QUARTER
| QUOTE
| RANGE
| READ
@@ -428,6 +429,7 @@ unreservedWord
| VIEW
| VIEWS
| VOLATILE
+ | WEEK
| WHITESPACE
| WITHIN
| WITHOUT
@@ -1114,7 +1116,9 @@ extractList
extractArg
: YEAR
+ | QUARTER
| MONTH
+ | WEEK
| DAY
| HOUR
| MINUTE
diff --git a/test/it/parser/src/main/resources/case/dml/select-special-function.xml b/test/it/parser/src/main/resources/case/dml/select-special-function.xml
index 696568f2e0828..6712182134b86 100644
--- a/test/it/parser/src/main/resources/case/dml/select-special-function.xml
+++ b/test/it/parser/src/main/resources/case/dml/select-special-function.xml
@@ -440,6 +440,50 @@
+
+
+
+