dawidwys commented on code in PR #26874:
URL: https://github.com/apache/flink/pull/26874#discussion_r2256893102


##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/FunctionDescriptor.java:
##########
@@ -0,0 +1,444 @@
+/*
+ * 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.api;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.configuration.ConfigOption;
+import org.apache.flink.configuration.ConfigurationUtils;
+import org.apache.flink.table.catalog.CatalogTable;
+import org.apache.flink.table.catalog.TableDistribution;
+import org.apache.flink.table.connector.format.Format;
+import org.apache.flink.table.factories.FactoryUtil;
+import org.apache.flink.table.utils.EncodingUtils;
+import org.apache.flink.util.Preconditions;
+
+import javax.annotation.Nullable;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+/**
+ * Describes a {@link CatalogTable} representing a source or sink.
+ *
+ * <p>A {@link TableDescriptor} is a template for creating a {@link 
CatalogTable} instance. It
+ * closely resembles the "CREATE TABLE" SQL DDL statement, containing schema, 
connector options, and
+ * other characteristics. Since tables in Flink are typically backed by 
external systems, the
+ * descriptor describes how a connector (and possibly its format) are 
configured.
+ *
+ * <p>This can be used to register a table in the Table API, see {@link
+ * TableEnvironment#createTemporaryTable(String, TableDescriptor)}.
+ */
+@PublicEvolving
+public class TableDescriptor {
+
+    private final @Nullable Schema schema;
+    private final Map<String, String> options;
+    private final @Nullable TableDistribution distribution;
+    private final List<String> partitionKeys;
+    private final @Nullable String comment;
+
+    protected TableDescriptor(
+            @Nullable Schema schema,
+            Map<String, String> options,
+            @Nullable TableDistribution distribution,
+            List<String> partitionKeys,
+            @Nullable String comment) {
+        this.schema = schema;
+        this.options = Collections.unmodifiableMap(options);
+        this.distribution = distribution;
+        this.partitionKeys = Collections.unmodifiableList(partitionKeys);
+        this.comment = comment;
+    }
+
+    /**
+     * Creates a new {@link Builder} for a table using the given connector.
+     *
+     * @param connector The factory identifier for the connector.
+     */
+    public static Builder forConnector(String connector) {
+        Preconditions.checkNotNull(connector, "Table descriptors require a 
connector identifier.");
+        final Builder descriptorBuilder = new Builder();
+        descriptorBuilder.option(FactoryUtil.CONNECTOR, connector);
+        return descriptorBuilder;
+    }
+
+    // 
---------------------------------------------------------------------------------------------
+
+    public Optional<Schema> getSchema() {
+        return Optional.ofNullable(schema);
+    }
+
+    public Map<String, String> getOptions() {
+        return options;
+    }
+
+    public Optional<TableDistribution> getDistribution() {
+        return Optional.ofNullable(distribution);
+    }
+
+    public List<String> getPartitionKeys() {
+        return partitionKeys;
+    }
+
+    public Optional<String> getComment() {
+        return Optional.ofNullable(comment);
+    }
+
+    // 
---------------------------------------------------------------------------------------------
+
+    /** Converts this descriptor into a {@link CatalogTable}. */
+    public CatalogTable toCatalogTable() {
+        final Schema schema =
+                getSchema()
+                        .orElseThrow(
+                                () ->
+                                        new ValidationException(
+                                                "Missing schema in 
TableDescriptor. "
+                                                        + "A schema is 
typically required. "
+                                                        + "It can only be 
omitted at certain "
+                                                        + "documented 
locations."));
+
+        return CatalogTable.newBuilder()
+                .schema(schema)
+                .options(getOptions())
+                .distribution(distribution)
+                .partitionKeys(partitionKeys)
+                .comment(getComment().orElse(null))
+                .build();
+    }
+
+    /** Converts this immutable instance into a mutable {@link Builder}. */
+    public Builder toBuilder() {
+        return new Builder(this);
+    }
+
+    // 
---------------------------------------------------------------------------------------------
+
+    @Override
+    public String toString() {
+        final String escapedPartitionKeys =
+                partitionKeys.stream()
+                        .map(EncodingUtils::escapeIdentifier)
+                        .collect(Collectors.joining(", "));
+
+        final String distributedBy = distribution == null ? "" : 
distribution.toString();
+
+        final String partitionedBy =
+                !partitionKeys.isEmpty()
+                        ? String.format("PARTITIONED BY (%s)", 
escapedPartitionKeys)

Review Comment:
   The entire file is a mistake from rebasing.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to