Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PostgreSQL and openGauss time extract function parse week and quarter error #33564

Merged
merged 8 commits into from
Nov 8, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ unreservedWord
| PROCEDURES
| PROGRAM
| PUBLICATION
| QUARTER
| QUOTE
| RANGE
| READ
Expand Down Expand Up @@ -427,6 +428,7 @@ unreservedWord
| VIEW
| VIEWS
| VOLATILE
| WEEK
| WHITESPACE
| WITHIN
| WITHOUT
Expand Down Expand Up @@ -1147,7 +1149,9 @@ extractList

extractArg
: YEAR
| QUARTER
| MONTH
| WEEK
| DAY
| HOUR
| MINUTE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ unreservedWord
| PROCEDURES
| PROGRAM
| PUBLICATION
| QUARTER
| QUOTE
| RANGE
| READ
Expand Down Expand Up @@ -428,6 +429,7 @@ unreservedWord
| VIEW
| VIEWS
| VOLATILE
| WEEK
| WHITESPACE
| WITHIN
| WITHOUT
Expand Down Expand Up @@ -1114,7 +1116,9 @@ extractList

extractArg
: YEAR
| QUARTER
| MONTH
| WEEK
| DAY
| HOUR
| MINUTE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,50 @@
</projections>
</select>

<select sql-case-id="select_extract_function_week">
<projections start-index="7" stop-index="56">
<expression-projection text="EXTRACT(WEEK FROM TIMESTAMP '2001-02-16 20:38:40')" start-index="7" stop-index="56">
<expr>
<function function-name="EXTRACT" start-index="7" stop-index="56" text="EXTRACT(WEEK FROM TIMESTAMP '2001-02-16 20:38:40')">
<parameter>
<extract-arg start-index="15" stop-index="18" text="WEEK" />
</parameter>
<parameter>
<type-cast-expression>
<expression>
<literal-expression value="2001-02-16 20:38:40" start-index="35" stop-index="55" />
</expression>
<data-type>TIMESTAMP</data-type>
</type-cast-expression>
</parameter>
</function>
</expr>
</expression-projection>
</projections>
</select>

<select sql-case-id="select_extract_function_quarter">
<projections start-index="7" stop-index="59">
<expression-projection text="EXTRACT(QUARTER FROM TIMESTAMP '2001-02-16 20:38:40')" start-index="7" stop-index="59">
<expr>
<function function-name="EXTRACT" start-index="7" stop-index="59" text="EXTRACT(QUARTER FROM TIMESTAMP '2001-02-16 20:38:40')">
<parameter>
<extract-arg start-index="15" stop-index="21" text="QUARTER" />
</parameter>
<parameter>
<type-cast-expression>
<expression>
<literal-expression value="2001-02-16 20:38:40" start-index="38" stop-index="58" />
</expression>
<data-type>TIMESTAMP</data-type>
</type-cast-expression>
</parameter>
</function>
</expr>
</expression-projection>
</projections>
</select>

<select sql-case-id="select_extract_function_for_oracle">
<projections start-index="7" stop-index="56" literal-start-index="7" literal-stop-index="56">
<expression-projection text="EXTRACT(YEAR FROM TIMESTAMP '2001-02-16 20:38:40')" start-index="7" stop-index="56" literal-start-index="7" literal-stop-index="56">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
<sql-case id="select_values" value="SELECT VALUES(order_id) FROM t_order" db-types="MySQL" />
<sql-case id="select_current_user_brackets" value="SELECT CURRENT_USER()" db-types="MySQL" />
<sql-case id="select_extract_function" value="SELECT EXTRACT(YEAR FROM TIMESTAMP '2001-02-16 20:38:40')" db-types="PostgreSQL,openGauss" />
<sql-case id="select_extract_function_week" value="SELECT EXTRACT(WEEK FROM TIMESTAMP '2001-02-16 20:38:40')" db-types="PostgreSQL,openGauss" />
<sql-case id="select_extract_function_quarter" value="SELECT EXTRACT(QUARTER FROM TIMESTAMP '2001-02-16 20:38:40')" db-types="PostgreSQL,openGauss" />
<sql-case id="select_extract_function_for_oracle" value="SELECT EXTRACT(YEAR FROM TIMESTAMP '2001-02-16 20:38:40') FROM DUAL" db-types="Oracle" />
<sql-case id="select_mod_function" value="SELECT MOD(order_id, 1) from t_order" db-types="PostgreSQL,openGauss" />
<sql-case id="select_sys_xml_agg" value="SELECT SYS_XMLAGG(SYS_XMLGEN(last_name)) XMLAGG FROM employees WHERE last_name LIKE 'R%' ORDER BY xmlagg;" db-types="Oracle" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,6 @@
<sql-case id="unsupported_select_case_for_opengauss_438" value="select B'101' | as result;" db-types="openGauss" />
<sql-case id="unsupported_select_case_for_opengauss_439" value="select B'101' # as result;" db-types="openGauss" />
<sql-case id="unsupported_select_case_for_opengauss_440" value="select B'11110' # B'0000';" db-types="openGauss" />
<sql-case id="unsupported_select_case_for_opengauss_443" value="select extract(quarter from timestamp '2001-02-16 20:38:40') from sys_dummy;" db-types="openGauss" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lcfliuxi, can you move these two cases to supportes.xml and add expected file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, but is it duplicate with this?
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lcfliuxi, can you move these two cases to supportes.xml and add expected file.

Hi @strongduanmu, I added this, pls help review again thank you.

<sql-case id="unsupported_select_case_for_opengauss_444" value="select extract(week from timestamp '2001-02-16 20:38:40') from sys_dummy;" db-types="openGauss" />
<sql-case id="unsupported_select_case_for_opengauss_447" value="select atan(11 11) from sys_dummy;" db-types="openGauss" />
<sql-case id="unsupported_select_case_for_opengauss_448" value="select atan(,) from sys_dummy;" db-types="openGauss" />
<sql-case id="unsupported_select_case_for_opengauss_451" value="select $$the lexeme ' ' , contains spaces$$::tsvector@@ ','::tsquery as result;" db-types="openGauss" />
Expand Down