beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an...@apache.org
Subject [beam] branch master updated: Move schema assignment onto Create builder
Date Thu, 02 May 2019 22:49:16 GMT
This is an automated email from the ASF dual-hosted git repository.

anton 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 b343782  Move schema assignment onto Create builder
     new 2f821dc  Merge pull request #8479 from TheNeuralBit/empty-value-schema
b343782 is described below

commit b34378257501494a4e26c64f7c99da3abaaa718c
Author: Brian Hulette <bhulette@google.com>
AuthorDate: Thu May 2 14:44:59 2019 -0700

    Move schema assignment onto Create builder
    
    Fixes a bug where an empty BeamValuesResl throws an exception because it
    cannot create a default coder.
---
 .../beam/sdk/extensions/sql/impl/rel/BeamValuesRel.java     |  2 +-
 .../beam/sdk/extensions/sql/impl/rel/BeamValuesRelTest.java | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamValuesRel.java
b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamValuesRel.java
index b681738..9799ed8 100644
--- a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamValuesRel.java
+++ b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamValuesRel.java
@@ -82,7 +82,7 @@ public class BeamValuesRel extends Values implements BeamRelNode {
 
       Schema schema = CalciteUtils.toSchema(getRowType());
       List<Row> rows = tuples.stream().map(tuple -> tupleToRow(schema, tuple)).collect(toList());
-      return pinput.getPipeline().begin().apply(Create.of(rows)).setRowSchema(schema);
+      return pinput.getPipeline().begin().apply(Create.of(rows).withRowSchema(schema));
     }
   }
 
diff --git a/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamValuesRelTest.java
b/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamValuesRelTest.java
index cdc2eb2..0dc8e26 100644
--- a/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamValuesRelTest.java
+++ b/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamValuesRelTest.java
@@ -91,4 +91,17 @@ public class BeamValuesRelTest extends BaseRelTest {
                 .getRows());
     pipeline.run();
   }
+
+  @Test
+  public void testValues_selectEmpty() throws Exception {
+    String sql = "select 1, '1' FROM string_table WHERE false";
+    PCollection<Row> rows = compilePipeline(sql, pipeline);
+    PAssert.that(rows)
+        .containsInAnyOrder(
+            TestUtils.RowsBuilder.of(
+                    Schema.FieldType.INT32, "EXPR$0",
+                    Schema.FieldType.STRING, "EXPR$1")
+                .getRows());
+    pipeline.run();
+  }
 }


Mime
View raw message