[GitHub] [flink] JingsongLi commented on a change in pull request #8578: [FLINK-12685] [table-planner-blink] Supports UNNEST query in blink planner

2019-06-05 Thread GitBox
JingsongLi commented on a change in pull request #8578: [FLINK-12685] 
[table-planner-blink] Supports UNNEST query in blink planner
URL: https://github.com/apache/flink/pull/8578#discussion_r291013615
 
 

 ##
 File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/plan/rules/FlinkBatchRuleSets.scala
 ##
 @@ -119,7 +119,9 @@ object FlinkBatchRuleSets {
 new CoerceInputsRule(classOf[LogicalMinus], false),
 ConvertToNotInOrInRule.INSTANCE,
 // optimize limit 0
-FlinkLimit0RemoveRule.INSTANCE
+FlinkLimit0RemoveRule.INSTANCE,
+// unnest rule
+LogicalUnnestRule.INSTANCE
 
 Review comment:
   Can you add these replies to code comments?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] JingsongLi commented on a change in pull request #8578: [FLINK-12685] [table-planner-blink] Supports UNNEST query in blink planner

2019-06-05 Thread GitBox
JingsongLi commented on a change in pull request #8578: [FLINK-12685] 
[table-planner-blink] Supports UNNEST query in blink planner
URL: https://github.com/apache/flink/pull/8578#discussion_r290632511
 
 

 ##
 File path: 
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/runtime/stream/sql/UnnestITCase.scala
 ##
 @@ -0,0 +1,303 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.runtime.stream.sql
+
+import org.apache.flink.api.scala._
+import org.apache.flink.table.api.Types
+import org.apache.flink.table.api.scala._
+import 
org.apache.flink.table.runtime.utils.StreamingWithStateTestBase.StateBackendMode
+import 
org.apache.flink.table.runtime.utils.TimeTestUtil.TimestampAndWatermarkWithOffset
+import org.apache.flink.table.runtime.utils.{StreamingWithStateTestBase, 
TestData, TestingAppendSink, TestingRetractSink, TestingRetractTableSink}
+import org.apache.flink.types.Row
+
+import org.junit.Assert.assertEquals
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.Parameterized
+
+@RunWith(classOf[Parameterized])
+class UnnestITCase(mode: StateBackendMode) extends 
StreamingWithStateTestBase(mode) {
 
 Review comment:
   No, I mean `as A` and access it by `A.field0, A.field1` instead of `AS A (s, 
t)`


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] JingsongLi commented on a change in pull request #8578: [FLINK-12685] [table-planner-blink] Supports UNNEST query in blink planner

2019-06-04 Thread GitBox
JingsongLi commented on a change in pull request #8578: [FLINK-12685] 
[table-planner-blink] Supports UNNEST query in blink planner
URL: https://github.com/apache/flink/pull/8578#discussion_r290563675
 
 

 ##
 File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/plan/rules/FlinkBatchRuleSets.scala
 ##
 @@ -119,7 +119,9 @@ object FlinkBatchRuleSets {
 new CoerceInputsRule(classOf[LogicalMinus], false),
 ConvertToNotInOrInRule.INSTANCE,
 // optimize limit 0
-FlinkLimit0RemoveRule.INSTANCE
+FlinkLimit0RemoveRule.INSTANCE,
+// unnest rule
+LogicalUnnestRule.INSTANCE
 
 Review comment:
   It seems that `LogicalUnnestRule` is also part of de-correlate. Why not put 
it in the `DECORRELATE` phase?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] JingsongLi commented on a change in pull request #8578: [FLINK-12685] [table-planner-blink] Supports UNNEST query in blink planner

2019-06-04 Thread GitBox
JingsongLi commented on a change in pull request #8578: [FLINK-12685] 
[table-planner-blink] Supports UNNEST query in blink planner
URL: https://github.com/apache/flink/pull/8578#discussion_r290565276
 
 

 ##
 File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/calcite/FlinkTypeFactory.scala
 ##
 @@ -467,6 +467,9 @@ object FlinkTypeFactory {
   val mapRelDataType = relDataType.asInstanceOf[MapRelDataType]
   mapRelDataType.mapType
 
+// CURSOR for UDTF case, whose type info will never be used, just a 
placeholder
+case CURSOR => NothingType.INSTANCE
 
 Review comment:
   Just use a `GenericType(NothingTypeInfo)` is ok?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] JingsongLi commented on a change in pull request #8578: [FLINK-12685] [table-planner-blink] Supports UNNEST query in blink planner

2019-06-04 Thread GitBox
JingsongLi commented on a change in pull request #8578: [FLINK-12685] 
[table-planner-blink] Supports UNNEST query in blink planner
URL: https://github.com/apache/flink/pull/8578#discussion_r290564818
 
 

 ##
 File path: 
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/runtime/stream/sql/UnnestITCase.scala
 ##
 @@ -0,0 +1,303 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.runtime.stream.sql
+
+import org.apache.flink.api.scala._
+import org.apache.flink.table.api.Types
+import org.apache.flink.table.api.scala._
+import 
org.apache.flink.table.runtime.utils.StreamingWithStateTestBase.StateBackendMode
+import 
org.apache.flink.table.runtime.utils.TimeTestUtil.TimestampAndWatermarkWithOffset
+import org.apache.flink.table.runtime.utils.{StreamingWithStateTestBase, 
TestData, TestingAppendSink, TestingRetractSink, TestingRetractTableSink}
+import org.apache.flink.types.Row
+
+import org.junit.Assert.assertEquals
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.Parameterized
+
+@RunWith(classOf[Parameterized])
+class UnnestITCase(mode: StateBackendMode) extends 
StreamingWithStateTestBase(mode) {
 
 Review comment:
   Can you add some cases to PlanCase and ITCase like:
   `select , A.field0, A.field1 from T, unnest(c) as A`


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] JingsongLi commented on a change in pull request #8578: [FLINK-12685] [table-planner-blink] Supports UNNEST query in blink planner

2019-06-04 Thread GitBox
JingsongLi commented on a change in pull request #8578: [FLINK-12685] 
[table-planner-blink] Supports UNNEST query in blink planner
URL: https://github.com/apache/flink/pull/8578#discussion_r290564411
 
 

 ##
 File path: 
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/plan/rules/logical/LogicalUnnestRuleTest.scala
 ##
 @@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.plan.rules.logical
+
+import org.apache.flink.api.common.typeinfo.TypeInformation
+import org.apache.flink.api.scala._
+import org.apache.flink.table.api.Types
+import org.apache.flink.table.calcite.CalciteConfig
+import org.apache.flink.table.plan.optimize.program.{BatchOptimizeContext, 
FlinkChainedProgram, FlinkHepRuleSetProgramBuilder, HEP_RULES_EXECUTION_TYPE}
+import org.apache.flink.table.util.TableTestBase
+
+import org.apache.calcite.plan.hep.HepMatchOrder
+import org.apache.calcite.tools.RuleSets
+import org.junit.{Before, Test}
+
+import java.sql.Timestamp
+
+/**
+  * Test for [[LogicalUnnestRule]].
+  */
+class LogicalUnnestRuleTest extends TableTestBase {
 
 Review comment:
   `UnnestTestBase` is not enough?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] JingsongLi commented on a change in pull request #8578: [FLINK-12685] [table-planner-blink] Supports UNNEST query in blink planner

2019-06-04 Thread GitBox
JingsongLi commented on a change in pull request #8578: [FLINK-12685] 
[table-planner-blink] Supports UNNEST query in blink planner
URL: https://github.com/apache/flink/pull/8578#discussion_r290563400
 
 

 ##
 File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/plan/optimize/program/FlinkDecorrelateProgram.scala
 ##
 @@ -77,6 +81,15 @@ class FlinkDecorrelateProgram[OC <: FlinkOptimizeContext] 
extends FlinkOptimizeP
 join.getCondition.accept(visitor)
 super.visit(join)
   }
+
+  override def visit(other: RelNode): RelNode = {
+other match {
+  // ignore Uncollect's inputs due to the correlate variables are from 
UNNEST directly,
+  // not from cases which RelDecorrelator handles
+  case r: Uncollect => r
 
 Review comment:
   > not from cases which RelDecorrelator handles
   
   I don't get it.
   The real reason should be that `LogicalUnnestRule` is in the 
`DEFAULT_REWRITE` phase, and the `DEFAULT_REWRITE` phase is behind the 
`DECORRELATE` phase, so now we need not verify the Unnest correlation?
   Update comments?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services