morningman commented on a change in pull request #2821: The new materialized view selector URL: https://github.com/apache/incubator-doris/pull/2821#discussion_r383715254
########## File path: fe/src/main/java/org/apache/doris/planner/OlapScanNode.java ########## @@ -130,6 +138,83 @@ public void setForceOpenPreAgg(boolean forceOpenPreAgg) { this.forceOpenPreAgg = forceOpenPreAgg; } + public Collection<Long> getSelectedPartitionIds() { + return selectedPartitionIds; + } + + /** + * This method is mainly used to update scan range info in OlapScanNode by the new materialized selector. + * Situation1: + * If the new scan range is same as the old scan range which determined by the old materialized selector, + * the scan range will not be changed. + * <p> + * Situation2: Scan range is difference. The type of table is duplicated. + * The new scan range is used directly. + * The reason is that the old selector does not support SPJ<->SPJG, so the result of old one must be incorrect. + * <p> + * Situation3: Scan range is difference. The type of table is aggregated. + * The new scan range is different from the old one. + * If the test_materialized_view is set to true, an error will be reported. + * The query will be cancelled. + * <p> + * Situation4: Scan range is difference. The type of table is aggregated. `test_materialized_view` is set to false. + * The result of the old version selector will be selected. Print the warning log + * + * @param selectedIndexId + * @param isPreAggregation + * @param reasonOfDisable + * @throws UserException + */ + public void updateScanRangeInfoByNewMVSelector(long selectedIndexId, boolean isPreAggregation, String + reasonOfDisable) + throws UserException { + if (selectedIndexId == this.selectedIndexId && isPreAggregation == this.isPreAggregation) { + return; + } + StringBuilder stringBuilder = new StringBuilder("The new selected index id ") + .append(selectedIndexId) + .append(", pre aggregation tag ").append(isPreAggregation) + .append(", reason ").append(reasonOfDisable == null ? "null" : reasonOfDisable) + .append(". The old selected index id ").append(this.selectedIndexId) + .append(" pre aggregation tag ").append(this.isPreAggregation) + .append(" reason ").append(this.reasonOfPreAggregation == null ? "null" : this.reasonOfPreAggregation); + String scanRangeInfo = stringBuilder.toString(); + String situation; + boolean update; + CHECK: + { + if (olapTable.getKeysType() == KeysType.DUP_KEYS) { + situation = "The key type of table is duplicate."; + update = true; + break CHECK; + } + if (ConnectContext.get() == null) { + situation = "Connection context is null"; + update = true; + break CHECK; + } + SessionVariable sessionVariable = ConnectContext.get().getSessionVariable(); + if (sessionVariable.getTestMaterializedView()) { + throw new AnalysisException("The old scan range info is different from the new one when " + + "test_materialized_view is true. " + + scanRangeInfo); + } + situation = "The key type of table is aggregated."; + update = false; + break CHECK; + } + + if (update) { + this.selectedIndexId = selectedIndexId; + this.isPreAggregation = isPreAggregation; + this.reasonOfPreAggregation = reasonOfDisable; + computeTabletInfo(); + LOG.info("Using the new scan range info instead of the old one. " + situation + scanRangeInfo); + } else { + LOG.warn("Using the old scan range info instead of the new one. " + situation + scanRangeInfo); Review comment: ```suggestion LOG.warn("Using the old scan range info instead of the new one. {}, {}", situation, scanRangeInfo); ``` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org