twalthr commented on a change in pull request #11527: [FLINK-16035] Updated
Stream/BatchTableEnvironment.java to use Java's Expression DSL
URL: https://github.com/apache/flink/pull/11527#discussion_r401408303
##########
File path:
flink-table/flink-table-api-java-bridge/src/main/java/org/apache/flink/table/api/java/StreamTableEnvironment.java
##########
@@ -216,17 +244,52 @@ static StreamTableEnvironment
create(StreamExecutionEnvironment executionEnviron
/**
* Converts the given {@link DataStream} into a {@link Table} with
specified field names.
*
+ * <p>There are two modes for mapping original fields to the fields of
the {@link Table}:
+ *
+ * <p>1. Reference input fields by name:
+ * All fields in the schema definition are referenced by name
+ * (and possibly renamed using an alias (as). Moreover, we can define
proctime and rowtime
+ * attributes at arbitrary positions using arbitrary names (except
those that exist in the
+ * result schema). In this mode, fields can be reordered and projected
out. This mode can
+ * be used for any input type, including POJOs.
+ *
+ * <p>Example:
+ *
+ * <pre>
+ * {@code
+ * DataStream<Tuple2<String, Long>> stream = ...
+ * Table table = tableEnv.fromDataStream(
+ * stream,
+ * $("f1"), // reorder and use the original field
+ * $("rowtime").rowtime(), // add an event-time attribute named
'rowtime'
+ * $("f0").as("name") // reorder and give the original field a
better name
+ * );
+ * }
+ * </pre>
+ *
+ * <p>2. Reference input fields by position:
+ * In this mode, fields are simply renamed. Event-time attributes can
+ * replace the field on their position in the input data (if it is of
correct type) or be
+ * appended at the end. Proctime attributes must be appended at the
end. This mode can only be
+ * used if the input type has a defined field order (tuple, case class,
Row) and none of
+ * the {@code fields} references a field of the input type.
+ *
* <p>Example:
*
* <pre>
* {@code
* DataStream<Tuple2<String, Long>> stream = ...
- * Table tab = tableEnv.fromDataStream(stream, $("a"),
$("b").as("name"), $("timestamp").rowtime());
+ * Table table = tableEnv.fromDataStream(
+ * stream,
+ * $("a"), // rename the first field to 'a'
+ * $("b") // rename the second field to 'b'
Review comment:
missing comma
----------------------------------------------------------------
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