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-6021] Add CURRENT_DATETIME function (enabled in BigQuery library) #3457

Merged
merged 1 commit into from
Oct 12, 2023

Conversation

tanclary
Copy link
Contributor

@tanclary tanclary commented Oct 5, 2023

No description provided.

@tanclary tanclary changed the title [CALCITE-6021] Finish CURRENT_DATETIME implementation [CALCITE-6021] Add CURRENT_DATETIME function (enabled in BigQuery library) Oct 10, 2023
@tanclary tanclary marked this pull request as ready for review October 10, 2023 19:28
@tanclary tanclary force-pushed the 6021-current-datetime branch 3 times, most recently from 2f01971 to 99880b5 Compare October 10, 2023 21:37
| 2016-05-19T10:38:47.046465 |
+----------------------------+
SELECT CURRENT_DATETIME > DATETIME '2008-12-25 15:30:00' as now;
+------+
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be useful if Quidem had a way to mask out results? E.g.

!mask 6 "[0-9]" "x"
SELECT CURRENT_DATETIME as now;
+----------------------------+
| now                        |
+----------------------------+
| 2016-05-19T10:38:47.046465 |
+----------------------------+

would succeed because '2016-05-19T10:38:47.046465' and '2023-11-11T16:38:47.012345' would both be converted to 'xxxx-xx-xxTxx:xx:xx.xxxxxx'. The 6 means 'the next 6 lines'.

I logged julianhyde/quidem#79. Please add comments there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Left a comment on the issue, sounds like a good idea.

@@ -682,6 +682,9 @@ public enum BuiltInMethod {
CURRENT_TIMESTAMP(SqlFunctions.class, "currentTimestamp", DataContext.class),
CURRENT_TIME(SqlFunctions.class, "currentTime", DataContext.class),
CURRENT_DATE(SqlFunctions.class, "currentDate", DataContext.class),
CURRENT_DATETIME(SqlFunctions.class, "currentDatetime", DataContext.class),
CURRENT_DATETIME2(SqlFunctions.class, "currentDatetime", DataContext.class,
String.class),
Copy link
Contributor

Choose a reason for hiding this comment

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

indent 4, not 2

final String currentDateTimeExpr = "select ^current_datetime^";
SqlValidatorFixture shouldFail = sql(currentDateTimeExpr)
.withConformance(SqlConformanceEnum.BIG_QUERY);
final String expectedError = "query [select CURRENT_DATETIME]; exception "
+ "[Column 'CURRENT_DATETIME' not found in any table]; class "
+ "[class org.apache.calcite.sql.validate.SqlValidatorException]; pos [line 1 col 8 thru line 1 col 8]";
shouldFail.fails("Column 'CURRENT_DATETIME' not found in any table");
// shouldFail.fails("Column 'CURRENT_DATETIME' not found in any table");
Copy link
Contributor

Choose a reason for hiding this comment

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

remove the comment or the line

Copy link
Contributor

@julianhyde julianhyde left a comment

Choose a reason for hiding this comment

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

LGTM when you've fixed some cosmetic changes.

@tanclary tanclary force-pushed the 6021-current-datetime branch 4 times, most recently from 9cea2e0 to 5aafb98 Compare October 12, 2023 18:16
@sonarcloud
Copy link

sonarcloud bot commented Oct 12, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 4 Code Smells

98.2% 98.2% Coverage
0.0% 0.0% Duplication

@tanclary tanclary merged commit db60219 into apache:main Oct 12, 2023
18 checks passed
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.

3 participants