{"record":{"id":"4139da1c7eed75d3","repo":"apache/beam","slug":"does-not-support-table-valued-function-s","errorCode":null,"errorMessage":"Does not support table_valued function: %s","messagePattern":"Does not support table_valued function: (.+?)","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamTableFunctionScanRel.java","lineNumber":219,"sourceCode":"          \"Wrong number of inputs for %s, expected 1 input but received: %s\",\n          BeamTableFunctionScanRel.class.getSimpleName(),\n          input);\n      String operatorName = ((RexCall) getCall()).getOperator().getName();\n\n      // builtin TVF uses existing PTransform implementations.\n      if (tvfToPTransformMap.keySet().contains(operatorName)) {\n        return tvfToPTransformMap\n            .get(operatorName)\n            .toPTransform(((RexCall) getCall()), input.get(0));\n      }\n\n      // ZetaSQL pure SQL TVF should pass through input to output.\n      if (((RexCall) getCall()).getOperator()\n          instanceof ZetaSqlUserDefinedSQLNativeTableValuedFunction) {\n        return input.get(0);\n      }\n\n      throw new IllegalArgumentException(\n          String.format(\"Does not support table_valued function: %s\", operatorName));\n    }\n\n    private Schema getKeySchema(Schema inputSchema, List<Integer> keys) {\n      List<Field> fields = new ArrayList<>();\n      for (Integer i : keys) {\n        fields.add(inputSchema.getField(i));\n      }\n      return Schema.builder().addFields(fields).build();\n    }\n\n    /** Extract timestamps from the windowFieldIndex, then window into windowFns. */\n    private PCollection<Row> assignTimestampsAndWindow(\n        PCollection<Row> upstream, int windowFieldIndex, WindowFn<Row, IntervalWindow> windowFn) {\n      PCollection<Row> windowedStream;\n      windowedStream =\n          upstream\n              .apply(","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamTableFunctionScanRel.java#L201-L237","documentation":"BeamTableFunctionScanRel supports only a limited set of table-valued functions (e.g. Tumble, Session, FixedWindow TVFs, and ZetaSQL native TVFs that pass input through). When expand() encounters a TVF operator it doesn't implement, it throws this IllegalArgumentException naming the unsupported operator.","triggerScenarios":"Invoking a table-valued function in BeamSql whose operator is not one of the supported windowing/TVF implementations — e.g. a custom or ZetaSQL TVF not registered as a native pass-through — during translation of the TableFunctionScan.","commonSituations":"Using TVF syntax from ZetaSQL (like APPENDS or vendor-specific TVFs) against BeamSql, or calling a user-registered TVF that only has a UDF binding but no BeamSqlTableFunction implementation.","solutions":["Use one of the supported TVFs (e.g. TUMBLE, HOP, SESSION windowing functions) instead of the unsupported one.","If it's a ZetaSQL native TVF, ensure it resolves to ZetaSqlUserDefinedSQLNativeTableValuedFunction so input passes through.","Implement a BeamSqlTableFunction (and a matching Calcite operator) for the desired TVF if extending Beam.","Rewrite the query using regular joins/aggregations/Window transforms to achieve the same effect."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"SqlOperator op = ((RexCall) call).getOperator(); if (!(op instanceof BeamSqlTableFunction) && !(op instanceof ZetaSqlUserDefinedSQLNativeTableValuedFunction)) { throw new IllegalArgumentException(\"Unsupported TVF: \" + op.getName()); }","typeGuard":"boolean isSupportedTvf = operator instanceof BeamSqlTableFunction || operator instanceof ZetaSqlUserDefinedSQLNativeTableValuedFunction;","tryCatchPattern":"try { result = pipeline.apply(SqlTransform.query(sql)); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Does not support table_valued function\")) { /* rewrite with supported TVFs or transforms */ } else { throw e; } }","preventionTips":["Restrict queries to the TVFs Beam implements (TUMBLE/HOP/SESSION and registered native TVFs)","Register a BeamSqlTableFunction implementation for any custom TVF before using it","Check ZetaSQL TVF resolution so native TVFs pass through as expected","Maintain a whitelist of allowed TVF operators for user-submitted SQL"],"tags":["sql","table-valued-function","unsupported","beam-sql"],"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"}