flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fhue...@apache.org
Subject [1/2] flink git commit: [FLINK-6562] [table] Support implicit table references for nested fields in SQL.
Date Fri, 12 May 2017 16:47:47 GMT
Repository: flink
Updated Branches:
  refs/heads/master 423f4d65e -> ef751b2a1


[FLINK-6562] [table] Support implicit table references for nested fields in SQL.

This closes #3879.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/88d56a9c
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/88d56a9c
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/88d56a9c

Branch: refs/heads/master
Commit: 88d56a9ce46ae0b7d73b64e340c2f59e76f79bf3
Parents: 423f4d6
Author: Haohui Mai <wheat9@apache.org>
Authored: Thu May 11 15:35:39 2017 -0700
Committer: Fabian Hueske <fhueske@apache.org>
Committed: Fri May 12 17:15:23 2017 +0200

----------------------------------------------------------------------
 .../plan/schema/CompositeRelDataType.scala      |  4 ++--
 .../table/expressions/CompositeAccessTest.scala | 22 +++++++++++++++++++-
 2 files changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/88d56a9c/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/plan/schema/CompositeRelDataType.scala
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/plan/schema/CompositeRelDataType.scala
b/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/plan/schema/CompositeRelDataType.scala
index 92f9199..a60514b 100644
--- a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/plan/schema/CompositeRelDataType.scala
+++ b/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/plan/schema/CompositeRelDataType.scala
@@ -20,7 +20,7 @@ package org.apache.flink.table.plan.schema
 
 import java.util
 
-import org.apache.calcite.rel.`type`.{RelDataTypeField, RelDataTypeFieldImpl, RelRecordType}
+import org.apache.calcite.rel.`type`.{RelDataTypeField, RelDataTypeFieldImpl, RelRecordType,
StructKind}
 import org.apache.flink.api.common.typeutils.CompositeType
 import org.apache.flink.table.calcite.FlinkTypeFactory
 import org.apache.flink.table.plan.schema.CompositeRelDataType.createFieldList
@@ -36,7 +36,7 @@ import scala.collection.JavaConverters._
 class CompositeRelDataType(
     val compositeType: CompositeType[_],
     typeFactory: FlinkTypeFactory)
-  extends RelRecordType(createFieldList(compositeType, typeFactory)) {
+  extends RelRecordType(StructKind.PEEK_FIELDS, createFieldList(compositeType, typeFactory))
{
 
   override def toString = s"COMPOSITE($compositeType)"
 

http://git-wip-us.apache.org/repos/asf/flink/blob/88d56a9c/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/CompositeAccessTest.scala
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/CompositeAccessTest.scala
b/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/CompositeAccessTest.scala
index 2025880..91e06c5 100644
--- a/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/CompositeAccessTest.scala
+++ b/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/CompositeAccessTest.scala
@@ -41,10 +41,13 @@ class CompositeAccessTest extends ExpressionTestBase {
       "f0.get('intField')",
       "testTable.f0.intField",
       "42")
+    testSqlApi("f0.intField", "42")
 
     testSqlApi("testTable.f0.stringField", "Bob")
+    testSqlApi("f0.stringField", "Bob")
 
     testSqlApi("testTable.f0.booleanField", "true")
+    testSqlApi("f0.booleanField", "true")
 
     // single field by int key
     testTableApi(
@@ -58,22 +61,29 @@ class CompositeAccessTest extends ExpressionTestBase {
       "f1.get('objectField').get('intField')",
       "testTable.f1.objectField.intField",
       "25")
+    testSqlApi("f1.objectField.intField", "25")
 
     testSqlApi("testTable.f1.objectField.stringField", "Timo")
+    testSqlApi("f1.objectField.stringField", "Timo")
 
     testSqlApi("testTable.f1.objectField.booleanField", "false")
+    testSqlApi("f1.objectField.booleanField", "false")
 
     testAllApis(
       'f2.get(0),
       "f2.get(0)",
       "testTable.f2._1",
       "a")
+    testSqlApi("f2._1", "a")
 
     testSqlApi("testTable.f3.f1", "b")
+    testSqlApi("f3.f1", "b")
 
     testSqlApi("testTable.f4.myString", "Hello")
+    testSqlApi("f4.myString", "Hello")
 
     testSqlApi("testTable.f5", "13")
+    testSqlApi("f5", "13")
 
     testAllApis(
       'f7.get("_1"),
@@ -83,18 +93,21 @@ class CompositeAccessTest extends ExpressionTestBase {
 
     // composite field return type
     testSqlApi("testTable.f6", "MyCaseClass2(null)")
+    testSqlApi("f6", "MyCaseClass2(null)")
 
     testAllApis(
       'f1.get("objectField"),
       "f1.get('objectField')",
       "testTable.f1.objectField",
       "MyCaseClass(25,Timo,false)")
+    testSqlApi("f1.objectField", "MyCaseClass(25,Timo,false)")
 
     testAllApis(
       'f0,
       "f0",
       "testTable.f0",
       "MyCaseClass(42,Bob,true)")
+    testSqlApi("f0", "MyCaseClass(42,Bob,true)")
 
     // flattening (test base only returns first column)
     testAllApis(
@@ -102,12 +115,14 @@ class CompositeAccessTest extends ExpressionTestBase {
       "f1.get('objectField').flatten()",
       "testTable.f1.objectField.*",
       "25")
+    testSqlApi("f1.objectField.*", "25")
 
     testAllApis(
       'f0.flatten(),
       "flatten(f0)",
       "testTable.f0.*",
       "42")
+    testSqlApi("f0.*", "42")
 
     testTableApi(12.flatten(), "12.flatten()", "12")
 
@@ -115,11 +130,16 @@ class CompositeAccessTest extends ExpressionTestBase {
   }
 
   @Test(expected = classOf[ValidationException])
-  def testWrongSqlField(): Unit = {
+  def testWrongSqlFieldFull(): Unit = {
     testSqlApi("testTable.f5.test", "13")
   }
 
   @Test(expected = classOf[ValidationException])
+  def testWrongSqlField(): Unit = {
+    testSqlApi("f5.test", "13")
+  }
+
+  @Test(expected = classOf[ValidationException])
   def testWrongIntKeyField(): Unit = {
     testTableApi('f0.get(555), "'fail'", "fail")
   }


Mime
View raw message