beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ib...@apache.org
Subject [beam] branch master updated: [BEAM-12042] Check TVF argument list size.
Date Wed, 24 Mar 2021 00:46:08 GMT
This is an automated email from the ASF dual-hosted git repository.

ibzib pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 135974e  [BEAM-12042] Check TVF argument list size.
     new 7bb91fb  Merge pull request #14316 from ibzib/BEAM-12042
135974e is described below

commit 135974eaf3edbec0f774a42828a9ab16dec34768
Author: Kyle Weaver <kcweaver@google.com>
AuthorDate: Tue Mar 23 12:51:54 2021 -0700

    [BEAM-12042] Check TVF argument list size.
---
 .../sql/zetasql/translation/TVFScanConverter.java   |  3 ++-
 .../sql/zetasql/ZetaSqlNativeUdfTest.java           | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/translation/TVFScanConverter.java
b/sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/translation/TVFScanConverter.java
index 01a1df2..d971ce0 100644
--- a/sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/translation/TVFScanConverter.java
+++ b/sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/translation/TVFScanConverter.java
@@ -52,7 +52,8 @@ class TVFScanConverter extends RelConverter<ResolvedTVFScan> {
                 input,
                 zetaNode.getTvf(),
                 zetaNode.getArgumentList(),
-                zetaNode.getArgumentList().get(0).getScan() != null
+                zetaNode.getArgumentList().size() > 0
+                        && zetaNode.getArgumentList().get(0).getScan() != null
                     ? zetaNode.getArgumentList().get(0).getScan().getColumnList()
                     : Collections.emptyList());
     RelNode tableFunctionScan =
diff --git a/sdks/java/extensions/sql/zetasql/src/test/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSqlNativeUdfTest.java
b/sdks/java/extensions/sql/zetasql/src/test/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSqlNativeUdfTest.java
index 0357242..d1fecc2 100644
--- a/sdks/java/extensions/sql/zetasql/src/test/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSqlNativeUdfTest.java
+++ b/sdks/java/extensions/sql/zetasql/src/test/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSqlNativeUdfTest.java
@@ -184,6 +184,27 @@ public class ZetaSqlNativeUdfTest extends ZetaSqlTestBase {
   }
 
   @Test
+  public void testNullaryUdtvf() {
+    String sql =
+        "CREATE TABLE FUNCTION CustomerRange()\n"
+            + "  AS\n"
+            + "    SELECT *\n"
+            + "    FROM KeyValue;\n"
+            + " SELECT key FROM CustomerRange()";
+
+    ZetaSQLQueryPlanner zetaSQLQueryPlanner = new ZetaSQLQueryPlanner(config);
+    BeamRelNode beamRelNode = zetaSQLQueryPlanner.convertToBeamRel(sql);
+    PCollection<Row> stream = BeamSqlRelUtils.toPCollection(pipeline, beamRelNode);
+
+    Schema singleField = Schema.builder().addInt64Field("field1").build();
+    PAssert.that(stream)
+        .containsInAnyOrder(
+            Row.withSchema(singleField).addValues(14L).build(),
+            Row.withSchema(singleField).addValues(15L).build());
+    pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
+  }
+
+  @Test
   public void testUDTVFTableNotFound() {
     String sql =
         "CREATE TABLE FUNCTION CustomerRange(MinID INT64, MaxID INT64)\n"

Mime
View raw message