prestodb/presto · error · IllegalArgumentException
Wrong dataFormat '%s' specified for column '%s'; %s type imp
Error message
Wrong dataFormat '%s' specified for column '%s'; %s type implies use of %s
What it means
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.
Source
Thrown at presto-record-decoder/src/main/java/com/facebook/presto/decoder/raw/RawColumnDecoder.java:175
throw new PrestoException(StandardErrorCode.GENERIC_USER_ERROR, e);
}
}
private static boolean isSupportedType(Type type)
{
if (isVarcharType(type)) {
return true;
}
if (ImmutableList.of(BIGINT, INTEGER, SMALLINT, TINYINT, BOOLEAN, DOUBLE).contains(type)) {
return true;
}
return false;
}
private void checkFieldTypeOneOf(FieldType declaredFieldType, String columnName, FieldType... allowedFieldTypes)
{
if (!Arrays.asList(allowedFieldTypes).contains(declaredFieldType)) {
throw new IllegalArgumentException(format(
"Wrong dataFormat '%s' specified for column '%s'; %s type implies use of %s",
declaredFieldType.name(),
columnName,
columnType.getDisplayName(),
Joiner.on("/").join(allowedFieldTypes)));
}
}
public FieldValueProvider decodeField(byte[] value)
{
requireNonNull(value, "value is null");
int actualEnd = end.orElse(value.length);
if (start > value.length) {
throw new PrestoException(DECODER_CONVERSION_NOT_SUPPORTED, format(
"start offset %s for column '%s' must be less that or equal to value length %s",
start,View on GitHub (pinned to 55bb57d202)
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.
Example fix
// before: mismatched type/format pair -- reading DOUBLE WITH (data_format='LONG', mapping='0:8') // after: DOUBLE format on a DOUBLE column (8-byte read) -- reading DOUBLE WITH (data_format='DOUBLE', mapping='0:8')
Defensive patterns
Strategy: validation
Validate before calling
Map<String,Set<String>> OK = Map.of(
"BYTE", Set.of("tinyint","smallint","integer","bigint"),
"SHORT", Set.of("smallint","integer","bigint"),
"INT", Set.of("integer","bigint"),
"LONG", Set.of("bigint"),
"FLOAT", Set.of("double"),
"DOUBLE", Set.of("double"));
void checkRawTypePair(String dataFormat, String columnType) {
if (!OK.getOrDefault(dataFormat.toUpperCase(), Set.of()).contains(columnType.toLowerCase()))
throw new IllegalArgumentException("type " + columnType + " incompatible with raw format " + dataFormat);
} Try / catch
try { stmt.execute(ddl); } catch (SQLException e) { if (e.getMessage().contains("Wrong dataFormat")) { alignColumnTypeAndFormat(); } else throw e; } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- invalid dataFormat '%s' for column '%s'
- TYPE_MISMATCH
- TYPE_MISMATCH
- invalid mapping format '%s' for column '%s'
- DECODER_CONVERSION_NOT_SUPPORTED
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/da6981ec18ed5a22.
Report an issue: GitHub.