You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/02/06 14:53:02 UTC

[GitHub] [flink] twalthr opened a new pull request #11034: [FLINK-15802][table] Support new type inference for table functions

twalthr opened a new pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034
 
 
   ## What is the purpose of the change
   
   Enables the new type inference for table functions. The PR conists of two commits.
   
   The first commit refactors the code generation around table functions such that return data type and argument data type are read from the function at the same location instead of reading each in a separate code generator. This adds an additional runtime collector that is only responsible for result conversion. All existing tests pass after this change.
   
   The second commit further develops the stack based on `BridgingSqlFunction` and the new type inference. Similar to FLINK-15487, we don't test every data type combination yet.
   
   ## Brief change log
   
   See commit messages.
   
   ## Verifying this change
   
   This change is already covered by existing tests, such as `CorrelateITCase`.
   
   Additional tests added in `FunctionITCase`.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: yes
     - The serializers: no
     - The runtime per-record code paths (performance sensitive): yes
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: no
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? yes
     - If yes, how is the feature documented? JavaDocs
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] twalthr closed pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
twalthr closed pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034
 
 
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#issuecomment-582952425
 
 
   <!--
   Meta data
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   -->
   ## CI report:
   
   * dc1e81f2b3af44ae05c45f730353b65634e9220b Travis: [FAILURE](https://travis-ci.com/flink-ci/flink/builds/147743884) Azure: [FAILURE](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] twalthr commented on issue #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
twalthr commented on issue #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#issuecomment-585207642
 
 
   @flinkbot run travis

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r376223974
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/codegen/calls/TableFunctionCallGen.scala
 ##########
 @@ -49,7 +71,7 @@ class TableFunctionCallGen(tableFunction: TableFunction[_]) extends CallGenerato
 
     // has no result
     GeneratedExpression(
-      functionReference,
+      resultCollectorTerm,
 
 Review comment:
   A `resultCollectorTerm` instead of `functionReference` seems complicated. Can you add comments into `TableFunctionCallGen` to explain this.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] twalthr commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
twalthr commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r378770124
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/validate/ProcedureNamespace.java
 ##########
 @@ -0,0 +1,80 @@
+/*
+ * 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.calcite.sql.validate;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.planner.functions.utils.TableSqlFunction;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlCallBinding;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlUtil;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+/**
+ * Namespace whose contents are defined by the result of a call to a user-defined procedure.
+ *
+ * <p>Note: Compared to Calcite, this class implements custom logic for dealing with collection tables
+ * like {@code TABLE(function(...))} procedures. Compared to the SQL standard, Flink's table functions
+ * can return arbitrary types that are wrapped into a ROW type if necessary. We don't interpret ARRAY
+ * or MULTISET types as it would be standard.
+ */
+@Internal
+public final class ProcedureNamespace extends AbstractNamespace {
+
+	private final SqlValidatorScope scope;
+
+	private final SqlCall call;
+
+	ProcedureNamespace(
+		SqlValidatorImpl validator,
+		SqlValidatorScope scope,
+		SqlCall call,
+		SqlNode enclosingNode) {
+		super(validator, enclosingNode);
+		this.scope = scope;
+		this.call = call;
+	}
+
+	public RelDataType validateImpl(RelDataType targetRowType) {
+		validator.inferUnknownTypes(validator.unknownType, scope, call);
+		final RelDataType type = validator.deriveTypeImpl(scope, call);
+		final SqlOperator operator = call.getOperator();
+		final SqlCallBinding callBinding =
+			new SqlCallBinding(validator, scope, call);
+		// legacy table functions
+		if (operator instanceof TableSqlFunction) {
 
 Review comment:
   I will use the previous `instanceof SqlUserDefinedTableFunction` to avoid any classloading issues. I copied the `ProcedureNamespace` in both planners so we should not have problems. 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r378646800
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/validate/ProcedureNamespace.java
 ##########
 @@ -0,0 +1,80 @@
+/*
+ * 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.calcite.sql.validate;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.planner.functions.utils.TableSqlFunction;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlCallBinding;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlUtil;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+/**
+ * Namespace whose contents are defined by the result of a call to a user-defined procedure.
+ *
+ * <p>Note: Compared to Calcite, this class implements custom logic for dealing with collection tables
+ * like {@code TABLE(function(...))} procedures. Compared to the SQL standard, Flink's table functions
+ * can return arbitrary types that are wrapped into a ROW type if necessary. We don't interpret ARRAY
+ * or MULTISET types as it would be standard.
+ */
+@Internal
+public final class ProcedureNamespace extends AbstractNamespace {
+
+	private final SqlValidatorScope scope;
+
+	private final SqlCall call;
+
+	ProcedureNamespace(
+		SqlValidatorImpl validator,
+		SqlValidatorScope scope,
+		SqlCall call,
+		SqlNode enclosingNode) {
+		super(validator, enclosingNode);
+		this.scope = scope;
+		this.call = call;
+	}
+
+	public RelDataType validateImpl(RelDataType targetRowType) {
+		validator.inferUnknownTypes(validator.unknownType, scope, call);
+		final RelDataType type = validator.deriveTypeImpl(scope, call);
+		final SqlOperator operator = call.getOperator();
+		final SqlCallBinding callBinding =
+			new SqlCallBinding(validator, scope, call);
+		// legacy table functions
+		if (operator instanceof TableSqlFunction) {
 
 Review comment:
   It seems that we can use `TableSqlFunction`, because `TableSqlFunction`s are different between legacy planner and blink planner.
   This lead to we have different `ProcedureNamespace` codes between legacy planner and blink planner.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot commented on issue #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
flinkbot commented on issue #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#issuecomment-582952425
 
 
   <!--
   Meta data
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:UNKNOWN URL:TBD TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   -->
   ## CI report:
   
   * dc1e81f2b3af44ae05c45f730353b65634e9220b UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] twalthr commented on issue #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
twalthr commented on issue #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#issuecomment-582942330
 
 
   CC @JingsongLi 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#issuecomment-582952425
 
 
   <!--
   Meta data
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:MANUAL TriggerID:585207642
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:MANUAL TriggerID:585207642
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/148581567 TriggerType:PUSH TriggerID:b17903fa533da56973ea764fd8e71b722bbe42a0
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:PENDING URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5108 TriggerType:PUSH TriggerID:b17903fa533da56973ea764fd8e71b722bbe42a0
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/148581567 TriggerType:MANUAL TriggerID:585287552
   Hash:ea033d01fedf6fdab42ebd196f07d8b014b91d5b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5112 TriggerType:PUSH TriggerID:ea033d01fedf6fdab42ebd196f07d8b014b91d5b
   Hash:ea033d01fedf6fdab42ebd196f07d8b014b91d5b Status:FAILURE URL:https://travis-ci.com/flink-ci/flink/builds/148613991 TriggerType:PUSH TriggerID:ea033d01fedf6fdab42ebd196f07d8b014b91d5b
   Hash:ea033d01fedf6fdab42ebd196f07d8b014b91d5b Status:PENDING URL:https://travis-ci.com/flink-ci/flink/builds/148613991 TriggerType:MANUAL TriggerID:585664480
   Hash:b5528bc218f197a8dfcf0f44710544f708306d76 Status:UNKNOWN URL:TBD TriggerType:PUSH TriggerID:b5528bc218f197a8dfcf0f44710544f708306d76
   -->
   ## CI report:
   
   * dc1e81f2b3af44ae05c45f730353b65634e9220b Travis: [CANCELED](https://travis-ci.com/flink-ci/flink/builds/147743884) Azure: [FAILURE](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913) 
   * b17903fa533da56973ea764fd8e71b722bbe42a0 Travis: [CANCELED](https://travis-ci.com/flink-ci/flink/builds/148581567) Azure: [PENDING](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5108) 
   * ea033d01fedf6fdab42ebd196f07d8b014b91d5b Travis: [PENDING](https://travis-ci.com/flink-ci/flink/builds/148613991) Azure: [FAILURE](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5112) 
   * b5528bc218f197a8dfcf0f44710544f708306d76 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r376226097
 
 

 ##########
 File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/collector/WrappingCollector.java
 ##########
 @@ -0,0 +1,49 @@
+/*
+ * 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.collector;
+
+import org.apache.flink.api.common.functions.AbstractRichFunction;
+import org.apache.flink.util.Collector;
+
+/**
+ * A {@link Collector} that wraps another collector. An implementation can decide when to emit to the
+ * wrapped collector.
+ */
+public abstract class WrappingCollector<T> extends AbstractRichFunction implements Collector<T> {
+
+	private Collector<T> collector;
+
+	/**
+	 * Sets the current collector which is used to emit the final result.
+	 */
+	public void setCollector(Collector<T> collector) {
+		this.collector = collector;
+	}
+
+	/**
+	 * Outputs the final result to the wrapped collector.
+	 */
+	public void outputResult(T result) {
+		this.collector.collect(result);
 
 Review comment:
   Looks like this call will introduce a virtual method call to separate UDTF invoking and subsequent projections.
   Can we use `TableFunctionCollector` here?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r376225561
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/codegen/calls/TableFunctionCallGen.scala
 ##########
 @@ -60,7 +82,61 @@ class TableFunctionCallGen(tableFunction: TableFunction[_]) extends CallGenerato
       operands: Seq[GeneratedExpression],
       func: TableFunction[_]): Array[GeneratedExpression] = {
     // get the expanded parameter types
-    var paramClasses = getEvalMethodSignature(func, operands.map(_.resultType).toArray)
+    val paramClasses = getEvalMethodSignature(func, operands.map(_.resultType).toArray)
     prepareFunctionArgs(ctx, operands, paramClasses, func.getParameterTypes(paramClasses))
   }
+
+  def getExternalDataType: DataType = {
+    val sqlFunction = rexCall.getOperator.asInstanceOf[TableSqlFunction]
+    val arguments = UserDefinedFunctionUtils.transformRexNodes(rexCall.operands)
+    val operandTypes = rexCall.operands
+        .map(_.getType)
+        .map(FlinkTypeFactory.toLogicalType).toArray
+    val func = sqlFunction.makeFunction(arguments, operandTypes)
+    val argTypes = getEvalMethodSignature(
+      func,
+      rexCall.operands
+        .map(_.getType)
+        .map(FlinkTypeFactory.toLogicalType).toArray)
+    sqlFunction
+        .getFunction
+        .asInstanceOf[FlinkTableFunction]
+        .getExternalResultType(func, arguments, argTypes)
+  }
+
+  /**
+   * Generates a collector that converts the output of a table function (possibly as an atomic type)
+   * into an internal row type. Returns a collector term for referencing the collector.
+   */
+  def generateResultCollector(ctx: CodeGeneratorContext): String = {
+    val externalDataType = getExternalDataType
+    val pojoFieldMapping = Some(UserDefinedFunctionUtils.getFieldInfo(externalDataType)._2)
+    val externalType = fromDataTypeToLogicalType(externalDataType)
+    val wrappedInternalType = PlannerTypeUtils.toRowType(externalType)
+
+    val collectorCtx = CodeGeneratorContext(ctx.tableConfig)
+    val externalTerm = newName("externalRecord")
+    val resultGenerator = new ExprCodeGenerator(collectorCtx, true)
+      .bindInput(externalType, externalTerm, pojoFieldMapping)
+    val wrappedResult = resultGenerator.generateConverterResultExpression(
 
 Review comment:
   It seems that we don't need this conversion when result type is not a pojo and atomic object.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] twalthr commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
twalthr commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r378093380
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/validate/ProcedureNamespace.java
 ##########
 @@ -0,0 +1,80 @@
+/*
+ * 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.calcite.sql.validate;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.planner.functions.utils.TableSqlFunction;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlCallBinding;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlUtil;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+/**
+ * Namespace whose contents are defined by the result of a call to a user-defined procedure.
+ *
+ * <p>Note: Compared to Calcite, this class implements custom logic for dealing with collection tables
+ * like {@code TABLE(function(...))} procedures. Compared to the SQL standard, Flink's table functions
 
 Review comment:
   The `LATERAL` keyword does not matter here. `TABLE` is defined in the SQL standard as a function that converts a functions output into a table. The function can take literals, expressions, etc.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r378646800
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/validate/ProcedureNamespace.java
 ##########
 @@ -0,0 +1,80 @@
+/*
+ * 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.calcite.sql.validate;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.planner.functions.utils.TableSqlFunction;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlCallBinding;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlUtil;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+/**
+ * Namespace whose contents are defined by the result of a call to a user-defined procedure.
+ *
+ * <p>Note: Compared to Calcite, this class implements custom logic for dealing with collection tables
+ * like {@code TABLE(function(...))} procedures. Compared to the SQL standard, Flink's table functions
+ * can return arbitrary types that are wrapped into a ROW type if necessary. We don't interpret ARRAY
+ * or MULTISET types as it would be standard.
+ */
+@Internal
+public final class ProcedureNamespace extends AbstractNamespace {
+
+	private final SqlValidatorScope scope;
+
+	private final SqlCall call;
+
+	ProcedureNamespace(
+		SqlValidatorImpl validator,
+		SqlValidatorScope scope,
+		SqlCall call,
+		SqlNode enclosingNode) {
+		super(validator, enclosingNode);
+		this.scope = scope;
+		this.call = call;
+	}
+
+	public RelDataType validateImpl(RelDataType targetRowType) {
+		validator.inferUnknownTypes(validator.unknownType, scope, call);
+		final RelDataType type = validator.deriveTypeImpl(scope, call);
+		final SqlOperator operator = call.getOperator();
+		final SqlCallBinding callBinding =
+			new SqlCallBinding(validator, scope, call);
+		// legacy table functions
+		if (operator instanceof TableSqlFunction) {
 
 Review comment:
   It seems that we can use `TableSqlFunction`, because `TableSqlFunction`s are different between legacy planner and blink planner.
   This lead to we have different codes in between legacy planner and blink planner.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r378224696
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/validate/ProcedureNamespace.java
 ##########
 @@ -0,0 +1,80 @@
+/*
+ * 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.calcite.sql.validate;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.planner.functions.utils.TableSqlFunction;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlCallBinding;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlUtil;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+/**
+ * Namespace whose contents are defined by the result of a call to a user-defined procedure.
+ *
+ * <p>Note: Compared to Calcite, this class implements custom logic for dealing with collection tables
+ * like {@code TABLE(function(...))} procedures. Compared to the SQL standard, Flink's table functions
 
 Review comment:
   OK, I got the meaning of "collection table".

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] twalthr commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
twalthr commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r378233909
 
 

 ##########
 File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/collector/WrappingCollector.java
 ##########
 @@ -0,0 +1,49 @@
+/*
+ * 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.collector;
+
+import org.apache.flink.api.common.functions.AbstractRichFunction;
+import org.apache.flink.util.Collector;
+
+/**
+ * A {@link Collector} that wraps another collector. An implementation can decide when to emit to the
+ * wrapped collector.
+ */
+public abstract class WrappingCollector<T> extends AbstractRichFunction implements Collector<T> {
+
+	private Collector<T> collector;
+
+	/**
+	 * Sets the current collector which is used to emit the final result.
+	 */
+	public void setCollector(Collector<T> collector) {
+		this.collector = collector;
+	}
+
+	/**
+	 * Outputs the final result to the wrapped collector.
+	 */
+	public void outputResult(T result) {
+		this.collector.collect(result);
 
 Review comment:
   This is what I also explained in the PR description. We will have another collector indirection. But the JVM should be smart enough to remove this simply call. I smaller projection collector is also beneficial for inlining the method. So I don't expect performance regressions here.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] twalthr commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
twalthr commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r378232832
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/codegen/calls/TableFunctionCallGen.scala
 ##########
 @@ -60,7 +82,61 @@ class TableFunctionCallGen(tableFunction: TableFunction[_]) extends CallGenerato
       operands: Seq[GeneratedExpression],
       func: TableFunction[_]): Array[GeneratedExpression] = {
     // get the expanded parameter types
-    var paramClasses = getEvalMethodSignature(func, operands.map(_.resultType).toArray)
+    val paramClasses = getEvalMethodSignature(func, operands.map(_.resultType).toArray)
     prepareFunctionArgs(ctx, operands, paramClasses, func.getParameterTypes(paramClasses))
   }
+
+  def getExternalDataType: DataType = {
+    val sqlFunction = rexCall.getOperator.asInstanceOf[TableSqlFunction]
+    val arguments = UserDefinedFunctionUtils.transformRexNodes(rexCall.operands)
+    val operandTypes = rexCall.operands
+        .map(_.getType)
+        .map(FlinkTypeFactory.toLogicalType).toArray
+    val func = sqlFunction.makeFunction(arguments, operandTypes)
+    val argTypes = getEvalMethodSignature(
+      func,
+      rexCall.operands
+        .map(_.getType)
+        .map(FlinkTypeFactory.toLogicalType).toArray)
+    sqlFunction
+        .getFunction
+        .asInstanceOf[FlinkTableFunction]
+        .getExternalResultType(func, arguments, argTypes)
+  }
+
+  /**
+   * Generates a collector that converts the output of a table function (possibly as an atomic type)
+   * into an internal row type. Returns a collector term for referencing the collector.
+   */
+  def generateResultCollector(ctx: CodeGeneratorContext): String = {
+    val externalDataType = getExternalDataType
+    val pojoFieldMapping = Some(UserDefinedFunctionUtils.getFieldInfo(externalDataType)._2)
+    val externalType = fromDataTypeToLogicalType(externalDataType)
+    val wrappedInternalType = PlannerTypeUtils.toRowType(externalType)
+
+    val collectorCtx = CodeGeneratorContext(ctx.tableConfig)
+    val externalTerm = newName("externalRecord")
+    val resultGenerator = new ExprCodeGenerator(collectorCtx, true)
+      .bindInput(externalType, externalTerm, pojoFieldMapping)
+    val wrappedResult = resultGenerator.generateConverterResultExpression(
 
 Review comment:
   good point, I changed the logic again. So we will skip the conversion for structured types. This also means that we have different handling for `collect(null)`. I think we should skip emitting in those cases.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] twalthr commented on issue #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
twalthr commented on issue #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#issuecomment-585287552
 
 
   @flinkbot run travis

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#issuecomment-582952425
 
 
   <!--
   Meta data
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:MANUAL TriggerID:585207642
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:MANUAL TriggerID:585207642
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/148581567 TriggerType:PUSH TriggerID:b17903fa533da56973ea764fd8e71b722bbe42a0
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:PENDING URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5108 TriggerType:PUSH TriggerID:b17903fa533da56973ea764fd8e71b722bbe42a0
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/148581567 TriggerType:MANUAL TriggerID:585287552
   Hash:ea033d01fedf6fdab42ebd196f07d8b014b91d5b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5112 TriggerType:PUSH TriggerID:ea033d01fedf6fdab42ebd196f07d8b014b91d5b
   Hash:ea033d01fedf6fdab42ebd196f07d8b014b91d5b Status:FAILURE URL:https://travis-ci.com/flink-ci/flink/builds/148613991 TriggerType:PUSH TriggerID:ea033d01fedf6fdab42ebd196f07d8b014b91d5b
   Hash:ea033d01fedf6fdab42ebd196f07d8b014b91d5b Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/148613991 TriggerType:MANUAL TriggerID:585664480
   Hash:ea033d01fedf6fdab42ebd196f07d8b014b91d5b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5112 TriggerType:MANUAL TriggerID:585664480
   Hash:b5528bc218f197a8dfcf0f44710544f708306d76 Status:SUCCESS URL:https://travis-ci.com/flink-ci/flink/builds/148771715 TriggerType:PUSH TriggerID:b5528bc218f197a8dfcf0f44710544f708306d76
   Hash:b5528bc218f197a8dfcf0f44710544f708306d76 Status:PENDING URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5133 TriggerType:PUSH TriggerID:b5528bc218f197a8dfcf0f44710544f708306d76
   -->
   ## CI report:
   
   * dc1e81f2b3af44ae05c45f730353b65634e9220b Travis: [CANCELED](https://travis-ci.com/flink-ci/flink/builds/147743884) Azure: [FAILURE](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913) 
   * b17903fa533da56973ea764fd8e71b722bbe42a0 Travis: [CANCELED](https://travis-ci.com/flink-ci/flink/builds/148581567) Azure: [PENDING](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5108) 
   * ea033d01fedf6fdab42ebd196f07d8b014b91d5b Travis: [CANCELED](https://travis-ci.com/flink-ci/flink/builds/148613991) Azure: [FAILURE](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5112) 
   * b5528bc218f197a8dfcf0f44710544f708306d76 Travis: [SUCCESS](https://travis-ci.com/flink-ci/flink/builds/148771715) Azure: [PENDING](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5133) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r378646800
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/validate/ProcedureNamespace.java
 ##########
 @@ -0,0 +1,80 @@
+/*
+ * 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.calcite.sql.validate;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.planner.functions.utils.TableSqlFunction;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlCallBinding;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlUtil;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+/**
+ * Namespace whose contents are defined by the result of a call to a user-defined procedure.
+ *
+ * <p>Note: Compared to Calcite, this class implements custom logic for dealing with collection tables
+ * like {@code TABLE(function(...))} procedures. Compared to the SQL standard, Flink's table functions
+ * can return arbitrary types that are wrapped into a ROW type if necessary. We don't interpret ARRAY
+ * or MULTISET types as it would be standard.
+ */
+@Internal
+public final class ProcedureNamespace extends AbstractNamespace {
+
+	private final SqlValidatorScope scope;
+
+	private final SqlCall call;
+
+	ProcedureNamespace(
+		SqlValidatorImpl validator,
+		SqlValidatorScope scope,
+		SqlCall call,
+		SqlNode enclosingNode) {
+		super(validator, enclosingNode);
+		this.scope = scope;
+		this.call = call;
+	}
+
+	public RelDataType validateImpl(RelDataType targetRowType) {
+		validator.inferUnknownTypes(validator.unknownType, scope, call);
+		final RelDataType type = validator.deriveTypeImpl(scope, call);
+		final SqlOperator operator = call.getOperator();
+		final SqlCallBinding callBinding =
+			new SqlCallBinding(validator, scope, call);
+		// legacy table functions
+		if (operator instanceof TableSqlFunction) {
 
 Review comment:
   It seems that we can use `TableSqlFunction`, because `TableSqlFunction`s are different between legacy planner and blink planner.
   This lead to we have different `ProcedureNamespace` codes in between legacy planner and blink planner.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#issuecomment-582952425
 
 
   <!--
   Meta data
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:MANUAL TriggerID:585207642
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:MANUAL TriggerID:585207642
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:PENDING URL:https://travis-ci.com/flink-ci/flink/builds/148581567 TriggerType:PUSH TriggerID:b17903fa533da56973ea764fd8e71b722bbe42a0
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:PENDING URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5108 TriggerType:PUSH TriggerID:b17903fa533da56973ea764fd8e71b722bbe42a0
   -->
   ## CI report:
   
   * dc1e81f2b3af44ae05c45f730353b65634e9220b Travis: [CANCELED](https://travis-ci.com/flink-ci/flink/builds/147743884) Azure: [FAILURE](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913) 
   * b17903fa533da56973ea764fd8e71b722bbe42a0 Travis: [PENDING](https://travis-ci.com/flink-ci/flink/builds/148581567) Azure: [PENDING](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5108) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r376220459
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/codegen/calls/TableFunctionCallGen.scala
 ##########
 @@ -18,29 +18,51 @@
 
 package org.apache.flink.table.planner.codegen.calls
 
+import org.apache.calcite.rex.RexCall
+import org.apache.flink.table.dataformat.GenericRow
 import org.apache.flink.table.functions.TableFunction
+import org.apache.flink.table.planner.calcite.FlinkTypeFactory
+import org.apache.flink.table.planner.codegen.CodeGenUtils.newName
 import org.apache.flink.table.planner.codegen.GeneratedExpression.NEVER_NULL
 import org.apache.flink.table.planner.codegen.calls.ScalarFunctionCallGen.prepareFunctionArgs
-import org.apache.flink.table.planner.codegen.{CodeGeneratorContext, GeneratedExpression}
+import org.apache.flink.table.planner.codegen._
 import org.apache.flink.table.planner.functions.utils.UserDefinedFunctionUtils.getEvalMethodSignature
+import org.apache.flink.table.planner.functions.utils.{TableSqlFunction, UserDefinedFunctionUtils}
+import org.apache.flink.table.planner.plan.schema.FlinkTableFunction
+import org.apache.flink.table.runtime.types.LogicalTypeDataTypeConverter.fromDataTypeToLogicalType
+import org.apache.flink.table.runtime.types.PlannerTypeUtils
+import org.apache.flink.table.types.DataType
 import org.apache.flink.table.types.logical.LogicalType
 
+import scala.collection.JavaConversions._
+
 /**
   * Generates a call to user-defined [[TableFunction]].
   *
   * @param tableFunction user-defined [[TableFunction]] that might be overloaded
   */
-class TableFunctionCallGen(tableFunction: TableFunction[_]) extends CallGenerator {
+class TableFunctionCallGen(
+    rexCall: RexCall,
+    tableFunction: TableFunction[_])
+  extends CallGenerator {
 
   override def generate(
       ctx: CodeGeneratorContext,
       operands: Seq[GeneratedExpression],
       returnType: LogicalType): GeneratedExpression = {
-    // convert parameters for function (output boxing)
-    val parameters = prepareUDFArgs(ctx, operands, tableFunction)
 
-    // generate function call
     val functionReference = ctx.addReusableFunction(tableFunction)
+
+    val resultCollectorTerm = generateResultCollector(ctx)
+
+    val setCollectorCode = s"""
 
 Review comment:
   Minor: just `s"$functionReference.setCollector($resultCollectorTerm);"`?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] twalthr commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
twalthr commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r378218050
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/codegen/calls/TableFunctionCallGen.scala
 ##########
 @@ -49,7 +71,7 @@ class TableFunctionCallGen(tableFunction: TableFunction[_]) extends CallGenerato
 
     // has no result
     GeneratedExpression(
-      functionReference,
+      resultCollectorTerm,
 
 Review comment:
   Yes, the logic was also complicated before. Conceptually, I think returning a collector as a result is better than the function itself. But I agree, I will add more documentation to the class.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] twalthr commented on issue #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
twalthr commented on issue #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#issuecomment-585206303
 
 
   Thanks for the feedback @JingsongLi and @dawidwys. I addressed your comments. I could further improve the runtime code in the collector. I also documented the behavior for `collect(null)`.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#issuecomment-582952425
 
 
   <!--
   Meta data
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:MANUAL TriggerID:585207642
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:MANUAL TriggerID:585207642
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:FAILURE URL:https://travis-ci.com/flink-ci/flink/builds/148581567 TriggerType:PUSH TriggerID:b17903fa533da56973ea764fd8e71b722bbe42a0
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:PENDING URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5108 TriggerType:PUSH TriggerID:b17903fa533da56973ea764fd8e71b722bbe42a0
   -->
   ## CI report:
   
   * dc1e81f2b3af44ae05c45f730353b65634e9220b Travis: [CANCELED](https://travis-ci.com/flink-ci/flink/builds/147743884) Azure: [FAILURE](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913) 
   * b17903fa533da56973ea764fd8e71b722bbe42a0 Travis: [FAILURE](https://travis-ci.com/flink-ci/flink/builds/148581567) Azure: [PENDING](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5108) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#issuecomment-582952425
 
 
   <!--
   Meta data
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:MANUAL TriggerID:585207642
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:MANUAL TriggerID:585207642
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/148581567 TriggerType:PUSH TriggerID:b17903fa533da56973ea764fd8e71b722bbe42a0
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:PENDING URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5108 TriggerType:PUSH TriggerID:b17903fa533da56973ea764fd8e71b722bbe42a0
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/148581567 TriggerType:MANUAL TriggerID:585287552
   Hash:ea033d01fedf6fdab42ebd196f07d8b014b91d5b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5112 TriggerType:PUSH TriggerID:ea033d01fedf6fdab42ebd196f07d8b014b91d5b
   Hash:ea033d01fedf6fdab42ebd196f07d8b014b91d5b Status:FAILURE URL:https://travis-ci.com/flink-ci/flink/builds/148613991 TriggerType:PUSH TriggerID:ea033d01fedf6fdab42ebd196f07d8b014b91d5b
   -->
   ## CI report:
   
   * dc1e81f2b3af44ae05c45f730353b65634e9220b Travis: [CANCELED](https://travis-ci.com/flink-ci/flink/builds/147743884) Azure: [FAILURE](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913) 
   * b17903fa533da56973ea764fd8e71b722bbe42a0 Travis: [CANCELED](https://travis-ci.com/flink-ci/flink/builds/148581567) Azure: [PENDING](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5108) 
   * ea033d01fedf6fdab42ebd196f07d8b014b91d5b Travis: [FAILURE](https://travis-ci.com/flink-ci/flink/builds/148613991) Azure: [FAILURE](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5112) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r376197098
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/validate/ProcedureNamespace.java
 ##########
 @@ -0,0 +1,80 @@
+/*
+ * 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.calcite.sql.validate;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.planner.functions.utils.TableSqlFunction;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlCallBinding;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlUtil;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+/**
+ * Namespace whose contents are defined by the result of a call to a user-defined procedure.
+ *
+ * <p>Note: Compared to Calcite, this class implements custom logic for dealing with collection tables
+ * like {@code TABLE(function(...))} procedures. Compared to the SQL standard, Flink's table functions
 
 Review comment:
   I don't quite understand `TABLE(function(...))`, it seems only `TABLE(function(literals))` support? Is this useful?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#issuecomment-582952425
 
 
   <!--
   Meta data
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:MANUAL TriggerID:585207642
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:MANUAL TriggerID:585207642
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/148581567 TriggerType:PUSH TriggerID:b17903fa533da56973ea764fd8e71b722bbe42a0
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:PENDING URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5108 TriggerType:PUSH TriggerID:b17903fa533da56973ea764fd8e71b722bbe42a0
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/148581567 TriggerType:MANUAL TriggerID:585287552
   Hash:ea033d01fedf6fdab42ebd196f07d8b014b91d5b Status:PENDING URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5112 TriggerType:PUSH TriggerID:ea033d01fedf6fdab42ebd196f07d8b014b91d5b
   Hash:ea033d01fedf6fdab42ebd196f07d8b014b91d5b Status:PENDING URL:https://travis-ci.com/flink-ci/flink/builds/148613991 TriggerType:PUSH TriggerID:ea033d01fedf6fdab42ebd196f07d8b014b91d5b
   -->
   ## CI report:
   
   * dc1e81f2b3af44ae05c45f730353b65634e9220b Travis: [CANCELED](https://travis-ci.com/flink-ci/flink/builds/147743884) Azure: [FAILURE](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913) 
   * b17903fa533da56973ea764fd8e71b722bbe42a0 Travis: [CANCELED](https://travis-ci.com/flink-ci/flink/builds/148581567) Azure: [PENDING](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5108) 
   * ea033d01fedf6fdab42ebd196f07d8b014b91d5b Travis: [PENDING](https://travis-ci.com/flink-ci/flink/builds/148613991) Azure: [PENDING](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5112) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#issuecomment-582952425
 
 
   <!--
   Meta data
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:PENDING URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:MANUAL TriggerID:585207642
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:UNKNOWN URL:TBD TriggerType:PUSH TriggerID:b17903fa533da56973ea764fd8e71b722bbe42a0
   -->
   ## CI report:
   
   * dc1e81f2b3af44ae05c45f730353b65634e9220b Travis: [PENDING](https://travis-ci.com/flink-ci/flink/builds/147743884) Azure: [FAILURE](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913) 
   * b17903fa533da56973ea764fd8e71b722bbe42a0 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot commented on issue #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
flinkbot commented on issue #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#issuecomment-582943086
 
 
   Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
   to review your pull request. We will use this comment to track the progress of the review.
   
   
   ## Automated Checks
   Last check on commit dc1e81f2b3af44ae05c45f730353b65634e9220b (Thu Feb 06 14:55:36 UTC 2020)
   
   **Warnings:**
    * No documentation files were touched! Remember to keep the Flink docs up to date!
   
   
   <sub>Mention the bot in a comment to re-run the automated checks.</sub>
   ## Review Progress
   
   * ❓ 1. The [description] looks good.
   * ❓ 2. There is [consensus] that the contribution should go into to Flink.
   * ❓ 3. Needs [attention] from.
   * ❓ 4. The change fits into the overall [architecture].
   * ❓ 5. Overall code [quality] is good.
   
   Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
    The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
    - `@flinkbot approve all` to approve all aspects
    - `@flinkbot approve-until architecture` to approve everything until `architecture`
    - `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
    - `@flinkbot disapprove architecture` to remove an approval you gave earlier
   </details>

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r376220830
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/codegen/calls/TableFunctionCallGen.scala
 ##########
 @@ -60,7 +82,61 @@ class TableFunctionCallGen(tableFunction: TableFunction[_]) extends CallGenerato
       operands: Seq[GeneratedExpression],
       func: TableFunction[_]): Array[GeneratedExpression] = {
     // get the expanded parameter types
-    var paramClasses = getEvalMethodSignature(func, operands.map(_.resultType).toArray)
+    val paramClasses = getEvalMethodSignature(func, operands.map(_.resultType).toArray)
     prepareFunctionArgs(ctx, operands, paramClasses, func.getParameterTypes(paramClasses))
   }
+
+  def getExternalDataType: DataType = {
+    val sqlFunction = rexCall.getOperator.asInstanceOf[TableSqlFunction]
+    val arguments = UserDefinedFunctionUtils.transformRexNodes(rexCall.operands)
+    val operandTypes = rexCall.operands
+        .map(_.getType)
+        .map(FlinkTypeFactory.toLogicalType).toArray
+    val func = sqlFunction.makeFunction(arguments, operandTypes)
+    val argTypes = getEvalMethodSignature(
+      func,
+      rexCall.operands
+        .map(_.getType)
+        .map(FlinkTypeFactory.toLogicalType).toArray)
+    sqlFunction
+        .getFunction
+        .asInstanceOf[FlinkTableFunction]
+        .getExternalResultType(func, arguments, argTypes)
+  }
+
+  /**
+   * Generates a collector that converts the output of a table function (possibly as an atomic type)
+   * into an internal row type. Returns a collector term for referencing the collector.
+   */
+  def generateResultCollector(ctx: CodeGeneratorContext): String = {
 
 Review comment:
   really like this refactoring: move pojo and external conversion things to here, and this consistent with ScalarFunction too.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] twalthr commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
twalthr commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r378207216
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/validate/ProcedureNamespace.java
 ##########
 @@ -0,0 +1,80 @@
+/*
+ * 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.calcite.sql.validate;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.planner.functions.utils.TableSqlFunction;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlCallBinding;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlUtil;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+/**
+ * Namespace whose contents are defined by the result of a call to a user-defined procedure.
+ *
+ * <p>Note: Compared to Calcite, this class implements custom logic for dealing with collection tables
+ * like {@code TABLE(function(...))} procedures. Compared to the SQL standard, Flink's table functions
 
 Review comment:
   Input fields might depend on a `LATERAL` keyword. But in any case, this JavaDoc and class is correctly describing the SQL standard "collection table".

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] dawidwys commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
dawidwys commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r377081317
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/catalog/FunctionCatalogOperatorTable.java
 ##########
 @@ -145,12 +145,18 @@ public void lookupOperatorOverloads(
 			}
 		}
 		// new stack
-		return convertToBridgingSqlFunction(identifier, definition);
+		return convertToBridgingSqlFunction(category, identifier, definition);
 	}
 
 	private Optional<SqlFunction> convertToBridgingSqlFunction(
+			@Nullable SqlFunctionCategory category,
 			FunctionIdentifier identifier,
 			FunctionDefinition definition) {
+
+		if (!verifyFunctionKind(category, definition)) {
 
 Review comment:
   This makes the line 177 unreachable. Can we have a comment why is it so? Is it because we do not support aggregate functions in code generator yet?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r376224405
 
 

 ##########
 File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/collector/WrappingCollector.java
 ##########
 @@ -0,0 +1,49 @@
+/*
+ * 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.collector;
+
+import org.apache.flink.api.common.functions.AbstractRichFunction;
+import org.apache.flink.util.Collector;
+
+/**
+ * A {@link Collector} that wraps another collector. An implementation can decide when to emit to the
+ * wrapped collector.
+ */
+public abstract class WrappingCollector<T> extends AbstractRichFunction implements Collector<T> {
+
+	private Collector<T> collector;
+
+	/**
+	 * Sets the current collector which is used to emit the final result.
+	 */
+	public void setCollector(Collector<T> collector) {
+		this.collector = collector;
+	}
+
+	/**
+	 * Outputs the final result to the wrapped collector.
+	 */
+	public void outputResult(T result) {
+		this.collector.collect(result);
+	}
+
+	public void close() {
 
 Review comment:
   `@Override`

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] twalthr commented on issue #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
twalthr commented on issue #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#issuecomment-585664480
 
 
   @flinkbot run travis
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#issuecomment-582952425
 
 
   <!--
   Meta data
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:MANUAL TriggerID:585207642
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:MANUAL TriggerID:585207642
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/148581567 TriggerType:PUSH TriggerID:b17903fa533da56973ea764fd8e71b722bbe42a0
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:PENDING URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5108 TriggerType:PUSH TriggerID:b17903fa533da56973ea764fd8e71b722bbe42a0
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/148581567 TriggerType:MANUAL TriggerID:585287552
   Hash:ea033d01fedf6fdab42ebd196f07d8b014b91d5b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5112 TriggerType:PUSH TriggerID:ea033d01fedf6fdab42ebd196f07d8b014b91d5b
   Hash:ea033d01fedf6fdab42ebd196f07d8b014b91d5b Status:PENDING URL:https://travis-ci.com/flink-ci/flink/builds/148613991 TriggerType:PUSH TriggerID:ea033d01fedf6fdab42ebd196f07d8b014b91d5b
   -->
   ## CI report:
   
   * dc1e81f2b3af44ae05c45f730353b65634e9220b Travis: [CANCELED](https://travis-ci.com/flink-ci/flink/builds/147743884) Azure: [FAILURE](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913) 
   * b17903fa533da56973ea764fd8e71b722bbe42a0 Travis: [CANCELED](https://travis-ci.com/flink-ci/flink/builds/148581567) Azure: [PENDING](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5108) 
   * ea033d01fedf6fdab42ebd196f07d8b014b91d5b Travis: [PENDING](https://travis-ci.com/flink-ci/flink/builds/148613991) Azure: [FAILURE](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5112) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r376199644
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/QueryOperationConverter.java
 ##########
 @@ -295,10 +295,12 @@ public RelNode visit(SortQueryOperation sort) {
 
 			List<RexNode> parameters = convertToRexNodes(calculatedTable.getParameters());
 
+			// TODO use relBuilder.functionScan() once we remove TableSqlFunction
 			return LogicalTableFunctionScan.create(
 					relBuilder.peek().getCluster(),
 					Collections.emptyList(),
-					relBuilder.call(sqlFunction, parameters),
+					relBuilder.getRexBuilder()
+						.makeCall(function.getRowType(typeFactory, null, null), sqlFunction, parameters),
 
 Review comment:
   Can you modify the `FlinkTableFunction`, just remove `arguments: Array[AnyRef]` and `argTypes: Array[Class[_]`, them are useless. The follow-up plan doesn't depend on them either.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r378167489
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/validate/ProcedureNamespace.java
 ##########
 @@ -0,0 +1,80 @@
+/*
+ * 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.calcite.sql.validate;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.planner.functions.utils.TableSqlFunction;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlCallBinding;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlUtil;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+/**
+ * Namespace whose contents are defined by the result of a call to a user-defined procedure.
+ *
+ * <p>Note: Compared to Calcite, this class implements custom logic for dealing with collection tables
+ * like {@code TABLE(function(...))} procedures. Compared to the SQL standard, Flink's table functions
 
 Review comment:
   But no input reference fields?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#issuecomment-582952425
 
 
   <!--
   Meta data
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:PENDING URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   -->
   ## CI report:
   
   * dc1e81f2b3af44ae05c45f730353b65634e9220b Travis: [PENDING](https://travis-ci.com/flink-ci/flink/builds/147743884) Azure: [FAILURE](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#discussion_r378646800
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/validate/ProcedureNamespace.java
 ##########
 @@ -0,0 +1,80 @@
+/*
+ * 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.calcite.sql.validate;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.planner.functions.utils.TableSqlFunction;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlCallBinding;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlUtil;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+/**
+ * Namespace whose contents are defined by the result of a call to a user-defined procedure.
+ *
+ * <p>Note: Compared to Calcite, this class implements custom logic for dealing with collection tables
+ * like {@code TABLE(function(...))} procedures. Compared to the SQL standard, Flink's table functions
+ * can return arbitrary types that are wrapped into a ROW type if necessary. We don't interpret ARRAY
+ * or MULTISET types as it would be standard.
+ */
+@Internal
+public final class ProcedureNamespace extends AbstractNamespace {
+
+	private final SqlValidatorScope scope;
+
+	private final SqlCall call;
+
+	ProcedureNamespace(
+		SqlValidatorImpl validator,
+		SqlValidatorScope scope,
+		SqlCall call,
+		SqlNode enclosingNode) {
+		super(validator, enclosingNode);
+		this.scope = scope;
+		this.call = call;
+	}
+
+	public RelDataType validateImpl(RelDataType targetRowType) {
+		validator.inferUnknownTypes(validator.unknownType, scope, call);
+		final RelDataType type = validator.deriveTypeImpl(scope, call);
+		final SqlOperator operator = call.getOperator();
+		final SqlCallBinding callBinding =
+			new SqlCallBinding(validator, scope, call);
+		// legacy table functions
+		if (operator instanceof TableSqlFunction) {
 
 Review comment:
   It seems that we can not use `TableSqlFunction`, because `TableSqlFunction`s are different between legacy planner and blink planner.
   This lead to we have different `ProcedureNamespace` codes between legacy planner and blink planner.
   This will lead to bugs.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#issuecomment-582952425
 
 
   <!--
   Meta data
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:MANUAL TriggerID:585207642
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:MANUAL TriggerID:585207642
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/148581567 TriggerType:PUSH TriggerID:b17903fa533da56973ea764fd8e71b722bbe42a0
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:PENDING URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5108 TriggerType:PUSH TriggerID:b17903fa533da56973ea764fd8e71b722bbe42a0
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/148581567 TriggerType:MANUAL TriggerID:585287552
   Hash:ea033d01fedf6fdab42ebd196f07d8b014b91d5b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5112 TriggerType:PUSH TriggerID:ea033d01fedf6fdab42ebd196f07d8b014b91d5b
   Hash:ea033d01fedf6fdab42ebd196f07d8b014b91d5b Status:FAILURE URL:https://travis-ci.com/flink-ci/flink/builds/148613991 TriggerType:PUSH TriggerID:ea033d01fedf6fdab42ebd196f07d8b014b91d5b
   Hash:ea033d01fedf6fdab42ebd196f07d8b014b91d5b Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/148613991 TriggerType:MANUAL TriggerID:585664480
   Hash:ea033d01fedf6fdab42ebd196f07d8b014b91d5b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5112 TriggerType:MANUAL TriggerID:585664480
   Hash:b5528bc218f197a8dfcf0f44710544f708306d76 Status:PENDING URL:https://travis-ci.com/flink-ci/flink/builds/148771715 TriggerType:PUSH TriggerID:b5528bc218f197a8dfcf0f44710544f708306d76
   Hash:b5528bc218f197a8dfcf0f44710544f708306d76 Status:PENDING URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5133 TriggerType:PUSH TriggerID:b5528bc218f197a8dfcf0f44710544f708306d76
   -->
   ## CI report:
   
   * dc1e81f2b3af44ae05c45f730353b65634e9220b Travis: [CANCELED](https://travis-ci.com/flink-ci/flink/builds/147743884) Azure: [FAILURE](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913) 
   * b17903fa533da56973ea764fd8e71b722bbe42a0 Travis: [CANCELED](https://travis-ci.com/flink-ci/flink/builds/148581567) Azure: [PENDING](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5108) 
   * ea033d01fedf6fdab42ebd196f07d8b014b91d5b Travis: [CANCELED](https://travis-ci.com/flink-ci/flink/builds/148613991) Azure: [FAILURE](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5112) 
   * b5528bc218f197a8dfcf0f44710544f708306d76 Travis: [PENDING](https://travis-ci.com/flink-ci/flink/builds/148771715) Azure: [PENDING](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5133) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#issuecomment-582952425
 
 
   <!--
   Meta data
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:PUSH TriggerID:dc1e81f2b3af44ae05c45f730353b65634e9220b
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/147743884 TriggerType:MANUAL TriggerID:585207642
   Hash:dc1e81f2b3af44ae05c45f730353b65634e9220b Status:FAILURE URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913 TriggerType:MANUAL TriggerID:585207642
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:FAILURE URL:https://travis-ci.com/flink-ci/flink/builds/148581567 TriggerType:PUSH TriggerID:b17903fa533da56973ea764fd8e71b722bbe42a0
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:PENDING URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5108 TriggerType:PUSH TriggerID:b17903fa533da56973ea764fd8e71b722bbe42a0
   Hash:b17903fa533da56973ea764fd8e71b722bbe42a0 Status:PENDING URL:https://travis-ci.com/flink-ci/flink/builds/148581567 TriggerType:MANUAL TriggerID:585287552
   Hash:ea033d01fedf6fdab42ebd196f07d8b014b91d5b Status:UNKNOWN URL:TBD TriggerType:PUSH TriggerID:ea033d01fedf6fdab42ebd196f07d8b014b91d5b
   -->
   ## CI report:
   
   * dc1e81f2b3af44ae05c45f730353b65634e9220b Travis: [CANCELED](https://travis-ci.com/flink-ci/flink/builds/147743884) Azure: [FAILURE](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4913) 
   * b17903fa533da56973ea764fd8e71b722bbe42a0 Travis: [PENDING](https://travis-ci.com/flink-ci/flink/builds/148581567) Azure: [PENDING](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5108) 
   * ea033d01fedf6fdab42ebd196f07d8b014b91d5b UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] twalthr commented on issue #11034: [FLINK-15802][table] Support new type inference for table functions

Posted by GitBox <gi...@apache.org>.
twalthr commented on issue #11034: [FLINK-15802][table] Support new type inference for table functions
URL: https://github.com/apache/flink/pull/11034#issuecomment-585744237
 
 
   Travis gave green light. Merging...

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services