{"record":{"id":"84c079973380a418","repo":"prestodb/presto","slug":"can-t-handle-type","errorCode":null,"errorMessage":"Can't handle type: ","messagePattern":"Can't handle type: ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"presto-clickhouse/src/main/java/com/facebook/presto/plugin/clickhouse/QueryBuilder.java","lineNumber":223,"sourceCode":"                statement.setTime(i + 1, new Time((long) typeAndValue.getValue()));\n            }\n            else if (typeAndValue.getType().equals(TIME_WITH_TIME_ZONE)) {\n                statement.setTime(i + 1, new Time(unpackMillisUtc((long) typeAndValue.getValue())));\n            }\n            else if (typeAndValue.getType().equals(TIMESTAMP)) {\n                statement.setTimestamp(i + 1, new Timestamp((long) typeAndValue.getValue()));\n            }\n            else if (typeAndValue.getType().equals(TIMESTAMP_WITH_TIME_ZONE)) {\n                statement.setTimestamp(i + 1, new Timestamp(unpackMillisUtc((long) typeAndValue.getValue())));\n            }\n            else if (typeAndValue.getType() instanceof VarcharType) {\n                statement.setString(i + 1, ((Slice) typeAndValue.getValue()).toStringUtf8());\n            }\n            else if (typeAndValue.getType() instanceof CharType) {\n                statement.setString(i + 1, ((Slice) typeAndValue.getValue()).toStringUtf8());\n            }\n            else {\n                throw new UnsupportedOperationException(\"Can't handle type: \" + typeAndValue.getType());\n            }\n        }\n\n        return statement;\n    }\n\n    private static boolean isAcceptedType(Type type)\n    {\n        Type validType = requireNonNull(type, \"type is null\");\n        return validType.equals(BIGINT) ||\n                validType.equals(TINYINT) ||\n                validType.equals(SMALLINT) ||\n                validType.equals(INTEGER) ||\n                validType.equals(DOUBLE) ||\n                validType.equals(REAL) ||\n                validType.equals(BOOLEAN) ||\n                validType.equals(DATE) ||\n                validType.equals(TIME) ||","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-clickhouse/src/main/java/com/facebook/presto/plugin/clickhouse/QueryBuilder.java#L205-L241","documentation":"QueryBuilder.buildSql() binds predicate/bucket values into the generated SQL; it handles boolean, bigint, integer, smallint, tinyint, double, real, varchar and char types explicitly. Any other Presto type used in a pushdown predicate (e.g. date, timestamp, decimal, varbinary) throws UnsupportedOperationException \"Can't handle type: ...\".","triggerScenarios":"Running a query whose WHERE clause contains a comparison predicate on a column type the ClickHouse QueryBuilder cannot bind (date, timestamp, decimal, varbinary, etc.), causing that predicate value to reach the unsupported else branch.","commonSituations":"Filtering on DATE/TIMESTAMP columns with literal comparisons; predicates pushed down after optimization; decimal comparisons from other catalogs joined against ClickHouse tables.","solutions":["Cast the literal to a handled type or compare via string/numeric conversion, e.g. WHERE ts = TIMESTAMP '...' → use a cast of the column","Rewrite the predicate so the unhandled type is not pushed as a literal (e.g. cast the column to VARCHAR)","Disable predicate pushdown for that query by wrapping the filter so the connector filters locally","Upgrade the connector — the handled-type list grows over versions"],"exampleFix":"// before\nSELECT * FROM ch.db.t WHERE d = DATE '2024-01-01';\n// after\nSELECT * FROM ch.db.t WHERE CAST(d AS VARCHAR) = '2024-01-01';","handlingStrategy":"type-guard","validationCode":"// Pre-check predicate types eligible for pushdown binding\nSet<Class<?>> bindable = Set.of(Boolean.class, Long.class, Double.class, Float.class, Slice.class /*varchar/char*/);\nType t = predicateType;\nboolean pushable = t instanceof BooleanType || t instanceof BigintType || t instanceof IntegerType\n    || t instanceof SmallintType || t instanceof TinyintType || t instanceof DoubleType\n    || t instanceof RealType || t instanceof VarcharType || t instanceof CharType;\nif (!pushable) throw new IllegalArgumentException(\"Predicate on \" + t + \" cannot be pushed to ClickHouse; cast or filter locally\");","typeGuard":"boolean isPredicateBindableToClickHouse(Type t) {\n    return t instanceof BooleanType || t instanceof BigintType || t instanceof IntegerType\n        || t instanceof SmallintType || t instanceof TinyintType || t instanceof DoubleType\n        || t instanceof RealType || t instanceof VarcharType || t instanceof CharType;\n}","tryCatchPattern":"try {\n    executeWithPushdown(...);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage().startsWith(\"Can't handle type:\")) {\n        // re-run with the predicate evaluated locally (disable pushdown)\n    } else throw e;\n}","preventionTips":["Cast DATE/TIMESTAMP/DECIMAL literals so predicates bind to handled types","Restrict pushdown-friendly filters to numeric/string columns","Wrap unsupported predicates in a subquery so they evaluate locally","Track connector releases for expanded bindable types"],"tags":["predicate-pushdown","type-mapping","sql-generation","clickhouse"],"backgroundTag":"unsupported-predicate-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"}