apache/flink · error · IllegalArgumentException

Avro does not support TIMESTAMP type with precision: %s, it

Error message

Avro does not support TIMESTAMP type with precision: %s, it only supports precision less than 6.

What it means

Thrown when converting TIMESTAMP(p) WITH LOCAL TIME ZONE to an Avro schema with modern mapping and precision above 6. Avro only defines timestamp-millis (p<=3) and timestamp-micros (p<=6) logical types for zoned timestamps, so precisions 7-9 cannot be represented.

Source

Thrown at flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSchemaConverter.java:505

                                        + ", it only supports precision less than 6.");
                    }
                }
                Schema timestamp = avroLogicalType.addToSchema(SchemaBuilder.builder().longType());
                return nullable ? nullableSchema(timestamp) : timestamp;
            case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
                if (legacyTimestampMapping) {
                    throw new UnsupportedOperationException(
                            "Unsupported to derive Schema for type: " + logicalType);
                } else {
                    final LocalZonedTimestampType localZonedTimestampType =
                            (LocalZonedTimestampType) logicalType;
                    precision = localZonedTimestampType.getPrecision();
                    if (precision <= 3) {
                        avroLogicalType = LogicalTypes.timestampMillis();
                    } else if (precision <= 6) {
                        avroLogicalType = LogicalTypes.timestampMicros();
                    } else {
                        throw new IllegalArgumentException(
                                "Avro does not support TIMESTAMP type "
                                        + "with precision: "
                                        + precision
                                        + ", it only supports precision less than 6.");
                    }
                    timestamp = avroLogicalType.addToSchema(SchemaBuilder.builder().longType());
                    return nullable ? nullableSchema(timestamp) : timestamp;
                }
            case DATE:
                // use int to represents Date
                Schema date = LogicalTypes.date().addToSchema(SchemaBuilder.builder().intType());
                return nullable ? nullableSchema(date) : date;
            case TIME_WITHOUT_TIME_ZONE:
                precision = ((TimeType) logicalType).getPrecision();
                if (precision > 3) {
                    throw new IllegalArgumentException(
                            "Avro does not support TIME type with precision: "
                                    + precision

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Declare the column as TIMESTAMP(3) WITH LOCAL TIME ZONE or TIMESTAMP(6) WITH LOCAL TIME ZONE.
  2. Preserve nanoseconds by storing them in a separate BIGINT column.

Example fix

-- before
ts TIMESTAMP_LTZ(9),

-- after
ts TIMESTAMP(6) WITH LOCAL TIME ZONE,
Defensive patterns

Strategy: validation

Validate before calling

import org.apache.flink.table.types.logical.LocalZonedTimestampType;

boolean avroConvertible(LocalZonedTimestampType t) { return t.getPrecision() <= 6; }

Type guard

boolean fitsAvro(LocalZonedTimestampType t) { return t.getPrecision() <= 6; }

Prevention

When it happens

Trigger: convertToSchema on TIMESTAMP_LTZ with precision 7-9; an avro-format table declaring TIMESTAMP(9) WITH LOCAL TIME ZONE (or TIMESTAMP_LTZ(9)).

Common situations: TIMESTAMP_LTZ columns defined without explicit precision (defaults to 9); high-frequency event pipelines requiring nanosecond zoned timestamps.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/3c072fbd4d6cad0b. Report an issue: GitHub.