{"record":{"id":"1699a26728e022d9","repo":"apache/flink","slug":"csv-does-not-support-time-type-with-precision-s","errorCode":null,"errorMessage":"Csv does not support TIME type with precision: %s, it only supports precision 0 ~ 3.","messagePattern":"Csv does not support TIME type with precision: (.+?), it only supports precision 0 ~ 3\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/CsvToRowDataConverters.java","lineNumber":244,"sourceCode":"            // avoid redundant toString and parseDouble, for better performance\n            return (float) jsonNode.asDouble();\n        } else {\n            return Float.parseFloat(jsonNode.asText().trim());\n        }\n    }\n\n    private int convertToDate(JsonNode jsonNode) {\n        // csv currently is using Date.valueOf() to parse date string\n        return (int) Date.valueOf(jsonNode.asText()).toLocalDate().toEpochDay();\n    }\n\n    private CsvToRowDataConverter convertToTime(TimeType timeType) {\n        final int precision = timeType.getPrecision();\n        // csv currently is using Time.valueOf() to parse time string\n        // TODO: FLINK-17525 support millisecond and nanosecond\n        // get number of milliseconds of the day\n        if (precision > 3) {\n            throw new IllegalArgumentException(\n                    \"Csv does not support TIME type \"\n                            + \"with precision: \"\n                            + precision\n                            + \", it only supports precision 0 ~ 3.\");\n        }\n        return jsonNode -> {\n            LocalTime localTime = LocalTime.parse(jsonNode.asText());\n            int mills = (int) (localTime.toNanoOfDay() / 1000_000L);\n            // this is for rounding off values out of precision\n            if (precision == 2) {\n                mills = mills / 10 * 10;\n            } else if (precision == 1) {\n                mills = mills / 100 * 100;\n            } else if (precision == 0) {\n                mills = mills / 1000 * 1000;\n            }\n            return mills;\n        };","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/CsvToRowDataConverters.java#L226-L262","documentation":"CsvToRowDataConverters.convertToTime refuses TIME(p) columns with precision > 3: CSV parsing goes through LocalTime.parse and keeps only milliseconds (see FLINK-17525), so higher precisions would silently lose digits. The converter therefore fails fast with IllegalArgumentException while building the deserialization schema rather than corrupting data at runtime.","triggerScenarios":"A csv-format table declaring TIME(4) through TIME(9); common when copying a TIME(6) column definition from another system (e.g. Oracle/MySQL TIME(6), or a JSON/Avro schema with micro precision).","commonSituations":"Porting DDLs from databases whose default TIME precision exceeds 3; upstream producers emitting microseconds in time fields; schema-import tooling that preserves source precision verbatim.","solutions":["Change the column to TIME(3) or plain TIME (precision 0) if millisecond resolution is acceptable.","Ingest the field as STRING and parse to a higher-precision type downstream (e.g. TO_TIMESTAMP_LSB or custom UDF).","If micro/nano precision is a hard requirement, vote/track FLINK-17525 or use a format that supports it (avro/json with LONG micros)."],"exampleFix":"-- before\nevent_time TIME(6),\n\n-- after\nevent_time TIME(3),  -- or: event_time STRING parsed downstream","handlingStrategy":"validation","validationCode":"// Check every TIME column when format='csv':\nfor (Column c : table.getResolvedSchema().getColumns()) {\n    if (c.getDataType().getLogicalType() instanceof TimeType\n            && ((TimeType) c.getDataType().getLogicalType()).getPrecision() > 3) {\n        throw new ValidationException(\"csv does not support TIME(>3): \" + c.getName());\n    }\n}","typeGuard":"static boolean csvTimePrecisionOk(TimeType t) { return t.getPrecision() <= 3; }","tryCatchPattern":null,"preventionTips":["Default to TIME(3) or plain TIME in csv DDLs","Ingest high-precision times as STRING and parse downstream","Track FLINK-17525 for micro/nano TIME support"],"tags":["csv","time","precision","unsupported-type","ddl"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}