{"record":{"id":"e82b33200c2671df","repo":"apache/iceberg","slug":"unsupported-base-type-for-decimal-e82b33","errorCode":null,"errorMessage":"Unsupported base type for decimal: ","messagePattern":"Unsupported base type for decimal: ","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/data/FlinkParquetWriters.java","lineNumber":253,"sourceCode":"      return Optional.of(strings(desc));\n    }\n\n    @Override\n    public Optional<ParquetValueWriter<?>> visit(DecimalLogicalTypeAnnotation decimal) {\n      ParquetValueWriter<DecimalData> writer;\n      switch (desc.getPrimitiveType().getPrimitiveTypeName()) {\n        case INT32:\n          writer = decimalAsInteger(desc, decimal.getPrecision(), decimal.getScale());\n          break;\n        case INT64:\n          writer = decimalAsLong(desc, decimal.getPrecision(), decimal.getScale());\n          break;\n        case BINARY:\n        case FIXED_LEN_BYTE_ARRAY:\n          writer = decimalAsFixed(desc, decimal.getPrecision(), decimal.getScale());\n          break;\n        default:\n          throw new UnsupportedOperationException(\n              \"Unsupported base type for decimal: \"\n                  + desc.getPrimitiveType().getPrimitiveTypeName());\n      }\n      return Optional.of(writer);\n    }\n\n    @Override\n    public Optional<ParquetValueWriter<?>> visit(DateLogicalTypeAnnotation dates) {\n      return Optional.of(ints(flinkType, desc));\n    }\n\n    @Override\n    public Optional<ParquetValueWriter<?>> visit(TimeLogicalTypeAnnotation times) {\n      Preconditions.checkArgument(\n          LogicalTypeAnnotation.TimeUnit.MICROS.equals(times.getUnit()),\n          \"Cannot write time in %s, only MICROS is supported\",\n          times.getUnit());\n      return Optional.of(timeMicros(desc));","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/data/FlinkParquetWriters.java#L235-L271","documentation":"LogicalTypeWriterBuilder.visit(DecimalLogicalTypeAnnotation) builds a decimal writer based on the underlying primitive type: BINARY and FIXED_LEN_BYTE_ARRAY use decimalAsFixed; other bases (e.g. INT32/INT64-backed decimals) are not handled and trigger UnsupportedOperationException 'Unsupported base type for decimal'.","triggerScenarios":"Writing a decimal column whose Parquet primitive base type is neither BINARY nor FIXED_LEN_BYTE_ARRAY — for instance a DecimalLogicalTypeAnnotation attached to INT32 or INT64 — while creating a Flink Parquet writer.","commonSituations":"Schemas produced by other systems that store decimals as int-backed Parquet columns; programmatic Parquet schema building with a decimal annotation on the wrong physical type; conversion tools mapping Flink DECIMAL to integer-backed Parquet columns.","solutions":["Write decimals with a BINARY or FIXED_LEN_BYTE_ARRAY base type, matching the precision (FLBA typically for precision <= 38 with fixed width).","Fix the schema conversion so Flink DECIMAL(p, s) maps to BINARY/FLBA with DecimalLogicalTypeAnnotation.","Add support for INT32/INT64-backed decimals in visit(...) if reading such files is required."],"exampleFix":"// before\n// optional int64 ts (DECIMAL(18,2))\n// after\n// optional binary val (DECIMAL(18,2)) — BINARY/FLBA base with decimal annotation","handlingStrategy":"validation","validationCode":"// java\nif (annotation instanceof DecimalLogicalTypeAnnotation) {\n  PrimitiveTypeName base = primitive.getPrimitiveTypeName();\n  if (base != PrimitiveTypeName.BINARY && base != PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY) {\n    throw new IllegalArgumentException(\"Decimal column must use BINARY/FLBA, got \" + base);\n  }\n}","typeGuard":null,"tryCatchPattern":"// java\ntry {\n  writer = FlinkParquetWriters.createWriter(...);\n} catch (UnsupportedOperationException e) {\n  // remap the decimal column to a BINARY/FLBA-backed Parquet type\n}","preventionTips":["Always define decimals as BINARY or FIXED_LEN_BYTE_ARRAY based Parquet columns.","Check schemas produced by conversion tools for int-backed decimals.","Add a schema sanity test that walks decimal columns and asserts their base type."],"tags":["flink","parquet","decimal","writer"],"backgroundTag":"incompatible-source-type","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}