pyscala commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r521295218



##########
File path: 
flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/CsvToRowDataConverters.java
##########
@@ -221,12 +221,27 @@ private int convertToDate(JsonNode jsonNode) {
                return (int) 
Date.valueOf(jsonNode.asText()).toLocalDate().toEpochDay();
        }
 
-       private int convertToTime(JsonNode jsonNode) {
+       private CsvToRowDataConverter convertToTime(TimeType timeType) {
+               final int precision = timeType.getPrecision();
                // csv currently is using Time.valueOf() to parse time string
-               LocalTime localTime = 
Time.valueOf(jsonNode.asText()).toLocalTime();
                // TODO: FLINK-17525 support millisecond and nanosecond
                // get number of milliseconds of the day
-               return localTime.toSecondOfDay() * 1000;
+               if (precision > 3) {
+                       throw new IllegalArgumentException("Csv does not 
support TIME type " +
+                               "with precision: " + precision + ", it only 
supports precision 0 ~ 3.");
+               }
+               return jsonNode -> {
+                       LocalTime localTime = 
LocalTime.parse(jsonNode.asText());
+                       int mills = (int) (localTime.toNanoOfDay() / 1000_000L);
+                       if (precision == 2) {
+                               mills = mills / 10 * 10;

Review comment:
       ok
   




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


Reply via email to