danny0405 commented on a change in pull request #10224: 
[FLINK-14716][table-planner-blink] Cooperate computed column with push down 
rules
URL: https://github.com/apache/flink/pull/10224#discussion_r347777331
 
 

 ##########
 File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/schema/TableSourceTable.scala
 ##########
 @@ -70,60 +70,39 @@ class TableSourceTable[T](
           " via DefinedRowtimeAttributes interface.")
   }
 
-  // TODO implements this
-  // TableSourceUtil.validateTableSource(tableSource)
-
-  override def getRowType(typeFactory: RelDataTypeFactory): RelDataType = {
-    val factory = typeFactory.asInstanceOf[FlinkTypeFactory]
-    val (fieldNames, fieldTypes) = TableSourceUtil.getFieldNameType(
-      catalogTable.getSchema,
-      tableSource,
-      selectedFields,
-      streaming = isStreamingMode)
-    // patch rowtime field according to WatermarkSpec
-    val patchedTypes = if (isStreamingMode && watermarkSpec.isDefined) {
-      // TODO: [FLINK-14473] we only support top-level rowtime attribute right 
now
-      val rowtime = watermarkSpec.get.getRowtimeAttribute
-      if (rowtime.contains(".")) {
-        throw new TableException(
-          s"Nested field '$rowtime' as rowtime attribute is not supported 
right now.")
-      }
-      val idx = fieldNames.indexOf(rowtime)
-      val originalType = fieldTypes(idx).asInstanceOf[TimestampType]
-      val rowtimeType = new TimestampType(
-        originalType.isNullable,
-        TimestampKind.ROWTIME,
-        originalType.getPrecision)
-      fieldTypes.patch(idx, Seq(rowtimeType), 1)
-    } else {
-      fieldTypes
-    }
-    factory.buildRelNodeRowType(fieldNames, patchedTypes)
-  }
+  override def getQualifiedName: JList[String] = 
explainSourceAsString(tableSource)
 
   /**
-    * Creates a copy of this table, changing statistic.
+    * Creates a copy of this table, changing table source and statistic.
     *
-    * @param statistic A new FlinkStatistic.
-    * @return Copy of this table, substituting statistic.
+    * @param tableSource tableSource to replace
+    * @param statistic New FlinkStatistic to replace
+    * @return New TableSourceTable instance with specified table source and 
[[FlinkStatistic]]
     */
-  override def copy(statistic: FlinkStatistic): TableSourceTable[T] = {
-    new TableSourceTable(tableSource, isStreamingMode, statistic, catalogTable)
+  def copy(tableSource: TableSource[_], statistic: FlinkStatistic): 
TableSourceTable[T] = {
+    new TableSourceTable[T](relOptSchema, names, rowType, statistic,
+      tableSource.asInstanceOf[TableSource[T]], isStreamingMode, catalogTable)
   }
 
   /**
-    * Returns statistics of current table.
-    */
-  override def getStatistic: FlinkStatistic = statistic
-
-  /**
-    * Replaces table source with the given one, and create a new table source 
table.
+    * Creates a copy of this table, changing table source, statistic and 
rowType based on
+    * selected fields.
     *
-    * @param tableSource tableSource to replace.
-    * @return new TableSourceTable
+    * @param tableSource tableSource to replace
+    * @param statistic New FlinkStatistic to replace
+    * @param selectedFields Selected indices of the table source output fields
+    * @return New TableSourceTable instance with specified table source, 
[[FlinkStatistic]],
+    *         and selected fields
     */
-  def replaceTableSource(tableSource: TableSource[T]): TableSourceTable[T] = {
-    new TableSourceTable[T](
-      tableSource, isStreamingMode, statistic, catalogTable)
+  def copy(tableSource: TableSource[_], statistic: FlinkStatistic,
 
 Review comment:
   Yep, thanks.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to