{"record":{"id":"6cc7bbb76bd32c52","repo":"apache/beam","slug":"cannot-infer-types-from-s-this-is-currently-unsupported-use","errorCode":null,"errorMessage":"Cannot infer types from %s. This is currently unsupported, use List instead of Array.","messagePattern":"Cannot infer types from (.+?)\\. This is currently unsupported, use List instead of Array\\.","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":420,"sourceCode":"    if (type instanceof Class && AbstractInstant.class.isAssignableFrom((Class<?>) type)) {\n      return typeFactory.createJavaType(Date.class);\n    } else if (type instanceof Class && ByteString.class.isAssignableFrom((Class<?>) type)) {\n      return typeFactory.createJavaType(byte[].class);\n    } else if (type instanceof ParameterizedType) {\n      ParameterizedType parameterizedType = (ParameterizedType) type;\n      if (java.util.List.class.isAssignableFrom((Class<?>) parameterizedType.getRawType())) {\n        RelDataType elementType =\n            sqlTypeWithAutoCast(typeFactory, parameterizedType.getActualTypeArguments()[0]);\n        return typeFactory.createArrayType(elementType, UNLIMITED_ARRAY_SIZE);\n      } else if (java.util.Map.class.isAssignableFrom((Class<?>) parameterizedType.getRawType())) {\n        RelDataType mapElementKeyType =\n            sqlTypeWithAutoCast(typeFactory, parameterizedType.getActualTypeArguments()[0]);\n        RelDataType mapElementValueType =\n            sqlTypeWithAutoCast(typeFactory, parameterizedType.getActualTypeArguments()[1]);\n        return typeFactory.createMapType(mapElementKeyType, mapElementValueType);\n      }\n    } else if (type instanceof GenericArrayType) {\n      throw new IllegalArgumentException(\n          \"Cannot infer types from \"\n              + type\n              + \". This is currently unsupported, use List instead \"\n              + \"of Array.\");\n    }\n    if (type instanceof Class) {\n      Class<?> clazz = (Class<?>) type;\n      SqlTypeName sqlTypeName = JAVA_TO_SQL_TYPE_MAPPING.get(clazz);\n      if (sqlTypeName != null) {\n        return typeFactory.createTypeWithNullability(\n            typeFactory.createSqlType(sqlTypeName), !clazz.isPrimitive());\n      }\n    }\n    return typeFactory.createJavaType((Class) type);\n  }\n}\n","sourceCodeStart":402,"sourceCodeEnd":437,"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#L402-L437","documentation":"CalciteUtils.sqlTypeWithAutoCast infers a Calcite RelDataType from a Java reflection Type for UDF/UDAF argument resolution. Java GenericArrayType (i.e. T[] parameters) is not supported, so IllegalArgumentException tells you to use java.util.List instead of raw arrays. Beam SQL maps List<E> to ARRAY and Map<K,V> to MAP, but not array-typed signatures.","triggerScenarios":"Declaring a UDF method with an array parameter or return type (e.g. String[] or int[]) and invoking it through Beam SQL; the reflection-based type inference hits the `instanceof GenericArrayType` branch.","commonSituations":"Migrating plain Java UDFs that use arrays into Beam SQL UDFs; copying scalar UDF code from other SQL engines that allow array parameters.","solutions":["Change the UDF signature to use java.util.List (e.g. List<String>) instead of String[].","Wrap array values into a List before returning them from the UDF.","Adjust the SQL call site to pass ARRAY literals, which map to List on the Java side."],"exampleFix":"// before\npublic String[] splitNames(String input) { ... }\n// after\npublic List<String> splitNames(String input) { ... }","handlingStrategy":"type-guard","validationCode":"for (Type p : method.getGenericParameterTypes()) {\n  if (p instanceof GenericArrayType) throw new IllegalArgumentException(\"Use List instead of arrays in UDF signature\");\n}","typeGuard":"boolean usesArrays(Type t) { return t instanceof GenericArrayType || (t instanceof Class<?> c && c.isArray()); }","tryCatchPattern":"try { relType = CalciteUtils.sqlTypeWithAutoCast(typeFactory, type); }\ncatch (IllegalArgumentException e) { /* reject UDF or rewrite signature before registration */ }","preventionTips":["Always use java.util.List in Beam SQL UDF signatures","Add a startup check that rejects array-typed UDF methods","Document List/Map conventions for UDF authors","Validate UDF signatures at registration, not query time"],"tags":["beam-sql","calcite","udf","reflection","arrays"],"backgroundTag":"incompatible-source-type","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"}