{"record":{"id":"cb8bf206811b668a","repo":"apache/beam","slug":"s-is-a-type-constructor-that-takes-parameters-not-a-type-so","errorCode":null,"errorMessage":"%s is a type constructor that takes parameters, not a type,so it cannot be converted to a %s","messagePattern":"(.+?) is a type constructor that takes parameters, not a type,so it cannot be converted to a (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/utils/CalciteUtils.java","lineNumber":265,"sourceCode":"        }\n    }\n  }\n\n  public static FieldType toFieldType(SqlTypeNameSpec sqlTypeName) {\n    return toFieldType(\n        Preconditions.checkArgumentNotNull(\n            SqlTypeName.get(sqlTypeName.getTypeName().getSimple()),\n            \"Failed to find Calcite type with name '%s'\",\n            sqlTypeName.getTypeName().getSimple()));\n  }\n\n  public static FieldType toFieldType(SqlTypeName sqlTypeName) {\n    switch (sqlTypeName) {\n      case MAP:\n      case MULTISET:\n      case ARRAY:\n      case ROW:\n        throw new IllegalArgumentException(\n            String.format(\n                \"%s is a type constructor that takes parameters, not a type,\"\n                    + \"so it cannot be converted to a %s\",\n                sqlTypeName, Schema.FieldType.class.getSimpleName()));\n      default:\n        FieldType fieldType = CALCITE_TO_BEAM_TYPE_MAPPING.get(sqlTypeName);\n        if (fieldType == null) {\n          throw new IllegalArgumentException(\n              \"Cannot find a matching Beam FieldType for Calcite type: \" + sqlTypeName);\n        }\n        return fieldType;\n    }\n  }\n\n  public static Schema.Field toField(RelDataTypeField calciteField) {\n    return toField(calciteField.getName(), calciteField.getType());\n  }\n","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/utils/CalciteUtils.java#L247-L283","documentation":"CalciteUtils.toFieldType(SqlTypeName) only converts atomic Calcite types. MAP, MULTISET, ARRAY and ROW are type constructors requiring parameter types, so converting one to a standalone Schema.FieldType is invalid and throws IllegalArgumentException. You must convert the element/row types and construct the composite FieldType yourself.","triggerScenarios":"Calling CalciteUtils.toFieldType with SqlTypeName.MAP, MULTISET, ARRAY or ROW, typically when a column's type is parameterized (e.g. an ARRAY<INT64> column whose SqlTypeName is ARRAY).","commonSituations":"Iterating RelDataType fields of a table containing array/map/struct columns and naively calling toFieldType per SqlTypeName; custom schema extraction from Calcite plans.","solutions":["Branch on the SqlTypeName before calling: for ARRAY use FieldType.array(toFieldType(elementType)), for MAP use FieldType.map(k, v), for ROW use FieldType.row(toSchema(relDataType)).","Use CalciteUtils.toFieldType(RelDataType) (the overload at line ~315) which handles parameterized types.","Skip/composite-handle constructor types in schema conversion code."],"exampleFix":"// before\nFieldType ft = CalciteUtils.toFieldType(relDataType.getSqlTypeName()); // throws for ARRAY\n// after\nFieldType ft = relDataType.getSqlTypeName() == SqlTypeName.ARRAY\n    ? FieldType.array(CalciteUtils.toFieldType(relDataType.getComponentType()))\n    : CalciteUtils.toFieldType(relDataType.getSqlTypeName());","handlingStrategy":"type-guard","validationCode":"Set<SqlTypeName> constructors = Set.of(SqlTypeName.MAP, SqlTypeName.MULTISET, SqlTypeName.ARRAY, SqlTypeName.ROW);\nif (constructors.contains(sqlTypeName)) { /* use composite conversion path */ }","typeGuard":"boolean isTypeConstructor(SqlTypeName t) {\n  return t == SqlTypeName.MAP || t == SqlTypeName.MULTISET || t == SqlTypeName.ARRAY || t == SqlTypeName.ROW;\n}","tryCatchPattern":"try { ft = CalciteUtils.toFieldType(sqlTypeName); }\ncatch (IllegalArgumentException e) { /* branch to array/map/row construction using element types */ }","preventionTips":["Always handle ARRAY/MAP/ROW with their element-type-aware overloads","Call toFieldType(RelDataType) instead of toFieldType(SqlTypeName) for column types","Write a switch on SqlTypeName before schema conversion loops"],"tags":["beam-sql","calcite","schema","type-constructor"],"backgroundTag":"unsupported-operation","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"}