Skip to content

[feature](fe) Add partition filter sql block rule#62196

Open
CalvinKirs wants to merge 6 commits intoapache:masterfrom
CalvinKirs:sql-block
Open

[feature](fe) Add partition filter sql block rule#62196
CalvinKirs wants to merge 6 commits intoapache:masterfrom
CalvinKirs:sql-block

Conversation

@CalvinKirs
Copy link
Copy Markdown
Member

@CalvinKirs CalvinKirs commented Apr 8, 2026

Today SQL_BLOCK_RULE can block SQL by regex/sqlHash or by scan scale thresholds such as
partition_num, tablet_num, and cardinality, but it cannot directly reject queries that
scan a partitioned table without using any partition filter.

This PR adds a new scan-based SQL block rule option: require_partition_filter.

When this option is enabled on a rule, Doris rejects scans on supported partitioned tables if
the query does not contain any usable partition predicate. This helps prevent accidental full
partition scans caused by missing partition filters.

The rule is intended for workloads where partition filters are mandatory for safety or cost
control.

User-visible behavior

Users can now create a SQL block rule like this:

CREATE SQL_BLOCK_RULE require_partition_filter_rule
PROPERTIES(
    "require_partition_filter" = "true",
    "global" = "true",
    "enable" = "true"
);

Or bind it to specific users:

CREATE SQL_BLOCK_RULE require_partition_filter_rule
PROPERTIES(
    "require_partition_filter" = "true",
    "global" = "false",
    "enable" = "true"
);

SET PROPERTY FOR 'test_user' 'sql_block_rules' = 'require_partition_filter_rule';

If a supported partitioned table is scanned without any partition predicate, Doris returns an
error like:

sql hits sql block rule: require_partition_filter_rule, missing partition filter

### Scope

This new rule currently applies to:

- Partitioned internal tables
- Partitioned Hive external tables

This rule does not apply to:

- Non-partitioned internal tables
- Non-partitioned Hive tables
- Iceberg tables
- Other external table types not wired into this rule yet

### Rule semantics

The new property is:

- require_partition_filter = true|false

Behavior:

- The rule only takes effect when require_partition_filter=true
- For supported partitioned tables, the scan is allowed if the query hits any partition column
  in partition pruning predicates
- Filters on non-partition columns do not count
- The rule applies to scan-producing statements, such as:
    - SELECT
    - INSERT INTO ... SELECT ...
- EXPLAIN is not blocked

Examples:

Blocked:

SELECT * FROM part_tbl;
SELECT * FROM part_tbl WHERE non_partition_col = 1;
INSERT INTO dst SELECT * FROM part_tbl;

Allowed:

SELECT * FROM part_tbl WHERE dt = '2026-04-09';
SELECT * FROM part_tbl WHERE dt = '2026-04-09' AND hh = '10';
INSERT INTO dst SELECT * FROM part_tbl WHERE dt = '2026-04-09';

### Compatibility and validation

require_partition_filter is treated as a scan-based SQL block condition.

It can be used together with existing scan-based limits such as:

- partition_num
- tablet_num
- cardinality

It cannot be mixed with text-based block conditions such as:

- sql
- sqlHash

@Thearas
Copy link
Copy Markdown
Contributor

Thearas commented Apr 8, 2026

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@CalvinKirs
Copy link
Copy Markdown
Member Author

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100% (0/0) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 57.38% (21322/37162)
Line Coverage 40.44% (208538/515622)
Region Coverage 36.89% (166455/451226)
Branch Coverage 37.78% (71704/189815)

@CalvinKirs
Copy link
Copy Markdown
Member Author

run cloud_p0

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100% (0/0) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 57.38% (21322/37162)
Line Coverage 40.44% (208538/515622)
Region Coverage 36.89% (166455/451226)
Branch Coverage 37.78% (71704/189815)

@CalvinKirs
Copy link
Copy Markdown
Member Author

/review

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  1. fe/fe-core/src/main/java/org/apache/doris/datasource/hive/source/HiveScanNode.java: require_partition_filter is incorrect for Hive scans planned by the legacy planner. The new signal comes only from selectedPartitions.hasPartitionPredicate, but this file explicitly documents that selectedPartitions is only populated in Nereids, so the legacy planner will always look like it has no partition predicate.
  2. fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java: require_partition_filter can still block EXPLAIN in the Nereids query path, because scan-based block-rule checking runs immediately after planning and before handleQueryStmt() returns early for explain statements.
  3. fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AlterSqlBlockRuleCommand.java: malformed boolean input for require_partition_filter is silently treated as false during ALTER SQL_BLOCK_RULE, unlike CREATE SQL_BLOCK_RULE which validates the property. That can unexpectedly disable the rule instead of rejecting bad input.

Critical Checkpoints

  • Goal / correctness: Partially met. The new field is wired through rule metadata and positive planner paths, but the issues above mean the behavior still does not match the intended contract.
  • Minimal / focused change: Yes.
  • Concurrency: No new concurrency-sensitive logic found.
  • Lifecycle / static initialization: No concerns found.
  • Config changes: None.
  • Compatibility / persistence: Applicable and okay. The new field is serialized and old persisted rules are defaulted to false in gsonPostProcess().
  • Parallel code paths: Not fully covered. Legacy Hive planning and EXPLAIN handling diverge from the intended behavior.
  • Special condition checks: The new planner-mode / explain / boolean-validation conditions are not handled robustly enough.
  • Test coverage: Positive coverage is good, but there is no coverage for legacy-planner Hive scans, malformed ALTER booleans, or a negative EXPLAIN case for require_partition_filter.
  • Observability: No additional observability issues found.
  • Transaction / persistence: Applicable and okay.
  • Data writes / modifications: Not directly involved.
  • FE-BE variable passing: Not applicable.
  • Performance: No obvious new hot-path regression found.
  • Other issues: None beyond the findings above.

}

public boolean hasPartitionPredicate() {
return selectedPartitions != null && selectedPartitions.hasPartitionPredicate;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only works for Nereids. The field comment directly above says selectedPartitions is only populated in Nereids and stays null in the legacy planner, so hasPartitionPredicate() is always false there. With enable_nereids_planner=false, a partitioned Hive query like ... WHERE pt1 = a will still hit missing partition filter even though the scan is pruned correctly.

scanNode.getSelectedSplitNum(),
scanNode.getCardinality(),
isPartitionedTable,
hasPartitionPredicate,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still runs before the Nereids EXPLAIN fast path. In executeByNereids, planner.plan(...) and checkBlockRulesByScan(planner) happen before handleQueryStmt() returns early for queryStmt.isExplain(), so a global require_partition_filter rule can reject EXPLAIN SELECT * FROM partitioned_tbl. That contradicts the PR description and the regression comments that say EXPLAIN must remain allowed.

String cardinalityString = properties.get(SCANNED_CARDINALITY);
String requirePartitionFilterString = properties.get(REQUIRE_PARTITION_FILTER_PROPERTY);
this.requirePartitionFilter = StringUtils.isNotEmpty(requirePartitionFilterString)
? Boolean.parseBoolean(requirePartitionFilterString) : null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean.parseBoolean() silently maps any non-true string to false. That means ALTER SQL_BLOCK_RULE ... PROPERTIES("require_partition_filter" = "not_a_bool") will clear the flag instead of rejecting invalid input. CREATE SQL_BLOCK_RULE already uses Util.getBooleanPropertyOrDefault(...) here, so ALTER should validate the new property the same way.

**/
public SqlBlockRule(String name, String sql, String sqlHash, Long partitionNum, Long tabletNum, Long cardinality,
Boolean global, Boolean enable) {
Boolean global, Boolean enable, Boolean requirePartitionFilter) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add this parameter before Boolean global

String cardinalityString = properties.get(SCANNED_CARDINALITY);
String requirePartitionFilterString = properties.get(REQUIRE_PARTITION_FILTER_PROPERTY);
this.requirePartitionFilter = StringUtils.isNotEmpty(requirePartitionFilterString)
? Boolean.parseBoolean(requirePartitionFilterString) : null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe need more clear error message when Boolean.parseBoolean(requirePartitionFilterString) throw exception

.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)))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use boolean type?

if (partitionSlots == null) {
return false;
}
return !BooleanLiteral.TRUE.equals(PartitionPruneExpressionExtractor.extract(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PartitionPruner will call PartitionPruneExpressionExtractor.extract too. we should let pruner return the info to avoid call it twice for better perfermance

* todo: should be pulled up to base class?
*/
private final boolean partitionPruned;
private final boolean hasPartitionPruningPredicate;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the attribute name should same as the one in LogicalFileScan, or better, you should add the attribute in their common super class

private final long selectedIndexId;
private final ImmutableList<Long> selectedTabletIds;
private final ImmutableList<Long> selectedPartitionIds;
private final boolean hasPartitionPruningPredicate;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another name issue

private final PartitionPruneV2ForShortCircuitPlan cachedPartitionPruner =
new PartitionPruneV2ForShortCircuitPlan();

private boolean hasPartitionPruningPredicate = false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add into ScanNode is better


private PartitionColumnFilter createPartitionFilter(SlotDescriptor desc, List<Expr> conjuncts,
@VisibleForTesting
static boolean hasUsablePartitionPruningPredicate(List<Column> partitionColumns, TupleDescriptor tupleDescriptor,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useless function, remove it

boolean hasPartitionPredicate = false;
if (scanNode instanceof OlapScanNode) {
OlapScanNode olapScanNode = (OlapScanNode) scanNode;
isPartitionedTable = olapScanNode.getOlapTable().isPartitionedTable();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should add a interface isPartitionedTable on ScanNode

Issue Number: None

Related PR: None

Problem Summary: Add a scan-based SQL_BLOCK_RULE option that rejects partitioned internal-table and Hive-table scans without partition predicates when the rule enables require_partition_filter, and expose the new field through SHOW and information_schema with unit and regression coverage.

Add require_partition_filter to SQL_BLOCK_RULE for partitioned internal and Hive table scans.

- Test: FE unit tests and FE checkstyle
    - Regression test not run in this session
- Behavior changed: Yes (configured SQL block rules can now reject partitioned scans without partition filters)
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: apache#62196

Problem Summary: Address morrySnow's review feedback for sql block rule partition-filter handling, scan-node partition predicate exposure, and repeated partition-prune extraction in Nereids.

### Release note

None

### Check List (For Author)

- Test: FE Unit Test
    - ./run-fe-ut.sh --run org.apache.doris.blockrule.SqlBlockRuleMgrTest,org.apache.doris.nereids.trees.plans.commands.SqlBlockRuleCommandTest,org.apache.doris.planner.OlapScanNodeTest,org.apache.doris.datasource.hive.source.HiveScanNodeTest,org.apache.doris.nereids.glue.translator.PhysicalPlanTranslatorTest
- Behavior changed: Yes (stricter boolean property validation, unified partition-predicate exposure on scan nodes)
- Does this need documentation: No
@CalvinKirs
Copy link
Copy Markdown
Member Author

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 53.09% (20179/38008)
Line Coverage 36.68% (190088/518251)
Region Coverage 32.97% (147751/448172)
Branch Coverage 34.09% (64653/189674)

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100% (0/0) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.64% (27409/37222)
Line Coverage 57.30% (296047/516668)
Region Coverage 54.39% (246018/452296)
Branch Coverage 56.16% (106850/190250)

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 57.84% (107/185) 🎉
Increment coverage report
Complete coverage report

### What problem does this PR solve?

Issue Number: None

Related PR: apache#62196

Problem Summary: Fix SHOW SQL_BLOCK_RULE boolean output so JDBC clients can decode RequirePartitionFilter after the column type change to BOOLEAN.

### Release note

None

### Check List (For Author)

- Test: FE Unit Test
    - ./run-fe-ut.sh --run org.apache.doris.blockrule.SqlBlockRuleMgrTest
    - ./run-fe-ut.sh --run org.apache.doris.blockrule.SqlBlockRuleMgrTest,org.apache.doris.nereids.trees.plans.commands.SqlBlockRuleCommandTest
- Behavior changed: Yes (SHOW SQL_BLOCK_RULE now returns 1/0 text for the BOOLEAN RequirePartitionFilter column)
- Does this need documentation: No
@CalvinKirs
Copy link
Copy Markdown
Member Author

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 56.45% (105/186) 🎉
Increment coverage report
Complete coverage report

### What problem does this PR solve?

Issue Number: None

Related PR: apache#62196

Problem Summary: Update OptimizeGetAvailableMvsTest to mock the new PartitionPruner.pruneWithResult API and always clean up materialized views so failed assertions do not leak state into later tests.

### Release note

None

### Check List (For Author)

- Test: FE Unit Test
    - ./run-fe-ut.sh --run org.apache.doris.nereids.mv.OptimizeGetAvailableMvsTest
- Behavior changed: No
- Does this need documentation: No
@CalvinKirs
Copy link
Copy Markdown
Member Author

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 61.66% (119/193) 🎉
Increment coverage report
Complete coverage report

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100% (0/0) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.72% (27438/37217)
Line Coverage 57.35% (296312/516672)
Region Coverage 54.59% (246915/452331)
Branch Coverage 56.28% (107075/190266)

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 63.98% (119/186) 🎉
Increment coverage report
Complete coverage report

@CalvinKirs CalvinKirs closed this Apr 22, 2026
@CalvinKirs CalvinKirs reopened this Apr 22, 2026
@morrySnow
Copy link
Copy Markdown
Contributor

/review

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking findings:

  1. StmtExecutor.checkBlockRulesByScan() now applies require_partition_filter to every FileScanNode, but only Hive/Hudi populate hasPartitionPredicate(). Partitioned Iceberg/Paimon/MaxCompute scans are rejected even with partition filters.
  2. PruneOlapScanPartition still marks explicit TABLET(...) scans as missing partition filters.
  3. PruneOlapScanPartition still marks explicit PARTITION(...) scans as missing partition filters.
  4. PartitionPruner.pruneWithResult() records hasPartitionPredicate too early, so Nereids can satisfy the rule with predicates like p IS NOT NULL that do not actually prune partitions.
  5. information_schema.sql_block_rule_status adds a new FE/BE schema-table column without mixed-version compatibility, so old/new FE-BE combinations can fail with col size not equal during rolling upgrade.

Critical checkpoints:

  • Goal and proof: Partially achieved. The PR wires the new rule, show output, schema-table output, and tests, but the blocking cases above mean it does not yet correctly enforce the intended semantics across supported query shapes and deployment modes. Current tests only cover happy paths.
  • Small and focused: Mostly focused, but the StmtExecutor change unintentionally broadens enforcement from Hive-only to all FileScanNode implementations.
  • Concurrency: No new concurrency or lock-order issue identified.
  • Lifecycle / static init: No special lifecycle or static-initialization issue identified.
  • Configuration: No new config item added.
  • Compatibility: Not safe for rolling upgrade because the schema-table RPC row width changed without backward-compatible handling.
  • Parallel code paths: Not handled consistently. Legacy planner and Nereids now disagree on what counts as a usable partition predicate, and external scan implementations are not wired uniformly.
  • Special conditions: The new hasPartitionPredicate signal is too broad for some Nereids predicates and too narrow for explicit PARTITION(...) / TABLET(...) restrictions.
  • Test coverage: Missing regression/UT coverage for Iceberg/Paimon/MaxCompute, explicit PARTITION(...), explicit TABLET(...), and non-pruning predicates such as IS NOT NULL. The new tests look reasonable for happy paths but do not cover these blockers.
  • Persist / replay: The new requirePartitionFilter field itself appears correctly persisted and defaulted via Gson post-processing.
  • Observability: No additional observability requirement identified.

scanNode.getSelectedPartitionNum(),
scanNode.getSelectedSplitNum(),
scanNode.getCardinality(),
scanNode.isPartitionedTable(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This widens require_partition_filter from the old Hive-only path to every FileScanNode, but the new generic ScanNode.hasPartitionPredicate() flag is only populated for Hive/Hudi. IcebergScanNode, PaimonScanNode, and MaxComputeScanNode still leave it at the default false, while isPartitionedTable() is true for partitioned tables. With a rule like require_partition_filter=true, queries such as SELECT * FROM iceberg_pt WHERE ds = '2026-04-09' will now be rejected as missing partition filter, which both breaks valid queries and contradicts the PR's documented scope (Iceberg / other unwired external tables should not be covered yet).

LogicalFilter filter,
MatchingContext ctx) {
Set<String> partitionColumnNameSet = Utils.execWithReturnVal(table::getPartitionColumnNames);
if (partitionColumnNameSet.isEmpty()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the query is restricted only by TABLET(...), this branch feeds hasPartitionPredicate=false into prunePartitionByTabletIds(), so the final scan still looks like it has missing partition filter. With require_partition_filter=true, SELECT * FROM part_tbl TABLET(12345) gets blocked even though the scan is already narrower than any partition predicate. This query shape needs to satisfy the rule, or be exempted before the generic block-rule check.

partitionSlots, filter.getPredicate(), idToPartitions, ctx.cascadesContext,
PartitionTableType.OLAP, sortedPartitionRanges);
return prunedPartitions;
} else if (!manuallySpecifiedPartitions.isEmpty()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This marks explicit PARTITION(...) selection as hasPartitionPredicate=false. That means SELECT * FROM part_tbl PARTITION(p20260409) is rejected as missing partition filter under require_partition_filter=true, even though the query already names the only partition(s) it is allowed to scan. The rule is supposed to prevent accidental full partition scans, so explicit partition selection should not be treated the same as an unrestricted scan.

List<Slot> partitionSlots,
Expression partitionPredicate,
Map<K, PartitionItem> idToPartitions, CascadesContext cascadesContext,
PartitionTableType partitionTableType, Optional<SortedPartitionRanges<K>> sortedPartitionRanges) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flag is recorded before we know whether the extracted partition expression is actually usable for pruning. Any evaluable predicate on the partition slot will count here, even if it prunes nothing. For example, on a normal range-partitioned table WHERE p IS NOT NULL leaves hasPartitionPredicate=true, so require_partition_filter is satisfied even though the scan still reads every partition. The old OlapScanNode.hasPartitionPredicate() helper only treated predicates that createPartitionFilter() / createColumnRange() could really use for pruning as valid, so this creates a Nereids-only bypass.

{"CARDINALITY", TYPE_BIGINT, sizeof(int64_t), true},
{"GLOBAL", TYPE_BOOLEAN, sizeof(bool), true},
{"ENABLE", TYPE_BOOLEAN, sizeof(bool), true},
{"REQUIRE_PARTITION_FILTER", TYPE_BOOLEAN, sizeof(bool), true},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a new schema-table column here changes the FE<->BE row width from 12 cells to 13, but _get_sql_block_rule_status_block_from_fe() still hard-fails on any size mismatch. During a rolling upgrade, an old FE will still return 12 cells and a new FE will return 13 cells, so SELECT * FROM information_schema.sql_block_rule_status can fail with col size not equal as soon as FE/BE versions are mixed. We need a compatibility path here (for example, tolerate missing/extra trailing REQUIRE_PARTITION_FILTER and fill false for older peers) before extending this RPC schema.

@@ -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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove this import?

Comment on lines +123 to +147
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");
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

}
}
return false;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not add logic code here, should be return hasPartitionPredicate directly

}
}
return false;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not add logic code here, should return hasPartitionPredicate directly

### What problem does this PR solve?

Issue Number: None

Related PR: apache#62196

Problem Summary: Fix the sql block rule follow-up review items, including partition-filter enforcement propagation, effective partition-pruning detection, rolling-upgrade compatibility for sql_block_rule_status, and prepared-statement boolean result handling. Also add regression and unit-test coverage for the new behavior.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - ./run-fe-ut.sh --run org.apache.doris.blockrule.SqlBlockRuleMgrTest,org.apache.doris.nereids.trees.plans.commands.SqlBlockRuleCommandTest,org.apache.doris.planner.OlapScanNodeTest,org.apache.doris.nereids.rules.rewrite.PartitionPrunerTest,org.apache.doris.nereids.glue.translator.PhysicalPlanTranslatorTest
    - ./run-fe-ut.sh --run org.apache.doris.qe.StmtExecutorTest,org.apache.doris.blockrule.SqlBlockRuleMgrTest,org.apache.doris.nereids.trees.plans.commands.SqlBlockRuleCommandTest
- Test: Regression test / Added case, not run locally against a rebuilt FE service because no usable local service was available
- Behavior changed: Yes (sql block rule partition-filter checks, SHOW output handling, and upgrade compatibility)
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: apache#62196

Problem Summary: Fix the remaining java checkstyle and clang-format issues introduced in the sql block rule review follow-up changes.

### Release note

None

### Check List (For Author)

- Test: Java checkstyle and clang-format check
    - Unit Test / Manual test
- Behavior changed: No
- Does this need documentation: No
@CalvinKirs
Copy link
Copy Markdown
Member Author

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 57.14% (112/196) 🎉
Increment coverage report
Complete coverage report

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 61.11% (11/18) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.55% (27514/37407)
Line Coverage 57.33% (297508/518954)
Region Coverage 54.47% (247370/454111)
Branch Coverage 56.10% (107144/190983)

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 48.26% (125/259) 🎉
Increment coverage report
Complete coverage report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants