{"record":{"id":"4b559cb93307c6d7","repo":"prestodb/presto","slug":"type-mismatch-4b559c","errorCode":"TYPE_MISMATCH","errorMessage":"Unknown type '%s' for column '%s'","messagePattern":"Unknown type '(.+?)' for column '(.+?)'","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/execution/SetColumnTypeTask.java","lineNumber":102,"sourceCode":"        TableHandle tableHandleOptional = tableHandle.get();\n        Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandleOptional);\n        ColumnHandle column = columnHandles.get(statement.getColumnName().getValue());\n        if (column == null) {\n            throw new SemanticException(MISSING_COLUMN, statement, \"Column '%s' does not exist\", statement.getColumnName());\n        }\n        metadata.setColumnType(session, tableHandleOptional, column, getColumnType(statement));\n\n        return immediateFuture(null);\n    }\n\n    private Type getColumnType(SetColumnType statement)\n    {\n        Type type;\n        try {\n            type = metadata.getType(parseTypeSignature(statement.getType()));\n        }\n        catch (IllegalArgumentException e) {\n            throw new SemanticException(TYPE_MISMATCH, statement, \"Unknown type '%s' for column '%s'\", statement.getType(), statement.getColumnName());\n        }\n        if (type.equals(UNKNOWN)) {\n            throw new SemanticException(TYPE_MISMATCH, statement, \"Unknown type '%s' for column '%s'\", statement.getType(), statement.getColumnName());\n        }\n        return type;\n    }\n}\n","sourceCodeStart":84,"sourceCodeEnd":110,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/SetColumnTypeTask.java#L84-L110","documentation":"Thrown by the type-parsing helper of ALTER COLUMN SET TYPE when the type string in the statement cannot be resolved to a known Type via metadata.getType(parseTypeSignature(...)) and the parse throws IllegalArgumentException. Presto validates the requested type before applying the column type change, so an unparseable or unknown type name fails early with TYPE_MISMATCH. It guarantees the ALTER never applies a type the engine does not know.","triggerScenarios":"Executing ALTER TABLE ... ALTER COLUMN col SET TYPE <type> where <type> is not a registered type name/signature (parseTypeSignature throws IllegalArgumentException).","commonSituations":"Misspelled type names (e.g. VARCHER); using connector-specific or engine-unsupported types; copying types from other databases (e.g. NVARCHAR, TEXT) not valid in Presto.","solutions":["Use SHOW COLUMNS / documentation to pick a valid Presto type name and re-run the ALTER.","Check the type spelling and parameters, e.g. VARCHAR(50) instead of VARCHR(50).","If mapping from another engine's type, translate it to the closest Presto type (e.g. TEXT -> VARCHAR)."],"exampleFix":"-- before\nALTER TABLE t ALTER COLUMN c SET TYPE NVARCHAR\n-- after\nALTER TABLE t ALTER COLUMN c SET TYPE VARCHAR","handlingStrategy":"validation","validationCode":"SHOW SESSION; -- not type related; instead validate type against a known list\nconst VALID = new Set(['VARCHAR','BIGINT','INTEGER','DOUBLE','BOOLEAN','DATE','TIMESTAMP','DECIMAL','ROW','MAP','ARRAY']);\nif (!VALID.has(typeName.toUpperCase().split('(')[0])) throw new Error(`Unknown Presto type: ${typeName}`);","typeGuard":"function isKnownPrestoType(t) {\n  return /^(varchar|bigint|integer|smallint|tinyint|double|real|boolean|date|time|timestamp|decimal|json|map|array|row|ipaddress|uuid)/i.test(t);\n}","tryCatchPattern":"try {\n  await run(`ALTER TABLE t ALTER COLUMN c SET TYPE ${type}`);\n} catch (e) {\n  if (e.message.includes(\"Unknown type\")) {\n    console.error(`Invalid type '${type}'; use a Presto-documented type`);\n  }\n  throw e;\n}","preventionTips":["Only use types from the Presto type reference documentation.","Map foreign engine types to Presto equivalents before generating DDL.","Test DDL scripts on a dev cluster first.","Avoid free-form user input as type names in generated SQL."],"tags":["sql","ddl","presto","type-error"],"backgroundTag":"unknown-type","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"}