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

[CALCITE-6150] Unparse for certain EXTRACT Unit with ClickHouseSqlDialect #3557

Closed
wants to merge 4 commits into from

Conversation

Chen768959
Copy link
Contributor

Clickhouse does not support the following EXTRACT Unit syntax, and ClickHouseSqlDialect may need some adaptation.

SELECT EXTRACT(DOW FROM Date '2023-12-01')
image
SELECT EXTRACT(DOY FROM Date '2023-12-01')
image
SELECT EXTRACT(WEEK FROM Date '2023-12-01')
image

@Chen768959 Chen768959 changed the title [CALCITE-6149] Unparse for certain EXTRACT Unit with ClickHouseSqlDialect [CALCITE-6150] Unparse for certain EXTRACT Unit with ClickHouseSqlDialect Dec 1, 2023
@@ -7453,6 +7453,23 @@ private void checkLiteral2(String expression, String expected) {
sql(query).withSpark().withLibrary(SqlLibrary.SPARK).ok(expectedSql);
}

/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-6150">[CALCITE-6150]
Copy link
Contributor

Choose a reason for hiding this comment

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

Convert this to testExtract, move it to the right place in the file (at the end will collide with other changes), and test at least one other dialect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@julianhyde Thank you for your review. It seems that there were no tests for the EXTRACT operator previously, so I have changed the test case to testExtract and added tests for the EXTRACT operator in various dialects. If it's convenient for you, I look forward to your further review. Thank you.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is good. Can you break up the strings to make the lines shorter (just one call per line). Put + at the start of the line (per our style checker).

Move the method after testBigQueryDatetimeFormatFunctions, which is similar. (Anywhere but the end of the 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.

This is good. Can you break up the strings to make the lines shorter (just one call per line). Put + at the start of the line (per our style checker).

Move the method after testBigQueryDatetimeFormatFunctions, which is similar. (Anywhere but the end of the file.)

I have fixed the code style and moved testExtract after testBigQuery. I look forward to your further review. Thank you.

Copy link
Contributor

@mihaibudiu mihaibudiu left a comment

Choose a reason for hiding this comment

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

There are many existing extract tests.
I tried to fix many more cases for extract here: #3435
But this failed the Druid tests. (Not sure it's the same problem with the current Druid failures. Didn't have time to investigate.)

@julianhyde
Copy link
Contributor

@mihaibudiu, By 'no tests for EXTRACT previously' I believe @Chen768959 is referring specifically to RelToSqlConverterTest.

@Chen768959
Copy link
Contributor Author

@mihaibudiu, By 'no tests for EXTRACT previously' I believe @Chen768959 is referring specifically to RelToSqlConverterTest.

Yes

@@ -2264,6 +2264,74 @@ private SqlDialect nonOrdinalDialect() {
sql(query).withLibrary(SqlLibrary.BIG_QUERY).ok(expected);
}

/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-6150">[CALCITE-6150]
* Generate dialect-specific SQL for EXTRACT operator.</a>. */
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you can remove . before a tag.

Copy link
Contributor Author

@Chen768959 Chen768959 Dec 6, 2023

Choose a reason for hiding this comment

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

Maybe you can remove . before a tag.

Okay, it seems that other tags also don't have a . at the end, I will remove it.

julianhyde added a commit to julianhyde/calcite that referenced this pull request Dec 6, 2023
julianhyde added a commit to julianhyde/calcite that referenced this pull request Dec 6, 2023
@asfgit asfgit closed this in d3ab0bc Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants