twalthr commented on code in PR #30019:
URL: https://github.com/apache/flink/pull/30019#discussion_r4628084290
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/sql/BuiltInSqlOperator.java:
##########
@@ -20,76 +20,204 @@
import org.apache.flink.annotation.Internal;
import org.apache.flink.table.functions.BuiltInFunctionDefinition;
-import org.apache.flink.table.planner.functions.bridging.BridgingSqlFunction;
+import org.apache.calcite.plan.Strong;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlCallBinding;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperandCountRange;
import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlOperatorBinding;
+import org.apache.calcite.sql.SqlSyntax;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.validate.SqlMonotonicity;
+import org.apache.calcite.sql.validate.SqlValidator;
+import org.apache.calcite.sql.validate.SqlValidatorScope;
+
+import javax.annotation.Nullable;
import java.util.Optional;
+import java.util.function.Supplier;
import static
org.apache.flink.table.functions.BuiltInFunctionDefinition.DEFAULT_VERSION;
import static
org.apache.flink.table.functions.BuiltInFunctionDefinition.qualifyFunctionName;
+import static
org.apache.flink.table.functions.BuiltInFunctionDefinition.validateFunction;
+import static org.apache.flink.util.Preconditions.checkNotNull;
/**
- * SQL version of {@link BuiltInFunctionDefinition} in cases where {@link
BridgingSqlFunction} does
- * not apply. This is the case when the operator has a special parsing syntax
or uses other
- * Calcite-specific features that are not exposed via {@link
BuiltInFunctionDefinition} yet.
+ * A versioned copy of an existing {@link SqlOperator} that cannot be replaced
by a {@link
+ * BuiltInSqlFunction}, for example because Calcite references it directly in
the parser or {@code
+ * RexBuilder}.
+ *
+ * <p>The operator behaves like the wrapped operator during planning. The
latest version only
+ * defines the version of the wrapped operator in {@link
FlinkSqlOperatorTable#VERSIONED_OPERATORS}.
+ * Older versions are registered in {@link FlinkSqlOperatorTable} for
restoring compiled plans and
+ * must be matched on during code generation, see {@link
FlinkSqlOperatorTable#VERSIONED_OPERATORS}
+ * for details.
*
- * <p>If {@link SqlOperator} were an interface, this interface would extend
from it.
+ * <p>The name includes the version (e.g. {@code $ITEM$1}), which makes older
versions accessible
+ * for restoring compiled plans without conflicting with the wrapped operator.
Similar to {@link
+ * BuiltInFunctionDefinition}, older versions should be internal to not expose
them when listing
+ * functions. For internal operators, the version is only part of the name.
*/
@Internal
-public interface BuiltInSqlOperator {
+public final class BuiltInSqlOperator extends SqlOperator implements
VersionedSqlOperator {
Review Comment:
Aggregates will require `SqlAggFunction` and thus we need a
`BuiltInSqlAggFunction`. But that's future work, once we need it we can add it.
--
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]