{"record":{"id":"aa7a7d5ac3a88d06","repo":"apache/iceberg","slug":"unsupported-base-type-for-decimal-s-aa7a7d","errorCode":null,"errorMessage":"Unsupported base type for decimal: %s","messagePattern":"Unsupported base type for decimal: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"parquet/src/main/java/org/apache/iceberg/parquet/ParquetAvroWriter.java","lineNumber":145,"sourceCode":"          case TIME_MICROS:\n          case TIMESTAMP_MICROS:\n            return ParquetValueWriters.longs(desc);\n          case DECIMAL:\n            DecimalLogicalTypeAnnotation decimal =\n                (DecimalLogicalTypeAnnotation) primitive.getLogicalTypeAnnotation();\n            switch (primitive.getPrimitiveTypeName()) {\n              case INT32:\n                return ParquetValueWriters.decimalAsInteger(\n                    desc, decimal.getPrecision(), decimal.getScale());\n              case INT64:\n                return ParquetValueWriters.decimalAsLong(\n                    desc, decimal.getPrecision(), decimal.getScale());\n              case BINARY:\n              case FIXED_LEN_BYTE_ARRAY:\n                return ParquetValueWriters.decimalAsFixed(\n                    desc, decimal.getPrecision(), decimal.getScale());\n              default:\n                throw new UnsupportedOperationException(\n                    \"Unsupported base type for decimal: \" + primitive.getPrimitiveTypeName());\n            }\n          case BSON:\n            return ParquetValueWriters.byteBuffers(desc);\n          default:\n            throw new UnsupportedOperationException(\n                \"Unsupported logical type: \" + primitive.getOriginalType());\n        }\n      }\n\n      switch (primitive.getPrimitiveTypeName()) {\n        case FIXED_LEN_BYTE_ARRAY:\n          return new FixedWriter(desc);\n        case BINARY:\n          return ParquetValueWriters.byteBuffers(desc);\n        case BOOLEAN:\n          return ParquetValueWriters.booleans(desc);\n        case INT32:","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/parquet/src/main/java/org/apache/iceberg/parquet/ParquetAvroWriter.java#L127-L163","documentation":"In ParquetAvroWriter.primitive, a DECIMAL logical type whose underlying Parquet primitive is INT32/INT64 (non-BINARY/FIXED_LEN_BYTE_ARRAY) cannot be mapped to an Avro decimal writer. The library throws because the decimalAsFixed/decimalAsLong writers expect byte-backed storage. INT32/INT64-backed decimals are not supported by this Avro path.","triggerScenarios":"Writing a Parquet column annotated DECIMAL with physical type INT32 or INT64 (or any primitive other than BINARY/FIXED_LEN_BYTE_ARRAY) through ParquetAvroWriter.primitive.","commonSituations":"Parquet files produced by other engines (e.g., Spark/Hive writing decimals as INT32/INT64 per newer spec revisions) are written via the Avro writer path; schema evolution changed decimal backing storage.","solutions":["Rewrite the data so the decimal is stored as BINARY or FIXED_LEN_BYTE_ARRAY physical type","Use a writer that handles INT32/INT64-backed decimals (non-Avro Iceberg Parquet writer)","Convert the column to a string or double before writing via the Avro path"],"exampleFix":"// before\nthrow new UnsupportedOperationException(\"Unsupported base type for decimal: \" + primitive.getPrimitiveTypeName());\n// after (engine-side fix): force binary-backed decimal\nTypes.DecimalType.of(precision, scale) written via FIXED_LEN_BYTE_ARRAY storage","handlingStrategy":"validation","validationCode":"boolean badDecimal = schema.columns().stream().anyMatch(c ->\n    c.type() instanceof Types.DecimalType && columnPhysical(c) != FIXED_LEN_BYTE_ARRAY && columnPhysical(c) != BINARY);\nif (badDecimal) throw new IllegalArgumentException(\"Decimal must be BINARY/FIXED_LEN_BYTE_ARRAY backed\");","typeGuard":null,"tryCatchPattern":"try { writer.write(record); } catch (UnsupportedOperationException e) { if (e.getMessage().startsWith(\"Unsupported base type for decimal\")) { /* rewrite decimal column as binary-backed */ } else { throw e; } }","preventionTips":["Use FIXED_LEN_BYTE_ARRAY-backed decimals (the common default)","Avoid INT32/INT64-backed decimal Parquet files on the Avro write path","Validate physical backing of decimal columns before writing"],"tags":["parquet","avro","decimal","unsupported-type"],"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"}