{"record":{"id":"f0a9ae6d038abbba","repo":"apache/flink","slug":"invalid-time-unit","errorCode":null,"errorMessage":"Invalid time unit: ","messagePattern":"Invalid time unit: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-formats/flink-parquet/src/main/java/org/apache/flink/formats/parquet/vector/reader/TimestampColumnReader.java","lineNumber":179,"sourceCode":"            boolean utcTimestamp, long value, LogicalTypeAnnotation.TimeUnit timeUnit) {\n        final long nanosOfMillisecond;\n        final long milliseconds;\n\n        switch (timeUnit) {\n            case MILLIS:\n                milliseconds = value;\n                nanosOfMillisecond = value % MILLIS_PER_SECOND * NANOS_PER_MILLISECOND;\n                break;\n            case MICROS:\n                milliseconds = value / MICROS_PER_MILLISECOND;\n                nanosOfMillisecond = (value % MICROS_PER_SECOND) * NANOS_PER_MICROSECONDS;\n                break;\n            case NANOS:\n                milliseconds = value / NANOS_PER_MILLISECOND;\n                nanosOfMillisecond = value % NANOS_PER_SECOND;\n                break;\n            default:\n                throw new IllegalArgumentException(\"Invalid time unit: \" + timeUnit);\n        }\n\n        if (utcTimestamp) {\n            return TimestampData.fromEpochMillis(\n                    milliseconds, (int) (nanosOfMillisecond % NANOS_PER_MILLISECOND));\n        }\n        Timestamp timestamp = new Timestamp(milliseconds);\n        timestamp.setNanos((int) nanosOfMillisecond);\n        return TimestampData.fromTimestamp(timestamp);\n    }\n\n    private static long julianDayToMillis(int julianDay) {\n        return (julianDay - JULIAN_EPOCH_OFFSET_DAYS) * MILLIS_IN_DAY;\n    }\n}\n","sourceCodeStart":161,"sourceCodeEnd":195,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-formats/flink-parquet/src/main/java/org/apache/flink/formats/parquet/vector/reader/TimestampColumnReader.java#L161-L195","documentation":"Thrown by TimestampColumnReader when decoding a Parquet TIMESTAMP column whose logical-type annotation carries a time unit that does not match MILLIS, MICROS, or NANOS in the reader's switch. Because the switch covers all three legal units, reaching the default branch in practice means the timeUnit object was null or an unexpected/enum-extended value, typically the result of a parquet-mr version mismatch or a malformed logical type annotation in the file.","triggerScenarios":"Reading a Parquet TIMESTAMP (INT64, isAdjustedToUTC or not) where the LogicalTypeAnnotation.TimeUnit resolved at runtime is not one of the handled enum constants; mixing parquet-mr/parquet-column versions on the classpath so the annotation enum classes differ; a file whose logicalType annotation is missing/malformed so the extracted unit is null.","commonSituations":"User jars bundling a different parquet-mr version than Flink's flink-parquet; Parquet files produced by writers that emit non-standard timestamp annotations; upgrading Flink while keeping an old shaded parquet in the job jar.","solutions":["Verify classpath parquet versions: the job jar must not override the parquet-mr version flink-parquet was built against (check 'mvn dependency:tree' in flink-parquet and compare).","Inspect the file schema with parquet-tools to confirm the timestamp logical annotation (unit + isAdjustedToUTC) is well-formed.","If the file uses a non-standard annotation, rewrite it with a standards-compliant writer (Spark/parquet-mr latest) into TIMESTAMP with MILLIS/MICROS/NANOS.","Report a Flink JIRA with the schema if a valid file triggers it."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"LogicalTypeAnnotation ann = primitiveType.getLogicalTypeAnnotation();\nif (ann instanceof TimestampLogicalTypeAnnotation) {\n    TimestampLogicalTypeAnnotation ts = (TimestampLogicalTypeAnnotation) ann;\n    TimeUnit unit = ts.getUnit(); // must be MILLIS, MICROS or NANOS\n    if (unit == null) throw new IOException(\"Malformed timestamp annotation in \" + path);\n}","typeGuard":null,"tryCatchPattern":"try { ... } catch (IllegalArgumentException e) { /* surface file path and schema */ throw new RuntimeException(\"Bad timestamp unit in \" + path, e); }","preventionTips":["Never let user jars override the parquet-mr version bundled with flink-parquet.","Standardize timestamp units (prefer MICROS/MILLIS) in upstream writers.","Validate schemas of external files with parquet-tools before ingesting."],"tags":["parquet","timestamp","version-conflict","flink-formats"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}