[ https://issues.apache.org/jira/browse/CALCITE-6045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17775934#comment-17775934 ]
Tanner Clary commented on CALCITE-6045: --------------------------------------- For FLOOR and CEIL, we added some logic to the parser that checks the current conformance and if it is BQ, then use the BQ-specific operator. I think Jerin is dealing with something similar and a lot of the suggestions (that I have had, at least) involve checking the conformance. Then maybe you could have an operator like CURRENT_TIMESTAMP_BQ or something similar. See FLOOR/CEIL like I mentioned or SUBSTR. If there's another difference between the operators, like operand count, which I don't think is applicable here, you could also use that instead. > CURRENT_TIMESTAMP has incorrect return type > ------------------------------------------- > > Key: CALCITE-6045 > URL: https://issues.apache.org/jira/browse/CALCITE-6045 > Project: Calcite > Issue Type: Bug > Reporter: Tanner Clary > Priority: Major > > When trying to work on CALCITE-6021, I noticed that {{CURRENT_TIMESTAMP}} > currently returns type {{TIMESTAMP}} when it should be > {{TIMESTAMP_WITH_LOCAL_TIME_ZONE}}. > After modifying it, I noticed function was returning the time from (UTC - > System TZ) hours ago. For example, I am in {{America/Los_Angeles}} and if I > called the function at {{2023-10-10 13:28:00 America/Los_Angeles}}, it would > return {{2023-10-10 06:28:00 America/Los_Angeles}}. > I think this is because the DataContext {{CURRENT_TIMESTAMP}} variable, which > is meant to represent milliseconds since epoch UTC, actually has the timezone > offset applied in {{CalciteConnectionImpl#DataContextImpl}} > [here|https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/jdbc/CalciteConnectionImpl.java#L442]. > To be clear: it is meant to represent millis since epoch UTC, but instead it > is millis since epoch [system tz], as I understand it. > Additionally, I believe the {{getString()}} method for timestamps in > AvaticaResultSet should behave similarly to > [{{SqlFunctions#timestampWithLocalTimezoneToString()}}|https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java#L4021] > when dealing with a {{TIMESTAMP WITH LOCAL TIME ZONE}}. Right now, it does > not take the timezone into consideration so although it represents the > accurate instant in time, it displays differently than > {{CAST(CURRENT_TIMESTAMP AS VARCHAR)}}. > For example, {{SELECT CURRENT_TIMESTAMP, CAST(CURRENT_TIMESTAMP AS > VARCHAR)}}, with the correct return type, returns something like: > {{2023-10-10 13:28:00 | 2023-10-10 06:28:00.000 America/Los_Angeles}} -- This message was sent by Atlassian Jira (v8.20.10#820010)