You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by sh...@apache.org on 2026/02/04 07:06:50 UTC

(iotdb) branch table_disk_usage_statistics_with_cache updated (0076b6b01e7 -> d4d641cda31)

This is an automated email from the ASF dual-hosted git repository.

shuwenwei pushed a change to branch table_disk_usage_statistics_with_cache
in repository https://gitbox.apache.org/repos/asf/iotdb.git


    from 0076b6b01e7 use final
     new eda01feee40 refactor
     new d4d641cda31 fix

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../InformationSchemaContentSupplierFactory.java   |  24 ++-
 .../plan/planner/TableOperatorGenerator.java       |  19 +--
 .../optimizations/PushPredicateIntoTableScan.java  | 165 +++++++++------------
 3 files changed, 96 insertions(+), 112 deletions(-)


(iotdb) 01/02: refactor

Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

shuwenwei pushed a commit to branch table_disk_usage_statistics_with_cache
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit eda01feee40530636cef1c4334916c44d7b68421
Author: shuwenwei <s1...@gmail.com>
AuthorDate: Wed Feb 4 14:51:09 2026 +0800

    refactor
---
 .../optimizations/PushPredicateIntoTableScan.java  | 165 +++++++++------------
 1 file changed, 73 insertions(+), 92 deletions(-)

diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/PushPredicateIntoTableScan.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/PushPredicateIntoTableScan.java
index 6c1a4af4a41..7bd4530afd1 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/PushPredicateIntoTableScan.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/PushPredicateIntoTableScan.java
@@ -453,91 +453,10 @@ public class PushPredicateIntoTableScan implements PlanOptimizer {
         return node;
       }
 
-      // push-down for CURRENT_QUERIES
-      if (CURRENT_QUERIES.equals(node.getQualifiedObjectName().getObjectName())) {
-        SplitExpression splitExpression = splitCurrentQueriesPredicate(context.inheritedPredicate);
-        // exist expressions can push down to scan operator
-        if (!splitExpression.getExpressionsCanPushDown().isEmpty()) {
-          List<Expression> expressions = splitExpression.getExpressionsCanPushDown();
-          checkState(expressions.size() == 1, "Unexpected number of expressions in table scan");
-          node.setPushDownPredicate(expressions.get(0));
-        }
-
-        // exist expressions cannot push down
-        if (!splitExpression.getExpressionsCannotPushDown().isEmpty()) {
-          List<Expression> expressions = splitExpression.getExpressionsCannotPushDown();
-          return new FilterNode(
-              queryId.genPlanNodeId(),
-              node,
-              expressions.size() == 1
-                  ? expressions.get(0)
-                  : new LogicalExpression(LogicalExpression.Operator.AND, expressions));
-        }
-        return node;
-      }
-      // push down for other information schema tables
+      // push down for information schema tables
       return combineFilterAndScan(node, context.inheritedPredicate);
     }
 
-    private SplitExpression splitCurrentQueriesPredicate(Expression predicate) {
-      List<Expression> expressionsCanPushDown = new ArrayList<>();
-      List<Expression> expressionsCannotPushDown = new ArrayList<>();
-
-      if (predicate instanceof LogicalExpression
-          && ((LogicalExpression) predicate).getOperator() == LogicalExpression.Operator.AND) {
-
-        // predicate like state = 'xxx' can be push down
-        // Note: the optimizer CanonicalizeExpressionRewriter will ensure the predicate like 'xxx' =
-        // state will be canonicalized to state = 'xxx'
-        boolean hasExpressionPushDown = false;
-        for (Expression expression : ((LogicalExpression) predicate).getTerms()) {
-          if (isStateComparedWithConstant(expression) && !hasExpressionPushDown) {
-            // if there are more than one state = 'xxx' terms, only add first to push-down candidate
-            expressionsCanPushDown.add(expression);
-            hasExpressionPushDown = true;
-          } else {
-            expressionsCannotPushDown.add(expression);
-          }
-        }
-
-        return new SplitExpression(
-            Collections.emptyList(), expressionsCanPushDown, expressionsCannotPushDown, null);
-      }
-
-      if (isStateComparedWithConstant(predicate)) {
-        expressionsCanPushDown.add(predicate);
-      } else {
-        expressionsCannotPushDown.add(predicate);
-      }
-
-      return new SplitExpression(
-          Collections.emptyList(), expressionsCanPushDown, expressionsCannotPushDown, null);
-    }
-
-    private boolean isStateComparedWithConstant(Expression expression) {
-      if (!(expression instanceof ComparisonExpression)) {
-        return false;
-      }
-
-      ComparisonExpression comparisonExpression = (ComparisonExpression) expression;
-
-      if (ComparisonExpression.Operator.EQUAL != comparisonExpression.getOperator()) {
-        return false;
-      }
-
-      if (!(comparisonExpression.getLeft() instanceof SymbolReference)
-          || !STATE_TABLE_MODEL.equals(
-              ((SymbolReference) comparisonExpression.getLeft()).getName())) {
-        return false;
-      }
-
-      if (!(comparisonExpression.getRight() instanceof StringLiteral)) {
-        return false;
-      }
-
-      return true;
-    }
-
     @Override
     public PlanNode visitDeviceTableScan(
         DeviceTableScanNode tableScanNode, RewriteContext context) {
@@ -555,7 +474,8 @@ public class PushPredicateIntoTableScan implements PlanOptimizer {
     public PlanNode combineFilterAndScan(TableScanNode tableScanNode, Expression predicate) {
       SplitExpression splitExpression =
           tableScanNode instanceof InformationSchemaTableScanNode
-              ? splitPredicate((InformationSchemaTableScanNode) tableScanNode, predicate)
+              ? splitPredicateForInformationSchemaTable(
+                  (InformationSchemaTableScanNode) tableScanNode, predicate)
               : splitPredicate((DeviceTableScanNode) tableScanNode, predicate);
 
       // exist expressions can push down to scan operator
@@ -606,19 +526,81 @@ public class PushPredicateIntoTableScan implements PlanOptimizer {
       return tableScanNode;
     }
 
-    private SplitExpression splitPredicate(
-        InformationSchemaTableScanNode node, Expression predicate) {
-      Set<String> columnsThatSupportPushDownPredicate =
-          InformationSchema.getColumnsSupportPushDownPredicate(
-              node.getQualifiedObjectName().getObjectName());
+    interface InformationSchemaTablePredicatePushDownChecker {
+      boolean canPushDown(Expression expression);
+    }
+
+    private SplitExpression splitPredicateForInformationSchemaTable(
+        InformationSchemaTableScanNode tableScanNode, Expression predicate) {
+      String informationSchemaTable = tableScanNode.getQualifiedObjectName().getObjectName();
+      InformationSchemaTablePredicatePushDownChecker checker;
+      switch (informationSchemaTable) {
+        case CURRENT_QUERIES:
+          checker =
+              new InformationSchemaTablePredicatePushDownChecker() {
+                // predicate like state = 'xxx' can be push down
+                // Note: the optimizer CanonicalizeExpressionRewriter will ensure the predicate like
+                // 'xxx' =
+                // state will be canonicalized to state = 'xxx'
+                boolean hasExpressionPushDown = false;
+
+                @Override
+                public boolean canPushDown(Expression expression) {
+                  if (isStateComparedWithConstant(expression) && !hasExpressionPushDown) {
+                    // if there are more than one state = 'xxx' terms, only add first to push-down
+                    // candidate
+                    hasExpressionPushDown = true;
+                    return true;
+                  }
+                  return false;
+                }
+
+                private boolean isStateComparedWithConstant(Expression expression) {
+                  if (!(expression instanceof ComparisonExpression)) {
+                    return false;
+                  }
+
+                  ComparisonExpression comparisonExpression = (ComparisonExpression) expression;
+
+                  if (ComparisonExpression.Operator.EQUAL != comparisonExpression.getOperator()) {
+                    return false;
+                  }
+
+                  if (!(comparisonExpression.getLeft() instanceof SymbolReference)
+                      || !STATE_TABLE_MODEL.equals(
+                          ((SymbolReference) comparisonExpression.getLeft()).getName())) {
+                    return false;
+                  }
+
+                  return comparisonExpression.getRight() instanceof StringLiteral;
+                }
+              };
+          break;
+        default:
+          checker =
+              new InformationSchemaTablePredicatePushDownChecker() {
+                final Set<String> columnsThatSupportPushDownPredicate =
+                    InformationSchema.getColumnsSupportPushDownPredicate(informationSchemaTable);
+
+                @Override
+                public boolean canPushDown(Expression expression) {
+                  return PredicateCombineIntoTableScanChecker.check(
+                      columnsThatSupportPushDownPredicate, expression);
+                }
+              };
+      }
+      return splitPredicateForInformationSchemaTable(predicate, checker);
+    }
+
+    private SplitExpression splitPredicateForInformationSchemaTable(
+        Expression predicate, InformationSchemaTablePredicatePushDownChecker checker) {
       List<Expression> expressionsCanPushDown = new ArrayList<>();
       List<Expression> expressionsCannotPushDown = new ArrayList<>();
       if (predicate instanceof LogicalExpression
           && ((LogicalExpression) predicate).getOperator() == LogicalExpression.Operator.AND) {
 
         for (Expression expression : ((LogicalExpression) predicate).getTerms()) {
-          if (PredicateCombineIntoTableScanChecker.check(
-              columnsThatSupportPushDownPredicate, expression)) {
+          if (checker.canPushDown(expression)) {
             expressionsCanPushDown.add(expression);
           } else {
             expressionsCannotPushDown.add(expression);
@@ -629,8 +611,7 @@ public class PushPredicateIntoTableScan implements PlanOptimizer {
             Collections.emptyList(), expressionsCanPushDown, expressionsCannotPushDown, null);
       }
 
-      if (PredicateCombineIntoTableScanChecker.check(
-          columnsThatSupportPushDownPredicate, predicate)) {
+      if (checker.canPushDown(predicate)) {
         expressionsCanPushDown.add(predicate);
       } else {
         expressionsCannotPushDown.add(predicate);


(iotdb) 02/02: fix

Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

shuwenwei pushed a commit to branch table_disk_usage_statistics_with_cache
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit d4d641cda311656fcfc3c8c1c7101facb0846805
Author: shuwenwei <s1...@gmail.com>
AuthorDate: Wed Feb 4 15:06:35 2026 +0800

    fix
---
 .../InformationSchemaContentSupplierFactory.java   | 24 ++++++++++++++++++++--
 .../plan/planner/TableOperatorGenerator.java       | 19 +----------------
 2 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/InformationSchemaContentSupplierFactory.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/InformationSchemaContentSupplierFactory.java
index 782f5acc184..aaeabf14401 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/InformationSchemaContentSupplierFactory.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/InformationSchemaContentSupplierFactory.java
@@ -116,6 +116,7 @@ import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -139,6 +140,7 @@ import static org.apache.iotdb.commons.schema.column.ColumnHeaderConstant.NODE_T
 import static org.apache.iotdb.commons.schema.column.ColumnHeaderConstant.NODE_TYPE_CONFIG_NODE;
 import static org.apache.iotdb.commons.schema.column.ColumnHeaderConstant.NODE_TYPE_DATA_NODE;
 import static org.apache.iotdb.commons.schema.table.TsTable.TTL_PROPERTY;
+import static org.apache.iotdb.db.queryengine.plan.analyze.PredicateUtils.convertPredicateToFilter;
 import static org.apache.iotdb.db.queryengine.plan.execution.config.TableConfigTaskVisitor.canShowDB;
 import static org.apache.iotdb.db.queryengine.plan.execution.config.TableConfigTaskVisitor.canShowTable;
 import static org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowFunctionsTask.BINARY_MAP;
@@ -158,8 +160,7 @@ public class InformationSchemaContentSupplierFactory {
       final OperatorContext context,
       final List<TSDataType> dataTypes,
       final UserEntity userEntity,
-      final InformationSchemaTableScanNode node,
-      final Filter pushDownFilter) {
+      final InformationSchemaTableScanNode node) {
     String tableName = node.getQualifiedObjectName().getObjectName();
     try {
       switch (tableName) {
@@ -196,6 +197,25 @@ public class InformationSchemaContentSupplierFactory {
         case InformationSchema.DATA_NODES:
           return new DataNodesSupplier(dataTypes, userEntity);
         case InformationSchema.TABLE_DISK_USAGE:
+          Filter pushDownFilter = null;
+          if (!InformationSchema.getColumnsSupportPushDownPredicate(
+                      node.getQualifiedObjectName().getObjectName())
+                  .isEmpty()
+              && node.getPushDownPredicate() != null) {
+            Map<String, Integer> measurementColumnsIndexMap =
+                new HashMap<>(node.getOutputColumnNames().size());
+            for (int i = 0; i < node.getOutputColumnNames().size(); i++) {
+              measurementColumnsIndexMap.put(node.getOutputColumnNames().get(i), i);
+            }
+            pushDownFilter =
+                convertPredicateToFilter(
+                    node.getPushDownPredicate(),
+                    measurementColumnsIndexMap,
+                    node.getAssignments(),
+                    null,
+                    context.getSessionInfo().getZoneId(),
+                    TimestampPrecisionUtils.currPrecision);
+          }
           return new TableDiskUsageSupplier(
               dataTypes,
               userEntity,
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/TableOperatorGenerator.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/TableOperatorGenerator.java
index ca7e5ad7fb8..63705c78910 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/TableOperatorGenerator.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/TableOperatorGenerator.java
@@ -1310,22 +1310,6 @@ public class TableOperatorGenerator extends PlanVisitor<Operator, LocalExecution
                 node.getPlanNodeId(),
                 InformationSchemaTableScanOperator.class.getSimpleName());
 
-    Filter pushDownFilter = null;
-    if (node.getPushDownPredicate() != null) {
-      Map<String, Integer> measurementColumnsIndexMap =
-          new HashMap<>(node.getOutputColumnNames().size());
-      for (int i = 0; i < node.getOutputColumnNames().size(); i++) {
-        measurementColumnsIndexMap.put(node.getOutputColumnNames().get(i), i);
-      }
-      pushDownFilter =
-          convertPredicateToFilter(
-              node.getPushDownPredicate(),
-              measurementColumnsIndexMap,
-              node.getAssignments(),
-              null,
-              context.getZoneId(),
-              TimestampPrecisionUtils.currPrecision);
-    }
     final List<TSDataType> dataTypes =
         node.getOutputSymbols().stream()
             .map(symbol -> getTSDataType(context.getTypeProvider().getTableModelType(symbol)))
@@ -1342,8 +1326,7 @@ public class TableOperatorGenerator extends PlanVisitor<Operator, LocalExecution
                 .getFragmentInstanceContext()
                 .getSessionInfo()
                 .getUserEntity(),
-            node,
-            pushDownFilter));
+            node));
   }
 
   @Override