{"record":{"id":"5924bc3e0602132d","repo":"apache/iceberg","slug":"unsupported-base-type-for-decimal-desc-getprimi","errorCode":null,"errorMessage":"Unsupported base type for decimal: ${desc.getPrimitiveType().getPrimitiveTypeName()}","messagePattern":"Unsupported base type for decimal: (.+?)","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink/v2.1/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.1/flink/src/main/java/org/apache/iceberg/flink/data/FlinkParquetWriters.java#L235-L271","documentation":"Iceberg's Flink Parquet writer visits a Parquet column of logical decimal type and chooses a writer based on the underlying physical Parquet type (INT32, INT64, BINARY, FIXED_LEN_BYTE_ARRAY). If the physical type is none of those, no decimal writer exists and the library throws this UnsupportedOperationException. This indicates malformed or unsupported Parquet schema rather than bad user data.","triggerScenarios":"Writing decimal data through FlinkParquetWriters when the Parquet ColumnDescriptor's physical primitive type is not INT32/INT64/BINARY/FIXED_LEN_BYTE_ARRAY (e.g. FLOAT/DOUBLE or BOOLEAN physical type carrying a decimal logical annotation), typically from corrupt or non-standard Parquet files.","commonSituations":"Reading/writing Parquet files produced by third-party tools that attach a decimal logical type to an unexpected physical type; corrupted schema metadata; manually crafted Parquet schemas.","solutions":["Check the Parquet file's schema with parquet-tools and fix the physical type to INT32, INT64, BINARY, or FIXED_LEN_BYTE_ARRAY for the decimal column","Regenerate the file with a standards-compliant writer (Spark/Iceberg)","If this is a legitimately new physical encoding, extend FlinkParquetWriters.decimal switch to support it and file an upstream issue"],"exampleFix":"// before: file written with nonstandard physical type FLOAT + decimal annotation\n// after: rewrite the table so decimals use a valid physical type\nspark.sql(\"CREATE TABLE fixed STORED BY iceberg AS SELECT CAST(dec_col AS DECIMAL(20,6)) FROM bad\")","handlingStrategy":"validation","validationCode":"org.apache.parquet.schema.PrimitiveType pt = desc.getPrimitiveType();\nif (!(pt.getPrimitiveTypeName() == PrimitiveTypeName.INT32 || pt.getPrimitiveTypeName() == PrimitiveTypeName.INT64 || pt.getPrimitiveTypeName() == PrimitiveTypeName.BINARY || pt.getPrimitiveTypeName() == PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY)) {\n  throw new IllegalArgumentException(\"Column \" + desc + \" has invalid physical type for decimal: \" + pt.getPrimitiveTypeName());\n}","typeGuard":null,"tryCatchPattern":"try { writer = FlinkParquetWriters.buildWriter(...); } catch (UnsupportedOperationException e) { if (e.getMessage().startsWith(\"Unsupported base type for decimal\")) { /* repair schema or reroute */ } else throw e; }","preventionTips":["Inspect Parquet schema with parquet-tools before ingesting third-party files","Only write decimals with Spark/Iceberg-compliant writers","Validate physical/logical type pairs in a schema check step"],"tags":["parquet","flink","decimal","unsupported-type"],"backgroundTag":"unsupported-enum-value","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"}