{"record":{"id":"da6981ec18ed5a22","repo":"prestodb/presto","slug":"wrong-dataformat-s-specified-for-column-s","errorCode":null,"errorMessage":"Wrong dataFormat '%s' specified for column '%s'; %s type implies use of %s","messagePattern":"Wrong dataFormat '(.+?)' specified for column '(.+?)'; (.+?) type implies use of (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-record-decoder/src/main/java/com/facebook/presto/decoder/raw/RawColumnDecoder.java","lineNumber":175,"sourceCode":"            throw new PrestoException(StandardErrorCode.GENERIC_USER_ERROR, e);\n        }\n    }\n\n    private static boolean isSupportedType(Type type)\n    {\n        if (isVarcharType(type)) {\n            return true;\n        }\n        if (ImmutableList.of(BIGINT, INTEGER, SMALLINT, TINYINT, BOOLEAN, DOUBLE).contains(type)) {\n            return true;\n        }\n        return false;\n    }\n\n    private void checkFieldTypeOneOf(FieldType declaredFieldType, String columnName, FieldType... allowedFieldTypes)\n    {\n        if (!Arrays.asList(allowedFieldTypes).contains(declaredFieldType)) {\n            throw new IllegalArgumentException(format(\n                    \"Wrong dataFormat '%s' specified for column '%s'; %s type implies use of %s\",\n                    declaredFieldType.name(),\n                    columnName,\n                    columnType.getDisplayName(),\n                    Joiner.on(\"/\").join(allowedFieldTypes)));\n        }\n    }\n\n    public FieldValueProvider decodeField(byte[] value)\n    {\n        requireNonNull(value, \"value is null\");\n\n        int actualEnd = end.orElse(value.length);\n\n        if (start > value.length) {\n            throw new PrestoException(DECODER_CONVERSION_NOT_SUPPORTED, format(\n                    \"start offset %s for column '%s' must be less that or equal to value length %s\",\n                    start,","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-record-decoder/src/main/java/com/facebook/presto/decoder/raw/RawColumnDecoder.java#L157-L193","documentation":"RawColumnDecoder.checkFieldTypeOneOf enforces that a column's declared SQL type is compatible with its raw FieldType (dataFormat). For example BYTE/SHORT/INT/LONG formats require an integral column type (TINYINT..BIGINT), FLOAT/DOUBLE require DOUBLE. When the pair is inconsistent, it throws IllegalArgumentException \"Wrong dataFormat '%s' specified for column '%s'; %s type implies use of %s\" at decoder construction.","triggerScenarios":"Declaring a raw column whose columnType does not fit the dataFormat, e.g. data_format='DOUBLE' on a BIGINT column, or data_format='LONG' on a VARCHAR column; checkFieldTypeOneOf is invoked from the RawColumnDecoder constructor for each raw column at metadata-build time.","commonSituations":"Hand-edited DDL where the SQL type was changed but data_format wasn't (or vice versa); generic templates applied across topics; expecting implicit numeric coercion that raw decoding does not perform.","solutions":["Align the column's SQL type with its dataFormat: integral types (TINYINT/SMALLINT/INT/BIGINT) for BYTE/SHORT/INT/LONG; DOUBLE for FLOAT/DOUBLE.","If you need a different output type, keep the raw column with the matching type and CAST in your queries.","Decode variable-length bytes into VARCHAR (no dataFormat) instead of forcing a numeric format.","Review the raw decoder's type-compatibility table in the connector docs before writing DDL."],"exampleFix":"// before: mismatched type/format pair\n-- reading DOUBLE WITH (data_format='LONG', mapping='0:8')\n// after: DOUBLE format on a DOUBLE column (8-byte read)\n-- reading DOUBLE WITH (data_format='DOUBLE', mapping='0:8')","handlingStrategy":"validation","validationCode":"Map<String,Set<String>> OK = Map.of(\n  \"BYTE\", Set.of(\"tinyint\",\"smallint\",\"integer\",\"bigint\"),\n  \"SHORT\", Set.of(\"smallint\",\"integer\",\"bigint\"),\n  \"INT\", Set.of(\"integer\",\"bigint\"),\n  \"LONG\", Set.of(\"bigint\"),\n  \"FLOAT\", Set.of(\"double\"),\n  \"DOUBLE\", Set.of(\"double\"));\nvoid checkRawTypePair(String dataFormat, String columnType) {\n  if (!OK.getOrDefault(dataFormat.toUpperCase(), Set.of()).contains(columnType.toLowerCase()))\n    throw new IllegalArgumentException(\"type \" + columnType + \" incompatible with raw format \" + dataFormat);\n}","typeGuard":null,"tryCatchPattern":"try { stmt.execute(ddl); } catch (SQLException e) { if (e.getMessage().contains(\"Wrong dataFormat\")) { alignColumnTypeAndFormat(); } else throw e; }","preventionTips":["Keep (dataFormat, columnType) pairs in a checked table rather than free-form DDL.","Integral raw formats need integral column types; FLOAT/DOUBLE need DOUBLE.","CAST in queries instead of coercing the decoder's output type via mismatched DDL."],"tags":["presto","kafka-decoder","raw","type-mismatch","ddl"],"backgroundTag":"invalid-column-config","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}