{"record":{"id":"d425e14a4b317cbe","repo":"apache/beam","slug":"sql-type-not-supported","errorCode":null,"errorMessage":"SQL type not supported: ","messagePattern":"SQL type not supported: ","errorType":"exception","errorClass":"SqlConversionException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/cep/CEPLiteral.java","lineNumber":61,"sourceCode":"      case INTEGER:\n        return of(lit.getValueAs(Integer.class));\n      case BIGINT:\n        return of(lit.getValueAs(Long.class));\n      case DECIMAL:\n        return of(lit.getValueAs(BigDecimal.class));\n      case FLOAT:\n        return of(lit.getValueAs(Float.class));\n      case DOUBLE:\n        return of(lit.getValueAs(Double.class));\n      case BOOLEAN:\n        return of(lit.getValueAs(Boolean.class));\n      case DATE:\n        return of(lit.getValueAs(ReadableDateTime.class));\n      case CHAR:\n      case VARCHAR:\n        return of(lit.getValueAs(String.class));\n      default:\n        throw new SqlConversionException(\"SQL type not supported: \" + lit.getTypeName().toString());\n    }\n  }\n\n  public static CEPLiteral of(Byte myByte) {\n    return new CEPLiteral(Schema.TypeName.BYTE) {\n      @Override\n      public Byte getByte() {\n        return myByte;\n      }\n\n      @Override\n      public int compareTo(Object other) {\n        if (!(other instanceof CEPLiteral)) {\n          throw new IllegalStateException(\"The other object should be an instance of CEPLiteral\");\n        }\n        CEPLiteral otherLit = (CEPLiteral) other;\n        if (getTypeName() != otherLit.getTypeName()) {\n          throw new IllegalStateException(","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/cep/CEPLiteral.java#L43-L79","documentation":"When converting a Calcite RexLiteral into a CEPLiteral, only a fixed set of SQL types (e.g. INTEGER, BIGINT, DOUBLE, DECIMAL, BOOLEAN, DATE, CHAR/VARCHAR) is supported; any other type name falls into the default branch and raises SqlConversionException with the unsupported type name. Beam SQL's CEP translation cannot represent that literal.","triggerScenarios":"Using a literal in a MATCH_RECOGNIZE DEFINE clause whose Calcite SqlTypeName is outside the supported switch cases, e.g. TIMESTAMP, TIME, INTERVAL, ARRAY, or ANY-typed literals.","commonSituations":"Comparing pattern variables against TIMESTAMP/TIME literals in CEP DEFINE clauses; using typed empty arrays or interval literals in pattern conditions; Calcite inferring an unexpected type (e.g. DECIMAL vs DOUBLE) for a numeric literal.","solutions":["Cast the literal to a supported type in the query, e.g. CAST(ts AS TIMESTAMP) only if supported, or restructure to compare supported types (BIGINT epoch millis, VARCHAR, DOUBLE, BOOLEAN, DATE)","Replace the unsupported literal with a supported equivalent (e.g. epoch-millis BIGINT instead of TIMESTAMP)","Rewrite the DEFINE condition to avoid the unsupported literal type entirely"],"exampleFix":"// before\nDEFINE x AS event_time > TIMESTAMP '2020-01-01 00:00:00' -- unsupported\n// after\nDEFINE x AS event_ts > 1577836800000 -- BIGINT epoch millis literal","handlingStrategy":"validation","validationCode":"SqlTypeName tn = lit.getTypeName();\nSet<SqlTypeName> supported = Set.of(SqlTypeName.INTEGER, SqlTypeName.BIGINT, SqlTypeName.DOUBLE,\n    SqlTypeName.DECIMAL, SqlTypeName.BOOLEAN, SqlTypeName.DATE, SqlTypeName.CHAR, SqlTypeName.VARCHAR);\nif (!supported.contains(tn)) throw new IllegalArgumentException(\"Unsupported CEP literal type: \" + tn);","typeGuard":"static boolean isSupportedCepLiteralType(RexLiteral lit) {\n  switch (lit.getTypeName()) {\n    case INTEGER: case BIGINT: case DOUBLE: case DECIMAL:\n    case BOOLEAN: case DATE: case CHAR: case VARCHAR:\n      return true;\n    default:\n      return false;\n  }\n}","tryCatchPattern":"try {\n  CEPLiteral l = CEPLiteral.of(lit);\n} catch (SqlConversionException e) {\n  if (e.getMessage().startsWith(\"SQL type not supported\")) {\n    throw new IllegalStateException(\"Replace literal of type \" + lit.getTypeName() + \" in DEFINE clause\", e);\n  } else throw e;\n}","preventionTips":["Use BIGINT/DOUBLE/VARCHAR/BOOLEAN/DATE literals in CEP DEFINE clauses","Avoid TIMESTAMP/TIME/INTERVAL/ARRAY literals in MATCH_RECOGNIZE patterns","Cast or convert literals to supported types before pattern matching"],"tags":["beam-sql","cep","calcite","sql-type","literal"],"backgroundTag":"invalid-enum-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}