{"record":{"id":"6b2a7be7111d8e03","repo":"prestodb/presto","slug":"not-supported-6b2a7b","errorCode":"NOT_SUPPORTED","errorMessage":"Unsupported coercion from %s to %s","messagePattern":"Unsupported coercion from (.+?) to (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/HiveCoercer.java","lineNumber":106,"sourceCode":"            return new IntegerNumberUpscaleCoercer(fromType, toType);\n        }\n        else if (fromHiveType.equals(HIVE_INT) && toHiveType.equals(HIVE_LONG)) {\n            return new IntegerNumberUpscaleCoercer(fromType, toType);\n        }\n        else if (fromHiveType.equals(HIVE_FLOAT) && toHiveType.equals(HIVE_DOUBLE)) {\n            return new FloatToDoubleCoercer();\n        }\n        else if (isArrayType(fromType) && isArrayType(toType)) {\n            return new ListCoercer(typeManager, fromHiveType, toHiveType);\n        }\n        else if (isMapType(fromType) && isMapType(toType)) {\n            return new MapCoercer(typeManager, fromHiveType, toHiveType);\n        }\n        else if (isRowType(fromType) && isRowType(toType)) {\n            return new StructCoercer(typeManager, fromHiveType, toHiveType);\n        }\n\n        throw new PrestoException(NOT_SUPPORTED, format(\"Unsupported coercion from %s to %s\", fromHiveType, toHiveType));\n    }\n\n    class IntegerNumberUpscaleCoercer\n            implements HiveCoercer\n    {\n        private final Type fromType;\n        private final Type toType;\n\n        public IntegerNumberUpscaleCoercer(Type fromType, Type toType)\n        {\n            this.fromType = requireNonNull(fromType, \"fromType is null\");\n            this.toType = requireNonNull(toType, \"toType is null\");\n        }\n\n        @Override\n        public Block apply(Block block)\n        {\n            BlockBuilder blockBuilder = toType.createBlockBuilder(null, block.getPositionCount());","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/HiveCoercer.java#L88-L124","documentation":"HiveCoercer.createCoercer builds a Block-to-Block conversion when a Hive table's column type changes (schema evolution, e.g. via ALTER TABLE CHANGE COLUMN); only a fixed set of coercions is supported: integer upscaling (tinyint/smallint/int -> bigger ints), int types -> varchar, varchar -> integer types, float -> double, and element-wise array/map/struct coercions. Any other source/target combination reaches the terminal throw of NOT_SUPPORTED, meaning Presto cannot read old files with the new declared type.","triggerScenarios":"Altering a Hive table column to a type outside the supported set — e.g. varchar -> varchar/date/timestamp/boolean, int -> double, tinyint -> float, changing array element types to anything unsupported, map key/value coercions not supported — then querying the table so existing files must be coerced at read time.","commonSituations":"Schema evolution via ALTER TABLE changing a column to an incompatible type (string to date, int to decimal, int to double); changing a struct field to an unsupported type; data written before the ALTER whose files are lazily coerced during a subsequent SELECT.","solutions":["Rewrite the affected data instead of coercing at read time: CREATE TABLE new AS SELECT CAST(col AS <new_type>) ... and swap tables, so files physically match the new schema.","Choose a supported target type for the ALTER (e.g. tinyint->int->bigint, int->varchar, varchar->bigint, float->double) that createCoercer supports.","If a decimal/double/date conversion is genuinely needed, use an explicit INSERT OVERWRITE with CAST after creating the table with the new schema, ensuring no old-format files remain."],"exampleFix":"-- before: read-time coercion that is unsupported\nALTER TABLE t CHANGE COLUMN c c DATE;\n\n-- after: physically rewrite data with an explicit cast\nCREATE TABLE t_new AS SELECT CAST(c AS DATE) AS c, ... FROM t;\n-- then drop/rename t_new to t","handlingStrategy":"validation","validationCode":"-- before ALTERing a column type, check it is a supported read-time coercion:\n-- allowed: tinyint/smallint/int -> (larger) int types; int types -> varchar;\n-- varchar -> tinyint/smallint/int/bigint; float -> double;\n-- array/array, map/map, row/row with recursively supported element coercions.\nSHOW COLUMNS FROM t;  -- confirm old and new types fall in the supported set, else rewrite data","typeGuard":null,"tryCatchPattern":"try { ResultSet rs = stmt.executeQuery(\"SELECT * FROM t\"); ... }\ncatch (SQLException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"Unsupported coercion from\")) {\n    // rewrite the table with explicit CASTs instead of relying on read-time coercion\n  } else throw e;\n}","preventionTips":["Restrict ALTER TABLE type changes to the supported coercion set.","Prefer CTAS + INSERT with explicit CAST to physically rewrite data instead of lazy read-time coercion.","Document the supported Hive type-evolution matrix for your team.","After any type change, run a smoke SELECT over an old partition immediately."],"tags":["hive","schema-evolution","type-coercion","presto"],"backgroundTag":"unsupported-type-coercion","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"}