{"record":{"id":"894fe93bda860c1e","repo":"apache/iceberg","slug":"unsupported-base-type-for-decimal-primitive-get","errorCode":null,"errorMessage":"Unsupported base type for decimal: ${primitive.getPrimitiveTypeName()}","messagePattern":"Unsupported base type for decimal: (.+?)","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/SparkParquetReaders.java","lineNumber":246,"sourceCode":"          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:\n          if (expected != null && expected.typeId() == TypeID.LONG) {\n            return new IntAsLongReader(desc);\n          } else {\n            return new UnboxedReader<>(desc);\n          }\n        case FLOAT:","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/SparkParquetReaders.java#L228-L264","documentation":"Iceberg's Spark Parquet reader throws this when a Parquet column carries the DECIMAL logical type but is physically stored with a primitive base type it cannot decode. Only INT32, INT64, BINARY, and FIXED_LEN_BYTE_ARRAY encodings are supported for decimals per the Parquet spec; anything else (e.g. FLOAT, DOUBLE, BOOLEAN) has no defined decimal representation.","triggerScenarios":"Reading a Parquet file during a Spark query whose schema contains a decimal column, where the underlying physical column has the DECIMAL logical type annotation but an unexpected physical primitive type (e.g. FLOAT/DOUBLE), typically from a nonstandard writer or a corrupted/hand-edited schema.","commonSituations":"Files written by third-party or buggy tools that mislabel decimal columns; manually crafted Parquet schemas in tests; version mismatches where a writer emitted decimals with an unsupported encoding.","solutions":["Rewrite the offending Parquet files with a standard writer so decimals use BINARY, FIXED_LEN_BYTE_ARRAY, INT64, or INT32 physical storage","Verify the Parquet file's schema with parquet-tools/meta and confirm the decimal column's physical type","Check the writer library version that produced the file and upgrade/fix it to emit spec-compliant decimals","Cast/reconvert the data outside Iceberg into a supported physical layout before reading"],"exampleFix":"// before: reading a file whose decimal column is stored as FLOAT (invalid)\nspark.read.format(\"iceberg\").load(\"db.table\") // throws\n// after: rewrite the file with proper decimal physical type\nCREATE TABLE fixed STORED AS ... ; INSERT INTO fixed SELECT CAST(dec_col AS DECIMAL(38,10)) FROM bad;","handlingStrategy":"validation","validationCode":"// Before reading, verify decimal physical types with parquet-tools\n// parquet-tools schema file.parquet | grep -A2 DECIMAL\n// Each DECIMAL column must be INT32/INT64/BINARY/FIXED_LEN_BYTE_ARRAY","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write Parquet via Iceberg/standard writers so decimals use spec-compliant physical types","Validate third-party Parquet files with parquet-tools before ingesting","Pin writer library versions known to emit correct decimal encodings"],"tags":["parquet","spark","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"}