wuchong commented on a change in pull request #10096: [FLINK-14623][table-api]
Add computed column information into TableSc…
URL: https://github.com/apache/flink/pull/10096#discussion_r343703577
##########
File path:
flink-table/flink-table-common/src/main/java/org/apache/flink/table/api/TableSchema.java
##########
@@ -373,8 +444,38 @@ public Builder() {
public Builder field(String name, DataType dataType) {
Preconditions.checkNotNull(name);
Preconditions.checkNotNull(dataType);
- fieldNames.add(name);
- fieldDataTypes.add(dataType);
+ columns.add(TableColumn.of(name, dataType));
+ return this;
+ }
+
+ /**
+ * Add a field with name, data type and computation expression.
+ * This column would be a computed column.
+ *
+ * <p>The call order of this method determines the order of
fields in the schema.
+ *
+ * @param name Field name
+ * @param dataType Field data type
+ * @param expression Computed column expression, it should be a
SQL-style expression whose
+ * identifiers should be all quoted and
expanded.
+ *
+ * It should be expanded because this
expression may be persisted
+ * then deserialized from the catalog, an
expanded identifier would
+ * avoid the ambiguity if there are same name
UDF referenced from
+ * different paths. For example, if there is
a UDF named "my_udf" from
+ * path "my_catalog.my_database", you could
pass in an expression like
+ * "my_catalog.my_database.my_udf(f0) + 1";
Review comment:
The identifiers should be quoted.
----------------------------------------------------------------
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