You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "normanj-bitquill (via GitHub)" <gi...@apache.org> on 2024/04/05 21:44:08 UTC
[PR] [CALCITE-6315] Add TO_CHAR, TO_DATE, TO_TIMESTAMP functions [calcite]
normanj-bitquill opened a new pull request, #3753:
URL: https://github.com/apache/calcite/pull/3753
* All 3 functions use PostgreSQL format patterns
* Added tests for format patterns supported by PostgreSQL but missing from Calcite
* If the data or timestamp cannot be parsed using format string, then an exception is thrown.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6315] Add TO_DATE, TO_TIMESTAMP functions [calcite]
Posted by "normanj-bitquill (via GitHub)" <gi...@apache.org>.
normanj-bitquill commented on code in PR #3753:
URL: https://github.com/apache/calcite/pull/3753#discussion_r1558283731
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -4465,44 +4465,35 @@ void testBitGetFunc(SqlOperatorFixture f, String functionName) {
f.checkString("to_char(timestamp '2022-06-03 12:15:48.678', 'YYYY-MM-DD HH24:MI:SS.MS TZ')",
"2022-06-03 12:15:48.678",
"VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 12:15:48.678', 'Day')",
Review Comment:
A mistake on my part. They have been added back, and I have added some more tests.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6315] Add TO_CHAR, TO_DATE, TO_TIMESTAMP functions [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #3753:
URL: https://github.com/apache/calcite/pull/3753#issuecomment-2041558708
The style checker has some complaints about your code. You can see them in the failed CI run.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6315] Add TO_CHAR, TO_DATE, TO_TIMESTAMP functions [calcite]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3753:
URL: https://github.com/apache/calcite/pull/3753#issuecomment-2040688469
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3753) **Quality Gate passed**
Issues
 [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3753&resolved=false&inNewCodePeriod=true)
 [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3753&metric=new_accepted_issues&view=list)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3753&resolved=false&inNewCodePeriod=true)
 [97.1% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3753&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3753&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3753)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6315] Add TO_CHAR, TO_DATE, TO_TIMESTAMP functions [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #3753:
URL: https://github.com/apache/calcite/pull/3753#discussion_r1556254049
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -4465,44 +4465,35 @@ void testBitGetFunc(SqlOperatorFixture f, String functionName) {
f.checkString("to_char(timestamp '2022-06-03 12:15:48.678', 'YYYY-MM-DD HH24:MI:SS.MS TZ')",
"2022-06-03 12:15:48.678",
"VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 12:15:48.678', 'Day')",
Review Comment:
why delete these tests?
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -4465,44 +4465,35 @@ void testBitGetFunc(SqlOperatorFixture f, String functionName) {
f.checkString("to_char(timestamp '2022-06-03 12:15:48.678', 'YYYY-MM-DD HH24:MI:SS.MS TZ')",
"2022-06-03 12:15:48.678",
"VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 12:15:48.678', 'Day')",
- "Friday",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '0001-01-01 00:00:00.000', 'Day')",
- "Monday",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 12:15:48.678', 'DY')",
- "Fri",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '0001-01-01 00:00:00.000', 'DY')",
- "Mon",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 12:15:48.678', 'CC')",
- "21",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 13:15:48.678', 'HH12')",
- "01",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 13:15:48.678', 'HH24')",
- "13",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 13:15:48.678', 'MI')",
- "15",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 13:15:48.678', 'MS')",
- "678",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 13:15:48.678', 'Q')",
- "2",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 13:15:48.678', 'IW')",
- "23",
- "VARCHAR NOT NULL");
f.checkNull("to_char(timestamp '2022-06-03 12:15:48.678', NULL)");
f.checkNull("to_char(cast(NULL as timestamp), NULL)");
f.checkNull("to_char(cast(NULL as timestamp), 'Day')");
}
+ @Test void testToDate() {
+ final SqlOperatorFixture f = fixture().withLibrary(SqlLibrary.POSTGRESQL);
+ f.setFor(SqlLibraryOperators.TO_DATE);
+
+ f.checkString("to_date('2022-06-03', 'YYYY-MM-DD')",
+ "2022-06-03",
+ "DATE NOT NULL");
+ f.checkFails("to_date('ABCD', 'YYYY-MM-DD')",
+ "java.sql.SQLException: Invalid format: 'YYYY-MM-DD' for datetime string: 'ABCD'.",
+ true);
+ }
+
+ @Test void testToTimestamp() {
+ final SqlOperatorFixture f = fixture().withLibrary(SqlLibrary.POSTGRESQL);
+ f.setFor(SqlLibraryOperators.TO_TIMESTAMP);
+
+ f.checkString("to_timestamp('2022-06-03 18:34:56', 'YYYY-MM-DD HH24:MI:SS')",
+ "2022-06-03 18:34:56",
+ "TIMESTAMP(0) NOT NULL");
+ f.checkFails("to_timestamp('ABCD', 'YYYY-MM-DD HH24:MI:SS')",
Review Comment:
please add more tests, including nulls, and illegal value for date, and dates before the Gregorian calendar
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6315] Add TO_CHAR, TO_DATE, TO_TIMESTAMP functions [calcite]
Posted by "normanj-bitquill (via GitHub)" <gi...@apache.org>.
normanj-bitquill commented on PR #3753:
URL: https://github.com/apache/calcite/pull/3753#issuecomment-2043386567
@mihaibudiu Thank you, I have addressed the style checker error. The latest CI run failed when trying to pull the redis docker image.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6315] Add TO_DATE, TO_TIMESTAMP functions [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #3753:
URL: https://github.com/apache/calcite/pull/3753#issuecomment-2046049159
In order to keep track of JIRA/github, we require the JIRA title to be the same as the PR title, and the commit message.
Can you please make sure they match?
The JIRA title is good if you remove "TO_CHAR" from it.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6315] Add TO_DATE, TO_TIMESTAMP functions [calcite]
Posted by "normanj-bitquill (via GitHub)" <gi...@apache.org>.
normanj-bitquill commented on PR #3753:
URL: https://github.com/apache/calcite/pull/3753#issuecomment-2046110801
> In order to keep track of JIRA/github, we require the JIRA title to be the same as the PR title, and the commit message. Can you please make sure they match? The JIRA title is good if you remove "TO_CHAR" from it.
@mihaibudiu I don't have permission to change the title in Jira or to assign the ticket to myself. Can I get the necessary permissions?
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6315] Add TO_DATE, TO_TIMESTAMP functions [calcite]
Posted by "normanj-bitquill (via GitHub)" <gi...@apache.org>.
normanj-bitquill commented on PR #3753:
URL: https://github.com/apache/calcite/pull/3753#issuecomment-2046036405
> I don't understand what happens to TO_CHAR in this PR.
@mihaibudiu Good point. I have updated the title of this PR and the commit message to say that I only added support for `TO_DATE` and `TO_TIMESTAMP`.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6315] Support PostgreSQL TO_CHAR, TO_DATE, TO_TIMESTAMP [calcite]
Posted by "normanj-bitquill (via GitHub)" <gi...@apache.org>.
normanj-bitquill commented on PR #3753:
URL: https://github.com/apache/calcite/pull/3753#issuecomment-2046162746
@mihaibudiu Thanks for changing the title in Jira. I have updated the commit message and title of this PR. I'll sort out my Jira permissions.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6315] Support PostgreSQL TO_CHAR, TO_DATE, TO_TIMESTAMP [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu merged PR #3753:
URL: https://github.com/apache/calcite/pull/3753
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6315] Add TO_DATE, TO_TIMESTAMP functions [calcite]
Posted by "normanj-bitquill (via GitHub)" <gi...@apache.org>.
normanj-bitquill commented on code in PR #3753:
URL: https://github.com/apache/calcite/pull/3753#discussion_r1558284201
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -4465,44 +4465,35 @@ void testBitGetFunc(SqlOperatorFixture f, String functionName) {
f.checkString("to_char(timestamp '2022-06-03 12:15:48.678', 'YYYY-MM-DD HH24:MI:SS.MS TZ')",
"2022-06-03 12:15:48.678",
"VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 12:15:48.678', 'Day')",
- "Friday",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '0001-01-01 00:00:00.000', 'Day')",
- "Monday",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 12:15:48.678', 'DY')",
- "Fri",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '0001-01-01 00:00:00.000', 'DY')",
- "Mon",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 12:15:48.678', 'CC')",
- "21",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 13:15:48.678', 'HH12')",
- "01",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 13:15:48.678', 'HH24')",
- "13",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 13:15:48.678', 'MI')",
- "15",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 13:15:48.678', 'MS')",
- "678",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 13:15:48.678', 'Q')",
- "2",
- "VARCHAR NOT NULL");
- f.checkString("to_char(timestamp '2022-06-03 13:15:48.678', 'IW')",
- "23",
- "VARCHAR NOT NULL");
f.checkNull("to_char(timestamp '2022-06-03 12:15:48.678', NULL)");
f.checkNull("to_char(cast(NULL as timestamp), NULL)");
f.checkNull("to_char(cast(NULL as timestamp), 'Day')");
}
+ @Test void testToDate() {
+ final SqlOperatorFixture f = fixture().withLibrary(SqlLibrary.POSTGRESQL);
+ f.setFor(SqlLibraryOperators.TO_DATE);
+
+ f.checkString("to_date('2022-06-03', 'YYYY-MM-DD')",
+ "2022-06-03",
+ "DATE NOT NULL");
+ f.checkFails("to_date('ABCD', 'YYYY-MM-DD')",
+ "java.sql.SQLException: Invalid format: 'YYYY-MM-DD' for datetime string: 'ABCD'.",
+ true);
+ }
+
+ @Test void testToTimestamp() {
+ final SqlOperatorFixture f = fixture().withLibrary(SqlLibrary.POSTGRESQL);
+ f.setFor(SqlLibraryOperators.TO_TIMESTAMP);
+
+ f.checkString("to_timestamp('2022-06-03 18:34:56', 'YYYY-MM-DD HH24:MI:SS')",
+ "2022-06-03 18:34:56",
+ "TIMESTAMP(0) NOT NULL");
+ f.checkFails("to_timestamp('ABCD', 'YYYY-MM-DD HH24:MI:SS')",
Review Comment:
Added more tests for both `TO_DATE` and `TO_TIMESTAMP`.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6315] Add TO_DATE, TO_TIMESTAMP functions [calcite]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3753:
URL: https://github.com/apache/calcite/pull/3753#issuecomment-2046066643
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3753) **Quality Gate passed**
Issues
 [6 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3753&resolved=false&inNewCodePeriod=true)
 [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3753&metric=new_accepted_issues&view=list)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3753&resolved=false&inNewCodePeriod=true)
 [98.5% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3753&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3753&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3753)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6315] Add TO_DATE, TO_TIMESTAMP functions [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #3753:
URL: https://github.com/apache/calcite/pull/3753#issuecomment-2046158241
I edited the JIRA title. You shoud change the commit and PR titles.
But if you have a JIRA account and you filed the issue I would expect you to be able to edit it... I don't know much about JIRA, though. Don't worry about assigning it.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org