twalthr commented on a change in pull request #8585: [FLINK-12690][table-api]
Introduce a Planner interface
URL: https://github.com/apache/flink/pull/8585#discussion_r291221471
##########
File path:
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/TableOperation.java
##########
@@ -18,87 +18,16 @@
package org.apache.flink.table.operations;
-import org.apache.flink.annotation.Internal;
-import org.apache.flink.table.api.Table;
-import org.apache.flink.table.api.TableSchema;
-import org.apache.flink.util.StringUtils;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
+import org.apache.flink.annotation.PublicEvolving;
/**
- * Base class for representing the operation structure behind a user-facing
{@link Table} API.
+ * Covers all sort of Table operations such as queries(DQL),
modifications(DML), definitions(DDL),
+ * or control actions(DCL). This is the output of
+ * {@link org.apache.flink.table.planner.Planner#parse(String)}.
+ *
+ * @see QueryOperation
+ * @see ModifyOperation
*/
-@Internal
-public abstract class TableOperation {
-
- /**
- * Resolved schema of this operation.
- */
- public abstract TableSchema getTableSchema();
-
- /**
- * Returns a string that summarizes this operation for printing to a
console. An implementation might
- * skip very specific properties.
- *
- * <p>Use {@link #asSerializableString()} for a operation string that
fully serializes
- * this instance.
- *
- * @return summary string of this operation for debugging purposes
- */
- public abstract String asSummaryString();
-
- /**
- * Returns a string that fully serializes this instance. The serialized
string can be used for storing
- * the query in e.g. a {@link org.apache.flink.table.catalog.Catalog}
as a view.
- *
- * @return detailed string for persisting in a catalog
- */
- public String asSerializableString() {
- throw new UnsupportedOperationException("TableOperations are
not string serializable for now.");
- }
-
- public abstract List<TableOperation> getChildren();
-
- public <T> T accept(TableOperationVisitor<T> visitor) {
- return visitor.visitOther(this);
- }
-
- protected final String formatWithChildren(String operationName,
Map<String, Object> parameters) {
- String description = parameters.entrySet()
- .stream()
- .map(entry -> formatParameter(entry.getKey(),
entry.getValue()))
- .collect(Collectors.joining(", "));
-
- final StringBuilder stringBuilder = new StringBuilder();
-
- stringBuilder.append(operationName).append(":");
-
- if (!StringUtils.isNullOrWhitespaceOnly(description)) {
- stringBuilder.append("
(").append(description).append(")");
- }
-
- String childrenDescription = getChildren().stream()
- .map(child ->
TableOperationUtils.indent(child.asSummaryString()))
- .collect(Collectors.joining());
-
- return stringBuilder.append(childrenDescription).toString();
- }
-
- private String formatParameter(String name, Object value) {
- final StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append(name);
- stringBuilder.append(": ");
- if (value.getClass().isArray()) {
- stringBuilder.append(Arrays.toString((Object[]) value));
- } else if (value instanceof Collection) {
- stringBuilder.append(value);
- } else {
- stringBuilder.append("[").append(value).append("]");
- }
- return stringBuilder.toString();
- }
+@PublicEvolving
+public interface TableOperation {
Review comment:
Shall we rename to `Operation`?
----------------------------------------------------------------
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