morrySnow commented on code in PR #62196:
URL: https://github.com/apache/doris/pull/62196#discussion_r3122016284
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateSqlBlockRuleCommand.java:
##########
@@ -24,7 +24,6 @@
import org.apache.doris.common.FeNameFormat;
import org.apache.doris.common.UserException;
import org.apache.doris.common.util.SqlBlockUtil;
-import org.apache.doris.common.util.Util;
Review Comment:
why remove this import?
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/SqlBlockRuleCommand.java:
##########
@@ -114,6 +120,32 @@ public void run(ConnectContext ctx, StmtExecutor executor)
throws Exception {
public abstract void setProperties(Map<String, String> properties) throws
UserException;
+ protected static boolean getBooleanPropertyOrDefault(Map<String, String>
properties,
+ String propertyName, boolean defaultValue) throws
AnalysisException {
+ if (!properties.containsKey(propertyName)) {
+ return defaultValue;
+ }
+ return parseBooleanProperty(properties.get(propertyName),
propertyName);
+ }
+
+ protected static Boolean getOptionalBooleanProperty(Map<String, String>
properties,
+ String propertyName) throws AnalysisException {
+ if (!properties.containsKey(propertyName)) {
+ return null;
+ }
+ return parseBooleanProperty(properties.get(propertyName),
propertyName);
+ }
+
+ private static boolean parseBooleanProperty(String value, String
propertyName) throws AnalysisException {
+ if ("true".equalsIgnoreCase(value)) {
+ return true;
+ }
+ if ("false".equalsIgnoreCase(value)) {
+ return false;
+ }
+ throw new AnalysisException(propertyName + " should be a boolean");
+ }
Review Comment:
these functions are general function that could be used for any properties,
maybe we already has similar util functions, if not, we should add them into a
general util helper class
##########
fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java:
##########
@@ -290,6 +290,22 @@ public void setSelectedPartitionIds(Collection<Long>
selectedPartitionIds) {
this.selectedPartitionIds = selectedPartitionIds;
}
+ @VisibleForTesting
+ static boolean hasPartitionPredicate(List<Column> partitionColumns,
TupleDescriptor tupleDescriptor,
+ List<Expr> conjuncts, PartitionInfo partitionInfo) {
+ for (Column partitionColumn : partitionColumns) {
+ SlotDescriptor slotDescriptor =
tupleDescriptor.getColumnSlot(partitionColumn.getName());
+ if (slotDescriptor == null) {
+ continue;
+ }
+ if (createPartitionFilter(slotDescriptor, conjuncts,
partitionInfo) != null
+ || createColumnRange(slotDescriptor, conjuncts,
partitionInfo).hasFilter()) {
+ return true;
+ }
+ }
+ return false;
+ }
Review Comment:
should not add logic code here, should be return `hasPartitionPredicate`
directly
##########
fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java:
##########
@@ -290,6 +290,22 @@ public void setSelectedPartitionIds(Collection<Long>
selectedPartitionIds) {
this.selectedPartitionIds = selectedPartitionIds;
}
+ @VisibleForTesting
+ static boolean hasPartitionPredicate(List<Column> partitionColumns,
TupleDescriptor tupleDescriptor,
+ List<Expr> conjuncts, PartitionInfo partitionInfo) {
+ for (Column partitionColumn : partitionColumns) {
+ SlotDescriptor slotDescriptor =
tupleDescriptor.getColumnSlot(partitionColumn.getName());
+ if (slotDescriptor == null) {
+ continue;
+ }
+ if (createPartitionFilter(slotDescriptor, conjuncts,
partitionInfo) != null
+ || createColumnRange(slotDescriptor, conjuncts,
partitionInfo).hasFilter()) {
+ return true;
+ }
+ }
+ return false;
+ }
Review Comment:
should not add logic code here, should return `hasPartitionPredicate`
directly
--
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]