caicancai commented on code in PR #4043:
URL: https://github.com/apache/calcite/pull/4043#discussion_r1840715269


##########
arrow/src/main/java/org/apache/calcite/adapter/arrow/ArrowTranslator.java:
##########
@@ -234,20 +233,20 @@ private String translateUnaryOp(String op, String name) {
     return name + " " + op;
   }
 
-  private static String getLiteralType(Object literal) {
-    if (literal instanceof BigDecimal) {
-      BigDecimal bigDecimalLiteral = (BigDecimal) literal;
-      int scale = bigDecimalLiteral.scale();
-      if (scale == 0) {
-        return "integer";
-      } else if (scale > 0) {
-        return "float";
-      }
-    } else if (String.class.equals(literal.getClass())) {
-      return "string";
-    } else if (literal instanceof Double) {
+  private static String getLiteralType(RelDataType  type) {
+    if (type.getSqlTypeName() == SqlTypeName.DECIMAL) {
+      return "decimal";
+    } else if (type.getSqlTypeName() == SqlTypeName.REAL) {
       return "float";
+    } else if (type.getSqlTypeName() == SqlTypeName.DOUBLE) {
+      return "double";
+    } else if (type.getSqlTypeName() == SqlTypeName.INTEGER) {
+      return "integer";
+    } else if (type.getSqlTypeName() == SqlTypeName.VARCHAR
+        || type.getSqlTypeName() == SqlTypeName.CHAR) {
+      return "string";
+    } else {

Review Comment:
   @mihaibudiu 
   Unfortunately, Arrow does not have a default decimal type.
   The Arrow adapter currently converts Decimal types to DECIMAL(19, 0) by 
default. I don't know why the previous person implemented it this way. It seems 
that he simply called the calcite native API without considering any precision 
issues, including timestamp, time and other types.
   
   
https://github.com/apache/calcite/blob/main/arrow/src/main/java/org/apache/calcite/adapter/arrow/ArrowFieldType.java
   
   I am working on a new type system for the Arrow adapter, which seems to be a 
big project



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to