{"record":{"id":"3e96d9fc62889156","repo":"apache/iceberg","slug":"unsupported-base-type-for-decimal-3e96d9","errorCode":null,"errorMessage":"Unsupported base type for decimal: ","messagePattern":"Unsupported base type for decimal: ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink/v2.2/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.2/flink/src/main/java/org/apache/iceberg/flink/data/FlinkParquetWriters.java#L235-L271","documentation":"When writing decimals to Parquet, FlinkParquetWriters' LogicalTypeWriterBuilder.visit(DecimalLogicalTypeAnnotation) writes decimals as either BINARY or FIXED_LEN_BYTE_ARRAY physical base types; any other primitive (INT32/INT64 bases used by some producers) hits the default branch and throws UnsupportedOperationException 'Unsupported base type for decimal: <type>'.","triggerScenarios":"Visiting a decimal logical annotation whose ColumnDescriptor primitive is not BINARY or FIXED_LEN_BYTE_ARRAY, e.g. decimals stored as INT32/INT64/FLBA-variant by external writers.","commonSituations":"Reading paths where the writer builder is handed descriptors from files written by other systems that store decimals on integer bases, or misconfigured schema evolution.","solutions":["Rewrite the data so decimals are stored as BINARY or FIXED_LEN_BYTE_ARRAY (Iceberg's canonical encoding)","Check which tool wrote the Parquet files and use its reader instead","Convert the column to a supported decimal representation"],"exampleFix":"// before: decimal stored as INT32 base (external writer)\n// after: rewrite via Iceberg spark rewrite or copy to BINARY-based decimal","handlingStrategy":"validation","validationCode":"org.apache.parquet.schema.PrimitiveTypeName base = desc.getPrimitiveType().getPrimitiveTypeName();\nPreconditions.checkArgument(\n    base == BINARY || base == FIXED_LEN_BYTE_ARRAY,\n    \"Decimal must use BINARY/FIXED_LEN_BYTE_ARRAY base, found: \" + base);","typeGuard":null,"tryCatchPattern":"try {\n  Optional<ParquetValueWriter<?>> w = visitor.visit(decimalAnnotation);\n} catch (UnsupportedOperationException e) {\n  throw new WriteException(\"Cannot write decimal with this base type\", e);\n}","preventionTips":["Write decimals via Iceberg writers only (BINARY/FLBA encoding)","Check file provenance when decimals come from other engines","Rewrite integer-based decimal files before Iceberg writes"],"tags":["flink","parquet","decimal"],"backgroundTag":"unsupported-operation","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"}