morrySnow commented on code in PR #62196:
URL: https://github.com/apache/doris/pull/62196#discussion_r3083929867
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowSqlBlockRuleCommand.java:
##########
@@ -49,6 +49,7 @@ public class ShowSqlBlockRuleCommand extends ShowCommand {
.addColumn(new Column("Cardinality",
ScalarType.createVarchar(20)))
.addColumn(new Column("Global",
ScalarType.createVarchar(4)))
.addColumn(new Column("Enable",
ScalarType.createVarchar(4)))
+ .addColumn(new Column("RequirePartitionFilter",
ScalarType.createVarchar(5)))
Review Comment:
why not use boolean type?
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PruneOlapScanPartition.java:
##########
@@ -174,6 +164,41 @@ private Pair<List<Long>, Optional<Expression>>
prunePartitionByFilters(LogicalOl
}
}
+ private boolean hasPartitionPredicate(LogicalOlapScan scan, OlapTable
table,
+ LogicalFilter filter, MatchingContext ctx) {
+ if (filter == null) {
+ return false;
+ }
+ List<Slot> partitionSlots = getPartitionSlots(scan, table);
+ if (partitionSlots == null) {
+ return false;
+ }
+ return
!BooleanLiteral.TRUE.equals(PartitionPruneExpressionExtractor.extract(
Review Comment:
PartitionPruner will call `PartitionPruneExpressionExtractor.extract` too.
we should let pruner return the info to avoid call it twice for better
perfermance
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AlterSqlBlockRuleCommand.java:
##########
@@ -70,10 +70,14 @@ public void setProperties(Map<String, String> properties)
throws AnalysisExcepti
String partitionNumString = properties.get(SCANNED_PARTITION_NUM);
String tabletNumString = properties.get(SCANNED_TABLET_NUM);
String cardinalityString = properties.get(SCANNED_CARDINALITY);
+ String requirePartitionFilterString =
properties.get(REQUIRE_PARTITION_FILTER_PROPERTY);
+ this.requirePartitionFilter =
StringUtils.isNotEmpty(requirePartitionFilterString)
+ ? Boolean.parseBoolean(requirePartitionFilterString) : null;
Review Comment:
maybe need more clear error message when
`Boolean.parseBoolean(requirePartitionFilterString)` throw exception
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalOlapScan.java:
##########
@@ -62,6 +62,7 @@ public class PhysicalOlapScan extends PhysicalCatalogRelation
implements OlapSca
private final long selectedIndexId;
private final ImmutableList<Long> selectedTabletIds;
private final ImmutableList<Long> selectedPartitionIds;
+ private final boolean hasPartitionPruningPredicate;
Review Comment:
another name issue
##########
fe/fe-core/src/main/java/org/apache/doris/planner/ScanNode.java:
##########
@@ -339,7 +340,23 @@ public static ColumnRanges expressionToRanges(Expr expr,
}
}
- private PartitionColumnFilter createPartitionFilter(SlotDescriptor desc,
List<Expr> conjuncts,
+ @VisibleForTesting
+ static boolean hasUsablePartitionPruningPredicate(List<Column>
partitionColumns, TupleDescriptor tupleDescriptor,
Review Comment:
useless function, remove it
##########
fe/fe-core/src/main/java/org/apache/doris/blockrule/SqlBlockRule.java:
##########
@@ -83,7 +87,7 @@ public class SqlBlockRule implements Writable,
GsonPostProcessable {
* Create SqlBlockRule.
**/
public SqlBlockRule(String name, String sql, String sqlHash, Long
partitionNum, Long tabletNum, Long cardinality,
- Boolean global, Boolean enable) {
+ Boolean global, Boolean enable, Boolean requirePartitionFilter) {
Review Comment:
add this parameter before `Boolean global`
##########
fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java:
##########
@@ -666,10 +665,23 @@ public void checkBlockRulesByScan(Planner planner) throws
AnalysisException {
List<ScanNode> scanNodeList = planner.getScanNodes();
for (ScanNode scanNode : scanNodeList) {
if (scanNode instanceof OlapScanNode || scanNode instanceof
FileScanNode) {
+ boolean isPartitionedTable = false;
+ boolean hasPartitionPredicate = false;
+ if (scanNode instanceof OlapScanNode) {
+ OlapScanNode olapScanNode = (OlapScanNode) scanNode;
+ isPartitionedTable =
olapScanNode.getOlapTable().isPartitionedTable();
Review Comment:
should add a interface `isPartitionedTable` on ScanNode
##########
fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java:
##########
@@ -198,6 +198,8 @@ public class OlapScanNode extends ScanNode {
private final PartitionPruneV2ForShortCircuitPlan cachedPartitionPruner =
new PartitionPruneV2ForShortCircuitPlan();
+ private boolean hasPartitionPruningPredicate = false;
Review Comment:
add into ScanNode is better
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java:
##########
@@ -136,6 +136,7 @@ public class LogicalOlapScan extends LogicalCatalogRelation
implements OlapScan,
* todo: should be pulled up to base class?
*/
private final boolean partitionPruned;
+ private final boolean hasPartitionPruningPredicate;
Review Comment:
the attribute name should same as the one in LogicalFileScan, or better, you
should add the attribute in their common super class
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]