julianhyde commented on a change in pull request #1482: [CALCITE-3381] When 
converting rel to bigquery sql dialect, types should be converted to BigQuery's 
data types
URL: https://github.com/apache/calcite/pull/1482#discussion_r330787477
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/sql/dialect/BigQuerySqlDialect.java
 ##########
 @@ -132,6 +138,43 @@ public BigQuerySqlDialect(SqlDialect.Context context) {
     }
   }
 
+  /** BigQuery data type reference:
+   * <a 
href="https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types";>
+   * Bigquery Standard SQL Data Types</a>
+   */
+  @Override public SqlNode getCastSpec(final RelDataType type) {
+    if (type instanceof BasicSqlType) {
+      SqlUserDefinedTypeNameSpec typeNameSpec;
+      switch (type.getSqlTypeName()) {
+      case BIGINT:
+        return createSqlDataTypeSpecByName("INT64");
+      case DOUBLE:
+        return createSqlDataTypeSpecByName("FLOAT64");
+      case DECIMAL:
+        return createSqlDataTypeSpecByName("NUMERIC");
+      case BOOLEAN:
+        return createSqlDataTypeSpecByName("BOOL");
+      case VARCHAR:
+        return createSqlDataTypeSpecByName("STRING");
+      case VARBINARY:
+        return createSqlDataTypeSpecByName("BYTES");
+      case DATE:
+        return createSqlDataTypeSpecByName("DATE");
+      case TIME:
+        return createSqlDataTypeSpecByName("TIME");
+      case TIMESTAMP:
+        return createSqlDataTypeSpecByName("TIMESTAMP");
+      }
+    }
+    return super.getCastSpec(type);
+  }
+
+  private static SqlDataTypeSpec createSqlDataTypeSpecByName(String 
identifierName) {
 
 Review comment:
   There isn't really a standard practice. Note that a few lines above 
`Aggregate.isPredicate`, which is static, is `isNotGrandTotal` which is 
non-static.
   
   In my opinion, if a method is `private` it doesn't really matter. Once it 
becomes `public` or `protected` it can be overridden, referenced from places 
that can't see the implementation, etc. So that's when some serious thought has 
to take place.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to