{"record":{"id":"3f0915b7d4c4e887","repo":"apache/iceberg","slug":"unsupported-base-type-for-decimal-primitive-getp","errorCode":null,"errorMessage":"Unsupported base type for decimal: {primitive.getPrimitiveTypeName()}","messagePattern":"Unsupported base type for decimal: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/data/SparkParquetReaders.java","lineNumber":270,"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":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/data/SparkParquetReaders.java#L252-L288","documentation":"In SparkParquetReaders.primitive, decimal columns must be backed by FLBA (fixed_len_byte_array), INT64, or INT32 Parquet storage. If the underlying physical type of a decimal logical type is anything else, this UnsupportedOperationException is thrown because no decimal reader exists for that base type.","triggerScenarios":"Reading a Parquet file whose column has the DECIMAL logical type but a physical primitive type other than FIXED_LEN_BYTE_ARRAY, INT64, or INT32 (e.g. BINARY-backed decimal from some writers).","commonSituations":"Reading Parquet files produced by non-Iceberg writers (Hive, Impala, third-party tools) that store decimals in unusual physical encodings; mixed-writer tables.","solutions":["Rewrite the source Parquet files with a writer that uses FLBA/INT64/INT32 storage for decimals (e.g. rewrite_data_files).","Verify the file's decimal encoding with parquet-tools and, if BINARY, convert the column (e.g. via Spark cast) before reading through Iceberg.","Upgrade Iceberg — newer versions may add support for more decimal physical representations."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// inspect physical encoding before reading\n// parquet-tools schema file.parquet | grep -B1 DECIMAL","typeGuard":null,"tryCatchPattern":"try {\n  icebergTable.newScan().planFiles();\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().contains(\"Unsupported base type for decimal\")) {\n    // fall back to non-Iceberg read or rewrite the files\n  }\n}","preventionTips":["Write Parquet with standard writers that store decimals as FLBA/INT64/INT32","Check foreign files with parquet-tools before registering them with Iceberg","Keep Iceberg upgraded to the latest patch release"],"tags":["spark","parquet","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"}