You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "mihaibudiu (via GitHub)" <gi...@apache.org> on 2023/12/07 21:16:05 UTC

[PR] [CALCITE-6138] Parser does not accept TIMESTAMP WITH TIME ZONE as a data type [calcite]

mihaibudiu opened a new pull request, #3569:
URL: https://github.com/apache/calcite/pull/3569

   This is a large pull request which adds preliminary support for the types `TIME WITH TIME ZONE` and `TIMESTAMP WITH TIMEZONE`. This pull requests contains mostly front-end work, for parsing and properly representing such literals. Follow-up work will need to implement many of the primitive operations on such values, such as casts, field extraction. I plan to contribute some of these in subsequent PRs. 
   
   So this is the first part required to implement CALCITE-208 https://issues.apache.org/jira/browse/CALCITE-208 which was opened 9 years ago.


-- 
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-6138] Parser does not accept TIMESTAMP WITH TIME ZONE as a data type [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #3569:
URL: https://github.com/apache/calcite/pull/3569#issuecomment-1869743676

   Thank you @tanclary for the review, I have tried to address your suggestions in the last commit.


-- 
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-6138] Parser does not accept TIMESTAMP WITH TIME ZONE as a data type [calcite]

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on PR #3569:
URL: https://github.com/apache/calcite/pull/3569#issuecomment-1980905984

   @mihaibudiu since we are going to have a release soon I would merge this by the end of this week
   please let me know if you have any objections


-- 
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-6138] Parser does not accept TIMESTAMP WITH TIME ZONE as a data type [calcite]

Posted by "julianhyde (via GitHub)" <gi...@apache.org>.
julianhyde commented on code in PR #3569:
URL: https://github.com/apache/calcite/pull/3569#discussion_r1468129736


##########
core/src/main/java/org/apache/calcite/sql/type/SqlTypeName.java:
##########
@@ -309,7 +314,10 @@ public enum SqlTypeName {
    * matches the given name, or throws {@link IllegalArgumentException}; never
    * returns null. */
   public static SqlTypeName lookup(String tag) {
-    String tag2 = tag.replace(' ', '_');
+    // Special handling for TIME WITH TIME ZONE and
+    // TIMESTAMP WITH TIME ZONE, whose names are TIME_TZ and TIMESTAMP_TZ
+    final String tag1 = tag.replace("WITH TIME ZONE", "TZ");

Review Comment:
   +1 mihai's perspective



-- 
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-6138] Parser does not accept TIMESTAMP WITH TIME ZONE as a data type [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #3569:
URL: https://github.com/apache/calcite/pull/3569#issuecomment-1867088799

   I have simplified the naming of the types, as suggested by @julianhyde in a JIRA discussion for the uber-issue 208 that this PR is a part of: https://issues.apache.org/jira/browse/CALCITE-208
   This is ready for review. If you were waiting for time with timezones, this is your chance to get 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-6138] Parser does not accept TIMESTAMP WITH TIME ZONE as a data type [calcite]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3569:
URL: https://github.com/apache/calcite/pull/3569#issuecomment-1846161471

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3569)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3569&resolved=false&types=BUG) [![D](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/D-16px.png 'D')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3569&resolved=false&types=BUG) [2 Bugs](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3569&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3569&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3569&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3569&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3569&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3569&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3569&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3569&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3569&resolved=false&types=CODE_SMELL) [11 Code Smells](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3569&resolved=false&types=CODE_SMELL)
   
   [![54.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/50-16px.png '54.0%')](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3569&metric=new_coverage&view=list) [54.0% Coverage](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3569&metric=new_coverage&view=list)  
   [![0.6%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.6%')](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3569&metric=new_duplicated_lines_density&view=list) [0.6% Duplication](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3569&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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-6138] Parser does not accept TIMESTAMP WITH TIME ZONE as a data type [calcite]

Posted by "tanclary (via GitHub)" <gi...@apache.org>.
tanclary commented on code in PR #3569:
URL: https://github.com/apache/calcite/pull/3569#discussion_r1436584354


##########
cassandra/src/main/java/org/apache/calcite/adapter/cassandra/CassandraFilter.java:
##########
@@ -192,6 +193,9 @@ private String translateMatch(RexNode condition) {
     private static Object literalValue(RexLiteral literal) {
       Comparable<?> value = RexLiteral.value(literal);
       switch (literal.getTypeName()) {
+      case TIMESTAMP_TZ:

Review Comment:
   I understand, I am not a fan of the naming style between TIMESTAMP-related types being different though, truth be told.



-- 
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-6138] Parser does not accept TIMESTAMP WITH TIME ZONE as a data type [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #3569:
URL: https://github.com/apache/calcite/pull/3569#discussion_r1436581647


##########
cassandra/src/main/java/org/apache/calcite/adapter/cassandra/CassandraFilter.java:
##########
@@ -192,6 +193,9 @@ private String translateMatch(RexNode condition) {
     private static Object literalValue(RexLiteral literal) {
       Comparable<?> value = RexLiteral.value(literal);
       switch (literal.getTypeName()) {
+      case TIMESTAMP_TZ:

Review Comment:
   The first commit in this PR uses this type name, but in a comment on Jira @julianhyde suggested the new name so the third commit changes the name to this one. The truth is that the long name is very hard to read and is very easy to mistype.



-- 
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-6138] Parser does not accept TIMESTAMP WITH TIME ZONE as a data type [calcite]

Posted by "julianhyde (via GitHub)" <gi...@apache.org>.
julianhyde commented on PR #3569:
URL: https://github.com/apache/calcite/pull/3569#issuecomment-1912676830

   +1
   
   Thanks for your work, @mihaibudiu!


-- 
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-6138] Parser does not accept TIMESTAMP WITH TIME ZONE as a data type [calcite]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3569:
URL: https://github.com/apache/calcite/pull/3569#issuecomment-1846157920

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3569)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3569&resolved=false&types=BUG) [![D](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/D-16px.png 'D')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3569&resolved=false&types=BUG) [2 Bugs](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3569&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3569&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3569&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3569&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3569&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3569&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3569&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3569&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3569&resolved=false&types=CODE_SMELL) [11 Code Smells](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3569&resolved=false&types=CODE_SMELL)
   
   [![54.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/50-16px.png '54.0%')](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3569&metric=new_coverage&view=list) [54.0% Coverage](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3569&metric=new_coverage&view=list)  
   [![0.6%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.6%')](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3569&metric=new_duplicated_lines_density&view=list) [0.6% Duplication](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3569&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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-6138] Parser does not accept TIMESTAMP WITH TIME ZONE as a data type [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #3569:
URL: https://github.com/apache/calcite/pull/3569#discussion_r1436582231


##########
core/src/main/java/org/apache/calcite/sql/type/SqlTypeName.java:
##########
@@ -65,12 +65,16 @@ public enum SqlTypeName {
   DATE(PrecScale.NO_NO, false, Types.DATE, SqlTypeFamily.DATE),
   TIME(PrecScale.NO_NO | PrecScale.YES_NO, false, Types.TIME,
       SqlTypeFamily.TIME),
-  TIME_WITH_LOCAL_TIME_ZONE(PrecScale.NO_NO | PrecScale.YES_NO, false, Types.OTHER,
+  TIME_WITH_LOCAL_TIME_ZONE(PrecScale.NO_NO | PrecScale.YES_NO, false, Types.TIME,
+      SqlTypeFamily.TIME),
+  TIME_TZ(PrecScale.NO_NO | PrecScale.YES_NO, false, Types.TIME,

Review Comment:
   That would be nice, but this may break any third party software that uses Calcite.
   Since we can't remove deprecated functions I assume we can't rename public enum fields either.



-- 
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-6138] Parser does not accept TIMESTAMP WITH TIME ZONE as a data type [calcite]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3569:
URL: https://github.com/apache/calcite/pull/3569#issuecomment-1962229883

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3569) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [9 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3569&resolved=false&inNewCodePeriod=true)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3569&resolved=false&inNewCodePeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [53.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3569&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.6% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3569&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3569)
   
   


-- 
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-6138] Parser does not accept TIMESTAMP WITH TIME ZONE as a data type [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #3569:
URL: https://github.com/apache/calcite/pull/3569#issuecomment-1981243084

   No objections from me 


-- 
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-6138] Parser does not accept TIMESTAMP WITH TIME ZONE as a data type [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #3569:
URL: https://github.com/apache/calcite/pull/3569#issuecomment-1911210533

   This PR is ready for a review. It adds a feature to Calcite which has been requested 9 years ago.


-- 
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-6138] Parser does not accept TIMESTAMP WITH TIME ZONE as a data type [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #3569:
URL: https://github.com/apache/calcite/pull/3569#discussion_r1436583927


##########
core/src/main/java/org/apache/calcite/sql/type/SqlTypeName.java:
##########
@@ -309,7 +314,10 @@ public enum SqlTypeName {
    * matches the given name, or throws {@link IllegalArgumentException}; never
    * returns null. */
   public static SqlTypeName lookup(String tag) {
-    String tag2 = tag.replace(' ', '_');
+    // Special handling for TIME WITH TIME ZONE and
+    // TIMESTAMP WITH TIME ZONE, whose names are TIME_TZ and TIMESTAMP_TZ
+    final String tag1 = tag.replace("WITH TIME ZONE", "TZ");

Review Comment:
   Since this is not performance-critical I think I prefer the version I wrote, because it is obvious what it does. To understand your version you have to be an expert in regular expressions, and most people aren't. Your version seems to be case-insensitive, but I think that this string will always be uppercase, since it is inserted here by the parser. I will document this behavior. 



-- 
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-6138] Parser does not accept TIMESTAMP WITH TIME ZONE as a data type [calcite]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3569:
URL: https://github.com/apache/calcite/pull/3569#issuecomment-1869755221

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3569) **Quality Gate passed**  
   The SonarCloud Quality Gate passed, but some issues were introduced.
   
   [3 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3569&resolved=false&inNewCodePeriod=true)  
   [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3569&resolved=false&inNewCodePeriod=true)  
   [53.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3569&metric=new_coverage&view=list)  
   [0.6% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3569&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3569)
   
   


-- 
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-6138] Parser does not accept TIMESTAMP WITH TIME ZONE as a data type [calcite]

Posted by "tanclary (via GitHub)" <gi...@apache.org>.
tanclary commented on code in PR #3569:
URL: https://github.com/apache/calcite/pull/3569#discussion_r1435825219


##########
cassandra/src/main/java/org/apache/calcite/adapter/cassandra/CassandraFilter.java:
##########
@@ -192,6 +193,9 @@ private String translateMatch(RexNode condition) {
     private static Object literalValue(RexLiteral literal) {
       Comparable<?> value = RexLiteral.value(literal);
       switch (literal.getTypeName()) {
+      case TIMESTAMP_TZ:

Review Comment:
   I think we should follow existing naming convention, if local time zone is spelled out then maybe this should be `TIMESTAMP_WITH_TIME_ZONE`



##########
core/src/main/java/org/apache/calcite/rel/type/RelDataTypeSystemImpl.java:
##########
@@ -126,8 +128,10 @@ public abstract class RelDataTypeSystemImpl implements RelDataTypeSystem {
       return 65536;
     case TIME:
     case TIME_WITH_LOCAL_TIME_ZONE:
+    case TIME_TZ:

Review Comment:
   same naming comment as above for `TIME`



##########
core/src/main/java/org/apache/calcite/sql/type/SqlTypeName.java:
##########
@@ -65,12 +65,16 @@ public enum SqlTypeName {
   DATE(PrecScale.NO_NO, false, Types.DATE, SqlTypeFamily.DATE),
   TIME(PrecScale.NO_NO | PrecScale.YES_NO, false, Types.TIME,
       SqlTypeFamily.TIME),
-  TIME_WITH_LOCAL_TIME_ZONE(PrecScale.NO_NO | PrecScale.YES_NO, false, Types.OTHER,
+  TIME_WITH_LOCAL_TIME_ZONE(PrecScale.NO_NO | PrecScale.YES_NO, false, Types.TIME,
+      SqlTypeFamily.TIME),
+  TIME_TZ(PrecScale.NO_NO | PrecScale.YES_NO, false, Types.TIME,

Review Comment:
   Going through this PR I'm also not opposed to changing the local time zones to something like `TIMESTAMP_LTZ`, I think we actually use that in some parts of the code. Either way should probably be consistent. What do you think?



##########
core/src/main/java/org/apache/calcite/sql/SqlBasicTypeNameSpec.java:
##########
@@ -245,16 +249,31 @@ private static boolean isWithLocalTimeZoneDef(SqlTypeName typeName) {
     }
   }
 
+  private static boolean isWithTimeZoneDef(SqlTypeName typeName) {

Review Comment:
   Alternatively you could add a set/list to `SqlTypeName` (see `DATETIME_TYPES` for example) and then just use `.contains()` or something similar.



##########
core/src/main/java/org/apache/calcite/sql/parser/SqlParserUtil.java:
##########
@@ -351,6 +356,31 @@ public static SqlTimeLiteral parseTimeLiteral(String s, SqlParserPos pos) {
     return SqlLiteral.createTime(t, pt.getPrecision(), pos);
   }
 
+  public static SqlTimeTzLiteral parseTimeTzLiteral(
+      String s, SqlParserPos pos) {
+    // We expect the string to end in a timezone.
+    int lastSpace = s.lastIndexOf(" ");

Review Comment:
   Should this be marked `final`?



##########
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##########
@@ -473,6 +473,9 @@ public static SqlOperandTypeChecker variadic(
   public static final SqlSingleOperandTypeChecker TIMESTAMP_LTZ =
       new TypeNameChecker(SqlTypeName.TIMESTAMP_WITH_LOCAL_TIME_ZONE);
 
+  public static final SqlSingleOperandTypeChecker TIMESTAMP_TZ =

Review Comment:
   Needs comment



##########
core/src/main/java/org/apache/calcite/sql/type/SqlTypeAssignmentRule.java:
##########
@@ -175,13 +175,21 @@ private SqlTypeAssignmentRule(
     rules.add(SqlTypeName.TIME_WITH_LOCAL_TIME_ZONE,
         EnumSet.of(SqlTypeName.TIME_WITH_LOCAL_TIME_ZONE));
 
+    // TIME WITH TIME ZONE is assignable from...
+    rules.add(SqlTypeName.TIME_TZ,

Review Comment:
   This can probably be one line right



##########
cassandra/src/main/java/org/apache/calcite/adapter/cassandra/CassandraFilter.java:
##########
@@ -192,6 +193,9 @@ private String translateMatch(RexNode condition) {
     private static Object literalValue(RexLiteral literal) {
       Comparable<?> value = RexLiteral.value(literal);
       switch (literal.getTypeName()) {
+      case TIMESTAMP_TZ:

Review Comment:
   If you make this change you can move this `case` below the one beneath to preserve alphabetical order.



##########
core/src/main/java/org/apache/calcite/sql/type/SqlTypeName.java:
##########
@@ -309,7 +314,10 @@ public enum SqlTypeName {
    * matches the given name, or throws {@link IllegalArgumentException}; never
    * returns null. */
   public static SqlTypeName lookup(String tag) {
-    String tag2 = tag.replace(' ', '_');
+    // Special handling for TIME WITH TIME ZONE and
+    // TIMESTAMP WITH TIME ZONE, whose names are TIME_TZ and TIMESTAMP_TZ
+    final String tag1 = tag.replace("WITH TIME ZONE", "TZ");

Review Comment:
   This is kind of personal preference but you could simplify this with a single regex like 
   `  return re.sub(r"(?i)WITH TIME ZONE|\s", "TZ", tag)`



-- 
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-6138] Parser does not accept TIMESTAMP WITH TIME ZONE as a data type [calcite]

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin merged PR #3569:
URL: https://github.com/apache/calcite/pull/3569


-- 
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-6138] Parser does not accept TIMESTAMP WITH TIME ZONE as a data type [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #3569:
URL: https://github.com/apache/calcite/pull/3569#issuecomment-1962222177

   I am interpreting the comments as an approval, so I plan to merge this soon.
   Let me know if you have objections.


-- 
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