{"record":{"id":"087d316cab924efa","repo":"prestodb/presto","slug":"not-supported-087d31","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/HiveCoercionRecordCursor.java","lineNumber":313,"sourceCode":"            return new IntegerNumberUpscaleCoercer();\n        }\n        else if (fromHiveType.equals(HIVE_INT) && toHiveType.equals(HIVE_LONG)) {\n            return new IntegerNumberUpscaleCoercer();\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, bridgingRecordCursor);\n        }\n        else if (isMapType(fromType) && isMapType(toType)) {\n            return new MapCoercer(typeManager, fromHiveType, toHiveType, bridgingRecordCursor);\n        }\n        else if (isRowType(fromType) && isRowType(toType)) {\n            return new StructCoercer(typeManager, fromHiveType, toHiveType, bridgingRecordCursor);\n        }\n\n        throw new PrestoException(NOT_SUPPORTED, format(\"Unsupported coercion from %s to %s\", fromHiveType, toHiveType));\n    }\n\n    private static class IntegerNumberUpscaleCoercer\n            extends Coercer\n    {\n        @Override\n        public void coerce(RecordCursor delegate, int field)\n        {\n            setLong(delegate.getLong(field));\n        }\n    }\n\n    private static class IntegerNumberToVarcharCoercer\n            extends Coercer\n    {\n        @Override\n        public void coerce(RecordCursor delegate, int field)\n        {","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/HiveCoercionRecordCursor.java#L295-L331","documentation":"HiveCoercionRecordCursor.createCoercer is the cursor-level twin of HiveCoercer.createCoercer, used when reading old files after a column type change and bridging values through a RecordCursor; it supports integer upscaling, varchar<->integer, float->double, and recursive list/map/struct coercions. Any other from/to combination throws NOT_SUPPORTED, since Presto cannot convert the on-disk values to the new declared column type.","triggerScenarios":"Querying a Hive table after ALTER TABLE changed a column to a type outside the supported coercion set (e.g. string->date/timestamp/boolean/decimal, int->double/real, tinyint->float), where the read path goes through HiveCoercionRecordCursor with a bridging record cursor; also unsupported nested element/field coercions inside array/map/struct columns.","commonSituations":"Schema evolution altering string columns to date/decimal/boolean; converting int to double/float; struct field type changes to unsupported targets; then running a SELECT over partitions still containing files written with the old schema.","solutions":["Physically rewrite the data with explicit casts: CREATE TABLE t_new AS SELECT CAST(col AS <new_type>) ... then swap, so no read-time coercion is needed.","Restrict the ALTER to coercion-supported transitions (tinyint/smallint/int->larger ints, int types->varchar, varchar->integer types, float->double, and element-wise compatible array/map/struct changes).","For nested types, evolve each element/field type only to supported coercions (e.g. array<int> -> array<bigint>), otherwise rewrite the column via INSERT OVERWRITE with casts."],"exampleFix":"-- before: unsupported read-time coercion after ALTER\nALTER TABLE t CHANGE COLUMN s s DECIMAL(10,2);\nSELECT * FROM t; -- fails: Unsupported coercion from varchar to decimal(10,2)\n\n-- after: rewrite data with explicit cast\nCREATE TABLE t_new AS SELECT CAST(s AS DECIMAL(10,2)) AS s FROM t;\n-- drop t, rename t_new to t","handlingStrategy":"validation","validationCode":"-- before changing a column type that old files must read through, verify the pair is supported:\n-- integer upscale (tinyint/smallint/int -> larger ints), int<->varchar, float -> double,\n-- array->array / map->map / row->row with supported element/field coercions.\n-- Otherwise plan a CTAS rewrite with explicit CASTs.","typeGuard":null,"tryCatchPattern":"try { ResultSet rs = stmt.executeQuery(\"SELECT * FROM evolved_table\"); ... }\ncatch (SQLException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"Unsupported coercion from\")) {\n    // rewrite old partitions with explicit casts, then retry the query\n  } else throw e;\n}","preventionTips":["After ALTERing column types, immediately rewrite all old partitions so no legacy-schema files remain.","Evolve nested (array/map/struct) element and field types only to supported coercions.","Test the read path on a copy of an old partition before promoting schema changes to production.","Keep a type-evolution compatibility checklist next to your migration runbooks."],"tags":["hive","schema-evolution","type-coercion","record-cursor"],"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"}