xwkuang5 commented on a change in pull request #2572:
URL: https://github.com/apache/calcite/pull/2572#discussion_r747522789



##########
File path: file/src/main/java/org/apache/calcite/adapter/file/CsvEnumerator.java
##########
@@ -314,22 +372,56 @@ static CSVReader openCsv(Source source) throws 
IOException {
         } catch (ParseException e) {
           return null;
         }
-      case STRING:
+      case VARCHAR:
       default:
         return string;
       }
     }
   }
 
+  private static RelDataType parseDecimalSqlType(JavaTypeFactory typeFactory, 
int precision,
+      int scale) {
+    checkArgument(precision > 0, "DECIMAL type must have precision > 0. Found 
%s", precision);
+    checkArgument(scale >= 0, "DECIMAL type must have scale >= 0. Found %s", 
scale);
+    checkArgument(precision >= scale,
+        "DECIMAL type must have precision >= scale. Found precision (%s) and 
scale (%s).",
+        precision, scale);
+    return typeFactory.createTypeWithNullability(
+        typeFactory.createSqlType(SqlTypeName.DECIMAL, precision, scale), 
true);
+  }
+
+  @VisibleForTesting
+  protected static BigDecimal parseDecimal(int precision, int scale, String 
string) {
+    BigDecimal result = new BigDecimal(string);
+    // If the parsed value has more fractional digits than the specified 
scale, round ties away
+    // from 0.
+    if (result.scale() > scale) {
+      LOGGER.warn(

Review comment:
       Oops, sorry I missed that. Corrected now. 




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