You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2020/02/01 19:43:12 UTC

[GitHub] [calcite] michaelmior commented on a change in pull request #1774: [CALCITE-3465] Add support for missing Cassandra 3.x data types (Alessandro Solimando)

michaelmior commented on a change in pull request #1774: [CALCITE-3465] Add support for missing Cassandra 3.x data types (Alessandro Solimando)
URL: https://github.com/apache/calcite/pull/1774#discussion_r373797682
 
 

 ##########
 File path: cassandra/src/main/java/org/apache/calcite/adapter/cassandra/CassandraSchema.java
 ##########
 @@ -160,28 +169,57 @@ RelProtoDataType getRelDataType(String columnFamily, boolean view) {
         new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
     final RelDataTypeFactory.Builder fieldInfo = typeFactory.builder();
     for (ColumnMetadata column : columns) {
-      final String columnName = column.getName();
-      final DataType type = column.getType();
-
-      // TODO: This mapping of types can be done much better
-      SqlTypeName typeName = SqlTypeName.ANY;
-      if (type == DataType.uuid() || type == DataType.timeuuid()) {
-        // We currently rely on this in CassandraFilter to detect UUID columns.
-        // That is, these fixed length literals should be unquoted in CQL.
-        typeName = SqlTypeName.CHAR;
-      } else if (type == DataType.ascii() || type == DataType.text()
-            || type == DataType.varchar()) {
-        typeName = SqlTypeName.VARCHAR;
-      } else if (type == DataType.cint() || type == DataType.varint()) {
-        typeName = SqlTypeName.INTEGER;
-      } else if (type == DataType.bigint()) {
-        typeName = SqlTypeName.BIGINT;
-      } else if (type == DataType.cdouble() || type == DataType.cfloat()
-          || type == DataType.decimal()) {
-        typeName = SqlTypeName.DOUBLE;
+      final SqlTypeName typeName =
+          CQL_TO_SQL_TYPE.lookup(column.getType().getName());
+
+      if ("ARRAY".equals(typeName.getName())) {
 
 Review comment:
   Is there any reason the comparison can't be against `SqlTypeName.ARRAY`? (similar comment for other comparisons below)

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services