{"record":{"id":"1792506cc5f31eb7","repo":"apache/iceberg","slug":"unsupported-base-type-for-decimal-179250","errorCode":null,"errorMessage":"Unsupported base type for decimal: ","messagePattern":"Unsupported base type for decimal: ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/data/SparkParquetReaders.java","lineNumber":257,"sourceCode":"          case DATE:\n          case INT_64:\n            return new UnboxedReader<>(desc);\n          case TIMESTAMP_MICROS:\n          case TIMESTAMP_MILLIS:\n            return ParquetValueReaders.timestamps(desc);\n          case DECIMAL:\n            DecimalLogicalTypeAnnotation decimal =\n                (DecimalLogicalTypeAnnotation) primitive.getLogicalTypeAnnotation();\n            switch (primitive.getPrimitiveTypeName()) {\n              case BINARY:\n              case FIXED_LEN_BYTE_ARRAY:\n                return new BinaryDecimalReader(desc, decimal.getScale());\n              case INT64:\n                return new LongDecimalReader(desc, decimal.getPrecision(), decimal.getScale());\n              case INT32:\n                return new IntegerDecimalReader(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 new ParquetValueReaders.ByteArrayReader(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        case BINARY:\n          if (expected != null && expected.typeId() == TypeID.UUID) {\n            return new UUIDReader(desc);\n          }\n          return new ParquetValueReaders.ByteArrayReader(desc);\n        case INT32:","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/data/SparkParquetReaders.java#L239-L275","documentation":"SparkParquetReaders.primitive() reads DECIMAL logical types from Parquet. Decimals must be physically stored as INT32, INT64, or FIXED_LEN_BYTE_ARRAY. If the underlying Parquet primitive is anything else (e.g. BINARY or FLOAT), the reader throws UnsupportedOperationException because it cannot decode a decimal from that storage type.","triggerScenarios":"Reading a Parquet file whose column is annotated as DECIMAL logical type but whose physical type is not INT32/INT64/FIXED_LEN_BYTE_ARRAY — encountered while doing a Spark read of an Iceberg Parquet table.","commonSituations":"Files written by non-standard Parquet producers that store decimals in BINARY without the expected FLBA layout; corrupted schema metadata; third-party tools that re-annotated columns as DECIMAL without re-encoding the physical data.","solutions":["Inspect the Parquet file schema (parquet-tools / parquet cat --schema) and confirm the decimal column's physical type","Rewrite the offending data files with a standard producer (Spark/Iceberg) so decimals use INT32/INT64/FIXED_LEN_BYTE_ARRAY","Re-annotate or re-encode the column as BINARY if the data is not actually decimal, and update the table schema accordingly","Upgrade Iceberg if support for additional decimal encodings has been added in newer versions"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"MessageType schema = parquetFileReader.getFooter().getFileMetaData().getSchema();\nfor (ColumnDescriptor col : schema.getColumns()) {\n  if (col.getPrimitiveTypeName() == PrimitiveTypeName.BINARY\n      && schema.containsPath(col.getPath()) /* check annotation */ ) {\n    // verify decimal columns use INT32/INT64/FIXED_LEN_BYTE_ARRAY before reading\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  spark.read().format(\"iceberg\").load(\"db.tbl\");\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().startsWith(\"Unsupported base type for decimal\")) {\n    // rewrite the offending files with a standard Parquet producer\n  } else {\n    throw e;\n  }\n}","preventionTips":["Run parquet-tools schema checks on externally produced files before registering them in Iceberg","Only write decimals with standard encodings (INT32/INT64/FIXED_LEN_BYTE_ARRAY)","Avoid third-party tools that re-annotate columns without re-encoding physical data"],"tags":["parquet","spark","decimal","reader"],"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"}