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/06/19 17:31:46 UTC

[GitHub] [flink] dawidwys opened a new pull request #12725: [FLINK-18378] Improve CatalogTable schema resolution

dawidwys opened a new pull request #12725:
URL: https://github.com/apache/flink/pull/12725


   # What is the purpose of the change
   
   Make it possible to use different `CatalogTable` implementation and properly resolve such tables. Moreover apply the schema fields resolution for fields of views.
   
   ## Brief change log
   
     - Pass the resolved schema as part of the `TableLookupResult`
     - When resolving proctime time attribute use the nullability of the resolved expression instead of the original field (otherwise if user declares proctime field nullable, there will be mismatch)
   
   
   ## Verifying this change
   
   Added tests in `JavaCatalogTableITCase`
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / **no**)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / **no**)
     - The serializers: (yes / **no** / don't know)
     - The runtime per-record code paths (performance sensitive): (yes / **no** / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (yes / **no** / don't know)
     - The S3 file system connector: (yes / **no** / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes / **no**)
     - If yes, how is the feature documented? (**not applicable** / docs / JavaDocs / not documented)
   


----------------------------------------------------------------
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



[GitHub] [flink] wuchong commented on a change in pull request #12725: [FLINK-18378] Improve CatalogTable schema resolution

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #12725:
URL: https://github.com/apache/flink/pull/12725#discussion_r443372461



##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/CatalogTableSchemaResolver.java
##########
@@ -76,16 +78,16 @@ public TableSchema resolve(TableSchema tableSchema) {
 		for (int i = 0; i < tableSchema.getFieldCount(); ++i) {
 			TableColumn tableColumn = tableSchema.getTableColumns().get(i);
 			DataType fieldType = fieldTypes[i];
-			if (tableColumn.isGenerated() && isProctimeType(tableColumn.getExpr().get(), tableSchema)) {
+			DataType exprType = null;
+			if (tableColumn.isGenerated()) {
+				exprType = resolveExpressionDataType(tableColumn.getExpr().get(), tableSchema);
+			}
+
+			if (exprType != null && isProctime(exprType)) {
 				if (fieldNames[i].equals(rowtime)) {
 					throw new TableException("Watermark can not be defined for a processing time attribute column.");
 				}
-				TimestampType originalType = (TimestampType) fieldType.getLogicalType();
-				LogicalType proctimeType = new TimestampType(
-						originalType.isNullable(),
-						TimestampKind.PROCTIME,
-						originalType.getPrecision());
-				fieldType = TypeConversions.fromLogicalToDataType(proctimeType);
+				fieldType = exprType;

Review comment:
       The case is that the return type of functions (built-in or UDF) may change in the future, e.g. we are planning to change the return type of `CURRENT_TIMESTAMP` to `TIMESTAMP WITH LCOAL TIME ZONE`.




----------------------------------------------------------------
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



[GitHub] [flink] wuchong commented on a change in pull request #12725: [FLINK-18378] Improve CatalogTable schema resolution

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #12725:
URL: https://github.com/apache/flink/pull/12725#discussion_r443372461



##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/CatalogTableSchemaResolver.java
##########
@@ -76,16 +78,16 @@ public TableSchema resolve(TableSchema tableSchema) {
 		for (int i = 0; i < tableSchema.getFieldCount(); ++i) {
 			TableColumn tableColumn = tableSchema.getTableColumns().get(i);
 			DataType fieldType = fieldTypes[i];
-			if (tableColumn.isGenerated() && isProctimeType(tableColumn.getExpr().get(), tableSchema)) {
+			DataType exprType = null;
+			if (tableColumn.isGenerated()) {
+				exprType = resolveExpressionDataType(tableColumn.getExpr().get(), tableSchema);
+			}
+
+			if (exprType != null && isProctime(exprType)) {
 				if (fieldNames[i].equals(rowtime)) {
 					throw new TableException("Watermark can not be defined for a processing time attribute column.");
 				}
-				TimestampType originalType = (TimestampType) fieldType.getLogicalType();
-				LogicalType proctimeType = new TimestampType(
-						originalType.isNullable(),
-						TimestampKind.PROCTIME,
-						originalType.getPrecision());
-				fieldType = TypeConversions.fromLogicalToDataType(proctimeType);
+				fieldType = exprType;

Review comment:
       The case is that the return type of functions (built-in or UDF) may change in the future, e.g. we are planning to change the return type of `CURRENT_TIMESTAMP` to `TIMESTAMP WITH LOCAL TIME ZONE`.




----------------------------------------------------------------
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



[GitHub] [flink] flinkbot edited a comment on pull request #12725: [FLINK-18378] Improve CatalogTable schema resolution

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12725:
URL: https://github.com/apache/flink/pull/12725#issuecomment-646792829


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "e41308a34c02611ac8d17b49a2de2c913f13e07e",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=3842",
       "triggerID" : "e41308a34c02611ac8d17b49a2de2c913f13e07e",
       "triggerType" : "PUSH"
     }, {
       "hash" : "feacf8d7d36c97ae640f8de567a69557d3de1981",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=3891",
       "triggerID" : "feacf8d7d36c97ae640f8de567a69557d3de1981",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8dc5206e29901f39572aaff358fe5f8aae50df7e",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "8dc5206e29901f39572aaff358fe5f8aae50df7e",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * e41308a34c02611ac8d17b49a2de2c913f13e07e Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=3842) 
   * feacf8d7d36c97ae640f8de567a69557d3de1981 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=3891) 
   * 8dc5206e29901f39572aaff358fe5f8aae50df7e 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



[GitHub] [flink] dawidwys edited a comment on pull request #12725: [FLINK-18378] Improve CatalogTable schema resolution

Posted by GitBox <gi...@apache.org>.
dawidwys edited a comment on pull request #12725:
URL: https://github.com/apache/flink/pull/12725#issuecomment-646777204


   Could you take a look @wuchong @godfreyhe ?


----------------------------------------------------------------
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



[GitHub] [flink] flinkbot edited a comment on pull request #12725: [FLINK-18378] Improve CatalogTable schema resolution

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12725:
URL: https://github.com/apache/flink/pull/12725#issuecomment-646792829


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "e41308a34c02611ac8d17b49a2de2c913f13e07e",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=3842",
       "triggerID" : "e41308a34c02611ac8d17b49a2de2c913f13e07e",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * e41308a34c02611ac8d17b49a2de2c913f13e07e Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=3842) 
   
   <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



[GitHub] [flink] dawidwys commented on a change in pull request #12725: [FLINK-18378] Improve CatalogTable schema resolution

Posted by GitBox <gi...@apache.org>.
dawidwys commented on a change in pull request #12725:
URL: https://github.com/apache/flink/pull/12725#discussion_r443375657



##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/CatalogTableSchemaResolver.java
##########
@@ -76,16 +78,16 @@ public TableSchema resolve(TableSchema tableSchema) {
 		for (int i = 0; i < tableSchema.getFieldCount(); ++i) {
 			TableColumn tableColumn = tableSchema.getTableColumns().get(i);
 			DataType fieldType = fieldTypes[i];
-			if (tableColumn.isGenerated() && isProctimeType(tableColumn.getExpr().get(), tableSchema)) {
+			DataType exprType = null;
+			if (tableColumn.isGenerated()) {
+				exprType = resolveExpressionDataType(tableColumn.getExpr().get(), tableSchema);
+			}
+
+			if (exprType != null && isProctime(exprType)) {
 				if (fieldNames[i].equals(rowtime)) {
 					throw new TableException("Watermark can not be defined for a processing time attribute column.");
 				}
-				TimestampType originalType = (TimestampType) fieldType.getLogicalType();
-				LogicalType proctimeType = new TimestampType(
-						originalType.isNullable(),
-						TimestampKind.PROCTIME,
-						originalType.getPrecision());
-				fieldType = TypeConversions.fromLogicalToDataType(proctimeType);
+				fieldType = exprType;

Review comment:
       I understand the goal and as I said I will change it the way you asked. Just wanted to point out that I think we do not have a clear semantic of the type of a computed column.




----------------------------------------------------------------
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



[GitHub] [flink] dawidwys commented on a change in pull request #12725: [FLINK-18378] Improve CatalogTable schema resolution

Posted by GitBox <gi...@apache.org>.
dawidwys commented on a change in pull request #12725:
URL: https://github.com/apache/flink/pull/12725#discussion_r443371169



##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/CatalogTableSchemaResolver.java
##########
@@ -76,16 +78,16 @@ public TableSchema resolve(TableSchema tableSchema) {
 		for (int i = 0; i < tableSchema.getFieldCount(); ++i) {
 			TableColumn tableColumn = tableSchema.getTableColumns().get(i);
 			DataType fieldType = fieldTypes[i];
-			if (tableColumn.isGenerated() && isProctimeType(tableColumn.getExpr().get(), tableSchema)) {
+			DataType exprType = null;
+			if (tableColumn.isGenerated()) {
+				exprType = resolveExpressionDataType(tableColumn.getExpr().get(), tableSchema);
+			}
+
+			if (exprType != null && isProctime(exprType)) {
 				if (fieldNames[i].equals(rowtime)) {
 					throw new TableException("Watermark can not be defined for a processing time attribute column.");
 				}
-				TimestampType originalType = (TimestampType) fieldType.getLogicalType();
-				LogicalType proctimeType = new TimestampType(
-						originalType.isNullable(),
-						TimestampKind.PROCTIME,
-						originalType.getPrecision());
-				fieldType = TypeConversions.fromLogicalToDataType(proctimeType);
+				fieldType = exprType;

Review comment:
       I was also thinking about it and I can do that. Nevertheless in my opinion this requires careful consideration.
   
   What is the point of data type of a computed column, if we completely ignore it?




----------------------------------------------------------------
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



[GitHub] [flink] flinkbot edited a comment on pull request #12725: [FLINK-18378] Improve CatalogTable schema resolution

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12725:
URL: https://github.com/apache/flink/pull/12725#issuecomment-646792829


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "e41308a34c02611ac8d17b49a2de2c913f13e07e",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=3842",
       "triggerID" : "e41308a34c02611ac8d17b49a2de2c913f13e07e",
       "triggerType" : "PUSH"
     }, {
       "hash" : "feacf8d7d36c97ae640f8de567a69557d3de1981",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=3891",
       "triggerID" : "feacf8d7d36c97ae640f8de567a69557d3de1981",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8dc5206e29901f39572aaff358fe5f8aae50df7e",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=3898",
       "triggerID" : "8dc5206e29901f39572aaff358fe5f8aae50df7e",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * e41308a34c02611ac8d17b49a2de2c913f13e07e Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=3842) 
   * feacf8d7d36c97ae640f8de567a69557d3de1981 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=3891) 
   * 8dc5206e29901f39572aaff358fe5f8aae50df7e Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=3898) 
   
   <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



[GitHub] [flink] dawidwys closed pull request #12725: [FLINK-18378] Improve CatalogTable schema resolution

Posted by GitBox <gi...@apache.org>.
dawidwys closed pull request #12725:
URL: https://github.com/apache/flink/pull/12725


   


----------------------------------------------------------------
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



[GitHub] [flink] dawidwys commented on a change in pull request #12725: [FLINK-18378] Improve CatalogTable schema resolution

Posted by GitBox <gi...@apache.org>.
dawidwys commented on a change in pull request #12725:
URL: https://github.com/apache/flink/pull/12725#discussion_r443368511



##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/CatalogTableSchemaResolver.java
##########
@@ -76,16 +78,16 @@ public TableSchema resolve(TableSchema tableSchema) {
 		for (int i = 0; i < tableSchema.getFieldCount(); ++i) {
 			TableColumn tableColumn = tableSchema.getTableColumns().get(i);
 			DataType fieldType = fieldTypes[i];
-			if (tableColumn.isGenerated() && isProctimeType(tableColumn.getExpr().get(), tableSchema)) {
+			DataType exprType = null;
+			if (tableColumn.isGenerated()) {
+				exprType = resolveExpressionDataType(tableColumn.getExpr().get(), tableSchema);
+			}
+
+			if (exprType != null && isProctime(exprType)) {
 				if (fieldNames[i].equals(rowtime)) {
 					throw new TableException("Watermark can not be defined for a processing time attribute column.");

Review comment:
       We need the check for `isProctime(...)`.




----------------------------------------------------------------
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



[GitHub] [flink] flinkbot edited a comment on pull request #12725: [FLINK-18378] Improve CatalogTable schema resolution

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12725:
URL: https://github.com/apache/flink/pull/12725#issuecomment-646792829


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "e41308a34c02611ac8d17b49a2de2c913f13e07e",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=3842",
       "triggerID" : "e41308a34c02611ac8d17b49a2de2c913f13e07e",
       "triggerType" : "PUSH"
     }, {
       "hash" : "feacf8d7d36c97ae640f8de567a69557d3de1981",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "feacf8d7d36c97ae640f8de567a69557d3de1981",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * e41308a34c02611ac8d17b49a2de2c913f13e07e Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=3842) 
   * feacf8d7d36c97ae640f8de567a69557d3de1981 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



[GitHub] [flink] wuchong commented on a change in pull request #12725: [FLINK-18378] Improve CatalogTable schema resolution

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #12725:
URL: https://github.com/apache/flink/pull/12725#discussion_r443291174



##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/CatalogTableSchemaResolver.java
##########
@@ -76,16 +78,16 @@ public TableSchema resolve(TableSchema tableSchema) {
 		for (int i = 0; i < tableSchema.getFieldCount(); ++i) {
 			TableColumn tableColumn = tableSchema.getTableColumns().get(i);
 			DataType fieldType = fieldTypes[i];
-			if (tableColumn.isGenerated() && isProctimeType(tableColumn.getExpr().get(), tableSchema)) {
+			DataType exprType = null;
+			if (tableColumn.isGenerated()) {
+				exprType = resolveExpressionDataType(tableColumn.getExpr().get(), tableSchema);
+			}
+
+			if (exprType != null && isProctime(exprType)) {
 				if (fieldNames[i].equals(rowtime)) {
 					throw new TableException("Watermark can not be defined for a processing time attribute column.");

Review comment:
       I think we can move this exception check into `if (tableColumn.isGenerated())` branch, then we don't need a `exprType != null` check. 

##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/catalog/CatalogSchemaTable.java
##########
@@ -183,7 +169,12 @@ private RelDataType getRowType(RelDataTypeFactory typeFactory,
 				flinkTypeFactory,
 				tableSchema,
 				scala.Option.empty(),
-				isStreamingMode);
+			isStreamingMode);

Review comment:
       Indent. 

##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/CatalogTableSchemaResolver.java
##########
@@ -76,16 +78,16 @@ public TableSchema resolve(TableSchema tableSchema) {
 		for (int i = 0; i < tableSchema.getFieldCount(); ++i) {
 			TableColumn tableColumn = tableSchema.getTableColumns().get(i);
 			DataType fieldType = fieldTypes[i];
-			if (tableColumn.isGenerated() && isProctimeType(tableColumn.getExpr().get(), tableSchema)) {
+			DataType exprType = null;
+			if (tableColumn.isGenerated()) {
+				exprType = resolveExpressionDataType(tableColumn.getExpr().get(), tableSchema);
+			}
+
+			if (exprType != null && isProctime(exprType)) {
 				if (fieldNames[i].equals(rowtime)) {
 					throw new TableException("Watermark can not be defined for a processing time attribute column.");
 				}
-				TimestampType originalType = (TimestampType) fieldType.getLogicalType();
-				LogicalType proctimeType = new TimestampType(
-						originalType.isNullable(),
-						TimestampKind.PROCTIME,
-						originalType.getPrecision());
-				fieldType = TypeConversions.fromLogicalToDataType(proctimeType);
+				fieldType = exprType;

Review comment:
       I think this should be moved into `if (tableColumn.isGenerated())` branch, to make all computed columns result type correct. 

##########
File path: flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/catalog/JavaCatalogTableITCase.java
##########
@@ -0,0 +1,211 @@
+/*
+ * 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.planner.catalog;
+
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.api.Table;
+import org.apache.flink.table.api.TableConfig;
+import org.apache.flink.table.api.TableEnvironment;
+import org.apache.flink.table.api.TableSchema;
+import org.apache.flink.table.api.Tumble;
+import org.apache.flink.table.catalog.CatalogBaseTable;
+import org.apache.flink.table.catalog.CatalogTable;
+import org.apache.flink.table.catalog.GenericInMemoryCatalog;
+import org.apache.flink.table.catalog.ObjectPath;
+import org.apache.flink.table.planner.utils.TableTestBase;
+import org.apache.flink.table.planner.utils.TableTestUtil;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.table.api.Expressions.lit;
+
+/**
+ * Tests for resolving types of computed columns (including time attributes) of tables from catalog.
+ */
+@RunWith(Parameterized.class)
+public class JavaCatalogTableITCase extends TableTestBase {

Review comment:
       `JavaCatalogTableTest`? I think this doesn't involve a whole Flink cluster? 




----------------------------------------------------------------
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



[GitHub] [flink] flinkbot commented on pull request #12725: [FLINK-18378] Improve CatalogTable schema resolution

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #12725:
URL: https://github.com/apache/flink/pull/12725#issuecomment-646792829


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "e41308a34c02611ac8d17b49a2de2c913f13e07e",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "e41308a34c02611ac8d17b49a2de2c913f13e07e",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * e41308a34c02611ac8d17b49a2de2c913f13e07e 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



[GitHub] [flink] flinkbot edited a comment on pull request #12725: [FLINK-18378] Improve CatalogTable schema resolution

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12725:
URL: https://github.com/apache/flink/pull/12725#issuecomment-646792829


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "e41308a34c02611ac8d17b49a2de2c913f13e07e",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=3842",
       "triggerID" : "e41308a34c02611ac8d17b49a2de2c913f13e07e",
       "triggerType" : "PUSH"
     }, {
       "hash" : "feacf8d7d36c97ae640f8de567a69557d3de1981",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=3891",
       "triggerID" : "feacf8d7d36c97ae640f8de567a69557d3de1981",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8dc5206e29901f39572aaff358fe5f8aae50df7e",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "8dc5206e29901f39572aaff358fe5f8aae50df7e",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * e41308a34c02611ac8d17b49a2de2c913f13e07e Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=3842) 
   * feacf8d7d36c97ae640f8de567a69557d3de1981 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=3891) 
   * 8dc5206e29901f39572aaff358fe5f8aae50df7e 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



[GitHub] [flink] dawidwys commented on a change in pull request #12725: [FLINK-18378] Improve CatalogTable schema resolution

Posted by GitBox <gi...@apache.org>.
dawidwys commented on a change in pull request #12725:
URL: https://github.com/apache/flink/pull/12725#discussion_r443366965



##########
File path: flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/catalog/JavaCatalogTableITCase.java
##########
@@ -0,0 +1,211 @@
+/*
+ * 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.planner.catalog;
+
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.api.Table;
+import org.apache.flink.table.api.TableConfig;
+import org.apache.flink.table.api.TableEnvironment;
+import org.apache.flink.table.api.TableSchema;
+import org.apache.flink.table.api.Tumble;
+import org.apache.flink.table.catalog.CatalogBaseTable;
+import org.apache.flink.table.catalog.CatalogTable;
+import org.apache.flink.table.catalog.GenericInMemoryCatalog;
+import org.apache.flink.table.catalog.ObjectPath;
+import org.apache.flink.table.planner.utils.TableTestBase;
+import org.apache.flink.table.planner.utils.TableTestUtil;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.table.api.Expressions.lit;
+
+/**
+ * Tests for resolving types of computed columns (including time attributes) of tables from catalog.
+ */
+@RunWith(Parameterized.class)
+public class JavaCatalogTableITCase extends TableTestBase {

Review comment:
       Sure I will rename the test. 
   
   Nevertheless it is still an IT test imo. It does not test a single module, but an integration of few (catalogmanager, parser, 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



[GitHub] [flink] dawidwys commented on pull request #12725: [FLINK-18378] Improve CatalogTable schema resolution

Posted by GitBox <gi...@apache.org>.
dawidwys commented on pull request #12725:
URL: https://github.com/apache/flink/pull/12725#issuecomment-646777204


   Could you take a look @wuchong @godfreyhe 


----------------------------------------------------------------
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



[GitHub] [flink] flinkbot commented on pull request #12725: [FLINK-18378] Improve CatalogTable schema resolution

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #12725:
URL: https://github.com/apache/flink/pull/12725#issuecomment-646778656


   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 e41308a34c02611ac8d17b49a2de2c913f13e07e (Fri Jun 19 17:34:22 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



[GitHub] [flink] wuchong commented on a change in pull request #12725: [FLINK-18378] Improve CatalogTable schema resolution

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #12725:
URL: https://github.com/apache/flink/pull/12725#discussion_r443391977



##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/CatalogTableSchemaResolver.java
##########
@@ -76,16 +78,16 @@ public TableSchema resolve(TableSchema tableSchema) {
 		for (int i = 0; i < tableSchema.getFieldCount(); ++i) {
 			TableColumn tableColumn = tableSchema.getTableColumns().get(i);
 			DataType fieldType = fieldTypes[i];
-			if (tableColumn.isGenerated() && isProctimeType(tableColumn.getExpr().get(), tableSchema)) {
+			DataType exprType = null;
+			if (tableColumn.isGenerated()) {
+				exprType = resolveExpressionDataType(tableColumn.getExpr().get(), tableSchema);
+			}
+
+			if (exprType != null && isProctime(exprType)) {
 				if (fieldNames[i].equals(rowtime)) {
 					throw new TableException("Watermark can not be defined for a processing time attribute column.");
 				}
-				TimestampType originalType = (TimestampType) fieldType.getLogicalType();
-				LogicalType proctimeType = new TimestampType(
-						originalType.isNullable(),
-						TimestampKind.PROCTIME,
-						originalType.getPrecision());
-				fieldType = TypeConversions.fromLogicalToDataType(proctimeType);
+				fieldType = exprType;

Review comment:
       Yes.. We didn't have a public discussion about this and some people may thought the type is snapshotted when CREATE TABLE. Maybe we should write this down in documentation. 




----------------------------------------------------------------
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