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


##########
arrow/src/main/java/org/apache/calcite/adapter/arrow/ArrowTable.java:
##########
@@ -194,6 +194,8 @@ private static TreeNode makeLiteralNode(String literal, 
String type) {
       return TreeBuilder.makeLiteral(parseFloat(literal));
     case "double":
       return TreeBuilder.makeLiteral(parseDouble(literal));
+    case "decimal":
+      return TreeBuilder.makeDecimalLiteral(literal, 19, 0);

Review Comment:
   You should use the type system to retrieve the default type, assuming it is 
available here.
   Maybe there is a default type for Arrow, but the "default" type for Calcite 
is irrelevant in this context.



##########
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:
   there are many unhandled cases, but perhaps this is a good start.



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