+ * Modification point: + *
select a+b as c, d as e from t. The
+ * output column c has two origins (a and b), both of them derived. The
+ * output column d as one origin (c), which is not derived.
+ *
+ * @return false if value taken directly from column in origin table; true
+ * otherwise
+ */
+ public boolean isDerived() {
+ return isDerived;
+ }
+
+ public String getTransform() {
+ return transform;
+ }
+
+ // TODO: ------------ end:二次开发代码 --------------- //
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof RelColumnOrigin)) {
+ return false;
+ }
+ RelColumnOrigin other = (RelColumnOrigin) obj;
+ return originTable.getQualifiedName().equals(
+ other.originTable.getQualifiedName())
+ && (iOriginColumn == other.iOriginColumn)
+ && (isDerived == other.isDerived);
+ }
+
+ @Override
+ public int hashCode() {
+ return originTable.getQualifiedName().hashCode()
+ + iOriginColumn + (isDerived ? 313 : 0);
+ }
+}
diff --git a/fire-enhance/apache-flink/src/main/java-flink-1.12/org/apache/calcite/rel/metadata/RelMdColumnOrigins.java b/fire-enhance/apache-flink/src/main/java-flink-1.12/org/apache/calcite/rel/metadata/RelMdColumnOrigins.java
new file mode 100644
index 0000000000000000000000000000000000000000..9bab76613baddf577657d8720dec7dddd80f94e8
--- /dev/null
+++ b/fire-enhance/apache-flink/src/main/java-flink-1.12/org/apache/calcite/rel/metadata/RelMdColumnOrigins.java
@@ -0,0 +1,523 @@
+/*
+ *
+ * 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.calcite.rel.metadata;
+
+import org.apache.calcite.plan.RelOptTable;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.SingleRel;
+import org.apache.calcite.rel.core.*;
+import org.apache.calcite.rel.type.RelDataTypeField;
+import org.apache.calcite.rex.*;
+import org.apache.calcite.util.BuiltInMethod;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.*;
+import java.util.function.Function;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+/**
+ * Modified based on calcite's source code org.apache.calcite.rel.metadata.RelMdColumnOrigins
+ *
+ * Modification point: + *
+ * Modification point: + *
select a+b as c, d as e from t. The
+ * output column c has two origins (a and b), both of them derived. The
+ * output column d as one origin (c), which is not derived.
+ *
+ * @return false if value taken directly from column in origin table; true
+ * otherwise
+ */
+ public boolean isDerived() {
+ return isDerived;
+ }
+
+ public String getTransform() {
+ return transform;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof RelColumnOrigin)) {
+ return false;
+ }
+ RelColumnOrigin other = (RelColumnOrigin) obj;
+ return originTable.getQualifiedName().equals(
+ other.originTable.getQualifiedName())
+ && (iOriginColumn == other.iOriginColumn)
+ && (isDerived == other.isDerived);
+ }
+
+ @Override
+ public int hashCode() {
+ return originTable.getQualifiedName().hashCode()
+ + iOriginColumn + (isDerived ? 313 : 0);
+ }
+}
diff --git a/fire-enhance/apache-flink/src/main/java-flink-1.13/org/apache/calcite/rel/metadata/RelMdColumnOrigins.java b/fire-enhance/apache-flink/src/main/java-flink-1.13/org/apache/calcite/rel/metadata/RelMdColumnOrigins.java
new file mode 100644
index 0000000000000000000000000000000000000000..02452e5842089b0967ad0e53bc321336cfe3c74c
--- /dev/null
+++ b/fire-enhance/apache-flink/src/main/java-flink-1.13/org/apache/calcite/rel/metadata/RelMdColumnOrigins.java
@@ -0,0 +1,522 @@
+/*
+ *
+ * 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.calcite.rel.metadata;
+
+import org.apache.calcite.plan.RelOptTable;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.SingleRel;
+import org.apache.calcite.rel.core.*;
+import org.apache.calcite.rel.type.RelDataTypeField;
+import org.apache.calcite.rex.*;
+import org.apache.calcite.util.BuiltInMethod;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.*;
+import java.util.function.Function;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+/**
+ * Modified based on calcite's source code org.apache.calcite.rel.metadata.RelMdColumnOrigins
+ *
+ * Modification point: + *
SqlSelect is a node of a parse tree which represents a select statement. It
+ * warrants its own node type just because we have a lot of methods to put somewhere.
+ *
+ * @description: Modify the value method of where to addCondition() to support row-level permission
+ * filtering
+ * @author: baisong
+ * @version: 1.0.0
+ * @date: 2022/12/14 12:24 PM
+ */
+public class SqlSelect extends SqlCall {
+
+ private static final Logger LOG = LoggerFactory.getLogger(SqlSelect.class);
+
+ public static final int FROM_OPERAND = 2;
+ public static final int WHERE_OPERAND = 3;
+ public static final int HAVING_OPERAND = 5;
+
+ SqlNodeList keywordList;
+ SqlNodeList selectList;
+ SqlNode from;
+ SqlNode where;
+ SqlNodeList groupBy;
+ SqlNode having;
+ SqlNodeList windowDecls;
+ SqlNodeList orderBy;
+ SqlNode offset;
+ SqlNode fetch;
+ SqlNodeList hints;
+
+ public SqlSelect(SqlParserPos pos,
+ SqlNodeList keywordList,
+ SqlNodeList selectList,
+ SqlNode from,
+ SqlNode where,
+ SqlNodeList groupBy,
+ SqlNode having,
+ SqlNodeList windowDecls,
+ SqlNodeList orderBy,
+ SqlNode offset,
+ SqlNode fetch,
+ SqlNodeList hints) {
+ super(pos);
+ this.keywordList = Objects.requireNonNull(keywordList != null
+ ? keywordList
+ : new SqlNodeList(pos));
+ this.selectList = selectList;
+ this.from = from;
+ this.groupBy = groupBy;
+ this.having = having;
+ this.windowDecls = Objects.requireNonNull(windowDecls != null
+ ? windowDecls
+ : new SqlNodeList(pos));
+ this.orderBy = orderBy;
+ this.offset = offset;
+ this.fetch = fetch;
+ this.hints = hints;
+
+ // add row level filter condition for where clause
+// this.where = addCondition(from, where, false);
+ }
+
+ /**
+ * The main process of controlling row-level permissions
+ */
+/* private SqlNode addCondition(SqlNode from, SqlNode where, boolean fromJoin) {
+ if (from instanceof SqlIdentifier) {
+ String tableName = from.toString();
+ // the table name is used as an alias for join
+ String tableAlias = fromJoin ? tableName : null;
+ return addPermission(where, tableName, tableAlias);
+ } else if (from instanceof SqlJoin) {
+ SqlJoin sqlJoin = (SqlJoin) from;
+ // support recursive processing, such as join for three tables, process left sqlNode
+ where = addCondition(sqlJoin.getLeft(), where, true);
+ // process right sqlNode
+ return addCondition(sqlJoin.getRight(), where, true);
+ } else if (from instanceof SqlBasicCall) {
+ // Table has an alias or comes from a subquery
+ SqlNode[] tableNodes = ((SqlBasicCall) from).getOperands();
+ *//**
+ * If there is a subquery in the Join, row-level filtering has been appended to the subquery.
+ * What is returned here is the SqlSelect type, just return the original where directly
+ *//*
+ if (!(tableNodes[0] instanceof SqlIdentifier)) {
+ return where;
+ }
+ String tableName = tableNodes[0].toString();
+ String tableAlias = tableNodes[1].toString();
+ return addPermission(where, tableName, tableAlias);
+ }
+ return where;
+ }*/
+
+ /**
+ * Add row-level filtering based on user-configured permission points
+ */
+/* private SqlNode addPermission(SqlNode where, String tableName, String tableAlias) {
+ SqlBasicCall permissions = null;
+ ConcurrentHashMap+ * Modification point: + *
select a+b as c, d as e from t. The
+ * output column c has two origins (a and b), both of them derived. The
+ * output column d as one origin (c), which is not derived.
+ *
+ * @return false if value taken directly from column in origin table; true
+ * otherwise
+ */
+ public boolean isDerived() {
+ return isDerived;
+ }
+
+ public String getTransform() {
+ return transform;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof RelColumnOrigin)) {
+ return false;
+ }
+ RelColumnOrigin other = (RelColumnOrigin) obj;
+ return originTable.getQualifiedName().equals(
+ other.originTable.getQualifiedName())
+ && (iOriginColumn == other.iOriginColumn)
+ && (isDerived == other.isDerived);
+ }
+
+ @Override
+ public int hashCode() {
+ return originTable.getQualifiedName().hashCode()
+ + iOriginColumn + (isDerived ? 313 : 0);
+ }
+}
diff --git a/fire-enhance/apache-flink/src/main/java-flink-1.14/org/apache/calcite/rel/metadata/RelMdColumnOrigins.java b/fire-enhance/apache-flink/src/main/java-flink-1.14/org/apache/calcite/rel/metadata/RelMdColumnOrigins.java
new file mode 100644
index 0000000000000000000000000000000000000000..e0576893739240d2eea1b713f3b482baca33a11d
--- /dev/null
+++ b/fire-enhance/apache-flink/src/main/java-flink-1.14/org/apache/calcite/rel/metadata/RelMdColumnOrigins.java
@@ -0,0 +1,550 @@
+/*
+ * 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.calcite.rel.metadata;
+
+import org.apache.calcite.plan.RelOptTable;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.SingleRel;
+import org.apache.calcite.rel.core.*;
+import org.apache.calcite.rel.type.RelDataTypeField;
+import org.apache.calcite.rex.*;
+import org.apache.calcite.util.BuiltInMethod;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.*;
+import java.util.function.Function;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import static com.zto.fire.common.util.Constant.DELIMITER;
+import static com.zto.fire.common.util.Constant.INITIAL_CAPACITY;
+
+
+/**
+ * Modified based on calcite's source code org.apache.calcite.rel.metadata.RelMdColumnOrigins
+ *
+ * Modification point: + *
+ * for example: ROW_NUMBER() OVER (PARTITION BY $0 ORDER BY $3 DESC NULLS LAST),
+ * The order of inputSet is $3, $0, instead of $0, $3 obtained by traversing the above string normally
+ */
+ private Map