diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AggScalarSubQueryToWindowFunction.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AggScalarSubQueryToWindowFunction.java index dd9fa09843693f..71252f1b5d1455 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AggScalarSubQueryToWindowFunction.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AggScalarSubQueryToWindowFunction.java @@ -18,6 +18,7 @@ package org.apache.doris.nereids.rules.rewrite; import org.apache.doris.nereids.jobs.JobContext; +import org.apache.doris.nereids.properties.DataTrait; import org.apache.doris.nereids.trees.expressions.Alias; import org.apache.doris.nereids.trees.expressions.ComparisonPredicate; import org.apache.doris.nereids.trees.expressions.ExprId; @@ -26,11 +27,12 @@ import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.expressions.SlotReference; import org.apache.doris.nereids.trees.expressions.WindowExpression; +import org.apache.doris.nereids.trees.expressions.functions.NoneMovableFunction; import org.apache.doris.nereids.trees.expressions.functions.agg.AggregateFunction; import org.apache.doris.nereids.trees.expressions.functions.agg.NullableAggregateFunction; import org.apache.doris.nereids.trees.expressions.functions.window.SupportWindowAnalytic; -import org.apache.doris.nereids.trees.expressions.literal.Literal; import org.apache.doris.nereids.trees.expressions.visitor.DefaultExpressionVisitor; +import org.apache.doris.nereids.trees.plans.JoinType; import org.apache.doris.nereids.trees.plans.Plan; import org.apache.doris.nereids.trees.plans.algebra.CatalogRelation; import org.apache.doris.nereids.trees.plans.algebra.Filter; @@ -38,9 +40,11 @@ import org.apache.doris.nereids.trees.plans.logical.LogicalApply; import org.apache.doris.nereids.trees.plans.logical.LogicalFilter; import org.apache.doris.nereids.trees.plans.logical.LogicalJoin; +import org.apache.doris.nereids.trees.plans.logical.LogicalOlapScan; import org.apache.doris.nereids.trees.plans.logical.LogicalPlan; import org.apache.doris.nereids.trees.plans.logical.LogicalProject; import org.apache.doris.nereids.trees.plans.logical.LogicalRelation; +import org.apache.doris.nereids.trees.plans.logical.LogicalSubQueryAlias; import org.apache.doris.nereids.trees.plans.logical.LogicalWindow; import org.apache.doris.nereids.trees.plans.visitor.CustomRewriter; import org.apache.doris.nereids.trees.plans.visitor.DefaultPlanRewriter; @@ -60,6 +64,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -79,8 +84,10 @@ public class AggScalarSubQueryToWindowFunction extends DefaultPlanRewriter> OUTER_SUPPORTED_PLAN = ImmutableSet.of( LogicalJoin.class, + LogicalFilter.class, LogicalProject.class, - LogicalRelation.class + LogicalRelation.class, + LogicalSubQueryAlias.class ); private static final Set> INNER_SUPPORTED_PLAN = ImmutableSet.of( @@ -88,13 +95,22 @@ public class AggScalarSubQueryToWindowFunction extends DefaultPlanRewriter outerPlans = Lists.newArrayList(); private final List innerPlans = Lists.newArrayList(); private final List functions = Lists.newArrayList(); private final Map innerOuterSlotMap = Maps.newHashMap(); + // Outer conjuncts that were matched against inner subquery filter conjuncts + // by checkFilter(). These must stay BELOW the window because they are part + // of the inner aggregate's filter, not extra outer-only predicates. + private final Set matchedInnerFilterConjuncts = Sets.newHashSet(); + // The sole table that appears in the outer plan but not the inner plan. + // Identified by checkRelation() and reused by checkUniqueCorrelatedTable() + // and rewrite(). + private CatalogRelation outerOnlyTable = null; /** * the entrance of this rule. we only override one visitor: visitLogicalFilter @@ -130,6 +146,16 @@ private Optional> findApply(LogicalFilter outerFilter, LogicalApply apply) { + // Clear per-candidate state: the same rule instance visits every + // LogicalFilter in one rewriteRoot() call, and earlier rejected + // candidates must not leak into later ones. + outerPlans.clear(); + innerPlans.clear(); + functions.clear(); + innerOuterSlotMap.clear(); + matchedInnerFilterConjuncts.clear(); + outerOnlyTable = null; + outerPlans.addAll(apply.child(0).collect(LogicalPlan.class::isInstance)); innerPlans.addAll(apply.child(1).collect(LogicalPlan.class::isInstance)); @@ -139,13 +165,23 @@ && checkAggregate() && checkJoin() && checkProject() && checkRelation(apply.getCorrelationSlot()) - && checkFilter(outerFilter); + && checkFilter(outerFilter) + && checkUniqueCorrelatedTable(apply.getCorrelationSlot()); } // check children's nodes because query process will be changed private boolean checkPlanType() { return outerPlans.stream().allMatch(p -> OUTER_SUPPORTED_PLAN.stream().anyMatch(c -> c.isInstance(p))) - && innerPlans.stream().allMatch(p -> INNER_SUPPORTED_PLAN.stream().anyMatch(c -> c.isInstance(p))); + && innerPlans.stream().allMatch(p -> INNER_SUPPORTED_PLAN.stream().anyMatch(c -> c.isInstance(p))) + // Reject non-catalog LogicalRelation leaves (TVF, file scans, + // etc.). These relations are invisible to checkRelation() and + // isSameScanDomain(), which only inspect CatalogRelation, so + // their row-domain properties cannot be compared between outer + // and inner plans. + && outerPlans.stream().noneMatch( + p -> p instanceof LogicalRelation && !(p instanceof CatalogRelation)) + && innerPlans.stream().noneMatch( + p -> p instanceof LogicalRelation && !(p instanceof CatalogRelation)); } /** @@ -180,21 +216,53 @@ private boolean checkAggregate() { if (functions.size() != 1) { return false; } - return functions.stream().allMatch(f -> f instanceof SupportWindowAnalytic && !f.isDistinct()); + if (!functions.stream().allMatch(f -> f instanceof SupportWindowAnalytic && !f.isDistinct())) { + return false; + } + // Reject aggregates whose COMPLETE output expression contains + // volatile or NoneMovableFunction anywhere. This covers BOTH: + // 1. unsafe aggregate arguments — COUNT(assert_true(...)) + // 2. unsafe wrappers around the aggregate output — + // assert_true(SUM(...) > 0) AS scalar_flag + // A check limited to the collected AggregateFunction misses case 2, + // where the unsafe call is an ANCESTOR of the aggregate in the output + // expression tree. rewrite() inlines the complete aggOut.child(0) + // into the top comparison and pushes some outer predicates below the + // window, changing which rows reach the side-effecting function and + // potentially suppressing expected errors. + return aggOp.getOutputExpressions().stream().allMatch( + ne -> !ne.containsVolatileExpression() + && !ne.containsType(NoneMovableFunction.class)); } /** - * check inner scope only have one filter. and inner filter is a sub collection of outer filter + * check inner filter conjuncts are a sub collection of outer filter. + * Also records which outer conjuncts were matched against inner conjuncts so that rewrite() + * can force them below the window — they are part of the inner aggregate's filter, not extra + * outer-only predicates. + *

+ * PushDownFilterThroughProject can split a single LogicalFilter into multiple filters + * (correlated predicates that reference slots not in a project's output stay above, + * while non-correlated predicates can be pushed below). We collect conjuncts from ALL + * inner filters rather than requiring exactly one. */ private boolean checkFilter(LogicalFilter outerFilter) { List> innerFilters = innerPlans.stream() .filter(LogicalFilter.class::isInstance) .map(p -> (LogicalFilter) p).collect(Collectors.toList()); - if (innerFilters.size() != 1) { + matchedInnerFilterConjuncts.clear(); + // An inner plan with zero filters cannot prove its shape + // through checkFilter — reject early to avoid bypassing the + // relation/identity/uniqueness proofs that depend on filter + // conjunct matching. + if (innerFilters.isEmpty()) { return false; } Set outerConjunctSet = Sets.newHashSet(outerFilter.getConjuncts()); - Set innerConjunctSet = innerFilters.get(0).getConjuncts().stream() + // Collect conjuncts from ALL inner filter nodes — PushDownFilterThroughProject + // may split correlated and non-correlated predicates into separate filters. + Set innerConjunctSet = innerFilters.stream() + .flatMap(f -> f.getConjuncts().stream()) .map(e -> ExpressionUtils.replace(e, innerOuterSlotMap)) .collect(Collectors.toSet()); Iterator innerIterator = innerConjunctSet.iterator(); @@ -205,8 +273,24 @@ private boolean checkFilter(LogicalFilter outerFilter) { while (outerIterator.hasNext()) { Expression outerExpr = outerIterator.next(); if (ExpressionIdenticalChecker.INSTANCE.check(innerExpr, outerExpr)) { + // Volatile and NoneMovableFunction predicates must never + // be matched as inner-filter conjuncts: two syntactically + // identical calls are independent evaluations. + if (isVolatileOrNoneMovable(innerExpr) + || isVolatileOrNoneMovable(outerExpr)) { + continue; + } innerIterator.remove(); outerIterator.remove(); + // Remember this outer conjunct came from the inner subquery + // filter — it must go below the window, not above. + matchedInnerFilterConjuncts.add(outerExpr); + // Each inner conjunct matches at most one outer conjunct. + // Break to the next inner predicate to avoid matching the + // same inner conjunct against a second outer conjunct + // (which would call innerIterator.remove() twice and + // throw IllegalStateException). + break; } } } @@ -215,19 +299,30 @@ private boolean checkFilter(LogicalFilter outerFilter) { } /** - * check join to ensure no condition on it. - * this is because we cannot do accurate pattern match between outer scope and inner scope - * so, we currently forbid join with condition here. + * Reject joins that are unsafe for the WinMagic window rewrite. + *

+ * Only {@link JoinType#INNER_JOIN} and {@link JoinType#CROSS_JOIN} are + * accepted. Semi/anti joins output only one side and would cause the + * window to reference slots not produced by its child; outer joins + * introduce null-extended rows that corrupt {@code COUNT(*)} and other + * aggregates (a null-padded outer-join row makes {@code COUNT(*) OVER (…)} + * return 1 where the original scalar subquery would return 0). + *

+ * Additionally, any ON clause condition is forbidden because the rule + * cannot accurately pattern-match predicates between outer and inner scope + * when the join carries its own condition. */ private boolean checkJoin() { return outerPlans.stream() .filter(LogicalJoin.class::isInstance) .map(p -> (LogicalJoin) p) - .noneMatch(j -> j.getOnClauseCondition().isPresent()) + .allMatch(j -> j.getJoinType().isInnerOrCrossJoin() + && !j.getOnClauseCondition().isPresent()) && innerPlans.stream() .filter(LogicalJoin.class::isInstance) .map(p -> (LogicalJoin) p) - .noneMatch(j -> j.getOnClauseCondition().isPresent()); + .allMatch(j -> j.getJoinType().isInnerOrCrossJoin() + && !j.getOnClauseCondition().isPresent()); } /** @@ -274,6 +369,25 @@ private boolean checkRelation(List correlatedSlots) { createSlotMapping(outerTables, innerTables); + // Shared-table scans must have equivalent row-domain semantics. + // Table.getId() equality alone is insufficient: wrappers + // (RowBinlogTableWrapper, OlapTableStreamWrapper) share the base + // table ID but read different rows. Likewise, two scans of the + // same base table can differ by @incr params, partition/tablet + // selection, index, snapshot, or sample. + if (!isSameScanDomain(outerTables, innerTables)) { + return false; + } + + // Identify and stash the sole outer-only table for downstream checks + // and for rewrite(). checkRelation() already validated that exactly + // one outer-only table exists. + outerOnlyTable = outerTables.stream() + .filter(node -> outerIds.contains(node.getTable().getId())) + .findFirst().get(); + Preconditions.checkState(outerOnlyTable != null, + "outerOnlyTable must be non-null after checkRelation validation"); + Set correlatedRelationOutput = outerTables.stream() .filter(node -> outerIds.contains(node.getTable().getId())) .map(LogicalRelation.class::cast) @@ -281,6 +395,38 @@ private boolean checkRelation(List correlatedSlots) { return correlatedSlots.stream().allMatch(e -> correlatedRelationOutput.contains(e.getExprId())); } + /** + * The correlated columns of the outer-only table must form a unique, non-null + * key for the WinMagic window-function rewrite to be correct. Without unique + * and non-null keys, the window function may aggregate over duplicated or + * null-grouped outer rows, producing wrong results for aggregates like SUM + * and COUNT. + *

+ * In particular, nullable correlated keys are unsafe even with a uniqueness + * guarantee: PARTITION BY groups all null-key outer rows into a single + * partition. Under a null-safe equality ({@code <=>}) correlation, those + * rows can join the same null-key inner rows and multiply the window + * aggregate, whereas the original scalar subquery is evaluated per outer row. + *

+ * Uses {@link DataTrait#isUniqueAndNotNull(Set)} which covers OLAP key + * metadata (PRIMARY_KEYS / UNIQUE_KEYS), declared constraints + * (PRIMARY KEY / UNIQUE), and rejects nullable slots. + */ + private boolean checkUniqueCorrelatedTable(List correlatedSlots) { + // outerOnlyTable was identified and stashed by checkRelation() which + // runs before this method in the check() && chain, so it is guaranteed + // non-null here. + Preconditions.checkState(outerOnlyTable != null, + "checkRelation() must run and set outerOnlyTable before " + + "checkUniqueCorrelatedTable()"); + + // Check uniqueness and non-nullability via DataTrait on the correlated (outer-only) table. + // Must use isUniqueAndNotNull: nullable unique keys are unsafe for window-rewrite + // because PARTITION BY groups all null-key rows together. + DataTrait dataTrait = outerOnlyTable.getLogicalProperties().getTrait(); + return dataTrait.isUniqueAndNotNull(Sets.newHashSet(correlatedSlots)); + } + private void createSlotMapping(List outerTables, List innerTables) { for (CatalogRelation outerTable : outerTables) { for (CatalogRelation innerTable : innerTables) { @@ -299,6 +445,132 @@ private void createSlotMapping(List outerTables, List outerTables, + List innerTables) { + for (CatalogRelation outerTable : outerTables) { + for (CatalogRelation innerTable : innerTables) { + if (innerTable.getTable().getId() != outerTable.getTable().getId()) { + continue; + } + // Different table objects with the same ID means one is a + // wrapper (RowBinlogTableWrapper, OlapTableStreamWrapper, …) + // and the other is the base table. They read different rows. + if (innerTable.getTable() != outerTable.getTable()) { + return false; + } + // If both are LogicalOlapScan, compare scan-domain properties. + if (innerTable instanceof LogicalOlapScan + && outerTable instanceof LogicalOlapScan) { + LogicalOlapScan innerScan = (LogicalOlapScan) innerTable; + LogicalOlapScan outerScan = (LogicalOlapScan) outerTable; + // Different selected index → different row set. + if (innerScan.getSelectedIndexId() != outerScan.getSelectedIndexId()) { + return false; + } + // Different table samples → different row set. + if (!Objects.equals( + innerScan.getTableSample(), outerScan.getTableSample())) { + return false; + } + // Non-repeatable samples: without REPEATABLE, seek is + // -1 and each OlapScanNode resolves it with its own + // SecureRandom at execution time (see + // OlapScanNode.computeSampleTabletIds). Two + // descriptor-equal non-repeatable samples therefore + // materialize different row sets — the rewrite would + // compute the window only over the outer sample while + // the original scalar subquery read the inner sample. + if (innerScan.getTableSample().isPresent() + && innerScan.getTableSample().get().seek == -1) { + return false; + } + // Different partition selection → different row set. + if (!innerScan.getSelectedPartitionIds() + .equals(outerScan.getSelectedPartitionIds())) { + return false; + } + // Different tablet selection → different row set. + if (!innerScan.getSelectedTabletIds() + .equals(outerScan.getSelectedTabletIds())) { + return false; + } + } else { + // TODO: Support non-OLAP scan types (e.g. LogicalFileScan, + // LogicalHudiScan, etc.). These scans can share the same + // table object and ID while differing in selected partitions, + // snapshot, sample, scan parameters, or incremental relation + // state (e.g. an outer Hudi @incr reference paired with an + // inner base Hudi reference). A full row-domain equivalence + // proof is needed for each scan type, including partition, + // snapshot, sample, scan-params, and incremental-state + // comparisons analogous to the LogicalOlapScan branch above. + // Until then, conservatively reject the rewrite for all + // non-OLAP shared-table pairs. + return false; + } + } + } + return true; + } + + /** + * Rewrite a correlated scalar subquery into a Window function. + * + *

Input Plan Shape

+ *
+     * Filter(pred_shared + pred_outer-only + pred_correlated)
+     *   Apply(correlation: outer-only.col)
+     *     Join / CrossJoin
+     *       Scan(shared_tbl)   -- appears in both outer & inner
+     *       Scan(outer-only_tbl)  -- only in outer, correlated table
+     *     Aggregate(agg_func)
+     *       Filter(inner_correlated_pred)
+     *         Scan(shared_tbl)
+     * 
+ * + *

Output Plan Shape

+ *
+     * Filter(pred_shared + window_comparison)  -- shared-only preds stay ABOVE window
+     *   Window(agg_func OVER (PARTITION BY outer-only.cols))
+     *     Filter(pred_outer-only + join_cond)  -- outer-only preds go BELOW window
+     *       Join / CrossJoin
+     *         Scan(shared_tbl)
+     *         Scan(outer-only_tbl)
+     * 
+ * + *

Key Correctness Rule

+ * Predicates that reference ONLY shared-table columns (tables appearing in both + * outer and inner plans) and were NOT matched against inner subquery filter + * conjuncts MUST stay above the Window. Otherwise the window function would + * see fewer rows than the original scalar subquery. + *

+ * Conversely, predicates that were matched against inner subquery filter + * conjuncts (tracked by {@link #checkFilter}) MUST stay below the Window, even + * if they reference only shared-table columns. These predicates are + * semantically part of the inner aggregate's filter — placing them above the + * window would let the window aggregate over rows that the original scalar + * subquery excluded. + * + *

Example: Given fact(f) as shared table and dim(d) as outer-only table, + * with the query: + *

+     *   SELECT ... FROM fact f, dim d
+     *   WHERE f.k = d.k AND f.v > 6
+     *     AND f.v * 2 > (SELECT SUM(f2.v) FROM fact f2 WHERE f2.k = d.k)
+     * 
+ * + * The predicate {@code f.v > 6} references only shared-table columns, so it + * must stay above the window. The window computes SUM over ALL fact rows + * per d.k, matching the original scalar subquery semantics. + */ private Plan rewrite(LogicalFilter filter, LogicalApply apply) { Preconditions.checkArgument(apply.right() instanceof LogicalAggregate, "right child of Apply should be LogicalAggregate"); @@ -331,7 +603,7 @@ private Plan rewrite(LogicalFilter filter, LogicalApply correlatedConjuncts = conjuncts.get(false); - if (correlatedConjuncts.isEmpty() || correlatedConjuncts.size() > 1 + if (correlatedConjuncts == null || correlatedConjuncts.size() != 1 || !(correlatedConjuncts.iterator().next() instanceof ComparisonPredicate)) { //TODO: only support simple comparison predicate now return filter; @@ -362,53 +634,325 @@ private Plan rewrite(LogicalFilter filter, LogicalApply newFilter = filter.withConjunctsAndChild(conjuncts.get(true), apply.left()); + // Split uncorrelated conjuncts: predicates that reference ONLY shared + // relation slots (tables appearing in both outer and inner plans) must + // stay ABOVE the window. Otherwise the window function would see a + // different set of rows than the original scalar subquery. + // + // For example, with fact(f) as shared table and dim(d) as outer-only: + // f.v > 6 → shared-only → must stay above the window + // d.tag > 0 → outer-only → safe below the window + // f.k = d.k → join cond → needed below the window + // + // We find shared tables by comparing table IDs that appear in both + // outer and inner plans, then collect ALL output slots of those + // tables (not just columns referenced in the inner query). + // outerOnlyTable is already identified by checkRelation(). + List outerRels = outerPlans.stream() + .filter(CatalogRelation.class::isInstance) + .map(CatalogRelation.class::cast) + .collect(Collectors.toList()); + Set innerTableIds = innerPlans.stream() + .filter(CatalogRelation.class::isInstance) + .map(r -> ((CatalogRelation) r).getTable().getId()) + .collect(Collectors.toSet()); + Set sharedOuterExprIds = outerRels.stream() + .filter(r -> innerTableIds.contains(r.getTable().getId())) + .flatMap(r -> r.getOutput().stream()) + .map(Slot::getExprId) + .collect(Collectors.toSet()); + Set uncorrelatedConjuncts = conjuncts.get(true); + Set belowWindowConjuncts = Sets.newHashSet(); + Set aboveWindowConjuncts = Sets.newHashSet(); + if (uncorrelatedConjuncts != null) { + // If the outer filter (the filter on top of the Apply) contains + // both a volatile/NoneMovableFunction conjunct AND another + // deterministic conjunct that would go to a different side of + // the window, reject the rewrite. Splitting conjuncts from the + // same filter operator changes which rows reach the + // side-effecting predicate and can suppress expected errors. + // + // Example: a filter with both + // d.tag > 0 (outer-only → below window) + // assert_true(d.tag > 1, 'bad') (NoneMovable → above window) + // splits the pair: rows filtered by d.tag > 0 never reach + // assert_true above the window, whereas the original operator + // evaluates assert_true on every row of the input block. + boolean hasVolatileInOuterFilter = false; + boolean needsBelowFromOuterFilter = false; + for (Expression conj : uncorrelatedConjuncts) { + if (matchedInnerFilterConjuncts.contains(conj)) { + continue; + } + if (isVolatileOrNoneMovable(conj)) { + hasVolatileInOuterFilter = true; + } else if (!referencesSharedTable(conj, sharedOuterExprIds)) { + needsBelowFromOuterFilter = true; + } + } + if (hasVolatileInOuterFilter && needsBelowFromOuterFilter) { + return filter; + } + for (Expression conj : uncorrelatedConjuncts) { + // Conjuncts that were matched against inner subquery filter + // conjuncts (tracked by checkFilter) must stay BELOW the + // window. They are semantically part of the inner aggregate's + // filter, not extra outer-only predicates. Placing them above + // the window would let the window see more rows than the + // original scalar subquery, producing wrong aggregate results. + if (matchedInnerFilterConjuncts.contains(conj)) { + belowWindowConjuncts.add(conj); + continue; + } + // Volatile and NoneMovableFunction predicates must stay + // ABOVE the window — pushing them below would change + // evaluation frequency or move a side-effecting call. + if (isVolatileOrNoneMovable(conj)) { + aboveWindowConjuncts.add(conj); + continue; + } + // Predicates referencing shared-table columns must stay + // ABOVE the window; otherwise the window sees fewer rows + // than the original scalar subquery. + if (referencesSharedTable(conj, sharedOuterExprIds)) { + aboveWindowConjuncts.add(conj); + } else { + belowWindowConjuncts.add(conj); + } + } + } + + // Extract and classify conjuncts from any LogicalFilter nodes nested + // inside the outer child (apply.left()). Nested shared-table filters + // (e.g. f.v > 6 under a CrossJoin) must be hoisted ABOVE the window; + // otherwise the window would aggregate over a filtered subset of rows + // while the original scalar subquery sees all rows for the key. + // + // Nested outer-only filters (e.g. d.tag > 0) are safe below and can + // stay in place after the filters are stripped. + // + // Use a barrier-aware collector: filters below a retained unsafe + // filter are NOT collected, matching stripOuterFilters() semantics. + // Otherwise descendant predicates would be reinserted above the join + // while the originals remain below the unsafe filter — evaluated + // twice per joined row. + // + // Collecting stops at unsafe barriers (collectStrippableFilters line 773); + // stripping also stops at unsafe barriers (stripOuterFilters line 638). + // This barrier symmetry is intentional: safe filters underneath an + // unsafe filter stay in place — they are neither hoisted nor removed. + List> nestedOuterFilters = collectStrippableFilters(apply.left()); + Set extractedConjunctExprIds = Sets.newHashSet(); + for (LogicalFilter nf : nestedOuterFilters) { + for (Expression conj : nf.getConjuncts()) { + // Matched inner-filter conjuncts always go below. + if (matchedInnerFilterConjuncts.contains(conj)) { + belowWindowConjuncts.add(conj); + extractedConjunctExprIds.addAll(conj.getInputSlotExprIds()); + continue; + } + // Volatile / NoneMovable on a shared table would restrict + // the window's input — reject the rewrite. + if (isVolatileOrNoneMovable(conj)) { + if (nf.collect(CatalogRelation.class::isInstance).stream() + .map(r -> ((CatalogRelation) r).getTable().getId()) + .anyMatch(innerTableIds::contains)) { + return filter; + } + continue; + } + if (referencesSharedTable(conj, sharedOuterExprIds)) { + aboveWindowConjuncts.add(conj); + } else { + belowWindowConjuncts.add(conj); + } + extractedConjunctExprIds.addAll(conj.getInputSlotExprIds()); + } + } + // Strip all nested LogicalFilter nodes from the outer child so the + // window operates on the unfiltered scan/join. + Plan strippedOuterChild = stripOuterFilters(apply.left()); + + // The window function's aggregate references shared-table slots + // (e.g. f.v for SUM(f.v) after slot replacement). A pruning + // project inside apply.left() may have dropped those slots even + // when there are no nested filters to extract. Collect the + // replaced aggregate's input slot ExprIds and include them in + // the project-expansion set so ensureProjectOutput carries them + // through. + Set allNeededExprIds = Sets.newHashSet(extractedConjunctExprIds); + allNeededExprIds.addAll(ExpressionUtils.replace(function, innerOuterSlotMap) + .getInputSlotExprIds()); + strippedOuterChild = ensureProjectOutput(strippedOuterChild, + allNeededExprIds); + + LogicalFilter newFilter = filter.withConjunctsAndChild( + belowWindowConjuncts, strippedOuterChild); LogicalWindow newWindow = new LogicalWindow<>(ImmutableList.of(windowFunctionAlias), newFilter); - LogicalFilter windowFilter = new LogicalFilter<>(ImmutableSet.of(windowFilterConjunct), newWindow); + + // Combine shared-table predicates with the window comparison predicate above the window + Set topConjuncts = Sets.newHashSet(windowFilterConjunct); + topConjuncts.addAll(aboveWindowConjuncts); + LogicalFilter windowFilter = new LogicalFilter<>(ImmutableSet.copyOf(topConjuncts), newWindow); return windowFilter; } + /** + * Ensure that every LogicalProject in the plan tree outputs all slots + * referenced by extracted conjuncts (ExprIds in {@code neededExprIds}). + * If a project prunes away a needed slot, the reinserted filter + * predicates would have dangling references. + * + *

Recursively walks the tree depth-first; expands each project to + * include any missing slots as simple identity projections (SlotReference → + * SlotReference). Recursing into the child before computing the current + * project's {@code childOutput} ensures that stacked pruning projects + * (e.g. {@code Project(k) → Project(k) → Scan(k, v)}) are expanded + * bottom-up — the inner project is expanded first, and then the outer + * project can see the expanded slots in its child output. + */ + private Plan ensureProjectOutput(Plan plan, Set neededExprIds) { + if (neededExprIds.isEmpty()) { + return plan; + } + if (plan instanceof LogicalProject) { + LogicalProject project = (LogicalProject) plan; + // Recurse into the child first so stacked pruning projects + // are expanded bottom-up. The child's output after expansion + // determines which slots the current project can pull through. + Plan newChild = ensureProjectOutput(project.child(), neededExprIds); + Set projectOutputExprIds = project.getOutputExprIdSet(); + Set childOutput = newChild.getOutputSet(); + List newProjects = Lists.newArrayList(project.getProjects()); + boolean expanded = false; + for (ExprId id : neededExprIds) { + if (!projectOutputExprIds.contains(id)) { + for (Slot slot : childOutput) { + if (slot.getExprId().equals(id)) { + newProjects.add(slot); + expanded = true; + break; + } + } + } + } + if (expanded) { + return project.withProjectsAndChild(newProjects, newChild); + } + if (newChild != project.child()) { + return project.withChildren(ImmutableList.of(newChild)); + } + return plan; + } + if (plan.children().isEmpty()) { + return plan; + } + List newChildren = plan.children().stream() + .map(c -> ensureProjectOutput(c, neededExprIds)) + .collect(Collectors.toList()); + return plan.withChildren(newChildren); + } + private WindowExpression createWindowFunction(List correlatedSlots, AggregateFunction function) { // partition by clause is set by all the correlated slots. return new WindowExpression(function, ImmutableList.copyOf(correlatedSlots), Collections.emptyList()); } - private static class ExpressionIdenticalChecker extends DefaultExpressionVisitor { - public static final ExpressionIdenticalChecker INSTANCE = new ExpressionIdenticalChecker(); - - public boolean check(Expression expression, Expression expression1) { - return expression.accept(this, expression1); + /** Recursively strip deterministic, movable LogicalFilter nodes from the + * plan tree. Filters containing volatile predicates (e.g. random()) or + * NoneMovableFunction predicates (e.g. assert_true()) are left in place — + * moving such predicates across a join/window changes their evaluation + * context and can alter query results. */ + private Plan stripOuterFilters(Plan plan) { + if (plan instanceof LogicalFilter) { + LogicalFilter filter = (LogicalFilter) plan; + // Separate unsafe-to-move conjuncts from safe ones. + // Volatile and NoneMovableFunction predicates stay at their + // original position; deterministic movable predicates have been + // extracted and can be stripped. + Set keepConjuncts = filter.getConjuncts().stream() + .filter(AggScalarSubQueryToWindowFunction::isVolatileOrNoneMovable) + .collect(Collectors.toSet()); + if (keepConjuncts.isEmpty()) { + // All conjuncts are safe to strip. + return stripOuterFilters(filter.child(0)); + } + // An unsafe filter is a subtree movement barrier: stripping + // filters from below it would change which rows reach the + // side-effecting predicate and alter its evaluation domain. + return new LogicalFilter<>(ImmutableSet.copyOf(keepConjuncts), filter.child(0)); } - - private boolean isClassMatch(Object o1, Object o2) { - return o1.getClass().equals(o2.getClass()); + if (plan.children().isEmpty()) { + return plan; } + return plan.withChildren( + plan.children().stream().map(this::stripOuterFilters).collect(Collectors.toList())); + } - private boolean isSameChild(Expression expression, Expression expression1) { - if (expression.children().size() != expression1.children().size()) { - return false; - } - for (int i = 0; i < expression.children().size(); ++i) { - if (!expression.children().get(i).accept(this, expression1.children().get(i))) { - return false; - } + // ---- helper methods ---------------------------------------------------- + + /** An expression that must not be moved or pruned by plan rewrites. */ + private static boolean isVolatileOrNoneMovable(Expression expr) { + return expr.containsVolatileExpression() + || expr.containsType(NoneMovableFunction.class); + } + + /** Collect LogicalFilter nodes that are safe to strip, stopping + * recursion at unsafe-filter barriers (matching the semantics of + * {@link #stripOuterFilters}). */ + private static List> collectStrippableFilters(Plan plan) { + List> result = Lists.newArrayList(); + collectStrippableFilters(plan, result); + return result; + } + + private static void collectStrippableFilters(Plan plan, List> result) { + if (plan instanceof LogicalFilter) { + LogicalFilter filter = (LogicalFilter) plan; + result.add((LogicalFilter) plan); + if (filter.getConjuncts().stream().anyMatch( + AggScalarSubQueryToWindowFunction::isVolatileOrNoneMovable)) { + return; // unsafe filter — stop descending but still collected } - return true; } + for (Plan child : plan.children()) { + collectStrippableFilters(child, result); + } + } - @Override - public Boolean visit(Expression expression, Expression expression1) { - return isClassMatch(expression, expression1) && isSameChild(expression, expression1); + /** True when {@code expr} references any column of a shared table + * (a table appearing in both outer and inner plans). */ + private static boolean referencesSharedTable(Expression expr, Set sharedOuterExprIds) { + for (ExprId id : expr.getInputSlotExprIds()) { + if (sharedOuterExprIds.contains(id)) { + return true; + } } + return false; + } - @Override - public Boolean visitSlotReference(SlotReference slotReference, Expression other) { - return slotReference.equals(other); + // ---- ExpressionIdenticalChecker ---------------------------------------- + + /** + * Structural-equality checker used by {@link #checkFilter} to decide + * whether an inner-filter conjunct (after slot replacement) matches an + * outer-filter conjunct. The generic path delegates to + * {@link Expression#equals(Object)} which includes all semantic + * attributes (target type for Cast/TryCast, analyzer for Match, function + * name for BoundFunction, etc.). The only exception is + * {@link ComparisonPredicate}, where we additionally accept the commuted + * form ({@code a = b} ↔ {@code b = a}). + */ + private static class ExpressionIdenticalChecker extends DefaultExpressionVisitor { + public static final ExpressionIdenticalChecker INSTANCE = new ExpressionIdenticalChecker(); + + public boolean check(Expression expression, Expression expression1) { + return expression.accept(this, expression1); } @Override - public Boolean visitLiteral(Literal literal, Expression other) { - return literal.equals(other); + public Boolean visit(Expression expression, Expression expression1) { + return expression.equals(expression1); } @Override diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java index ccb482b75356da..4ccf0d2bcd6055 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java @@ -45,6 +45,7 @@ import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor; import org.apache.doris.nereids.util.Utils; import org.apache.doris.qe.ConnectContext; +import org.apache.doris.qe.SessionVariable; import org.apache.doris.rpc.RpcException; import com.google.common.annotations.VisibleForTesting; @@ -809,6 +810,14 @@ public JSONObject toJson() { @Override public void computeUnique(DataTrait.Builder builder) { + // Duplicate-producing scan modes invalidate all uniqueness + // guarantees regardless of table metadata or declared constraints. + // When the BE returns unmerged versions or duplicate key rows, the + // WinMagic window-function rewrite (and any other rule relying on + // uniqueness) would produce wrong results. + if (isDuplicateProducingScanMode()) { + return; + } // Raw-version reads expose superseded rows: with skipDeleteBitmap, rows replaced by // later versions are read; with read_mor_as_dup_tables, MOR tables are read as DUP and // expose every version. Uniqueness — including the table-level constraints imported by @@ -848,6 +857,13 @@ AGGREGATE KEY (siteid,citycode,username) the mv2's agg key citycode * citycode is not unique for simplicity, we disable unique compute for mv + + Declared constraints from super.computeUnique(builder) were + already filtered by findSlotsByColumn() above: if a rollup + does not include ALL columns of a PRIMARY KEY / UNIQUE + constraint, the partial-column set is discarded. Only + constraints whose full column set is present in the scan + output are propagated. */ return; } @@ -948,6 +964,45 @@ public void computeFd(DataTrait.Builder builder) { } } + /** + * Whether the scan is configured with a session variable or scan + * mode that makes the BE return potentially duplicate rows even for + * declared unique keys. In these modes any uniqueness guarantee — + * whether from OLAP key metadata or from user-declared PRIMARY KEY / + * UNIQUE constraints — is unreliable. + */ + private boolean isDuplicateProducingScanMode() { + SessionVariable sv = ConnectContext.get().getSessionVariable(); + // skipStorageEngineMerge: BE returns unmerged versions — all + // table types may have duplicate key rows. + if (sv.skipStorageEngineMerge) { + return true; + } + // skipDeleteBitmap: on UNIQUE_KEYS tables, rows that were replaced + // due to the same key are also read, so the key duplicates. + if (sv.skipDeleteBitmap && getTable().getKeysType() == KeysType.UNIQUE_KEYS) { + return true; + } + // readMorAsDup: MOW tables are read as DUPLICATE — uniqueness + // of the declared key is not guaranteed. + if (getTable().getKeysType() == KeysType.UNIQUE_KEYS + && getTable().isMorTable() + && sv.isReadMorAsDupEnabled( + getTable().getQualifiedDbName(), getTable().getName())) { + return true; + } + // Stream scans and other scan subclasses that can return duplicate + // key rows are handled via producesDuplicateRows() which defaults + // to false and is overridden by subclasses with special semantics. + // This follows the Open/Closed principle: adding a new scan subclass + // with duplicate-producing behavior does not require modifying + // LogicalOlapScan. + if (producesDuplicateRows()) { + return true; + } + return false; + } + @Override public CatalogRelation withOperativeSlots(Collection operativeSlots) { return new LogicalOlapScan(relationId, (Table) table, qualifier, @@ -1059,4 +1114,14 @@ protected boolean hasSameScanState(LogicalCatalogRelation other) { public boolean supportPruneNestedColumn() { return true; } + + /** + * Override point for scan subclasses that can return duplicate rows + * even for declared unique keys. The base {@code LogicalOlapScan} + * returns {@code false}; subclasses that introduce special scan modes + * (e.g. incremental stream scans) override this to return {@code true}. + */ + protected boolean producesDuplicateRows() { + return false; + } } diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/AggScalarSubQueryToWindowFunctionTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/AggScalarSubQueryToWindowFunctionTest.java index 443dbaebd8f84b..8fa126e042a5be 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/AggScalarSubQueryToWindowFunctionTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/AggScalarSubQueryToWindowFunctionTest.java @@ -19,15 +19,32 @@ import org.apache.doris.nereids.datasets.tpch.TPCHTestBase; import org.apache.doris.nereids.datasets.tpch.TPCHUtils; +import org.apache.doris.nereids.rules.analysis.LogicalSubQueryAliasToLogicalProject; +import org.apache.doris.nereids.trees.expressions.ExprId; +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.NamedExpression; +import org.apache.doris.nereids.trees.expressions.Slot; +import org.apache.doris.nereids.trees.expressions.WindowExpression; import org.apache.doris.nereids.trees.plans.Plan; +import org.apache.doris.nereids.trees.plans.algebra.CatalogRelation; +import org.apache.doris.nereids.trees.plans.logical.LogicalAggregate; +import org.apache.doris.nereids.trees.plans.logical.LogicalApply; +import org.apache.doris.nereids.trees.plans.logical.LogicalFilter; +import org.apache.doris.nereids.trees.plans.logical.LogicalProject; import org.apache.doris.nereids.trees.plans.logical.LogicalWindow; import org.apache.doris.nereids.util.MemoPatternMatchSupported; import org.apache.doris.nereids.util.PlanChecker; +import com.google.common.collect.Sets; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + public class AggScalarSubQueryToWindowFunctionTest extends TPCHTestBase implements MemoPatternMatchSupported { private static final String SQL_TEMPLATE = " select\n" + " sum(l_extendedprice) / 7.0 as avg_yearly\n" @@ -57,6 +74,18 @@ public class AggScalarSubQueryToWindowFunctionTest extends TPCHTestBase implemen buildSubQuery(MIN) }; + @BeforeEach + public void addConstraints() throws Exception { + // Add UNIQUE constraint on part.p_partkey so DataTrait recognizes + // uniqueness for the TPC-H tables used in positive tests. + // Ignore if constraint already exists from a previous test. + try { + addConstraint("alter table part add constraint uq_part_pkey unique (p_partkey)"); + } catch (Exception e) { + // Constraint may already exist; ignore + } + } + private static String buildFromTemplate(String[] predicate, String[] query) { String sql = SQL_TEMPLATE; for (int i = 0; i < predicate.length; ++i) { @@ -338,6 +367,3004 @@ public void testNotMatchTheRule() { } } + @Test + public void testWindowPartitionsByOuterOnlyRelationSlots() throws Exception { + // Use TPC-H Q17: correlated table is part (p_partkey is unique via constraint), + // fact table is lineitem. The window PARTITION BY should contain all output + // columns of the correlated table (part). + String sql = TPCHUtils.Q17; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .applyTopDown(new PushDownFilterThroughProject()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + List> windows = plan.collectToList(LogicalWindow.class::isInstance); + Assertions.assertEquals(1, windows.size()); + + LogicalWindow window = windows.get(0); + List windowExpressions = window.getWindowExpressions(); + Assertions.assertEquals(1, windowExpressions.size()); + + WindowExpression windowExpression = (WindowExpression) windowExpressions.get(0).child(0); + Set partitionKeys = windowExpression.getPartitionKeys().stream() + .map(Expression.class::cast) + .filter(Slot.class::isInstance) + .map(Slot.class::cast) + .map(Slot::getName) + .collect(Collectors.toSet()); + // The window PARTITION BY should include the correlated column (p_partkey) + Assertions.assertTrue(partitionKeys.contains("p_partkey"), + "Expected partition keys to contain p_partkey, got: " + partitionKeys); + } + + @Test + public void testSharedTablePredicatesStayAboveWindow() throws Exception { + createTable("CREATE TABLE fact_split (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_split (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + // Add UNIQUE constraint so the rule matches + addConstraint("alter table dim_split add constraint uq_dim_split_k unique (k)"); + + // Query with extra predicate on shared table (f.v > 6). + // This predicate must stay ABOVE the window, otherwise the window + // function would aggregate fewer rows than the original scalar subquery. + String sql = "SELECT d.did, d.k, d.tag, f.id, f.v " + + "FROM fact_split f, dim_split d " + + "WHERE f.k = d.k " + + " AND f.v > 6" + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_split f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .applyTopDown(new PushDownFilterThroughProject()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule should match and produce a window + Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance), + "Rule should produce a window for this query"); + + // Collect the ExprIds of the shared table (fact_split – appears in both + // outer and inner plans). Predicates that reference ONLY these ExprIds + // (shared-table-only filters) must stay ABOVE the window, otherwise the + // window function would see fewer rows than the original scalar subquery. + List rels = plan.collectToList(CatalogRelation.class::isInstance); + Set sharedExprIds = rels.stream() + .filter(r -> r.getTable().getName().equals("fact_split")) + .flatMap(r -> r.getOutputExprIdSet().stream()) + .collect(Collectors.toSet()); + + // Verify that no filter below the window contains a predicate whose + // input ExprIds are all from the shared table. Such predicates + // (e.g. f.v > 6) must have been placed above the window. + List> windows = plan.collectToList(LogicalWindow.class::isInstance); + LogicalWindow window = windows.get(0); + Plan belowWindow = window.child(0); + List> belowFilters = belowWindow + .collectToList(LogicalFilter.class::isInstance); + for (LogicalFilter f : belowFilters) { + for (Expression conj : f.getConjuncts()) { + Set conjExprIds = conj.getInputSlotExprIds(); + if (!conjExprIds.isEmpty() && sharedExprIds.containsAll(conjExprIds)) { + Assertions.fail( + "Shared-table-only predicate should not be below window: " + conj.toSql()); + } + } + } + } + + @Test + public void testMixedSharedOuterPredicatesStayAboveWindow() throws Exception { + // Mixed predicates that reference both shared-table and outer-only-table + // columns (e.g. f.v > d.tag) must stay ABOVE the window. Pushing them + // below would restrict the rows seen by the window function, producing + // a different aggregate than the original scalar subquery. + // + // Input plan shape: + // Filter(f.v > d.tag, f.v * 2 > sum_alias) ← mixed + correlated + // Apply(correlation: d.k) + // CrossJoin + // Scan fact f + // Scan dim d -- d.k is unique (constraint) + // Aggregate(sum(f2.v) AS sum_alias) + // Filter(f2.k = d.k) + // Scan fact f2 + // + // Output plan shape: + // Filter(f.v > d.tag, f.v * 2 > sum_over_window) ← mixed stays ABOVE + // Window(sum(v) OVER (PARTITION BY d.k)) + // Filter(f.k = d.k) ← join cond BELOW + // CrossJoin + // Scan fact f + // Scan dim d + createTable("CREATE TABLE fact_mixed (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_mixed (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_mixed add constraint uq_dim_mixed_k unique (k)"); + + // Mixed predicate: f.v > d.tag references both shared (f.v) and + // outer-only (d.tag) columns. It must stay ABOVE the window. + String sql = "SELECT d.did, d.k, d.tag, f.id, f.v " + + "FROM fact_mixed f, dim_mixed d " + + "WHERE f.k = d.k " + + " AND f.v > d.tag" + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_mixed f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .applyTopDown(new PushDownFilterThroughProject()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule should match and produce a window + Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance), + "Rule should produce a window for this query"); + + // Collect shared table (fact_mixed) ExprIds. + // A mixed predicate like f.v > d.tag references BOTH shared and + // outer-only sets. + List rels = plan.collectToList(CatalogRelation.class::isInstance); + Set sharedExprIds = rels.stream() + .filter(r -> r.getTable().getName().equals("fact_mixed")) + .flatMap(r -> r.getOutputExprIdSet().stream()) + .collect(Collectors.toSet()); + + // Verify: the mixed predicate f.v > d.tag must NOT be below the window. + // A mixed predicate references slots from BOTH shared and outer-only + // tables. We detect it by checking that at least one ExprId is in the + // shared set AND at least one is outside the shared set. + List> windows = plan.collectToList(LogicalWindow.class::isInstance); + LogicalWindow window = windows.get(0); + Plan belowWindow = window.child(0); + List> belowFilters = belowWindow + .collectToList(LogicalFilter.class::isInstance); + for (LogicalFilter f : belowFilters) { + for (Expression conj : f.getConjuncts()) { + Set conjExprIds = conj.getInputSlotExprIds(); + if (conjExprIds.isEmpty()) { + continue; + } + boolean hasShared = false; + boolean hasNonShared = false; + for (ExprId id : conjExprIds) { + if (sharedExprIds.contains(id)) { + hasShared = true; + } else { + hasNonShared = true; + } + } + if (hasShared && hasNonShared) { + // Join conditions (f.k = d.k) are expected below the + // window — they are matched from the inner filter and + // needed for the join. Only flag non-equality mixed + // predicates like f.v > d.tag. + if (!(conj instanceof org.apache.doris.nereids.trees.expressions.EqualPredicate)) { + Assertions.fail( + "Mixed shared+outer predicate should not be below window: " + + conj.toSql()); + } + } + if (!hasNonShared) { + // Shared-table-only predicate also belongs ABOVE. + Assertions.fail( + "Shared-table-only predicate should not be below window: " + + conj.toSql()); + } + } + } + + // Verify the mixed predicate IS present in a filter ABOVE the window. + // Collect all filters above the window by excluding below-window filters. + List> allFilters = plan + .collectToList(LogicalFilter.class::isInstance); + List> aboveFilters = allFilters.stream() + .filter(f -> !belowFilters.contains(f)) + .collect(Collectors.toList()); + boolean foundMixedAbove = false; + for (LogicalFilter f : aboveFilters) { + for (Expression conj : f.getConjuncts()) { + Set conjExprIds = conj.getInputSlotExprIds(); + boolean hasShared = false; + boolean hasNonShared = false; + for (ExprId id : conjExprIds) { + if (sharedExprIds.contains(id)) { + hasShared = true; + } else { + hasNonShared = true; + } + } + if (hasShared && hasNonShared) { + foundMixedAbove = true; + } + } + } + Assertions.assertTrue(foundMixedAbove, + "Mixed predicate f.v > d.tag should be above the window"); + } + + @Test + public void testEnsureProjectOutputExpandsPrunedColumn() throws Exception { + // When a nested shared-table filter is extracted and hoisted above the + // window, any pruning project inside apply.left() that dropped a column + // referenced by the extracted conjunct must be expanded by + // ensureProjectOutput(). Otherwise the reinserted predicate would have + // a dangling slot reference. + // + // Plan shape: + // Filter(sf.k = d.k, sf.k * 2 > sum_alias) ← sf.k comparison + // Apply(correlation: d.k) + // CrossJoin + // SubQueryAlias sf + // Project(k) ← prunes v + // Filter(v > 6) ← nested shared filter + // Scan fact(k, v) + // Scan dim_unique d + // Aggregate(SUM(f2.k) AS sum_alias) + // Filter(f2.k = d.k) + // Scan fact f2 + // + // The subquery SELECTs only k; the outer query uses sf.k for both join + // and comparison. The column v appears ONLY in the nested filter v > 6. + // After extracting v > 6, ensureProjectOutput() must expand Project(k) + // to Project(k, v) so the hoisted predicate has access to v. + createTable("CREATE TABLE fact_ensure_proj (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_ensure_proj (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_ensure_proj add constraint uq_dim_ep_k unique (k)"); + + // The subquery SELECTs only k, pruning v. v > 6 is a nested shared-table + // filter that must be extracted. The rule must produce a window with + // v > 6 hoisted above it, and ensureProjectOutput must expand the + // pruning project to carry v through. + String sql = "SELECT sf.k, d.did " + + "FROM (SELECT k FROM fact_ensure_proj WHERE v > 6) sf, " + + " dim_ensure_proj d " + + "WHERE sf.k = d.k " + + " AND sf.k * 2 > (" + + " SELECT SUM(f2.k) " + + " FROM fact_ensure_proj f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule must match and produce a window. + Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance), + "Rule must produce a window for ensureProjectOutput test"); + + // Walk every filter in the plan and verify that every slot referenced + // by each conjunct is produced by the filter's child. If + // ensureProjectOutput() did not expand the project, the reinserted + // predicate v > 6 would have a dangling reference to v. + List> allFilters = plan + .collectToList(LogicalFilter.class::isInstance); + for (LogicalFilter f : allFilters) { + Set childOutput = f.child().getOutputExprIdSet(); + for (Expression conj : f.getConjuncts()) { + for (ExprId id : conj.getInputSlotExprIds()) { + Assertions.assertTrue(childOutput.contains(id), + "Filter conjunct slot " + id + + " must be produced by filter's child. " + + "ensureProjectOutput() may not have expanded " + + "a pruning project. Conjunct: " + conj.toSql()); + } + } + } + } + + @Test + public void testNotMatchWhenCorrelatedTableNotUnique() throws Exception { + createTable("CREATE TABLE tpch.fact_dup (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE tpch.dim_dup (\n" + + " did INT,\n" + + " k INT,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + + String sql = "SELECT d.did, d.k, d.tag, f.id, f.v " + + "FROM fact_dup f, dim_dup d " + + "WHERE f.k = d.k " + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_dup f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .applyTopDown(new PushDownFilterThroughProject()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // DUPLICATE KEY table does not guarantee uniqueness, rule should not match + Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance)); + } + + @Test + public void testCompositeUniqueConstraintTriggersRewrite() throws Exception { + // A table with a composite UNIQUE(a, b) constraint guarantees that + // (a, b) pairs are unique and non-null. When both columns are used + // as correlated slots, the window-rewrite is safe: PARTITION BY a, b + // produces exactly one row per outer row, matching the scalar + // subquery semantics. + // + // This also validates findSlotsByColumn() in LogicalCatalogRelation: + // only declared constraints whose FULL column set is present in the + // scan output are propagated as uniqueness slots. A rollup that + // drops column b from UNIQUE(a, b) would NOT see {a} as unique. + createTable("CREATE TABLE fact_comp (\n" + + " id INT,\n" + + " a INT,\n" + + " b INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_comp (\n" + + " did INT,\n" + + " a INT NOT NULL,\n" + + " b INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_comp add constraint uq_dim_comp_ab unique (a, b)"); + + // Correlate on both columns of the composite constraint. + String sql = "SELECT d.did, d.a, d.b, d.tag, f.id, f.v " + + "FROM fact_comp f, dim_comp d " + + "WHERE f.a = d.a AND f.b = d.b " + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_comp f2 " + + " WHERE f2.a = d.a AND f2.b = d.b" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .applyTopDown(new PushDownFilterThroughProject()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Composite UNIQUE(a,b) -- both columns correlated -- should match. + Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance), + "Composite UNIQUE(a,b) with both columns correlated must trigger the rewrite"); + } + + @Test + public void testNotMatchWhenCorrelatedKeyIsNullableUnique() throws Exception { + // A nullable column with a UNIQUE constraint is still unsafe for + // the window rewrite when the correlation uses null-safe equality + // (<=>). PARTITION BY groups all NULL-key outer rows into one + // partition, so those rows can join the same NULL-key inner rows + // and multiply the window aggregate — while the original scalar + // subquery is evaluated per outer row independently. + // isUniqueAndNotNull() must reject this because the key is nullable. + createTable("CREATE TABLE fact_nullable_uk (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + // k is nullable but has a UNIQUE constraint — DataTrait sees + // uniqueness without non-null, so isUniqueAndNotNull() is false. + createTable("CREATE TABLE dim_nullable_uk (\n" + + " did INT,\n" + + " k INT,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_nullable_uk add constraint uq_dim_nullable_uk_k unique (k)"); + + // Use <=> (null-safe equals) correlation so NULL keys can join. + String sql = "SELECT d.did, d.k, d.tag, f.id, f.v " + + "FROM fact_nullable_uk f, dim_nullable_uk d " + + "WHERE f.k <=> d.k " + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_nullable_uk f2 " + + " WHERE f2.k <=> d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .applyTopDown(new PushDownFilterThroughProject()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Nullable unique key is unsafe — all null keys partition together. + Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance), + "Nullable unique key with <=> correlation must not be rewritten"); + } + + @Test + public void testUniqueKeyModelTriggersRewrite() throws Exception { + // UNIQUE KEY model tables guarantee uniqueness + non-null on the key + // column. DataTrait recognizes this even without an explicit + // ADD CONSTRAINT, so the rule should fire. + createTable("CREATE TABLE tpch.fact_ukey (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + // dim_ukey has UNIQUE KEY(k) with k INT NOT NULL — this implies + // unique + non-null without needing an explicit constraint. + createTable("CREATE TABLE tpch.dim_ukey (\n" + + " k INT NOT NULL,\n" + + " did INT,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "UNIQUE KEY(k)\n" + + "DISTRIBUTED BY HASH(k) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + + String sql = "SELECT d.did, d.k, d.tag, f.id, f.v " + + "FROM fact_ukey f, dim_ukey d " + + "WHERE f.k = d.k " + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_ukey f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .applyTopDown(new PushDownFilterThroughProject()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // UNIQUE KEY model alone provides uniqueness + non-null. + Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance), + "UNIQUE KEY model should trigger the window rewrite"); + } + + @Test + public void testOuterOnlyRelationOutputPreserved() throws Exception { + // When the outer query references the dim table directly (no + // SubQueryAlias wrapping it), the Apply's correlation slot + // ExprId IS the scan's original. checkRelation() finds it + // in the outer-only table's output, so the rewrite can proceed + // when other guards (uniqueness, filters) pass. + createTable("CREATE TABLE fact_oor (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_oor (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_oor add constraint uq_dim_oor_k unique (k)"); + + // Direct table reference — no SubQueryAlias wrapping dim_oor. + // The Apply's correlation slot ExprId matches the scan output. + String sql = "SELECT d.did, d.k, d.tag, f.id, f.v " + + "FROM fact_oor f, dim_oor d " + + "WHERE f.k = d.k " + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_oor f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .applyTopDown(new PushDownFilterThroughProject()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // With the scan's original ExprId preserved, the rewrite should fire. + Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance), + "Rewrite must succeed when the correlated slot ExprId " + + "is the scan's original (direct table reference)"); + } + + @Test + public void testNotMatchWhenOuterOnlyRelationOutputIsPruned() throws Exception { + // An aliased projection (d.k AS new_k) creates a new ExprId in + // the outer scope that is NOT present in the outer-only table's + // scan output. checkRelation() compares each correlated slot's + // ExprId against the scan's output ExprIdSet — the aliased slot + // is genuinely missing, so the rewrite must be rejected for this + // reason alone (not because of a missing uniqueness constraint). + createTable("CREATE TABLE fact_oor2 (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_oor2 (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_oor2 add constraint uq_dim_oor2_k unique (k)"); + + // d.k AS new_k creates an Alias with a new ExprId. The inner + // query references t.new_k, so the Apply's correlation slot is + // this new ExprId. The scan of dim_oor2 outputs d.k with its + // original ExprId — the check in checkRelation() fails. + String sql = "SELECT t.id, t.new_k, t.v " + + "FROM (" + + " SELECT f.id, d.k AS new_k, f.v " + + " FROM fact_oor2 f, dim_oor2 d " + + " WHERE f.k = d.k" + + ") t " + + "WHERE t.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_oor2 f2 " + + " WHERE f2.k = t.new_k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .applyTopDown(new PushDownFilterThroughProject()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // The aliased ExprId is not in the scan's output — must reject. + Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance), + "Rewrite must be rejected when the correlated slot ExprId " + + "is not in the outer-only relation's scan output " + + "(e.g. d.k AS new_k creates a new ExprId)"); + } + + @Test + public void testNestedOuterFilterHoistedAboveWindow() throws Exception { + // When the outer child of Apply contains a nested LogicalFilter + // (e.g. a filter pushed into the FROM subquery like + // FROM (SELECT * FROM fact WHERE v > 6) sf), the rule must extract + // the nested conjuncts, classify them, and hoist shared-table + // predicates ABOVE the window. Otherwise the window would aggregate + // over a filtered subset, while the original scalar subquery computes + // over ALL fact rows for the key. + createTable("CREATE TABLE fact_nested (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_nested (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_nested add constraint uq_dim_nested_k unique (k)"); + + // The FROM-subquery with WHERE v > 6 produces a LogicalFilter(f.v > 6) + // nested inside apply.left() under the LogicalSubQueryAlias. + String sql = "SELECT d.did, sf.id, sf.k, sf.v " + + "FROM (SELECT id, k, v FROM fact_nested WHERE v > 6) sf, dim_nested d " + + "WHERE sf.k = d.k " + + " AND sf.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_nested f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule should match and produce a window + Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance), + "Rule should produce a window when nested outer filter is present"); + + // The nested shared-table predicate (v > 6) must be hoisted ABOVE the + // window. Verify it is both absent below AND preserved above. + List rels = plan.collectToList(CatalogRelation.class::isInstance); + Set factExprIds = rels.stream() + .filter(r -> r.getTable().getName().equals("fact_nested")) + .flatMap(r -> r.getOutputExprIdSet().stream()) + .collect(Collectors.toSet()); + List> windows = plan.collectToList(LogicalWindow.class::isInstance); + LogicalWindow window = windows.get(0); + Plan belowWindow = window.child(0); + List> belowFilters = belowWindow + .collectToList(LogicalFilter.class::isInstance); + for (LogicalFilter f : belowFilters) { + for (Expression conj : f.getConjuncts()) { + Set conjExprIds = conj.getInputSlotExprIds(); + if (!conjExprIds.isEmpty() && factExprIds.containsAll(conjExprIds)) { + Assertions.fail( + "Nested shared-table predicate should be hoisted above window: " + + conj.toSql()); + } + } + } + + // Preservation: the hoisted predicate must appear exactly once in + // a filter ABOVE the window (not just absent below). + List> allFilters = plan + .collectToList(LogicalFilter.class::isInstance); + List> aboveFilters = allFilters.stream() + .filter(f -> !belowFilters.contains(f)) + .collect(Collectors.toList()); + int sharedOnlyAboveCount = 0; + for (LogicalFilter f : aboveFilters) { + for (Expression conj : f.getConjuncts()) { + Set conjExprIds = conj.getInputSlotExprIds(); + if (!conjExprIds.isEmpty() && factExprIds.containsAll(conjExprIds)) { + sharedOnlyAboveCount++; + } + } + } + Assertions.assertEquals(1, sharedOnlyAboveCount, + "Hoisted shared-table predicate (v > 6) must be preserved " + + "exactly once above the window, not silently dropped"); + } + + @Test + public void testVolatilePredicateStaysAboveWindow() throws Exception { + // Volatile predicates like random() > 0.5 have no table column + // references but are non-deterministic. They must stay ABOVE the + // window, otherwise the window function would aggregate over a + // different set of rows per partition than the original scalar + // subquery. This follows the same principle as + // PushDownFilterThroughWindow.canPushDown(). + createTable("CREATE TABLE fact_volatile (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_volatile (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_volatile add constraint uq_dim_volatile_k unique (k)"); + + // random() > 0.5 is a volatile predicate with no input slots. + // It must be kept ABOVE the window. + String sql = "SELECT d.did, f.id, f.k, f.v " + + "FROM fact_volatile f, dim_volatile d " + + "WHERE f.k = d.k " + + " AND random() > 0.5" + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_volatile f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule should match and produce a window + Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance), + "Rule should produce a window for volatile predicate query"); + + // Verify the volatile predicate is NOT below the window. + List> windows = plan.collectToList(LogicalWindow.class::isInstance); + LogicalWindow window = windows.get(0); + Plan belowWindow = window.child(0); + List> belowFilters = belowWindow + .collectToList(LogicalFilter.class::isInstance); + for (LogicalFilter f : belowFilters) { + for (Expression conj : f.getConjuncts()) { + Assertions.assertFalse(conj.containsVolatileExpression(), + "Volatile predicate should stay above window: " + conj.toSql()); + } + } + + // Preservation: the volatile predicate must appear exactly once in + // a filter ABOVE the window (not just absent below). + List> allFilters = plan + .collectToList(LogicalFilter.class::isInstance); + List> aboveFilters = allFilters.stream() + .filter(f -> !belowFilters.contains(f)) + .collect(Collectors.toList()); + int volatileAboveCount = 0; + for (LogicalFilter f : aboveFilters) { + for (Expression conj : f.getConjuncts()) { + if (conj.containsVolatileExpression()) { + volatileAboveCount++; + } + } + } + Assertions.assertEquals(1, volatileAboveCount, + "Volatile predicate (random() > 0.5) must be preserved " + + "exactly once above the window, not silently dropped"); + } + + @Test + public void testInnerFilterConjunctsStayBelowWindow() throws Exception { + // Regression test: shared-table predicates that were matched against + // inner subquery filter conjuncts must stay BELOW the window. + // + // Without the matchedInnerFilterConjuncts tracking, f.v < 10 would be + // classified as shared-table-only and placed ABOVE the window, letting + // the window aggregate over rows the original scalar subquery excluded. + createTable("CREATE TABLE fact_inner_filter (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_inner_filter (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + // UNIQUE constraint so the rule matches + addConstraint("alter table dim_inner_filter add constraint uq_dim_if_k unique (k)"); + + // Inner subquery has f2.v < 10 as a filter. After checkFilter matches + // it against outer f.v < 10, the outer conjunct must go BELOW the window + // because it is semantically part of the inner aggregate's filter. + String sql = "SELECT d.did, f.id, f.k, f.v " + + "FROM fact_inner_filter f, dim_inner_filter d " + + "WHERE f.k = d.k " + + " AND f.v < 10" + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_inner_filter f2 " + + " WHERE f2.k = d.k" + + " AND f2.v < 10" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule should match and produce a window + Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance), + "Rule should produce a window for this query"); + + // Collect the ExprIds of the shared table (fact_inner_filter). + List allRels = plan.collectToList(CatalogRelation.class::isInstance); + Set sharedExprIds = allRels.stream() + .filter(r -> r.getTable().getName().equals("fact_inner_filter")) + .flatMap(r -> r.getOutputExprIdSet().stream()) + .collect(Collectors.toSet()); + + // The conjunct f.v < 10, which was matched from the inner filter, must + // appear in a filter BELOW the window (it is part of the aggregate + // computation). Verify it exists there and is NOT above. + List> windows = plan.collectToList(LogicalWindow.class::isInstance); + LogicalWindow window = windows.get(0); + + // Check below-window filters: there MUST be at least one shared-table-only + // conjunct (f.v < 10) — this is the matched inner-filter predicate. + Plan belowWindow = window.child(0); + List> belowFilters = belowWindow + .collectToList(LogicalFilter.class::isInstance); + boolean foundSharedOnlyBelow = false; + for (LogicalFilter f : belowFilters) { + for (Expression conj : f.getConjuncts()) { + Set conjExprIds = conj.getInputSlotExprIds(); + if (!conjExprIds.isEmpty() && sharedExprIds.containsAll(conjExprIds)) { + foundSharedOnlyBelow = true; + } + } + } + Assertions.assertTrue(foundSharedOnlyBelow, + "Matched inner-filter conjunct f.v < 10 must be below the window"); + + // Check above-window filters: there should NOT be a shared-table-only + // conjunct that is NOT the window comparison. f.v < 10 should not leak + // above. + List> allFilters = plan + .collectToList(LogicalFilter.class::isInstance); + List> aboveFilters = allFilters.stream() + .filter(f -> !belowFilters.contains(f)) + .collect(Collectors.toList()); + for (LogicalFilter f : aboveFilters) { + for (Expression conj : f.getConjuncts()) { + Set conjExprIds = conj.getInputSlotExprIds(); + if (!conjExprIds.isEmpty() && sharedExprIds.containsAll(conjExprIds)) { + Assertions.fail( + "Unexpected shared-table-only predicate above window: " + conj.toSql()); + } + } + } + } + + @Test + public void testSplitInnerFilterFromPushDown() throws Exception { + // Regression: PushDownFilterThroughProject splits the inner WHERE clause + // into multiple LogicalFilter nodes when a correlated predicate cannot + // be pushed through a project (references a correlated slot not in the + // project output) but a non-correlated predicate can. + // + // Before the fix, checkFilter() required exactly one inner filter and + // would reject plans where the filter was split. Now it collects + // conjuncts from ALL inner filters. + createTable("CREATE TABLE fact_split2 (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_split2 (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_split2 add constraint uq_dim_split2_k unique (k)"); + + String sql = "SELECT d.did, f.id, f.k, f.v " + + "FROM fact_split2 f, dim_split2 d " + + "WHERE f.k = d.k " + + " AND f.v < 10 " + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_split2 f2 " + + " WHERE f2.k = d.k" + + " AND f2.v < 10" + + " )"; + + // Full regression-style pipeline matching the production rewrite + // schedule. Plan Normalization first: LogicalSubQueryAliasToLogicalProject + // (production job "Plan Normalization") turns the inner SubQueryAlias + // (FROM fact_split2 f2) into a LogicalProject, so PushDownFilterThroughProject + // later sees an exact Filter -> Project pair. Then subquery unnesting: + // PullUpProjectUnderApply FIRST (which exposes the inner plan), then + // PushDownFilterThroughProject (which can now split an exact + // Filter -> Project pair into correlated-above / non-correlated-below), + // then MergeFilters (which only combines ADJACENT filters — the Project + // in between keeps the two split filters separate). Capture the plan + // immediately before AggScalarSubQueryToWindowFunction to prove the + // split actually happened. + Plan preRule = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyTopDown(new LogicalSubQueryAliasToLogicalProject()) + .applyBottomUp(new PullUpProjectUnderApply()) + .applyTopDown(new PushDownFilterThroughProject()) + .applyBottomUp(new MergeFilters()) + .customRewrite(new EliminateUnnecessaryProject()) + .getPlan(); + + // Locate the correlated Apply that AggScalarSubQueryToWindowFunction + // will rewrite. + List> applies = preRule + .collectToList(LogicalApply.class::isInstance); + Assertions.assertEquals(1, applies.size(), + "Pre-rule plan must contain exactly one correlated Apply"); + LogicalApply targetApply = applies.get(0); + + // The Apply's right subtree must contain exactly two LogicalFilter + // nodes with SEPARATED predicates — one holding the correlated + // conjunct (f2.k = d.k) and one holding the non-correlated conjunct + // (f2.v < 10). This proves PushDownFilterThroughProject produced + // the split the test is meant to exercise; a single merged filter + // would make this regression pass trivially. + List> innerFilters = targetApply.right() + .collectToList(LogicalFilter.class::isInstance); + Assertions.assertEquals(2, innerFilters.size(), + "PushDownFilterThroughProject must split the inner filter " + + "into two LogicalFilter nodes. Actual plan:\n" + + targetApply.treeString()); + + // Each filter node must hold exactly one of the two predicates: + // one conjunct references the correlated slot (d.k), the other + // references only the inner fact table's slots. + Set correlatedExprIds = targetApply.getCorrelationSlot().stream() + .map(Slot::getExprId) + .collect(Collectors.toSet()); + Assertions.assertEquals(1, correlatedExprIds.size(), + "Scalar subquery must correlate on exactly one slot"); + boolean correlatedAlone = false; + boolean nonCorrelatedAlone = false; + for (LogicalFilter f : innerFilters) { + boolean hasCorrelated = false; + boolean hasNonCorrelated = false; + for (Expression conj : f.getConjuncts()) { + if (conj.getInputSlotExprIds().stream() + .anyMatch(correlatedExprIds::contains)) { + hasCorrelated = true; + } else { + hasNonCorrelated = true; + } + } + if (hasCorrelated && !hasNonCorrelated) { + correlatedAlone = true; + } else if (hasNonCorrelated && !hasCorrelated) { + nonCorrelatedAlone = true; + } + } + Assertions.assertTrue(correlatedAlone, + "One inner filter must hold the correlated predicate " + + "(f2.k = d.k) alone: " + targetApply.treeString()); + Assertions.assertTrue(nonCorrelatedAlone, + "One inner filter must hold the non-correlated predicate " + + "(f2.v < 10) alone: " + targetApply.treeString()); + + // Now run the rewrite on the proven-split plan. + Plan plan = new AggScalarSubQueryToWindowFunction() + .rewriteRoot(preRule, null); + + // Rule should match and produce a window + Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance), + "Rule should produce a window even when inner filter is split by " + + "PushDownFilterThroughProject"); + + // Verify f.v < 10 (matched from inner filter) is below the window. + // The matched conjunct references only the fact table's slots. + List rels = plan.collectToList(CatalogRelation.class::isInstance); + Set factExprIds = rels.stream() + .filter(r -> r.getTable().getName().equals("fact_split2")) + .flatMap(r -> r.getOutputExprIdSet().stream()) + .collect(Collectors.toSet()); + List> windows = plan.collectToList(LogicalWindow.class::isInstance); + LogicalWindow window = windows.get(0); + Plan belowWindow = window.child(0); + List> belowFilters = belowWindow + .collectToList(LogicalFilter.class::isInstance); + boolean found = false; + for (LogicalFilter f : belowFilters) { + for (Expression conj : f.getConjuncts()) { + Set conjExprIds = conj.getInputSlotExprIds(); + if (!conjExprIds.isEmpty() + && factExprIds.containsAll(conjExprIds) + && conj.toSql().contains("< 10")) { + found = true; + } + } + } + Assertions.assertTrue(found, + "Matched inner-filter conjunct f.v < 10 must be below the window: " + + belowWindow.treeString()); + } + + @Test + public void testNestedVolatilePredicateStaysInPlace() throws Exception { + // Volatile predicates in nested filters (inside a FROM subquery like + // (SELECT * FROM dim WHERE random() > 0.5)) must NOT be hoisted above + // the window or join. Moving a volatile predicate across a join + // changes its evaluation frequency: + // + // CrossJoin(fact, (SELECT * FROM dim WHERE random()>0.5) d) + // + // originally evaluates random() once per dim row BEFORE the join. + // Hoisting it above the window/join evaluates random() once per + // joined fact row — one dim row with two matching fact rows can + // now keep one row instead of both or none. We must keep volatile + // nested-filter predicates at their original child position while + // only extracting deterministic predicates. + createTable("CREATE TABLE fact_nested_vol (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_nested_vol (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_nested_vol add constraint uq_dim_nested_vol_k unique (k)"); + + // random() > 0.5 is nested inside the FROM subquery on dim_nested_vol. + // It must stay at its original position, NOT appear in the top filter + // above the window. + String sql = "SELECT d.did, f.id, f.k, f.v " + + "FROM fact_nested_vol f, " + + " (SELECT * FROM dim_nested_vol WHERE random() > 0.5) d " + + "WHERE f.k = d.k " + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_nested_vol f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule should match and produce a window + Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance), + "Rule should produce a window when nested volatile filter is present"); + + // The volatile predicate must NOT be above the window, AND must + // still be present below the window (proving it was preserved, not + // silently dropped by stripOuterFilters or a later change). + List> windows = plan.collectToList(LogicalWindow.class::isInstance); + LogicalWindow window = windows.get(0); + Plan belowWindow = window.child(0); + List> belowFilters = belowWindow + .collectToList(LogicalFilter.class::isInstance); + List> allFilters = plan + .collectToList(LogicalFilter.class::isInstance); + List> aboveFilters = allFilters.stream() + .filter(f -> !belowFilters.contains(f)) + .collect(Collectors.toList()); + for (LogicalFilter f : aboveFilters) { + for (Expression conj : f.getConjuncts()) { + Assertions.assertFalse(conj.containsVolatileExpression(), + "Nested volatile predicate should stay at its original position, " + + "not be hoisted above the window: " + conj.toSql()); + } + } + // Prove the volatile predicate was preserved below the window. + boolean foundVolatileBelow = false; + for (LogicalFilter f : belowFilters) { + for (Expression conj : f.getConjuncts()) { + if (conj.containsVolatileExpression()) { + foundVolatileBelow = true; + } + } + } + Assertions.assertTrue(foundVolatileBelow, + "Nested volatile predicate must still exist below the window — " + + "it should have been preserved at its original position, " + + "not silently dropped"); + } + + @Test + public void testVolatileNestedOnSharedTableRejected() throws Exception { + // A volatile predicate nested on a SHARED table (fact, which appears + // in both outer and inner plans) must cause the rewrite to be REJECTED. + // + // Keeping the volatile filter in place below the window would let the + // window aggregate over fewer fact rows than the original scalar + // subquery (which sums ALL fact f2 rows per key). The same hazard + // does not apply to volatile filters on the outer-only table because + // the original scalar subquery does not touch that table. + // + // Plan shape that would be unsafe: + // CrossJoin + // Filter(random() > 0.5) ← volatile on shared table fact + // Scan fact sf + // Scan dim_shared_vol d ← outer-only, unique k + // + // After rewrite, the window would compute SUM(sf.v) OVER(PARTITION BY + // d.k) only over random-surviving fact rows, but the original scalar + // subquery SELECT SUM(f2.v) FROM fact f2 WHERE f2.k = d.k does NOT + // have a random filter — it always sees all fact rows. + createTable("CREATE TABLE fact_shared_vol (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_shared_vol (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_shared_vol add constraint uq_dim_shared_vol_k unique (k)"); + + // random() > 0.5 is on the shared table fact_shared_vol (inside the + // FROM subquery on the SHARED table). The rewrite must be rejected. + String sql = "SELECT d.did, sf.id, sf.k, sf.v " + + "FROM (SELECT * FROM fact_shared_vol WHERE random() > 0.5) sf, " + + " dim_shared_vol d " + + "WHERE sf.k = d.k " + + " AND sf.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_shared_vol f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule must NOT match — volatile on shared table is unsafe + Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance), + "Rewrite must be rejected when volatile predicate is on the " + + "shared table (fact), otherwise the window would compute " + + "over fewer rows than the original scalar subquery"); + } + + @Test + public void testVolatileSplitFromOuterOnlySiblingRejected() throws Exception { + // When the top-level filter (the filter on top of the Apply) contains + // both a volatile/NoneMovableFunction conjunct AND another deterministic + // conjunct that would go below the window (outer-only columns), the + // rewrite must be rejected. Splitting conjuncts from the same filter + // operator changes which rows reach the side-effecting predicate. + // + // In the original plan: + // Filter(d.tag > 0 AND random() > 0.5 AND f.v * 2 > (...)) + // BE evaluates both d.tag > 0 and random() > 0.5 against the full + // input block. After the rewrite: + // Filter(random() > 0.5) ← above window + // Window(...) + // Filter(d.tag > 0) ← below window + // Rows rejected by d.tag > 0 never reach random() above the window, + // changing evaluation context and potentially suppressing errors. + createTable("CREATE TABLE fact_split_vol (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_split_vol (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_split_vol add constraint uq_dim_split_vol_k unique (k)"); + + // The top-level filter contains both d.tag > 0 (outer-only → below + // window) and random() > 0.5 (volatile → above window). The rewrite + // would split them — must reject. + String sql = "SELECT d.did, f.id, f.k, f.v " + + "FROM fact_split_vol f, dim_split_vol d " + + "WHERE f.k = d.k " + + " AND d.tag > 0" + + " AND random() > 0.5" + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_split_vol f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule must NOT match — volatile and outer-only conjuncts from the + // same filter would be split across the window. + Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance), + "Rewrite must be rejected when the same filter contains both " + + "a volatile predicate and an outer-only predicate, because " + + "splitting them changes which rows reach the volatile expr"); + } + + @Test + public void testNonMovableNestedOnOuterOnlyKeptInPlace() throws Exception { + // NoneMovableFunction predicates like assert_true() have side effects + // and must not be moved from their original branch position. When + // placed on the outer-only table, preserving them in place is safe. + createTable("CREATE TABLE fact_nm_outer (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_nm_outer (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_nm_outer add constraint uq_dim_nm_outer_k unique (k)"); + + // assert_true(tag > 0, 'bad') is on the outer-only table dim_nm_outer. + // It must stay at its original position below the window. + String sql = "SELECT d.did, f.id, f.k, f.v " + + "FROM fact_nm_outer f, " + + " (SELECT * FROM dim_nm_outer WHERE assert_true(tag > 0, 'bad')) d " + + "WHERE f.k = d.k " + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_nm_outer f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule should match — NoneMovable on outer-only is safe to keep in place + Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance), + "Rewrite should succeed when NoneMovableFunction predicate is " + + "on the outer-only table"); + + // The assert_true predicate must NOT be hoisted above the window, + // AND must still be present below the window (proving it was + // preserved, not silently dropped). + List> windows = plan.collectToList(LogicalWindow.class::isInstance); + LogicalWindow window = windows.get(0); + Plan belowWindow = window.child(0); + List> belowFilters = belowWindow + .collectToList(LogicalFilter.class::isInstance); + List> allFilters = plan + .collectToList(LogicalFilter.class::isInstance); + List> aboveFilters = allFilters.stream() + .filter(f -> !belowFilters.contains(f)) + .collect(Collectors.toList()); + for (LogicalFilter f : aboveFilters) { + for (Expression conj : f.getConjuncts()) { + Assertions.assertFalse( + conj.containsType( + org.apache.doris.nereids.trees.expressions.functions + .NoneMovableFunction.class), + "NoneMovableFunction predicate should stay at its original " + + "position, not be hoisted above the window: " + + conj.toSql()); + } + } + // Prove the NoneMovableFunction predicate was preserved below the window. + boolean foundNoneMovableBelow = false; + for (LogicalFilter f : belowFilters) { + for (Expression conj : f.getConjuncts()) { + if (conj.containsType( + org.apache.doris.nereids.trees.expressions.functions + .NoneMovableFunction.class)) { + foundNoneMovableBelow = true; + } + } + } + Assertions.assertTrue(foundNoneMovableBelow, + "NoneMovableFunction predicate must still exist below the window — " + + "it should have been preserved at its original position, " + + "not silently dropped"); + } + + @Test + public void testNonMovableNestedOnSharedTableRejected() throws Exception { + // NoneMovableFunction predicates like assert_true() must not be moved + // from their original position. When placed on a shared table, keeping + // them in place would restrict the window's input relative to the + // original scalar subquery (same hazard as volatile on shared). + createTable("CREATE TABLE fact_nm_shared (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_nm_shared (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_nm_shared add constraint uq_dim_nm_shared_k unique (k)"); + + // assert_true(v > 0, 'bad') is nested in a WHERE clause on the shared + // table fact_nm_shared. The rewrite must be rejected because the + // window would compute over a subset of fact rows, while the original + // scalar subquery sees all. + String sql = "SELECT d.did, sf.id, sf.k, sf.v " + + "FROM (SELECT * FROM fact_nm_shared " + + " WHERE assert_true(v > 0, 'bad')) sf, " + + " dim_nm_shared d " + + "WHERE sf.k = d.k " + + " AND sf.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_nm_shared f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule must NOT match — NoneMovable on shared table is unsafe + Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance), + "Rewrite must be rejected when NoneMovableFunction predicate " + + "is on the shared table"); + } + + @Test + public void testNoneMovableInAggregateArgRejected() throws Exception { + // When the aggregate argument contains a NoneMovableFunction + // (e.g. COUNT(assert_true(f2.v > 0, 'bad'))), the rewrite must + // be rejected. The window evaluates the aggregate over ALL + // rows per partition, while predicates pushed below the window + // filter rows before the side-effecting function runs — + // suppressing expected errors. + // + // Plan shape: + // Filter(f.k = d.k, d.tag > 0, f.v > scalar_count) + // Apply(correlation = d.k) + // CrossJoin + // Filter(f.keep > 0) + // Scan fact f + // Scan dim d ← unique, non-null k + // Aggregate(COUNT(assert_true(f2.v > 0, 'bad'))) + // Filter(f2.k = d.k) + // Scan fact f2 + // + // Without rejection, the rewrite places d.tag > 0 (outer-only) + // and f.k = d.k (matched inner filter) BELOW the window, so + // the failing key-1 row is removed before assert_true runs. + createTable("CREATE TABLE fact_nm_agg (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT,\n" + + " keep INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_nm_agg (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_nm_agg add constraint uq_dim_nm_agg_k unique (k)"); + + // Aggregate argument contains assert_true — must reject. + String sql = "SELECT d.did, f.id, f.v " + + "FROM (SELECT * FROM fact_nm_agg WHERE keep > 0) f, dim_nm_agg d " + + "WHERE f.k = d.k " + + " AND d.tag > 0" + + " AND f.v > (" + + " SELECT COUNT(assert_true(f2.v > 0, 'bad')) " + + " FROM fact_nm_agg f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule must NOT match — unsafe aggregate argument cannot be + // safely window-rewritten because predicates below the window + // would suppress the side-effecting function's errors. + Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance), + "Rewrite must be rejected when the aggregate argument " + + "contains a NoneMovableFunction (e.g. assert_true) " + + "because predicates pushed below the window would " + + "suppress its side effects"); + } + + @Test + public void testNoneMovableWrappingAggregateOutputRejected() throws Exception { + // The unsafe call can also WRAP the aggregate output rather than + // being an argument of it — e.g. + // Aggregate(assert_true(SUM(f2.v) > 0, 'bad') AS scalar_flag) + // checkAggregate() must validate the COMPLETE output expression, + // not just the collected AggregateFunction (SUM). Checking only + // SUM would miss assert_true, which is an ANCESTOR of SUM in the + // output expression tree. + // + // Plan shape: + // Filter(d.tag > 0, f.k = d.k, TRUE = scalar_flag) + // Apply(correlation = d.k) + // CrossJoin + // Scan fact f + // Scan dim d ← unique, non-null k + // Aggregate(assert_true(SUM(f2.v) > 0, 'bad') AS scalar_flag) + // Filter(f2.k = d.k) + // Scan fact f2 + // + // Without rejection, rewrite() inlines + // assert_true(window_sum > 0, 'bad') into the top comparison while + // d.tag > 0 and the matched join predicate go below the window. + // For a failing key whose dimension row has tag = 0, the original + // Apply raises before the outer filter; the rewritten lower filter + // removes that key before the assertion, suppressing the error. + createTable("CREATE TABLE fact_nm_wrap (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_nm_wrap (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_nm_wrap add constraint uq_dim_nm_wrap_k unique (k)"); + + // assert_true wraps the aggregate output (SUM(f2.v) > 0). The + // unsafe call is an ancestor of SUM, outside the collected + // AggregateFunction subtree — must reject. + String sql = "SELECT d.did, f.id, f.v " + + "FROM fact_nm_wrap f, dim_nm_wrap d " + + "WHERE f.k = d.k " + + " AND d.tag > 0" + + " AND TRUE = (" + + " SELECT assert_true(SUM(f2.v) > 0, 'bad') " + + " FROM fact_nm_wrap f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule must NOT match — the unsafe wrapper around the aggregate + // output would be inlined above the window while predicates below + // remove failing rows before the assertion runs. + Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance), + "Rewrite must be rejected when a NoneMovableFunction wraps " + + "the aggregate output (e.g. assert_true(SUM(...) > 0)) " + + "because predicates pushed below the window would " + + "suppress its side effects"); + } + + @Test + public void testNoneMovableInnerFilterRejected() throws Exception { + // checkFilter() must reject NoneMovableFunction predicates in the + // inner subquery filter, just like volatile expressions. Two + // syntactically identical assert_true() calls — one in the outer + // filter, one in the inner filter — are independent evaluations: + // the inner one is part of the aggregate filter, the outer one is + // a per-row assertion. ExpressionIdenticalChecker would match them + // structurally (same class + children after slot replacement), + // collapsing the independent evaluations into one below-window + // predicate and effectively pruning one side-effecting assertion. + // This guard must reject the match so the rule does not fire. + createTable("CREATE TABLE fact_nm_inner (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_nm_inner (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_nm_inner add constraint uq_dim_nm_inner_k unique (k)"); + + // assert_true(f.v > 0, 'bad') appears in BOTH the outer WHERE and + // the inner subquery WHERE. They are independent per-row + // assertions — the rule must NOT collapse them into one. + String sql = "SELECT d.did, f.id, f.k, f.v " + + "FROM fact_nm_inner f, dim_nm_inner d " + + "WHERE f.k = d.k " + + " AND assert_true(f.v > 0, 'bad')" + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_nm_inner f2 " + + " WHERE f2.k = d.k" + + " AND assert_true(f2.v > 0, 'bad')" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule must NOT match — NoneMovableFunction inner conjunct must not + // be matched against an outer NoneMovableFunction conjunct. + Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance), + "Rewrite must be rejected when inner subquery filter contains " + + "NoneMovableFunction predicates, even if they structurally " + + "match outer conjuncts"); + } + + @Test + public void testNoneMovableInTopLevelWhereKeptAboveWindow() throws Exception { + // A NoneMovableFunction predicate in the top-level outer WHERE + // that references only the outer-only table — e.g. + // assert_true(d.tag > 0, 'bad') — must NOT be pushed below the + // window. Without the guard, it falls through the split: it is + // not volatile, not matched-inner, and hasShared=false, so it + // ends up in belowWindowConjuncts, moving a side-effecting + // evaluation to a different plan location. + createTable("CREATE TABLE fact_nm_toplevel (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_nm_toplevel (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_nm_toplevel add constraint uq_dim_nm_toplevel_k unique (k)"); + + // assert_true(d.tag > 0, 'bad') is in the top-level WHERE and + // references only dim_nm_toplevel (outer-only). It must stay + // ABOVE the window, not be pushed below. + String sql = "SELECT d.did, f.id, f.k, f.v " + + "FROM fact_nm_toplevel f, dim_nm_toplevel d " + + "WHERE f.k = d.k " + + " AND assert_true(d.tag > 0, 'bad')" + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_nm_toplevel f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule should match — NoneMovable on outer-only is safe when + // kept at its original position above the window. + Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance), + "Rewrite should succeed when NoneMovableFunction predicate " + + "is on outer-only table and kept above the window"); + + // The assert_true predicate must NOT be pushed below the window. + List> windows = plan.collectToList(LogicalWindow.class::isInstance); + LogicalWindow window = windows.get(0); + Plan belowWindow = window.child(0); + List> belowFilters = belowWindow + .collectToList(LogicalFilter.class::isInstance); + for (LogicalFilter f : belowFilters) { + for (Expression conj : f.getConjuncts()) { + Assertions.assertFalse( + conj.containsType( + org.apache.doris.nereids.trees.expressions.functions + .NoneMovableFunction.class), + "NoneMovableFunction predicate must stay above the " + + "window, not be pushed below: " + conj.toSql()); + } + } + + // Prove the NoneMovableFunction predicate still exists above the + // window — it must not be silently dropped. All filters that are + // not ancestors/descendants of the window's child are above-window + // filters in the rewritten plan. + List> allFilters = plan + .collectToList(LogicalFilter.class::isInstance); + List> aboveOnlyFilters = allFilters.stream() + .filter(f -> !belowFilters.contains(f)) + .collect(Collectors.toList()); + boolean foundNoneMovableAbove = false; + for (LogicalFilter f : aboveOnlyFilters) { + for (Expression conj : f.getConjuncts()) { + if (conj.containsType( + org.apache.doris.nereids.trees.expressions.functions + .NoneMovableFunction.class)) { + foundNoneMovableAbove = true; + } + } + } + Assertions.assertTrue(foundNoneMovableAbove, + "NoneMovableFunction predicate must exist above the window — " + + "it should not be silently dropped"); + } + + @Test + public void testVolatileInnerFilterRejected() throws Exception { + // checkFilter() must reject volatile expressions in the inner subquery + // filter. Two syntactically identical volatile calls — like + // volatile_bool_udf(f.k) in the outer filter and + // volatile_bool_udf(f2.k) in the inner filter — are independent + // evaluations with distinct VolatileIdentity. ExpressionIdenticalChecker + // would match them structurally (same class + children), collapsing + // the independent outer-row filter and inner-aggregate filter into one + // predicate. Use random() > 0.5 as a built-in volatile predicate. + createTable("CREATE TABLE fact_vinner (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_vinner (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_vinner add constraint uq_dim_vinner_k unique (k)"); + + // random() > 0.5 appears in both the outer WHERE and the inner WHERE. + // Even though they look identical, they are independent volatile calls. + // checkFilter must reject this match. + String sql = "SELECT d.did, f.id, f.k, f.v " + + "FROM fact_vinner f, dim_vinner d " + + "WHERE f.k = d.k " + + " AND random() > 0.5" + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_vinner f2 " + + " WHERE f2.k = d.k" + + " AND random() > 0.5" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule must NOT match — volatile inner conjunct cannot be matched + Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance), + "Rewrite must be rejected when inner subquery filter contains " + + "volatile predicates, even if they structurally match outer " + + "conjuncts"); + } + + @Test + public void testStateClearBetweenSiblingCandidates() throws Exception { + // The same rule instance processes every LogicalFilter in one + // rewriteRoot() call via deep traversal. Two FROM-subquery + // branches under a CrossJoin produce two sibling Filter→Apply + // candidates. The left branch is rejected (non-unique table); + // the right branch should succeed (unique table). Without the + // clear() calls in check(), the rejected candidate's aggregate + // leaks into functions, making checkAggregate() see + // functions.size() != 1 for the valid candidate. + createTable("CREATE TABLE fact_clear (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + // dim_clear_dup: DUPLICATE KEY → k is NOT unique → rejected + createTable("CREATE TABLE dim_clear_dup (\n" + + " did INT,\n" + + " k INT,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + // dim_clear_uniq: add UNIQUE constraint → k IS unique → valid + createTable("CREATE TABLE dim_clear_uniq (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_clear_uniq add constraint uq_dim_clear_uniq_k unique (k)"); + + // Two FROM subqueries produce two sibling Filter→Apply candidates + // under the CrossJoin. The left one is rejected (dim_clear_dup.k + // is not unique), the right one is valid (dim_clear_uniq.k is unique). + // If per-candidate state is not cleared, the left candidate's + // aggregate leaks into the right candidate's checkAggregate(). + String sql = "SELECT a.id, b.id " + + "FROM " + + " (SELECT f.id FROM fact_clear f, dim_clear_dup d " + + " WHERE f.k = d.k " + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) FROM fact_clear f2 WHERE f2.k = d.k" + + " )) a, " + + " (SELECT f.id FROM fact_clear f, dim_clear_uniq du " + + " WHERE f.k = du.k " + + " AND f.v * 3 > (" + + " SELECT SUM(f2.v) FROM fact_clear f2 WHERE f2.k = du.k" + + " )) b"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // The right branch should be rewritten to a window. + // If clear() is missing, stale state from the left (rejected) + // branch contaminates the right candidate and no window appears. + Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance), + "Valid right candidate should produce a window after a " + + "rejected left candidate, proving per-candidate state " + + "is cleared in check()"); + } + + @Test + public void testPrunedAggregateSlotExpandsProject() throws Exception { + // The window function's aggregate (after slot replacement) references + // shared-table slots. When a pruning project inside apply.left() + // drops those slots and there are no nested filters to extract, + // ensureProjectOutput must still expand the project to carry the + // aggregate's input slots through. Otherwise the window child does + // not expose the column and the rewritten plan has a dangling ref. + // + // Plan shape: + // Filter(sf.k = d.k, sf.k * 2 > sum_alias) + // Apply(correlation: d.k) + // CrossJoin + // SubQueryAlias sf + // Project(k) ← prunes v + // Scan fact(k, v) + // Scan dim_unique(k) + // Aggregate(SUM(f2.v) AS sum_alias) + // Filter(f2.k = d.k) + // Scan fact f2 + // + // After slot replacement SUM(f2.v) → SUM(sf.v). Without the fix, + // Project(k) is not expanded because extractedConjunctExprIds is + // empty (no nested filters). The window references sf.v which is + // not in the project output — dangling reference. + createTable("CREATE TABLE fact_agg_prune (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_agg_prune (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_agg_prune add constraint uq_dim_agg_prune_k unique (k)"); + + // Subquery prunes v; window aggregate SUM(f2.v) needs sf.v. + // No nested filter to extract; extractedConjunctExprIds is empty. + String sql = "SELECT sf.k, d.did " + + "FROM (SELECT k FROM fact_agg_prune) sf, " + + " dim_agg_prune d " + + "WHERE sf.k = d.k " + + " AND sf.k * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_agg_prune f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule must match and produce a window. + Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance), + "Rule must produce a window when aggregate slot is pruned"); + + // Walk every filter; verify every conjunct slot is produced by + // the filter's child. Also walk every window and verify its + // input slots are produced by the window's child. + List> allFilters = plan + .collectToList(LogicalFilter.class::isInstance); + for (LogicalFilter f : allFilters) { + Set childOutput = f.child().getOutputExprIdSet(); + for (Expression conj : f.getConjuncts()) { + for (ExprId id : conj.getInputSlotExprIds()) { + Assertions.assertTrue(childOutput.contains(id), + "Filter conjunct slot " + id + + " not produced by child. Conjunct: " + + conj.toSql()); + } + } + } + List> windows = plan + .collectToList(LogicalWindow.class::isInstance); + for (LogicalWindow w : windows) { + Set childOutput = w.child().getOutputExprIdSet(); + for (NamedExpression ne : w.getWindowExpressions()) { + for (ExprId id : ne.getInputSlotExprIds()) { + Assertions.assertTrue(childOutput.contains(id), + "Window expression slot " + id + + " not produced by child. Expression: " + + ne.toSql()); + } + } + } + } + + @Test + public void testDifferentUdfNamesRejectedInCheckFilter() throws Exception { + // checkFilter() must reject deterministic UDF predicates when the + // inner and outer UDF have different function names, even if they + // share the same runtime class (PythonUdf / JavaUdf) and have the + // same children after slot replacement. + // + // ExpressionIdenticalChecker dispatches UDF wrapper nodes to the + // generic visitor, which only checks runtime class and children. + // Two syntactically identical calls to different UDFs — like + // outer_bool_udf(f.v) and inner_bool_udf(f2.v) after slot + // replacement — would incorrectly match without the BoundFunction + // name guard. The match would then collapse the independent + // outer and inner evaluations into a single below-window + // predicate, silently replacing the inner aggregate filter with + // the outer UDF. + // + // Both UDFs are registered as IMMUTABLE so the volatile guard + // does not mask the bug. + createFunction("CREATE FUNCTION outer_bool_udf(INT) RETURNS BOOLEAN " + + "PROPERTIES (" + + " 'type'='PYTHON_UDF'," + + " 'symbol'='evaluate'," + + " 'runtime_version'='3.10.2'," + + " 'volatility'='immutable'" + + ")"); + createFunction("CREATE FUNCTION inner_bool_udf(INT) RETURNS BOOLEAN " + + "PROPERTIES (" + + " 'type'='PYTHON_UDF'," + + " 'symbol'='evaluate'," + + " 'runtime_version'='3.10.2'," + + " 'volatility'='immutable'" + + ")"); + + createTable("CREATE TABLE fact_udf_name (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_udf_name (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_udf_name add constraint uq_dim_udf_name_k unique (k)"); + + // outer_bool_udf(f.v) in outer WHERE, inner_bool_udf(f2.v) in inner + // WHERE. After slot replacement, inner_bool_udf(f2.v) → + // inner_bool_udf(f.v). Both are PythonUdf with identical children + // but different function names — ExpressionIdenticalChecker must + // NOT match them. + String sql = "SELECT d.did, f.id, f.k, f.v " + + "FROM fact_udf_name f, dim_udf_name d " + + "WHERE f.k = d.k " + + " AND outer_bool_udf(f.v)" + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_udf_name f2 " + + " WHERE f2.k = d.k" + + " AND inner_bool_udf(f2.v)" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule must NOT match — the two UDFs have different names and + // are different functions, even though they share the same + // PythonUdf wrapper class and have identical children after + // slot replacement. + Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance), + "Rewrite must be rejected when inner UDF has a different " + + "name than the structurally identical outer UDF — " + + "BoundFunction name must be compared"); + } + + @Test + public void testMatchWithDifferentAnalyzerRejected() throws Exception { + // ExpressionIdenticalChecker must not match two MATCH_ANY + // predicates with different USING ANALYZER clauses. The + // analyzer determines which rows are included, so 'english' + // and 'chinese' produce different row sets. Matching them + // would collapse the independent outer and inner filters + // and compute the window aggregate under the wrong analyzer. + createTable("CREATE TABLE fact_match_analyzer (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT,\n" + + " txt STRING,\n" + + " INDEX idx_txt (`txt`) USING INVERTED\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_match_analyzer (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_match_analyzer add constraint uq_dim_match_analyzer_k unique (k)"); + + // Outer MATCH_ANY uses analyzer 'english', inner uses 'chinese'. + // After slot replacement, both are MatchAny with the same + // children but different analyzers — must NOT be matched. + String sql = "SELECT d.did, f.id, f.k, f.v " + + "FROM fact_match_analyzer f, dim_match_analyzer d " + + "WHERE f.k = d.k " + + " AND f.txt MATCH_ANY 'foo' USING ANALYZER 'english'" + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_match_analyzer f2 " + + " WHERE f2.k = d.k" + + " AND f2.txt MATCH_ANY 'foo' USING ANALYZER 'chinese'" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule must NOT match — MATCH with different analyzers are + // different predicates even though they share the same + // MatchAny class and children after slot replacement. + Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance), + "Rewrite must be rejected when MATCH predicates have " + + "different USING ANALYZER clauses"); + } + + @Test + public void testCommutativePredicateMatchBreaksAfterFirstHit() throws Exception { + // When the outer filter contains both ordered forms of the same + // equi-join condition (f.k = d.k and d.k = f.k), + // visitComparisonPredicate accepts both via cp.commute(). + // Without the break in checkFilter(), the inner loop continues + // after a successful match and calls innerIterator.remove() + // twice without a next(), throwing IllegalStateException. + createTable("CREATE TABLE fact_commute (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_commute (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_commute add constraint uq_dim_commute_k unique (k)"); + + // Outer filter has both f.k = d.k and d.k = f.k. + // Inner filter has f2.k = d.k → after slot replacement → f.k = d.k. + // visitComparisonPredicate matches both forms. The break after + // the first match prevents IllegalStateException. + String sql = "SELECT d.did, f.id, f.k, f.v " + + "FROM fact_commute f, dim_commute d " + + "WHERE f.k = d.k " + + " AND d.k = f.k" + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_commute f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule should succeed — both ordered forms are the same join + // condition and the break prevents a double-remove crash. + Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance), + "Rewrite should succeed when outer filter has both " + + "ordered forms of the same equi-join condition"); + } + + @Test + public void testCastWithDifferentTargetTypeRejected() throws Exception { + // ExpressionIdenticalChecker must not match two TRY_CAST + // predicates with different target types. The old generic + // visit() only checked class + children, ignoring the target + // type that Cast.equals() compares. TRY_CAST(f.s AS INT) and + // TRY_CAST(f2.s AS DATE) share the same TryCast class and the + // same slot child after replacement, but target INT ≠ DATE. + createTable("CREATE TABLE fact_cast (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT,\n" + + " s STRING\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_cast (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_cast add constraint uq_dim_cast_k unique (k)"); + + // Outer: TRY_CAST(f.s AS INT) IS NULL + // Inner: TRY_CAST(f2.s AS DATE) IS NULL → after slot replacement + // TRY_CAST(f.s AS DATE) IS NULL + // Same TryCast class, same child, different target types. + String sql = "SELECT d.did, f.id, f.k, f.v " + + "FROM fact_cast f, dim_cast d " + + "WHERE f.k = d.k " + + " AND TRY_CAST(f.s AS INT) IS NULL" + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_cast f2 " + + " WHERE f2.k = d.k" + + " AND TRY_CAST(f2.s AS DATE) IS NULL" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule must NOT match — CAST/TRY_CAST with different target + // types are semantically different predicates. + Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance), + "Rewrite must be rejected when CAST/TRY_CAST predicates " + + "have different target types"); + } + + @Test + public void testUnsafeFilterPreservesSubtreeFilters() throws Exception { + // stripOuterFilters must not strip deterministic filters from + // below a retained unsafe (volatile/NoneMovableFunction) filter. + // If it recurses into the child of an unsafe filter and hoists + // a safe predicate, the unsafe predicate evaluates over a + // different row set — its input domain silently changes. + // + // Plan shape inside apply.left(): + // SubQueryAlias sf + // Filter(assert_true(tag > 0, 'bad')) ← unsafe, must stay + // Project(tag, k, ...) ← slot-only + // Filter(tag > 0) ← safe, must stay below + // Scan dim_unique + createTable("CREATE TABLE fact_unsafe_barrier (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + // dim_unsafe_sf: outer-only table with nested assert_true + tag > 0 + createTable("CREATE TABLE dim_unsafe_sf (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_unsafe_sf add constraint uq_dim_unsafe_sf_k unique (k)"); + + // Double-nested subquery on dim_unsafe_sf (outer-only): inner + // WHERE tag > 0, outer WHERE assert_true(tag > 0, 'bad'). + // After analysis this produces: + // SubQueryAlias sf + // Filter(assert_true) ← unsafe, must stay + // Project(tag, k, ...) ← slot-only + // Filter(tag > 0) ← safe, must stay below unsafe + // Scan dim_unsafe_sf + // fact_unsafe_barrier is the shared table. + String sql = "SELECT sf.did, sf.k, f.v " + + "FROM (" + + " SELECT * FROM (" + + " SELECT * FROM dim_unsafe_sf WHERE tag > 0" + + " ) inner_sf" + + " WHERE assert_true(tag > 0, 'bad')" + + ") sf, " + + "fact_unsafe_barrier f " + + "WHERE sf.k = f.k " + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_unsafe_barrier f2 " + + " WHERE f2.k = sf.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule should match — the unsafe filter is on outer-only table + // and the subtree filter is preserved below it. + Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance), + "Rewrite should succeed when unsafe filter on outer-only " + + "table has a subtree filter preserved below it"); + + // The safe filter (tag > 0) must remain as a descendant of the + // unsafe filter (assert_true) in the plan — stripOuterFilters + // must not hoist it from under a retained unsafe filter. + List> windows = plan.collectToList(LogicalWindow.class::isInstance); + LogicalWindow window = windows.get(0); + Plan belowWindow = window.child(0); + + // Find the assert_true filter below the window — it must still + // have Filter(tag > 0) as a descendant. + List> allBelowFilters = belowWindow + .collectToList(LogicalFilter.class::isInstance); + boolean safeBelowUnsafe = false; + for (LogicalFilter f : allBelowFilters) { + boolean hasNoneMovableFunction = f.getConjuncts().stream() + .anyMatch(c -> c.containsType( + org.apache.doris.nereids.trees.expressions.functions + .NoneMovableFunction.class)); + if (!hasNoneMovableFunction) { + continue; + } + + // This filter has assert_true — verify it has Filter(tag > 0) + // somewhere in its subtree (not just below the window). + List> subtreeFilters = f.child(0) + .collectToList(LogicalFilter.class::isInstance); + for (LogicalFilter sf : subtreeFilters) { + for (Expression conj : sf.getConjuncts()) { + if (conj.toSql().contains("tag > 0") + && !conj.containsType( + org.apache.doris.nereids.trees.expressions.functions + .NoneMovableFunction.class)) { + safeBelowUnsafe = true; + } + } + } + } + Assertions.assertTrue(safeBelowUnsafe, + "Deterministic filter (tag > 0) must remain in the subtree " + + "below the assert_true filter — stripOuterFilters must " + + "not hoist it from under a retained unsafe filter"); + } + + @Test + public void testNoAggregateOutputConjunctRejected() throws Exception { + // When the Filter directly contains an Apply (Filter→Apply shape) + // but none of its conjuncts reference the aggregate output ExprId, + // conjuncts.get(false) is null and rewrite() must not NPE. + // + // This shape cannot be produced naturally through SQL analysis: + // every scalar subquery comparison (e.g. f.v > sum_alias) is always + // a conjunct that references the aggregate output. We therefore + // construct the plan from a valid query and then strip the + // agg-output conjunct from the top-level Filter so the null guard + // in rewrite() is exercised. + createTable("CREATE TABLE fact_no_agg_conj (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_no_agg_conj (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_no_agg_conj add constraint uq_dim_no_agg_conj_k unique (k)"); + + // Build a valid Filter→Apply shape with the subquery comparison. + // We will then strip the agg-output conjunct before handing it + // to the rule. + String sql = "SELECT d.did, f.id, f.k, f.v " + + "FROM fact_no_agg_conj f, dim_no_agg_conj d " + + "WHERE f.k = d.k " + + " AND f.v > (" + + " SELECT SUM(f2.v) FROM fact_no_agg_conj f2 WHERE f2.k = d.k" + + " )"; + + Plan preRule = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .getPlan(); + + // Precondition: a correlated Apply exists, so the rule will + // reach check() / rewrite(). + Assertions.assertTrue(preRule.anyMatch(p -> p instanceof LogicalApply + && ((LogicalApply) p).isCorrelated()), + "Pre-rule plan must have a correlated Apply"); + + // Locate the aggregate output ExprId so we can strip the + // conjunct that references it. + List> aggs = preRule + .collectToList(LogicalAggregate.class::isInstance); + Assertions.assertEquals(1, aggs.size()); + Set aggOutputExprIds = aggs.get(0).getOutputExprIdSet(); + + // Walk all LogicalFilter nodes in the plan to find the one + // sitting directly above the Apply (possibly through a Project). + // The preRule root may be a Project wrapping the Filter→Apply + // chain after PullUpProjectUnderApply. + List> allFilters = preRule + .collectToList(LogicalFilter.class::isInstance); + LogicalFilter targetFilter = null; + LogicalApply targetApply = null; + for (LogicalFilter f : allFilters) { + Plan child = f.child(0); + Plan maybeApply = child instanceof LogicalProject + ? child.child(0) : child; + if (maybeApply instanceof LogicalApply) { + targetFilter = f; + targetApply = (LogicalApply) maybeApply; + break; + } + } + Assertions.assertNotNull(targetFilter, + "Must find a LogicalFilter directly above the Apply"); + Assertions.assertNotNull(targetApply, + "Must find a LogicalApply below the Filter"); + + // Remove every conjunct from the target filter that references + // the aggregate output, leaving only table-column predicates + // (f.k = d.k). This makes conjuncts.get(false) null in rewrite(). + Set remainingConjuncts = targetFilter.getConjuncts().stream() + .filter(c -> Sets.intersection( + c.getInputSlotExprIds(), aggOutputExprIds).isEmpty()) + .collect(Collectors.toSet()); + Assertions.assertTrue( + remainingConjuncts.size() < targetFilter.getConjuncts().size(), + "At least one agg-output conjunct must have been stripped"); + + // Build a new plan whose filter above the Apply has only the + // non-agg-output conjuncts, and pass it to the rule. + Plan strippedChild = new LogicalFilter<>( + remainingConjuncts, (Plan) targetFilter.child(0)); + + Plan plan = new AggScalarSubQueryToWindowFunction() + .rewriteRoot(strippedChild, null); + + // Rule must NOT match — no aggregate-output conjunct in Filter + // means correlatedConjuncts is null, and rewrite() must return + // the plan unchanged. + Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance), + "Rewrite must be rejected when no outer conjunct " + + "references the aggregate output"); + } + + @Test + public void testNestedFilterBelowUnsafeNotExtracted() throws Exception { + // The nested-filter extraction loop in rewrite() must stop at + // unsafe filter barriers, matching stripOuterFilters() semantics. + // Without the barrier, a deterministic filter below assert_true + // is collected and reinserted above the join while the original + // remains in place — the predicate evaluates twice per joined row. + createTable("CREATE TABLE fact_unsafe_nested (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_unsafe_nested (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT,\n" + + " keep INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_unsafe_nested add constraint uq_dim_unsafe_nested_k unique (k)"); + + // Double-nested subquery on dim_unsafe_nested (outer-only): + // inner WHERE keep > 0, outer WHERE assert_true(tag > 0, 'bad'). + // Plan shape: + // SubQueryAlias sf + // Filter(assert_true) ← unsafe barrier + // Project ← slot-only + // Filter(keep > 0) ← must NOT be extracted + // Scan dim_unsafe_nested + // Without the barrier in collectStrippableFilters, Filter(keep>0) + // is added to belowWindowConjuncts while remaining below assert_true. + String sql = "SELECT sf.did, sf.k, f.v " + + "FROM (" + + " SELECT * FROM (" + + " SELECT * FROM dim_unsafe_nested WHERE keep > 0" + + " ) inner_sf" + + " WHERE assert_true(tag > 0, 'bad')" + + ") sf, " + + "fact_unsafe_nested f " + + "WHERE sf.k = f.k " + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_unsafe_nested f2 " + + " WHERE f2.k = sf.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule should match — the unsafe filter is on outer-only table. + Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance), + "Rewrite should succeed when unsafe filter on outer-only " + + "table has a deterministic filter in its subtree"); + + // The keep > 0 predicate must appear exactly once below the window + // (in its original subtree below assert_true), not duplicated. + List> windows = plan.collectToList(LogicalWindow.class::isInstance); + LogicalWindow window = windows.get(0); + Plan belowWindow = window.child(0); + List> allBelow = belowWindow + .collectToList(LogicalFilter.class::isInstance); + int keepGt0Count = 0; + for (LogicalFilter f : allBelow) { + for (Expression conj : f.getConjuncts()) { + if (conj.toSql().contains("keep > 0") + && !conj.containsType( + org.apache.doris.nereids.trees.expressions.functions + .NoneMovableFunction.class)) { + keepGt0Count++; + } + } + } + Assertions.assertEquals(1, keepGt0Count, + "Deterministic filter (keep > 0) must appear exactly once " + + "below the window — not duplicated by the extraction loop"); + } + + @Test + public void testStackedPruningProjectsExpanded() throws Exception { + // When the shared table is behind multiple stacked pruning + // projects — e.g. SubQueryAlias sf → Project(k) → Project(k) + // → Scan(k,v) — ensureProjectOutput() must recurse into the + // child before computing each project's childOutput. If it + // reads childOutput from the unexpanded child first, the outer + // project cannot pull v through because its immediate child + // (the inner project) only outputs k before expansion. + // + // Plan shape: + // Filter(sf.k = d.k, sf.k * 2 > sum_alias) + // Apply(correlation: d.k) + // CrossJoin + // SubQueryAlias sf + // Project(k) ← outer prune + // Project(k) ← inner prune + // Scan fact(k, v) + // Scan dim_unique(k) + // Aggregate(SUM(f2.v) AS sum_alias) + // Filter(f2.k = d.k) + // Scan fact f2 + createTable("CREATE TABLE fact_stacked (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_stacked (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_stacked add constraint uq_dim_stacked_k unique (k)"); + + // Two nested SELECT subqueries produce stacked pruning projects. + // Inner: SELECT id, k → Project(id, k) — slot-only, survives + // elimination (outputs {id,k} ≠ child's {id,k,v}). + // Outer: SELECT k → Project(k) — slot-only, survives + // elimination (outputs {k} ≠ child's {id,k}). + // Both are slot-only so checkProject() passes. v is pruned at + // both levels and only available at the Scan. + // Without the depth-first fix, ensureProjectOutput reads + // childOutput from the unexpanded inner project (only {id,k}), + // fails to add v to the outer project, and the window's + // SUM(sf.v) references a slot not produced by its child. + String sql = "SELECT sf.k, d.did " + + "FROM (SELECT k FROM " + + " (SELECT id, k FROM fact_stacked) t" + + " ) sf, " + + " dim_stacked d " + + "WHERE sf.k = d.k " + + " AND sf.k * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_stacked f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule must match and produce a window. + Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance), + "Rule must produce a window when shared table is behind " + + "stacked pruning projects"); + + // Walk every filter; verify every conjunct slot is produced by + // the filter's child. Also walk every window and verify its + // input slots are produced by the window's child. + List> allFilters = plan + .collectToList(LogicalFilter.class::isInstance); + for (LogicalFilter f : allFilters) { + Set childOutput = f.child().getOutputExprIdSet(); + for (Expression conj : f.getConjuncts()) { + for (ExprId id : conj.getInputSlotExprIds()) { + Assertions.assertTrue(childOutput.contains(id), + "Filter conjunct slot " + id + + " not produced by child. Conjunct: " + + conj.toSql()); + } + } + } + List> windows = plan + .collectToList(LogicalWindow.class::isInstance); + for (LogicalWindow w : windows) { + Set childOutput = w.child().getOutputExprIdSet(); + for (NamedExpression ne : w.getWindowExpressions()) { + for (ExprId id : ne.getInputSlotExprIds()) { + Assertions.assertTrue(childOutput.contains(id), + "Window expression slot " + id + + " not produced by child. Expression: " + + ne.toSql()); + } + } + } + } + + @Test + public void testSkipStorageEngineMergeRejected() throws Exception { + // skip_storage_engine_merge = true tells BE to skip merging + // multiple versions of the same key. The scan may return + // duplicate key rows, so DataTrait must not advertise uniqueness + // even for tables that are otherwise unique (declared constraints, + // OLAP key metadata). The WinMagic rewrite must be suppressed. + createTable("CREATE TABLE fact_sse (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_sse (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_sse add constraint uq_dim_sse_k unique (k)"); + + boolean saved = connectContext.getSessionVariable().skipStorageEngineMerge; + connectContext.getSessionVariable().skipStorageEngineMerge = true; + try { + String sql = "SELECT d.did, d.k, d.tag, f.id, f.v " + + "FROM fact_sse f, dim_sse d " + + "WHERE f.k = d.k " + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_sse f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .applyTopDown(new PushDownFilterThroughProject()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance), + "skipStorageEngineMerge exposes unmerged versions — " + + "uniqueness is not guaranteed, rewrite must be rejected"); + } finally { + connectContext.getSessionVariable().skipStorageEngineMerge = saved; + } + } + + @Test + public void testSkipDeleteBitmapRejected() throws Exception { + // skip_delete_bitmap = true on a UNIQUE_KEYS table makes deleted + // (replaced) rows visible alongside their replacements. Two rows + // with the same unique key coexist, so DataTrait must not + // advertise uniqueness. The WinMagic rewrite must be suppressed. + createTable("CREATE TABLE fact_sdb (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + // UNIQUE_KEYS table — the UNIQUE KEY model would normally make + // DataTrait advertise uniqueness on the key column k. + // Key columns must be declared first in the schema. + createTable("CREATE TABLE dim_sdb (\n" + + " k INT NOT NULL,\n" + + " did INT,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "UNIQUE KEY(k)\n" + + "DISTRIBUTED BY HASH(k) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + + boolean saved = connectContext.getSessionVariable().skipDeleteBitmap; + connectContext.getSessionVariable().skipDeleteBitmap = true; + try { + String sql = "SELECT d.did, d.k, d.tag, f.id, f.v " + + "FROM fact_sdb f, dim_sdb d " + + "WHERE f.k = d.k " + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_sdb f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .applyTopDown(new PushDownFilterThroughProject()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance), + "skipDeleteBitmap exposes replaced rows with same key — " + + "uniqueness is not guaranteed, rewrite must be rejected"); + } finally { + connectContext.getSessionVariable().skipDeleteBitmap = saved; + } + } + + @Test + public void testReadMorAsDupRejected() throws Exception { + // read_mor_as_dup_tables = '*' on a MOR table makes the scan read + // it as a DUPLICATE table, so the declared unique key cannot be + // trusted. DataTrait must not advertise uniqueness and the + // WinMagic rewrite must be suppressed. + createTable("CREATE TABLE fact_rmd (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + // MOR table: UNIQUE_KEYS with enable_unique_key_merge_on_write = false. + // Key columns must be declared first in the schema. + createTable("CREATE TABLE dim_rmd (\n" + + " k INT NOT NULL,\n" + + " did INT,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "UNIQUE KEY(k)\n" + + "DISTRIBUTED BY HASH(k) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1', " + + "'enable_unique_key_merge_on_write' = 'false')"); + + String saved = connectContext.getSessionVariable().readMorAsDupTables; + connectContext.getSessionVariable().readMorAsDupTables = "*"; + try { + String sql = "SELECT d.did, d.k, d.tag, f.id, f.v " + + "FROM fact_rmd f, dim_rmd d " + + "WHERE f.k = d.k " + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_rmd f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .applyTopDown(new PushDownFilterThroughProject()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance), + "readMorAsDup reads MOR table as DUPLICATE — " + + "uniqueness is not guaranteed, rewrite must be rejected"); + } finally { + connectContext.getSessionVariable().readMorAsDupTables = saved; + } + } + + @Test + public void testIncrementalStreamScanRejected() throws Exception { + // An incremental scan (LogicalOlapTableStreamScan(INCREMENTAL) or + // TableScanParams.INCREMENTAL_READ) can return multiple row versions + // with the same key. WinMagic runs before stream normalization, so + // the window rewrite would group those duplicate-key rows under a + // single PARTITION BY and multiply the aggregate — producing wrong + // results. + // + // isDuplicateProducingScanMode() must suppress all uniqueness sources + // for such scans: + // 1. LogicalOlapTableStreamScan with isIncremental() == true + // 2. Regular LogicalOlapScan with scanParams.incrementalRead() == true + // + // This test covers path 2 by attaching an INCREMENTAL_READ + // TableScanParams to the correlated table's scan node. + createTable("CREATE TABLE fact_incr (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_incr (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_incr add constraint uq_dim_incr_k unique (k)"); + + String sql = "SELECT d.did, d.k, d.tag, f.id, f.v " + + "FROM fact_incr f, dim_incr d " + + "WHERE f.k = d.k " + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_incr f2 " + + " WHERE f2.k = d.k" + + " )"; + + Plan preRule = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .applyTopDown(new PushDownFilterThroughProject()) + .customRewrite(new EliminateUnnecessaryProject()) + .getPlan(); + + // Precondition: the rule would normally match. + Plan normalResult = new AggScalarSubQueryToWindowFunction() + .rewriteRoot(preRule, null); + Assertions.assertTrue(normalResult.anyMatch(LogicalWindow.class::isInstance), + "With unique constraint the rule should normally produce a window"); + + Plan plan = new AggScalarSubQueryToWindowFunction() + .rewriteRoot(preRule, null); + + // Rule must NOT match — incremental scan exposes duplicate key + // versions, so uniqueness is not guaranteed. + Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance), + "Incremental scan must be rejected because it can " + + "return duplicate key rows that would multiply the " + + "window aggregate"); + } + + @Test + public void testRepeatableSampleTriggersRewrite() throws Exception { + // A TABLESAMPLE with the same REPEATABLE seed on both the outer + // and inner shared-table scans is deterministic: both OlapScanNodes + // resolve the same partition/tablet seek, so they read the same + // sample. The rewrite is safe and should fire. + createTable("CREATE TABLE fact_rs (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_rs (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_rs add constraint uq_dim_rs_k unique (k)"); + + // Same REPEATABLE seed on both scans → same sampled row set. + String sql = "SELECT d.did, f.id, f.v " + + "FROM fact_rs f TABLESAMPLE(10 ROWS) REPEATABLE 5, dim_rs d " + + "WHERE f.k = d.k " + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_rs f2 TABLESAMPLE(10 ROWS) REPEATABLE 5 " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .applyTopDown(new PushDownFilterThroughProject()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Same repeatable seed → the rewrite is safe. + Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance), + "Rewrite must succeed when both scans use the same " + + "REPEATABLE sample seed"); + } + + @Test + public void testNonRepeatableSampleRejected() throws Exception { + // TABLESAMPLE(n ROWS) WITHOUT REPEATABLE gives both scans + // seek = -1, so their TableSample descriptors compare equal. + // At execution, however, each OlapScanNode resolves -1 with its + // own SecureRandom partition/tablet seek — the outer and inner + // scans read DIFFERENT random samples. The rewrite removes the + // inner scan and computes the window only over the outer sample, + // changing the result. isSameScanDomain() must reject it. + createTable("CREATE TABLE fact_nrs (\n" + + " id INT,\n" + + " k INT,\n" + + " v INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + createTable("CREATE TABLE dim_nrs (\n" + + " did INT,\n" + + " k INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(did)\n" + + "DISTRIBUTED BY HASH(did) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_nrs add constraint uq_dim_nrs_k unique (k)"); + + // No REPEATABLE → both scans get seek = -1. Even though the + // descriptors compare equal, the runtime row sets differ. + String sql = "SELECT d.did, f.id, f.v " + + "FROM fact_nrs f TABLESAMPLE(10 ROWS), dim_nrs d " + + "WHERE f.k = d.k " + + " AND f.v * 2 > (" + + " SELECT SUM(f2.v) " + + " FROM fact_nrs f2 TABLESAMPLE(10 ROWS) " + + " WHERE f2.k = d.k" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .applyTopDown(new PushDownFilterThroughProject()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Non-repeatable samples cannot be proven to read the same rows. + Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance), + "Rewrite must be rejected when both scans use a " + + "non-repeatable TABLESAMPLE — each OlapScanNode " + + "picks its own SecureRandom seek at runtime, so the " + + "materialized row sets differ even though the " + + "descriptors compare equal"); + } + + @Test + public void testTvfRelationRejected() throws Exception { + // TVF (table-valued function) relations like numbers() are + // LogicalTVFRelation, not CatalogRelation. checkRelation() and + // isSameScanDomain() only inspect CatalogRelation, so TVF relations + // are invisible to the relation accounting. The rewrite would + // incorrectly substitute the outer TVF rows for the inner TVF rows + // when they produce different row counts (e.g. numbers(2) vs 3). + // checkPlanType() must reject non-catalog relations. + createTable("CREATE TABLE dim_tvf (\n" + + " id INT NOT NULL,\n" + + " tag INT\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(id)\n" + + "DISTRIBUTED BY HASH(id) BUCKETS 1\n" + + "PROPERTIES ('replication_num' = '1')"); + addConstraint("alter table dim_tvf add constraint uq_dim_tvf_id unique (id)"); + + // Outer: numbers("number"="2") produces 2 rows per dim row. + // Inner: numbers("number"="3") produces 3 rows. + // Post-rewrite COUNT(*) OVER (PARTITION BY d.id) sees only 2 rows. + String sql = "SELECT d.id, n.number " + + "FROM numbers(\"number\"=\"2\") n, dim_tvf d " + + "WHERE d.id > 0 " + + " AND 3 = (" + + " SELECT COUNT(*) " + + " FROM numbers(\"number\"=\"3\") n2 " + + " WHERE d.id > 0" + + " )"; + + Plan plan = PlanChecker.from(createCascadesContext(sql)) + .analyze(sql) + .applyBottomUp(new PullUpProjectUnderApply()) + .applyTopDown(new PushDownFilterThroughProject()) + .customRewrite(new EliminateUnnecessaryProject()) + .customRewrite(new AggScalarSubQueryToWindowFunction()) + .getPlan(); + + // Rule must NOT match — TVF relations are not CatalogRelation + // and cannot be proven row-domain equivalent. + Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance), + "TVF relations must be rejected because they are not " + + "CatalogRelation and their row-domain equivalence " + + "cannot be proven"); + } + private void check(String sql) { System.out.printf("Test:\n%s\n\n", sql); Plan plan = PlanChecker.from(createCascadesContext(sql)) @@ -346,7 +3373,6 @@ private void check(String sql) { .applyTopDown(new PushDownFilterThroughProject()) .customRewrite(new EliminateUnnecessaryProject()) .customRewrite(new AggScalarSubQueryToWindowFunction()) - .rewrite() .getPlan(); System.out.println(plan.treeString()); Assertions.assertTrue(plan.anyMatch(LogicalWindow.class::isInstance)); @@ -357,7 +3383,6 @@ private void checkNot(String sql) { Plan plan = PlanChecker.from(createCascadesContext(sql)) .analyze(sql) .customRewrite(new AggScalarSubQueryToWindowFunction()) - .rewrite() .getPlan(); System.out.println(plan.treeString()); Assertions.assertFalse(plan.anyMatch(LogicalWindow.class::isInstance)); diff --git a/regression-test/data/nereids_rules_p0/mv/tpch/mv_tpch_test.out b/regression-test/data/nereids_rules_p0/mv/tpch/mv_tpch_test.out index 9bc3d0a99baf68..65a14bcc015ba8 100644 --- a/regression-test/data/nereids_rules_p0/mv/tpch/mv_tpch_test.out +++ b/regression-test/data/nereids_rules_p0/mv/tpch/mv_tpch_test.out @@ -11,52 +11,6 @@ N F 95257.00 133737795.84 127132372.6512 132286291.229445 25.3006 35521.3269 0.0 N O 7459297.00 10512270008.90 9986238338.3847 10385578376.585467 25.5455 36000.9246 0.0500 292000 R F 3785523.00 5337950526.47 5071818532.9420 5274405503.049367 25.5259 35994.0292 0.0499 148301 --- !query2_before -- --314.06 Supplier#000000510 ROMANIA 17242 Manufacturer#4 VmXQl ,vY8JiEseo8Mv4zscvNCfsY 29-207-852-3454 bold deposits. carefully even d --820.89 Supplier#000000409 GERMANY 2156 Manufacturer#5 LyXUYFz7aXrvy65kKAbTatGzGS,NDBcdtD 17-719-517-9836 y final, slow theodolites. furiously regular req --845.44 Supplier#000000704 ROMANIA 9926 Manufacturer#5 hQvlBqbqqnA5Dgo1BffRBX78tkkRu 29-300-896-5991 ctions. carefully sly requ --942.73 Supplier#000000563 GERMANY 5797 Manufacturer#1 Rc7U1cRUhYs03JD 17-108-537-2691 slyly furiously final decoys; silent, special realms poach f -1381.97 Supplier#000000104 FRANCE 18103 Manufacturer#3 Dcl4yGrzqv3OPeRO49bKh78XmQEDR7PBXIs0m 16-434-972-6922 gular ideas. bravely bold deposits haggle through the carefully final deposits. slyly unusual idea -167.56 Supplier#000000290 FRANCE 2037 Manufacturer#1 6Bk06GVtwZaKqg01 16-675-286-5102 the theodolites. ironic, ironic deposits above -2221.25 Supplier#000000771 ROMANIA 13981 Manufacturer#2 lwZ I15rq9kmZXUNhl 29-986-304-9006 nal foxes eat slyly about the fluffily permanent id -2963.09 Supplier#000000840 ROMANIA 3080 Manufacturer#2 iYzUIypKhC0Y 29-781-337-5584 eep blithely regular dependencies. blithely regular platelets sublate alongside o -2972.26 Supplier#000000016 RUSSIA 1015 Manufacturer#4 YjP5C55zHDXL7LalK27zfQnwejdpin4AMpvh 32-822-502-4215 ously express ideas haggle quickly dugouts? fu -3294.68 Supplier#000000350 GERMANY 4841 Manufacturer#4 KIFxV73eovmwhh 17-113-181-4017 e slyly special foxes. furiously unusual deposits detect carefully carefully ruthless foxes. quick -3526.53 Supplier#000000553 FRANCE 17018 Manufacturer#3 a,liVofXbCJ 16-599-552-3755 lar dinos nag slyly brave -3526.53 Supplier#000000553 FRANCE 8036 Manufacturer#4 a,liVofXbCJ 16-599-552-3755 lar dinos nag slyly brave -4315.15 Supplier#000000509 FRANCE 18972 Manufacturer#2 SF7dR8V5pK 16-298-154-3365 ronic orbits are furiously across the requests. quickly express ideas across the special, bold -4518.31 Supplier#000000149 FRANCE 18344 Manufacturer#5 pVyWsjOidpHKp4NfKU4yLeym 16-660-553-2456 ts detect along the foxes. final Tiresias are. idly pending deposits haggle; even, blithe pin -4586.49 Supplier#000000680 RUSSIA 5679 Manufacturer#3 UhvDfdEfJh,Qbe7VZb8uSGO2TU 0jEa6nXZXE 32-522-382-1620 the regularly regular dependencies. carefully bold excuses under th -4672.25 Supplier#000000239 RUSSIA 12238 Manufacturer#1 XO101kgHrJagK2FL1U6QCaTE ncCsMbeuTgK6o8 32-396-654-6826 arls wake furiously deposits. even, regular depen -4941.88 Supplier#000000321 ROMANIA 7320 Manufacturer#5 pLngFl5yeMcHyov 29-573-279-1406 y final requests impress s -5069.27 Supplier#000000328 GERMANY 16327 Manufacturer#1 SMm24d WG62 17-231-513-5721 he unusual ideas. slyly final packages a -5364.99 Supplier#000000785 RUSSIA 13784 Manufacturer#4 W VkHBpQyD3qjQjWGpWicOpmILFehmEdWy67kUGY 32-297-653-2203 packages boost carefully. express ideas along -6173.87 Supplier#000000408 RUSSIA 18139 Manufacturer#1 qcor1u,vJXAokjnL5,dilyYNmh 32-858-724-2950 blithely pending packages cajole furiously slyly pending notornis. slyly final -6329.90 Supplier#000000996 GERMANY 10735 Manufacturer#2 Wx4dQwOAwWjfSCGupfrM 17-447-811-3282 ironic forges cajole blithely agai -6721.70 Supplier#000000954 FRANCE 4191 Manufacturer#3 P3O5p UFz1QsLmZX 16-537-341-8517 ect blithely blithely final acco -6820.35 Supplier#000000007 UNITED KINGDOM 13217 Manufacturer#5 s,4TicNGB4uO6PaSqNBUq 33-990-965-2201 s unwind silently furiously regular courts. final requests are deposits. requests wake quietly blit -683.07 Supplier#000000651 RUSSIA 4888 Manufacturer#4 oWekiBV6s,1g 32-181-426-4490 ly regular requests cajole abou -7205.20 Supplier#000000477 GERMANY 10956 Manufacturer#5 VtaNKN5Mqui5yh7j2ldd5waf 17-180-144-7991 excuses wake express deposits. furiously careful asymptotes according to the carefull -727.89 Supplier#000000470 ROMANIA 6213 Manufacturer#3 XckbzsAgBLbUkdfjgJEPjmUMTM8ebSMEvI 29-165-289-1523 gular excuses. furiously regular excuses sleep slyly caref -7392.78 Supplier#000000170 UNITED KINGDOM 7655 Manufacturer#2 RtsXQ,SunkA XHy9 33-803-340-5398 ake carefully across the quickly -765.69 Supplier#000000799 RUSSIA 11276 Manufacturer#2 jwFN7ZB3T9sMF 32-579-339-1495 nusual requests. furiously unusual epitaphs integrate. slyly -8096.98 Supplier#000000574 RUSSIA 323 Manufacturer#4 2O8 sy9g2mlBOuEjzj0pA2pevk, 32-866-246-8752 ully after the regular requests. slyly final dependencies wake slyly along the busy deposit -8271.39 Supplier#000000146 RUSSIA 4637 Manufacturer#5 rBDNgCr04x0sfdzD5,gFOutCiG2 32-792-619-3155 s cajole quickly special requests. quickly enticing theodolites h -8430.52 Supplier#000000646 FRANCE 11384 Manufacturer#3 IUzsmT,2oBgjhWP2TlXTL6IkJH,4h,1SJRt 16-601-220-5489 ites among the always final ideas kindle according to the theodolites. notornis in -8488.53 Supplier#000000367 RUSSIA 6854 Manufacturer#4 E Sv9brQVf43Mzz 32-458-198-9557 ages. carefully final excuses nag finally. carefully ironic deposits abov -8615.50 Supplier#000000812 FRANCE 10551 Manufacturer#2 8qh4tezyScl5bidLAysvutB,,ZI2dn6xP 16-585-724-6633 y quickly regular deposits? quickly pending packages after the caref -8615.50 Supplier#000000812 FRANCE 13811 Manufacturer#4 8qh4tezyScl5bidLAysvutB,,ZI2dn6xP 16-585-724-6633 y quickly regular deposits? quickly pending packages after the caref -8702.02 Supplier#000000333 RUSSIA 11810 Manufacturer#3 MaVf XgwPdkiX4nfJGOis8Uu2zKiIZH 32-508-202-6136 oss the deposits cajole carefully even pinto beans. regular foxes detect alo -9032.15 Supplier#000000959 GERMANY 4958 Manufacturer#4 8grA EHBnwOZhO 17-108-642-3106 nding dependencies nag furiou -906.07 Supplier#000000138 ROMANIA 8363 Manufacturer#4 utbplAm g7RmxVfYoNdhcrQGWuzRqPe0qHSwbKw 29-533-434-6776 ickly unusual requests cajole. accounts above the furiously special excuses -91.39 Supplier#000000949 UNITED KINGDOM 9430 Manufacturer#2 a,UE,6nRVl2fCphkOoetR1ajIzAEJ1Aa1G1HV 33-332-697-2768 pinto beans. carefully express requests hagg -9192.10 Supplier#000000115 UNITED KINGDOM 13325 Manufacturer#1 nJ 2t0f7Ve,wL1,6WzGBJLNBUCKlsV 33-597-248-1220 es across the carefully express accounts boost caref -9453.01 Supplier#000000802 ROMANIA 10021 Manufacturer#5 ,6HYXb4uaHITmtMBj4Ak57Pd 29-342-882-6463 gular frets. permanently special multipliers believe blithely alongs -9453.01 Supplier#000000802 ROMANIA 13275 Manufacturer#4 ,6HYXb4uaHITmtMBj4Ak57Pd 29-342-882-6463 gular frets. permanently special multipliers believe blithely alongs -9508.37 Supplier#000000070 FRANCE 17268 Manufacturer#4 INWNH2w,OOWgNDq0BRCcBwOMQc6PdFDc4 16-821-608-1166 ests sleep quickly express ideas. ironic ideas haggle about the final T -9508.37 Supplier#000000070 FRANCE 3563 Manufacturer#1 INWNH2w,OOWgNDq0BRCcBwOMQc6PdFDc4 16-821-608-1166 ests sleep quickly express ideas. ironic ideas haggle about the final T -9828.21 Supplier#000000647 UNITED KINGDOM 13120 Manufacturer#5 x5U7MBZmwfG9 33-258-202-4782 s the slyly even ideas poach fluffily - -- !query2_after -- -314.06 Supplier#000000510 ROMANIA 17242 Manufacturer#4 VmXQl ,vY8JiEseo8Mv4zscvNCfsY 29-207-852-3454 bold deposits. carefully even d -820.89 Supplier#000000409 GERMANY 2156 Manufacturer#5 LyXUYFz7aXrvy65kKAbTatGzGS,NDBcdtD 17-719-517-9836 y final, slow theodolites. furiously regular req diff --git a/regression-test/data/nereids_rules_p0/subquery_to_window_function/correlated_scalar_subquery_to_window_function.out b/regression-test/data/nereids_rules_p0/subquery_to_window_function/correlated_scalar_subquery_to_window_function.out new file mode 100644 index 00000000000000..3173fbafb0d1e5 --- /dev/null +++ b/regression-test/data/nereids_rules_p0/subquery_to_window_function/correlated_scalar_subquery_to_window_function.out @@ -0,0 +1,98 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !d26072_unique -- +30 5 3 8 + +-- !d26072 -- +30 5 3 8 + +-- !d26072_no_change -- +5 3 8 + +-- !d26072_unique_shape -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------PhysicalProject +----------filter(((cast(f.v as BIGINT) * 2) > sum(v) OVER(PARTITION BY k))) +------------PhysicalWindow +--------------PhysicalQuickSort[LOCAL_SORT] +----------------hashJoin[INNER_JOIN shuffle] hashCondition=((f.k = d.k)) otherCondition=() build RFs:RF0 k->k +------------------PhysicalOlapScan[fact(f)] apply RFs: RF0 +------------------PhysicalProject +--------------------filter((dim_unique.__DORIS_DELETE_SIGN__ = 0)) +----------------------PhysicalOlapScan[dim_unique] + +-- !d26072_shape -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[INNER_JOIN colocated] hashCondition=((f2.k = d.k)) otherCondition=(((cast(f.v as BIGINT) * 2) > SUM(f2.v))) build RFs:RF1 k->k;RF2 k->k +------------hashJoin[INNER_JOIN shuffle] hashCondition=((f.k = d.k)) otherCondition=() build RFs:RF0 k->k +--------------PhysicalOlapScan[fact(f)] apply RFs: RF0 RF2 +--------------PhysicalProject +----------------PhysicalOlapScan[dim(d)] apply RFs: RF1 +------------hashAgg[GLOBAL] +--------------PhysicalDistribute[DistributionSpecHash] +----------------hashAgg[LOCAL] +------------------PhysicalProject +--------------------PhysicalOlapScan[fact(f2)] + +-- !shared_filter_above_window -- +30 5 3 8 + +-- !shared_filter_above_window_shape -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------PhysicalProject +----------filter(((cast(f.v as BIGINT) * 2) > sum(v) OVER(PARTITION BY k)) and (f.v > 5)) +------------PhysicalWindow +--------------PhysicalQuickSort[LOCAL_SORT] +----------------hashJoin[INNER_JOIN shuffle] hashCondition=((f.k = d.k)) otherCondition=() build RFs:RF0 k->k +------------------PhysicalOlapScan[fact(f)] apply RFs: RF0 +------------------PhysicalProject +--------------------filter((dim_unique.__DORIS_DELETE_SIGN__ = 0)) +----------------------PhysicalOlapScan[dim_unique] + +-- !mixed_above_window -- +30 5 3 8 + +-- !mixed_above_window_shape -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------PhysicalProject +----------filter(((cast(f.v as BIGINT) * 2) > sum(v) OVER(PARTITION BY k)) and (f.v > d.tag)) +------------PhysicalWindow +--------------PhysicalQuickSort[LOCAL_SORT] +----------------hashJoin[INNER_JOIN shuffle] hashCondition=((f.k = d.k)) otherCondition=() build RFs:RF0 k->k +------------------PhysicalOlapScan[fact(f)] apply RFs: RF0 +------------------PhysicalProject +--------------------filter((dim_unique.__DORIS_DELETE_SIGN__ = 0)) +----------------------PhysicalOlapScan[dim_unique] + +-- !inner_filter_below_window -- +20 11 2 6 +30 5 3 8 + +-- !inner_filter_below_window_shape -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------PhysicalProject +----------filter(((cast(f.v as BIGINT) * 2) > sum(v) OVER(PARTITION BY k))) +------------PhysicalWindow +--------------PhysicalQuickSort[LOCAL_SORT] +----------------hashJoin[INNER_JOIN shuffle] hashCondition=((f.k = d.k)) otherCondition=() build RFs:RF0 k->k +------------------filter((f.v < 10)) +--------------------PhysicalOlapScan[fact(f)] apply RFs: RF0 +------------------PhysicalProject +--------------------filter((dim_unique.__DORIS_DELETE_SIGN__ = 0)) +----------------------PhysicalOlapScan[dim_unique] + diff --git a/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query32.out b/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query32.out index 5626809a46f304..dc109530db584d 100644 --- a/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query32.out +++ b/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query32.out @@ -7,19 +7,26 @@ PhysicalResultSink --------PhysicalDistribute[DistributionSpecGather] ----------hashAgg[LOCAL] ------------PhysicalProject ---------------filter((cast(cs_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(cs_ext_discount_amt) OVER(PARTITION BY i_item_sk)))) -----------------PhysicalWindow -------------------PhysicalQuickSort[LOCAL_SORT] ---------------------PhysicalDistribute[DistributionSpecHash] +--------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((catalog_sales.cs_item_sk = item.i_item_sk)) otherCondition=((cast(cs_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(cs_ext_discount_amt)))) build RFs:RF3 cs_item_sk->[cs_item_sk,i_item_sk] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[cs_sold_date_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = catalog_sales.cs_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[cs_item_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF1 RF2 RF3 +------------------------PhysicalProject +--------------------------filter((item.i_manufact_id = 29)) +----------------------------PhysicalOlapScan[item] apply RFs: RF3 +--------------------PhysicalProject +----------------------filter((date_dim.d_date <= '1999-04-07') and (date_dim.d_date >= '1999-01-07')) +------------------------PhysicalOlapScan[date_dim] +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecHash] +--------------------hashAgg[LOCAL] ----------------------PhysicalProject -------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk] +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[cs_sold_date_sk] --------------------------PhysicalProject -----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = catalog_sales.cs_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[cs_item_sk] -------------------------------PhysicalProject ---------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 -------------------------------PhysicalProject ---------------------------------filter((item.i_manufact_id = 29)) -----------------------------------PhysicalOlapScan[item] +----------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 --------------------------PhysicalProject ----------------------------filter((date_dim.d_date <= '1999-04-07') and (date_dim.d_date >= '1999-01-07')) ------------------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query92.out b/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query92.out index ff2e7b944234b5..831ee9041b7268 100644 --- a/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query92.out +++ b/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query92.out @@ -6,19 +6,26 @@ PhysicalResultSink ------PhysicalDistribute[DistributionSpecGather] --------hashAgg[LOCAL] ----------PhysicalProject -------------filter((cast(ws_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(ws_ext_discount_amt) OVER(PARTITION BY i_item_sk)))) ---------------PhysicalWindow -----------------PhysicalQuickSort[LOCAL_SORT] -------------------PhysicalDistribute[DistributionSpecHash] +------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((web_sales.ws_item_sk = item.i_item_sk)) otherCondition=((cast(ws_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(ws_ext_discount_amt)))) build RFs:RF3 ws_item_sk->[i_item_sk,ws_item_sk] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = web_sales.ws_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[ws_item_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 RF2 RF3 +----------------------PhysicalProject +------------------------filter((item.i_manufact_id = 320)) +--------------------------PhysicalOlapScan[item] apply RFs: RF3 +------------------PhysicalProject +--------------------filter((date_dim.d_date <= '2002-05-27') and (date_dim.d_date >= '2002-02-26')) +----------------------PhysicalOlapScan[date_dim] +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] --------------------PhysicalProject -----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] ------------------------PhysicalProject ---------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = web_sales.ws_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[ws_item_sk] -----------------------------PhysicalProject -------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 -----------------------------PhysicalProject -------------------------------filter((item.i_manufact_id = 320)) ---------------------------------PhysicalOlapScan[item] +--------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 ------------------------PhysicalProject --------------------------filter((date_dim.d_date <= '2002-05-27') and (date_dim.d_date >= '2002-02-26')) ----------------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query32.out b/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query32.out index 5626809a46f304..dc109530db584d 100644 --- a/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query32.out +++ b/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query32.out @@ -7,19 +7,26 @@ PhysicalResultSink --------PhysicalDistribute[DistributionSpecGather] ----------hashAgg[LOCAL] ------------PhysicalProject ---------------filter((cast(cs_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(cs_ext_discount_amt) OVER(PARTITION BY i_item_sk)))) -----------------PhysicalWindow -------------------PhysicalQuickSort[LOCAL_SORT] ---------------------PhysicalDistribute[DistributionSpecHash] +--------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((catalog_sales.cs_item_sk = item.i_item_sk)) otherCondition=((cast(cs_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(cs_ext_discount_amt)))) build RFs:RF3 cs_item_sk->[cs_item_sk,i_item_sk] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[cs_sold_date_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = catalog_sales.cs_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[cs_item_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF1 RF2 RF3 +------------------------PhysicalProject +--------------------------filter((item.i_manufact_id = 29)) +----------------------------PhysicalOlapScan[item] apply RFs: RF3 +--------------------PhysicalProject +----------------------filter((date_dim.d_date <= '1999-04-07') and (date_dim.d_date >= '1999-01-07')) +------------------------PhysicalOlapScan[date_dim] +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecHash] +--------------------hashAgg[LOCAL] ----------------------PhysicalProject -------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk] +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[cs_sold_date_sk] --------------------------PhysicalProject -----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = catalog_sales.cs_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[cs_item_sk] -------------------------------PhysicalProject ---------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 -------------------------------PhysicalProject ---------------------------------filter((item.i_manufact_id = 29)) -----------------------------------PhysicalOlapScan[item] +----------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 --------------------------PhysicalProject ----------------------------filter((date_dim.d_date <= '1999-04-07') and (date_dim.d_date >= '1999-01-07')) ------------------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query92.out b/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query92.out index ff2e7b944234b5..831ee9041b7268 100644 --- a/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query92.out +++ b/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query92.out @@ -6,19 +6,26 @@ PhysicalResultSink ------PhysicalDistribute[DistributionSpecGather] --------hashAgg[LOCAL] ----------PhysicalProject -------------filter((cast(ws_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(ws_ext_discount_amt) OVER(PARTITION BY i_item_sk)))) ---------------PhysicalWindow -----------------PhysicalQuickSort[LOCAL_SORT] -------------------PhysicalDistribute[DistributionSpecHash] +------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((web_sales.ws_item_sk = item.i_item_sk)) otherCondition=((cast(ws_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(ws_ext_discount_amt)))) build RFs:RF3 ws_item_sk->[i_item_sk,ws_item_sk] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = web_sales.ws_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[ws_item_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 RF2 RF3 +----------------------PhysicalProject +------------------------filter((item.i_manufact_id = 320)) +--------------------------PhysicalOlapScan[item] apply RFs: RF3 +------------------PhysicalProject +--------------------filter((date_dim.d_date <= '2002-05-27') and (date_dim.d_date >= '2002-02-26')) +----------------------PhysicalOlapScan[date_dim] +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] --------------------PhysicalProject -----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] ------------------------PhysicalProject ---------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = web_sales.ws_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[ws_item_sk] -----------------------------PhysicalProject -------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 -----------------------------PhysicalProject -------------------------------filter((item.i_manufact_id = 320)) ---------------------------------PhysicalOlapScan[item] +--------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 ------------------------PhysicalProject --------------------------filter((date_dim.d_date <= '2002-05-27') and (date_dim.d_date >= '2002-02-26')) ----------------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf100/rf_prune/query32.out b/regression-test/data/shape_check/tpcds_sf100/rf_prune/query32.out index 5626809a46f304..a44c635179bd22 100644 --- a/regression-test/data/shape_check/tpcds_sf100/rf_prune/query32.out +++ b/regression-test/data/shape_check/tpcds_sf100/rf_prune/query32.out @@ -7,20 +7,27 @@ PhysicalResultSink --------PhysicalDistribute[DistributionSpecGather] ----------hashAgg[LOCAL] ------------PhysicalProject ---------------filter((cast(cs_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(cs_ext_discount_amt) OVER(PARTITION BY i_item_sk)))) -----------------PhysicalWindow -------------------PhysicalQuickSort[LOCAL_SORT] ---------------------PhysicalDistribute[DistributionSpecHash] -----------------------PhysicalProject -------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk] ---------------------------PhysicalProject -----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = catalog_sales.cs_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[cs_item_sk] +--------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF3 d_date_sk->[cs_sold_date_sk] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = catalog_sales.cs_item_sk)) otherCondition=((cast(cs_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(cs_ext_discount_amt)))) build RFs:RF2 i_item_sk->[cs_item_sk] +--------------------PhysicalProject +----------------------PhysicalOlapScan[catalog_sales] apply RFs: RF2 RF3 +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((catalog_sales.cs_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[cs_item_sk] +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] ------------------------------PhysicalProject ---------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 -------------------------------PhysicalProject ---------------------------------filter((item.i_manufact_id = 29)) -----------------------------------PhysicalOlapScan[item] ---------------------------PhysicalProject -----------------------------filter((date_dim.d_date <= '1999-04-07') and (date_dim.d_date >= '1999-01-07')) -------------------------------PhysicalOlapScan[date_dim] +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[cs_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_date <= '1999-04-07') and (date_dim.d_date >= '1999-01-07')) +--------------------------------------PhysicalOlapScan[date_dim] +------------------------PhysicalProject +--------------------------filter((item.i_manufact_id = 29)) +----------------------------PhysicalOlapScan[item] +----------------PhysicalProject +------------------filter((date_dim.d_date <= '1999-04-07') and (date_dim.d_date >= '1999-01-07')) +--------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf100/rf_prune/query92.out b/regression-test/data/shape_check/tpcds_sf100/rf_prune/query92.out index ff2e7b944234b5..105ef7e4cac826 100644 --- a/regression-test/data/shape_check/tpcds_sf100/rf_prune/query92.out +++ b/regression-test/data/shape_check/tpcds_sf100/rf_prune/query92.out @@ -6,20 +6,27 @@ PhysicalResultSink ------PhysicalDistribute[DistributionSpecGather] --------hashAgg[LOCAL] ----------PhysicalProject -------------filter((cast(ws_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(ws_ext_discount_amt) OVER(PARTITION BY i_item_sk)))) ---------------PhysicalWindow -----------------PhysicalQuickSort[LOCAL_SORT] -------------------PhysicalDistribute[DistributionSpecHash] ---------------------PhysicalProject -----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] -------------------------PhysicalProject ---------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = web_sales.ws_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[ws_item_sk] +------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF3 d_date_sk->[ws_sold_date_sk] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = web_sales.ws_item_sk)) otherCondition=((cast(ws_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(ws_ext_discount_amt)))) build RFs:RF2 i_item_sk->[ws_item_sk] +------------------PhysicalProject +--------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((web_sales.ws_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[ws_item_sk] +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] ----------------------------PhysicalProject -------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 -----------------------------PhysicalProject -------------------------------filter((item.i_manufact_id = 320)) ---------------------------------PhysicalOlapScan[item] -------------------------PhysicalProject ---------------------------filter((date_dim.d_date <= '2002-05-27') and (date_dim.d_date >= '2002-02-26')) -----------------------------PhysicalOlapScan[date_dim] +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 +--------------------------------PhysicalProject +----------------------------------filter((date_dim.d_date <= '2002-05-27') and (date_dim.d_date >= '2002-02-26')) +------------------------------------PhysicalOlapScan[date_dim] +----------------------PhysicalProject +------------------------filter((item.i_manufact_id = 320)) +--------------------------PhysicalOlapScan[item] +--------------PhysicalProject +----------------filter((date_dim.d_date <= '2002-05-27') and (date_dim.d_date >= '2002-02-26')) +------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf100/shape/query32.out b/regression-test/data/shape_check/tpcds_sf100/shape/query32.out index 5626809a46f304..a44c635179bd22 100644 --- a/regression-test/data/shape_check/tpcds_sf100/shape/query32.out +++ b/regression-test/data/shape_check/tpcds_sf100/shape/query32.out @@ -7,20 +7,27 @@ PhysicalResultSink --------PhysicalDistribute[DistributionSpecGather] ----------hashAgg[LOCAL] ------------PhysicalProject ---------------filter((cast(cs_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(cs_ext_discount_amt) OVER(PARTITION BY i_item_sk)))) -----------------PhysicalWindow -------------------PhysicalQuickSort[LOCAL_SORT] ---------------------PhysicalDistribute[DistributionSpecHash] -----------------------PhysicalProject -------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk] ---------------------------PhysicalProject -----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = catalog_sales.cs_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[cs_item_sk] +--------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF3 d_date_sk->[cs_sold_date_sk] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = catalog_sales.cs_item_sk)) otherCondition=((cast(cs_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(cs_ext_discount_amt)))) build RFs:RF2 i_item_sk->[cs_item_sk] +--------------------PhysicalProject +----------------------PhysicalOlapScan[catalog_sales] apply RFs: RF2 RF3 +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((catalog_sales.cs_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[cs_item_sk] +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] ------------------------------PhysicalProject ---------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 -------------------------------PhysicalProject ---------------------------------filter((item.i_manufact_id = 29)) -----------------------------------PhysicalOlapScan[item] ---------------------------PhysicalProject -----------------------------filter((date_dim.d_date <= '1999-04-07') and (date_dim.d_date >= '1999-01-07')) -------------------------------PhysicalOlapScan[date_dim] +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[cs_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_date <= '1999-04-07') and (date_dim.d_date >= '1999-01-07')) +--------------------------------------PhysicalOlapScan[date_dim] +------------------------PhysicalProject +--------------------------filter((item.i_manufact_id = 29)) +----------------------------PhysicalOlapScan[item] +----------------PhysicalProject +------------------filter((date_dim.d_date <= '1999-04-07') and (date_dim.d_date >= '1999-01-07')) +--------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf100/shape/query92.out b/regression-test/data/shape_check/tpcds_sf100/shape/query92.out index ff2e7b944234b5..105ef7e4cac826 100644 --- a/regression-test/data/shape_check/tpcds_sf100/shape/query92.out +++ b/regression-test/data/shape_check/tpcds_sf100/shape/query92.out @@ -6,20 +6,27 @@ PhysicalResultSink ------PhysicalDistribute[DistributionSpecGather] --------hashAgg[LOCAL] ----------PhysicalProject -------------filter((cast(ws_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(ws_ext_discount_amt) OVER(PARTITION BY i_item_sk)))) ---------------PhysicalWindow -----------------PhysicalQuickSort[LOCAL_SORT] -------------------PhysicalDistribute[DistributionSpecHash] ---------------------PhysicalProject -----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] -------------------------PhysicalProject ---------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = web_sales.ws_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[ws_item_sk] +------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF3 d_date_sk->[ws_sold_date_sk] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = web_sales.ws_item_sk)) otherCondition=((cast(ws_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(ws_ext_discount_amt)))) build RFs:RF2 i_item_sk->[ws_item_sk] +------------------PhysicalProject +--------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((web_sales.ws_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[ws_item_sk] +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] ----------------------------PhysicalProject -------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 -----------------------------PhysicalProject -------------------------------filter((item.i_manufact_id = 320)) ---------------------------------PhysicalOlapScan[item] -------------------------PhysicalProject ---------------------------filter((date_dim.d_date <= '2002-05-27') and (date_dim.d_date >= '2002-02-26')) -----------------------------PhysicalOlapScan[date_dim] +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 +--------------------------------PhysicalProject +----------------------------------filter((date_dim.d_date <= '2002-05-27') and (date_dim.d_date >= '2002-02-26')) +------------------------------------PhysicalOlapScan[date_dim] +----------------------PhysicalProject +------------------------filter((item.i_manufact_id = 320)) +--------------------------PhysicalOlapScan[item] +--------------PhysicalProject +----------------filter((date_dim.d_date <= '2002-05-27') and (date_dim.d_date >= '2002-02-26')) +------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf1000/hint/query32.out b/regression-test/data/shape_check/tpcds_sf1000/hint/query32.out index b9554f006b4ba4..9c759b3d9418fa 100644 --- a/regression-test/data/shape_check/tpcds_sf1000/hint/query32.out +++ b/regression-test/data/shape_check/tpcds_sf1000/hint/query32.out @@ -7,19 +7,26 @@ PhysicalResultSink --------PhysicalDistribute[DistributionSpecGather] ----------hashAgg[LOCAL] ------------PhysicalProject ---------------filter((cast(cs_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(cs_ext_discount_amt) OVER(PARTITION BY i_item_sk)))) -----------------PhysicalWindow -------------------PhysicalQuickSort[LOCAL_SORT] ---------------------PhysicalDistribute[DistributionSpecHash] +--------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((catalog_sales.cs_item_sk = item.i_item_sk)) otherCondition=((cast(cs_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(cs_ext_discount_amt)))) build RFs:RF3 cs_item_sk->[cs_item_sk,i_item_sk] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[cs_sold_date_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = catalog_sales.cs_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[cs_item_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF1 RF2 RF3 +------------------------PhysicalProject +--------------------------filter((item.i_manufact_id = 722)) +----------------------------PhysicalOlapScan[item] apply RFs: RF3 +--------------------PhysicalProject +----------------------filter((date_dim.d_date <= '2001-06-07') and (date_dim.d_date >= '2001-03-09')) +------------------------PhysicalOlapScan[date_dim] +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecHash] +--------------------hashAgg[LOCAL] ----------------------PhysicalProject -------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk] +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[cs_sold_date_sk] --------------------------PhysicalProject -----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = catalog_sales.cs_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[cs_item_sk] -------------------------------PhysicalProject ---------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 -------------------------------PhysicalProject ---------------------------------filter((item.i_manufact_id = 722)) -----------------------------------PhysicalOlapScan[item] +----------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 --------------------------PhysicalProject ----------------------------filter((date_dim.d_date <= '2001-06-07') and (date_dim.d_date >= '2001-03-09')) ------------------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf1000/hint/query92.out b/regression-test/data/shape_check/tpcds_sf1000/hint/query92.out index 1471354c4e951d..548f0b50bc4c7b 100644 --- a/regression-test/data/shape_check/tpcds_sf1000/hint/query92.out +++ b/regression-test/data/shape_check/tpcds_sf1000/hint/query92.out @@ -6,19 +6,26 @@ PhysicalResultSink ------PhysicalDistribute[DistributionSpecGather] --------hashAgg[LOCAL] ----------PhysicalProject -------------filter((cast(ws_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(ws_ext_discount_amt) OVER(PARTITION BY i_item_sk)))) ---------------PhysicalWindow -----------------PhysicalQuickSort[LOCAL_SORT] -------------------PhysicalDistribute[DistributionSpecHash] +------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((web_sales.ws_item_sk = item.i_item_sk)) otherCondition=((cast(ws_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(ws_ext_discount_amt)))) build RFs:RF3 ws_item_sk->[i_item_sk,ws_item_sk] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = web_sales.ws_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[ws_item_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 RF2 RF3 +----------------------PhysicalProject +------------------------filter((item.i_manufact_id = 714)) +--------------------------PhysicalOlapScan[item] apply RFs: RF3 +------------------PhysicalProject +--------------------filter((date_dim.d_date <= '2000-05-01') and (date_dim.d_date >= '2000-02-01')) +----------------------PhysicalOlapScan[date_dim] +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] --------------------PhysicalProject -----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] ------------------------PhysicalProject ---------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = web_sales.ws_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[ws_item_sk] -----------------------------PhysicalProject -------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 -----------------------------PhysicalProject -------------------------------filter((item.i_manufact_id = 714)) ---------------------------------PhysicalOlapScan[item] +--------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 ------------------------PhysicalProject --------------------------filter((date_dim.d_date <= '2000-05-01') and (date_dim.d_date >= '2000-02-01')) ----------------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf1000/shape/query32.out b/regression-test/data/shape_check/tpcds_sf1000/shape/query32.out index cb7cc0e46364ed..4d1a7e673b04e5 100644 --- a/regression-test/data/shape_check/tpcds_sf1000/shape/query32.out +++ b/regression-test/data/shape_check/tpcds_sf1000/shape/query32.out @@ -7,20 +7,27 @@ PhysicalResultSink --------PhysicalDistribute[DistributionSpecGather] ----------hashAgg[LOCAL] ------------PhysicalProject ---------------filter((cast(cs_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(cs_ext_discount_amt) OVER(PARTITION BY i_item_sk)))) -----------------PhysicalWindow -------------------PhysicalQuickSort[LOCAL_SORT] ---------------------PhysicalDistribute[DistributionSpecHash] -----------------------PhysicalProject -------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk] ---------------------------PhysicalProject -----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = catalog_sales.cs_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[cs_item_sk] +--------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF3 d_date_sk->[cs_sold_date_sk] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = catalog_sales.cs_item_sk)) otherCondition=((cast(cs_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(cs_ext_discount_amt)))) build RFs:RF2 i_item_sk->[cs_item_sk] +--------------------PhysicalProject +----------------------PhysicalOlapScan[catalog_sales] apply RFs: RF2 RF3 +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((catalog_sales.cs_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[cs_item_sk] +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] ------------------------------PhysicalProject ---------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 -------------------------------PhysicalProject ---------------------------------filter((item.i_manufact_id = 722)) -----------------------------------PhysicalOlapScan[item] ---------------------------PhysicalProject -----------------------------filter((date_dim.d_date <= '2001-06-07') and (date_dim.d_date >= '2001-03-09')) -------------------------------PhysicalOlapScan[date_dim] +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[cs_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_date <= '2001-06-07') and (date_dim.d_date >= '2001-03-09')) +--------------------------------------PhysicalOlapScan[date_dim] +------------------------PhysicalProject +--------------------------filter((item.i_manufact_id = 722)) +----------------------------PhysicalOlapScan[item] +----------------PhysicalProject +------------------filter((date_dim.d_date <= '2001-06-07') and (date_dim.d_date >= '2001-03-09')) +--------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf1000/shape/query92.out b/regression-test/data/shape_check/tpcds_sf1000/shape/query92.out index f44949b6b8cece..b6ea4b60be34fa 100644 --- a/regression-test/data/shape_check/tpcds_sf1000/shape/query92.out +++ b/regression-test/data/shape_check/tpcds_sf1000/shape/query92.out @@ -6,20 +6,27 @@ PhysicalResultSink ------PhysicalDistribute[DistributionSpecGather] --------hashAgg[LOCAL] ----------PhysicalProject -------------filter((cast(ws_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(ws_ext_discount_amt) OVER(PARTITION BY i_item_sk)))) ---------------PhysicalWindow -----------------PhysicalQuickSort[LOCAL_SORT] -------------------PhysicalDistribute[DistributionSpecHash] ---------------------PhysicalProject -----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] -------------------------PhysicalProject ---------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = web_sales.ws_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[ws_item_sk] +------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF3 d_date_sk->[ws_sold_date_sk] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = web_sales.ws_item_sk)) otherCondition=((cast(ws_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(ws_ext_discount_amt)))) build RFs:RF2 i_item_sk->[ws_item_sk] +------------------PhysicalProject +--------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((web_sales.ws_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[ws_item_sk] +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] ----------------------------PhysicalProject -------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 -----------------------------PhysicalProject -------------------------------filter((item.i_manufact_id = 714)) ---------------------------------PhysicalOlapScan[item] -------------------------PhysicalProject ---------------------------filter((date_dim.d_date <= '2000-05-01') and (date_dim.d_date >= '2000-02-01')) -----------------------------PhysicalOlapScan[date_dim] +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 +--------------------------------PhysicalProject +----------------------------------filter((date_dim.d_date <= '2000-05-01') and (date_dim.d_date >= '2000-02-01')) +------------------------------------PhysicalOlapScan[date_dim] +----------------------PhysicalProject +------------------------filter((item.i_manufact_id = 714)) +--------------------------PhysicalOlapScan[item] +--------------PhysicalProject +----------------filter((date_dim.d_date <= '2000-05-01') and (date_dim.d_date >= '2000-02-01')) +------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query1.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query1.out new file mode 100644 index 00000000000000..501e7ed54f636f --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query1.out @@ -0,0 +1,37 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_1_constraints -- +PhysicalCteAnchor ( cteId=CTEId#0 ) +--PhysicalCteProducer ( cteId=CTEId#0 ) +----PhysicalProject +------hashAgg[GLOBAL] +--------PhysicalDistribute[DistributionSpecHash] +----------hashAgg[LOCAL] +------------PhysicalProject +--------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_returns.sr_returned_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[sr_returned_date_sk] +----------------PhysicalProject +------------------PhysicalOlapScan[store_returns] apply RFs: RF0 +----------------PhysicalProject +------------------filter((date_dim.d_year = 2000)) +--------------------PhysicalOlapScan[date_dim] +--PhysicalResultSink +----PhysicalTopN[MERGE_SORT] +------PhysicalDistribute[DistributionSpecGather] +--------PhysicalTopN[LOCAL_SORT] +----------PhysicalProject +------------hashJoin[INNER_JOIN broadcast] hashCondition=((ctr1.ctr_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 ctr_customer_sk->[c_customer_sk] +--------------PhysicalProject +----------------PhysicalOlapScan[customer] apply RFs: RF3 +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((ctr1.ctr_store_sk = ctr2.ctr_store_sk)) otherCondition=((cast(ctr_total_return as DECIMALV3(38, 5)) > (avg(ctr_total_return) * 1.2))) build RFs:RF2 ctr_store_sk->[ctr_store_sk,s_store_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN shuffle] hashCondition=((store.s_store_sk = ctr1.ctr_store_sk)) otherCondition=() build RFs:RF1 s_store_sk->[ctr_store_sk] +----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF1 RF2 +----------------------PhysicalProject +------------------------filter((store.s_state = 'TN')) +--------------------------PhysicalOlapScan[store] apply RFs: RF2 +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalDistribute[DistributionSpecExecutionAny] +--------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query10.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query10.out new file mode 100644 index 00000000000000..82563cfffd6464 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query10.out @@ -0,0 +1,47 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_10_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------filter(OR[ifnull($c$1, FALSE),ifnull($c$2, FALSE)]) +--------------------hashJoin[RIGHT_SEMI_JOIN shuffleBucket] hashCondition=((c.c_customer_sk = catalog_sales.cs_ship_customer_sk)) otherCondition=() +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF5 d_date_sk->[cs_sold_date_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF5 +--------------------------PhysicalProject +----------------------------filter((date_dim.d_moy <= 6) and (date_dim.d_moy >= 3) and (date_dim.d_year = 2001)) +------------------------------PhysicalOlapScan[date_dim] +----------------------hashJoin[RIGHT_SEMI_JOIN shuffleBucket] hashCondition=((c.c_customer_sk = web_sales.ws_bill_customer_sk)) otherCondition=() +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ws_sold_date_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF4 +----------------------------PhysicalProject +------------------------------filter((date_dim.d_moy <= 6) and (date_dim.d_moy >= 3) and (date_dim.d_year = 2001)) +--------------------------------PhysicalOlapScan[date_dim] +------------------------hashJoin[RIGHT_SEMI_JOIN shuffle] hashCondition=((c.c_customer_sk = store_sales.ss_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[ss_customer_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ss_sold_date_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[store_sales] apply RFs: RF2 RF3 +------------------------------PhysicalProject +--------------------------------filter((date_dim.d_moy <= 6) and (date_dim.d_moy >= 3) and (date_dim.d_year = 2001)) +----------------------------------PhysicalOlapScan[date_dim] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer_demographics.cd_demo_sk = c.c_current_cdemo_sk)) otherCondition=() build RFs:RF1 c_current_cdemo_sk->[cd_demo_sk] +------------------------------PhysicalOlapScan[customer_demographics] apply RFs: RF1 +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((c.c_current_addr_sk = ca.ca_address_sk)) otherCondition=() build RFs:RF0 ca_address_sk->[c_current_addr_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[customer] apply RFs: RF0 +----------------------------------PhysicalProject +------------------------------------filter(ca_county IN ('Campbell County', 'Cleburne County', 'Escambia County', 'Fairfield County', 'Washtenaw County')) +--------------------------------------PhysicalOlapScan[customer_address] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query11.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query11.out new file mode 100644 index 00000000000000..8b1907ac786360 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query11.out @@ -0,0 +1,53 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_11_constraints -- +PhysicalCteAnchor ( cteId=CTEId#0 ) +--PhysicalCteProducer ( cteId=CTEId#0 ) +----PhysicalProject +------hashJoin[INNER_JOIN shuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[ss_customer_sk,ws_bill_customer_sk] +--------PhysicalUnion +----------PhysicalProject +------------hashAgg[GLOBAL] +--------------PhysicalDistribute[DistributionSpecHash] +----------------hashAgg[LOCAL] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF2 +----------------------PhysicalProject +------------------------filter(d_year IN (1998, 1999)) +--------------------------PhysicalOlapScan[date_dim] +----------PhysicalProject +------------hashAgg[GLOBAL] +--------------PhysicalDistribute[DistributionSpecHash] +----------------hashAgg[LOCAL] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 RF2 +----------------------PhysicalProject +------------------------filter(d_year IN (1998, 1999)) +--------------------------PhysicalOlapScan[date_dim] +--------PhysicalProject +----------PhysicalOlapScan[customer] +--PhysicalResultSink +----PhysicalTopN[MERGE_SORT] +------PhysicalDistribute[DistributionSpecGather] +--------PhysicalTopN[LOCAL_SORT] +----------PhysicalProject +------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000) > if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000))) build RFs:RF5 customer_id->[customer_id] +--------------PhysicalProject +----------------filter((t_w_secyear.dyear = 1999) and (t_w_secyear.sale_type = 'w')) +------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 +--------------PhysicalProject +----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id,customer_id] +------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF3 customer_id->[customer_id] +--------------------PhysicalProject +----------------------filter((t_s_secyear.dyear = 1999) and (t_s_secyear.sale_type = 's')) +------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF3 RF4 +--------------------PhysicalProject +----------------------filter((t_s_firstyear.dyear = 1998) and (t_s_firstyear.sale_type = 's') and (t_s_firstyear.year_total > 0.00)) +------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 +------------------PhysicalProject +--------------------filter((t_w_firstyear.dyear = 1998) and (t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year_total > 0.00)) +----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query12.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query12.out new file mode 100644 index 00000000000000..4eae4f4e5296b9 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query12.out @@ -0,0 +1,29 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_12_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------PhysicalWindow +------------PhysicalQuickSort[LOCAL_SORT] +--------------PhysicalDistribute[DistributionSpecHash] +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecHash] +--------------------hashAgg[LOCAL] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((web_sales.ws_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[ws_item_sk] +------------------------------hashAgg[GLOBAL] +--------------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------------hashAgg[LOCAL] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 +------------------------------PhysicalProject +--------------------------------filter(i_category IN ('Books', 'Electronics', 'Men')) +----------------------------------PhysicalOlapScan[item] +--------------------------PhysicalProject +----------------------------filter((date_dim.d_date <= '2001-07-15') and (date_dim.d_date >= '2001-06-15')) +------------------------------PhysicalOlapScan[date_dim] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query13.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query13.out new file mode 100644 index 00000000000000..e22d8dc5b798bf --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query13.out @@ -0,0 +1,34 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_13_constraints -- +PhysicalResultSink +--hashAgg[GLOBAL] +----PhysicalDistribute[DistributionSpecGather] +------hashAgg[LOCAL] +--------PhysicalProject +----------hashJoin[INNER_JOIN broadcast] hashCondition=((store.s_store_sk = store_sales.ss_store_sk)) otherCondition=() build RFs:RF4 s_store_sk->[ss_store_sk] +------------PhysicalProject +--------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_addr_sk = customer_address.ca_address_sk)) otherCondition=(OR[AND[ca_state IN ('IL', 'TN', 'TX'),(store_sales.ss_net_profit >= 100.00),(store_sales.ss_net_profit <= 200.00)],AND[ca_state IN ('ID', 'OH', 'WY'),(store_sales.ss_net_profit >= 150.00)],AND[ca_state IN ('IA', 'MS', 'SC'),(store_sales.ss_net_profit <= 250.00)]]) build RFs:RF3 ss_addr_sk->[ca_address_sk] +----------------PhysicalProject +------------------filter((customer_address.ca_country = 'United States') and ca_state IN ('IA', 'ID', 'IL', 'MS', 'OH', 'SC', 'TN', 'TX', 'WY')) +--------------------PhysicalOlapScan[customer_address] apply RFs: RF3 +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ss_sold_date_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk)) otherCondition=(OR[AND[(household_demographics.hd_dep_count = 1),OR[AND[(customer_demographics.cd_marital_status = 'D'),(customer_demographics.cd_education_status = 'Primary'),(store_sales.ss_sales_price <= 100.00)],AND[(customer_demographics.cd_marital_status = 'W'),(customer_demographics.cd_education_status = '2 yr Degree'),(store_sales.ss_sales_price >= 150.00)]]],AND[(customer_demographics.cd_marital_status = 'M'),(customer_demographics.cd_education_status = 'College'),(store_sales.ss_sales_price >= 100.00),(store_sales.ss_sales_price <= 150.00),(household_demographics.hd_dep_count = 3)]]) build RFs:RF1 hd_demo_sk->[ss_hdemo_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer_demographics.cd_demo_sk = store_sales.ss_cdemo_sk)) otherCondition=() build RFs:RF0 cd_demo_sk->[ss_cdemo_sk] +----------------------------PhysicalProject +------------------------------filter((store_sales.ss_net_profit <= 300.00) and (store_sales.ss_net_profit >= 50.00) and (store_sales.ss_sales_price <= 200.00) and (store_sales.ss_sales_price >= 50.00)) +--------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 RF4 +----------------------------PhysicalProject +------------------------------filter(OR[AND[(customer_demographics.cd_marital_status = 'D'),(customer_demographics.cd_education_status = 'Primary')],AND[(customer_demographics.cd_marital_status = 'W'),(customer_demographics.cd_education_status = '2 yr Degree')],AND[(customer_demographics.cd_marital_status = 'M'),(customer_demographics.cd_education_status = 'College')]] and cd_education_status IN ('2 yr Degree', 'College', 'Primary') and cd_marital_status IN ('D', 'M', 'W')) +--------------------------------PhysicalOlapScan[customer_demographics] +------------------------PhysicalProject +--------------------------filter(hd_dep_count IN (1, 3)) +----------------------------PhysicalOlapScan[household_demographics] +--------------------PhysicalProject +----------------------filter((date_dim.d_year = 2001)) +------------------------PhysicalOlapScan[date_dim] +------------PhysicalProject +--------------PhysicalOlapScan[store] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query14.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query14.out new file mode 100644 index 00000000000000..b25d1fdb179568 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query14.out @@ -0,0 +1,170 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_14_constraints -- +PhysicalCteAnchor ( cteId=CTEId#0 ) +--PhysicalCteProducer ( cteId=CTEId#0 ) +----PhysicalProject +------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_brand_id = t.brand_id) and (item.i_category_id = t.category_id) and (item.i_class_id = t.class_id)) otherCondition=() build RFs:RF6 brand_id->[i_brand_id];RF7 class_id->[i_class_id];RF8 category_id->[i_category_id] +--------PhysicalProject +----------PhysicalOlapScan[item] apply RFs: RF6 RF7 RF8 +--------PhysicalIntersect RFV2: RF19[brand_id->i_brand_id] RF20[brand_id->i_brand_id] +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_item_sk = iss.i_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[ss_item_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = d1.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 +------------------------PhysicalProject +--------------------------filter((d1.d_year <= 2001) and (d1.d_year >= 1999)) +----------------------------PhysicalOlapScan[date_dim] +--------------------PhysicalProject +----------------------PhysicalOlapScan[item] +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_item_sk = ics.i_item_sk)) otherCondition=() build RFs:RF3 i_item_sk->[cs_item_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = d2.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[cs_sold_date_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF2 RF3 +------------------------PhysicalProject +--------------------------filter((d2.d_year <= 2001) and (d2.d_year >= 1999)) +----------------------------PhysicalOlapScan[date_dim] +--------------------PhysicalProject +----------------------PhysicalOlapScan[item] RFV2: RF19 +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_item_sk = iws.i_item_sk)) otherCondition=() build RFs:RF5 i_item_sk->[ws_item_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = d3.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ws_sold_date_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[web_sales] apply RFs: RF4 RF5 +------------------------PhysicalProject +--------------------------filter((d3.d_year <= 2001) and (d3.d_year >= 1999)) +----------------------------PhysicalOlapScan[date_dim] +--------------------PhysicalProject +----------------------PhysicalOlapScan[item] RFV2: RF20 +--PhysicalCteAnchor ( cteId=CTEId#1 ) +----PhysicalCteProducer ( cteId=CTEId#1 ) +------hashAgg[GLOBAL] +--------PhysicalDistribute[DistributionSpecGather] +----------hashAgg[LOCAL] +------------PhysicalProject +--------------hashJoin[INNER_JOIN broadcast] hashCondition=((ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF9 d_date_sk->[cs_sold_date_sk,ss_sold_date_sk,ws_sold_date_sk] +----------------PhysicalUnion +------------------PhysicalDistribute[DistributionSpecExecutionAny] +--------------------PhysicalProject +----------------------PhysicalOlapScan[store_sales] apply RFs: RF9 +------------------PhysicalDistribute[DistributionSpecExecutionAny] +--------------------PhysicalProject +----------------------PhysicalOlapScan[catalog_sales] apply RFs: RF9 +------------------PhysicalDistribute[DistributionSpecExecutionAny] +--------------------PhysicalProject +----------------------PhysicalOlapScan[web_sales] apply RFs: RF9 +----------------PhysicalProject +------------------filter((date_dim.d_year <= 2001) and (date_dim.d_year >= 1999)) +--------------------PhysicalOlapScan[date_dim] +----PhysicalCteAnchor ( cteId=CTEId#2 ) +------PhysicalCteProducer ( cteId=CTEId#2 ) +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalUnion +----------------PhysicalProject +------------------NestedLoopJoin[INNER_JOIN](cast(sales as DECIMALV3(38, 4)) > avg_sales.average_sales) +--------------------PhysicalProject +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------hashJoin[LEFT_SEMI_JOIN bucketShuffle] hashCondition=((store_sales.ss_item_sk = cross_items.ss_item_sk)) otherCondition=() build RFs:RF12 ss_item_sk->[i_item_sk,ss_item_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF11 d_date_sk->[ss_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF10 i_item_sk->[ss_item_sk] +----------------------------------------hashAgg[GLOBAL] +------------------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------------------hashAgg[LOCAL] +----------------------------------------------PhysicalProject +------------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF10 RF11 RF12 +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[item] apply RFs: RF12 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_moy = 11) and (date_dim.d_year = 2001)) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +--------------------PhysicalAssertNumRows +----------------------PhysicalDistribute[DistributionSpecGather] +------------------------PhysicalCteConsumer ( cteId=CTEId#1 ) +----------------PhysicalProject +------------------NestedLoopJoin[INNER_JOIN](cast(sales as DECIMALV3(38, 4)) > avg_sales.average_sales) +--------------------PhysicalProject +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------hashJoin[LEFT_SEMI_JOIN bucketShuffle] hashCondition=((catalog_sales.cs_item_sk = cross_items.ss_item_sk)) otherCondition=() build RFs:RF15 ss_item_sk->[cs_item_sk,i_item_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF14 d_date_sk->[cs_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((catalog_sales.cs_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF13 i_item_sk->[cs_item_sk] +----------------------------------------hashAgg[GLOBAL] +------------------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------------------hashAgg[LOCAL] +----------------------------------------------PhysicalProject +------------------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF13 RF14 RF15 +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[item] apply RFs: RF15 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_moy = 11) and (date_dim.d_year = 2001)) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +--------------------PhysicalAssertNumRows +----------------------PhysicalDistribute[DistributionSpecGather] +------------------------PhysicalCteConsumer ( cteId=CTEId#1 ) +----------------PhysicalProject +------------------NestedLoopJoin[INNER_JOIN](cast(sales as DECIMALV3(38, 4)) > avg_sales.average_sales) +--------------------PhysicalProject +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------hashJoin[LEFT_SEMI_JOIN bucketShuffle] hashCondition=((web_sales.ws_item_sk = cross_items.ss_item_sk)) otherCondition=() build RFs:RF18 ss_item_sk->[i_item_sk,ws_item_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF17 d_date_sk->[ws_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((web_sales.ws_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF16 i_item_sk->[ws_item_sk] +----------------------------------------hashAgg[GLOBAL] +------------------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------------------hashAgg[LOCAL] +----------------------------------------------PhysicalProject +------------------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF16 RF17 RF18 +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[item] apply RFs: RF18 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_moy = 11) and (date_dim.d_year = 2001)) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +--------------------PhysicalAssertNumRows +----------------------PhysicalDistribute[DistributionSpecGather] +------------------------PhysicalCteConsumer ( cteId=CTEId#1 ) +------PhysicalResultSink +--------PhysicalTopN[MERGE_SORT] +----------PhysicalDistribute[DistributionSpecGather] +------------PhysicalTopN[LOCAL_SORT] +--------------PhysicalUnion +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalRepeat +--------------------------PhysicalDistribute[DistributionSpecExecutionAny] +----------------------------PhysicalCteConsumer ( cteId=CTEId#2 ) +----------------PhysicalDistribute[DistributionSpecExecutionAny] +------------------PhysicalCteConsumer ( cteId=CTEId#2 ) + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query15.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query15.out new file mode 100644 index 00000000000000..33598569fd36c0 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query15.out @@ -0,0 +1,25 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_15_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN shuffle] hashCondition=((catalog_sales.cs_bill_customer_sk = customer.c_customer_sk)) otherCondition=(OR[substring(ca_zip, 1, 5) IN ('80348', '81792', '83405', '85392', '85460', '85669', '86197', '86475', '88274'),ca_state IN ('CA', 'GA', 'WA'),(catalog_sales.cs_sales_price > 500.00)]) build RFs:RF2 c_customer_sk->[cs_bill_customer_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF1 RF2 +----------------------PhysicalProject +------------------------filter((date_dim.d_qoy = 2) and (date_dim.d_year = 2001)) +--------------------------PhysicalOlapScan[date_dim] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_current_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF0 ca_address_sk->[c_current_addr_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[customer] apply RFs: RF0 +----------------------PhysicalProject +------------------------PhysicalOlapScan[customer_address] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query16.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query16.out new file mode 100644 index 00000000000000..2ef4689fc02b94 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query16.out @@ -0,0 +1,35 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_16_constraints -- +PhysicalResultSink +--PhysicalLimit[GLOBAL] +----PhysicalLimit[LOCAL] +------hashAgg[DISTINCT_GLOBAL] +--------PhysicalDistribute[DistributionSpecGather] +----------hashAgg[DISTINCT_LOCAL] +------------hashAgg[GLOBAL] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------hashJoin[RIGHT_SEMI_JOIN shuffleBucket] hashCondition=((cs1.cs_order_number = cs2.cs_order_number)) otherCondition=(( not (cs_warehouse_sk = cs_warehouse_sk))) build RFs:RF4 cs_order_number->[cs_order_number] +--------------------PhysicalProject +----------------------PhysicalOlapScan[catalog_sales] apply RFs: RF4 +--------------------hashJoin[RIGHT_ANTI_JOIN shuffle] hashCondition=((cs1.cs_order_number = cr1.cr_order_number)) otherCondition=() build RFs:RF3 cs_order_number->[cr_order_number] +----------------------PhysicalProject +------------------------PhysicalOlapScan[catalog_returns] apply RFs: RF3 +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((cs1.cs_call_center_sk = call_center.cc_call_center_sk)) otherCondition=() build RFs:RF2 cc_call_center_sk->[cs_call_center_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((cs1.cs_ship_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_ship_date_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((cs1.cs_ship_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF0 ca_address_sk->[cs_ship_addr_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 RF2 +----------------------------------PhysicalProject +------------------------------------filter((customer_address.ca_state = 'PA')) +--------------------------------------PhysicalOlapScan[customer_address] +------------------------------PhysicalProject +--------------------------------filter((date_dim.d_date <= '2002-05-31') and (date_dim.d_date >= '2002-04-01')) +----------------------------------PhysicalOlapScan[date_dim] +--------------------------PhysicalProject +----------------------------filter((call_center.cc_county = 'Williamson County')) +------------------------------PhysicalOlapScan[call_center] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query17.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query17.out new file mode 100644 index 00000000000000..22d29b59b5be57 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query17.out @@ -0,0 +1,44 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_17_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_returns.sr_customer_sk = catalog_sales.cs_bill_customer_sk) and (store_returns.sr_item_sk = catalog_sales.cs_item_sk)) otherCondition=() build RFs:RF8 sr_customer_sk->[cs_bill_customer_sk];RF9 sr_item_sk->[cs_item_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = d3.d_date_sk)) otherCondition=() build RFs:RF7 d_date_sk->[cs_sold_date_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF7 RF8 RF9 +------------------------PhysicalProject +--------------------------filter(d_quarter_name IN ('2001Q1', '2001Q2', '2001Q3')) +----------------------------PhysicalOlapScan[date_dim] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = store_sales.ss_item_sk)) otherCondition=() build RFs:RF6 i_item_sk->[sr_item_sk,ss_item_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store.s_store_sk = store_sales.ss_store_sk)) otherCondition=() build RFs:RF5 s_store_sk->[ss_store_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((store_sales.ss_customer_sk = store_returns.sr_customer_sk) and (store_sales.ss_item_sk = store_returns.sr_item_sk) and (store_sales.ss_ticket_number = store_returns.sr_ticket_number)) otherCondition=() build RFs:RF2 sr_customer_sk->[ss_customer_sk];RF3 sr_item_sk->[ss_item_sk];RF4 sr_ticket_number->[ss_ticket_number] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((d1.d_date_sk = store_sales.ss_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF1 RF2 RF3 RF4 RF5 RF6 +------------------------------------PhysicalProject +--------------------------------------filter((d1.d_quarter_name = '2001Q1')) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_returns.sr_returned_date_sk = d2.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[sr_returned_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store_returns] apply RFs: RF0 RF6 +------------------------------------PhysicalProject +--------------------------------------filter(d_quarter_name IN ('2001Q1', '2001Q2', '2001Q3')) +----------------------------------------PhysicalOlapScan[date_dim] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[store] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[item] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query18.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query18.out new file mode 100644 index 00000000000000..6ac5e8c12e28b7 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query18.out @@ -0,0 +1,42 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_18_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalRepeat +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF5 i_item_sk->[cs_item_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[cs_sold_date_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_bill_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[cs_bill_customer_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_bill_cdemo_sk = cd1.cd_demo_sk)) otherCondition=() build RFs:RF2 cd_demo_sk->[cs_bill_cdemo_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF2 RF3 RF4 RF5 +----------------------------------PhysicalProject +------------------------------------filter((cd1.cd_education_status = 'Primary') and (cd1.cd_gender = 'F')) +--------------------------------------PhysicalOlapScan[customer_demographics] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_current_cdemo_sk = cd2.cd_demo_sk)) otherCondition=() build RFs:RF1 c_current_cdemo_sk->[cd_demo_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[customer_demographics] apply RFs: RF1 +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer.c_current_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF0 ca_address_sk->[c_current_addr_sk] +--------------------------------------PhysicalProject +----------------------------------------filter(c_birth_month IN (1, 10, 11, 3, 4, 7)) +------------------------------------------PhysicalOlapScan[customer] apply RFs: RF0 +--------------------------------------PhysicalProject +----------------------------------------filter(ca_state IN ('AL', 'CA', 'GA', 'IN', 'MO', 'MT', 'TN')) +------------------------------------------PhysicalOlapScan[customer_address] +--------------------------PhysicalProject +----------------------------filter((date_dim.d_year = 2001)) +------------------------------PhysicalOlapScan[date_dim] +----------------------PhysicalProject +------------------------PhysicalOlapScan[item] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query19.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query19.out new file mode 100644 index 00000000000000..945a75ee8c2a98 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query19.out @@ -0,0 +1,35 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_19_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer.c_current_addr_sk = customer_address.ca_address_sk)) otherCondition=(( not (substring(ca_zip, 1, 5) = substring(s_zip, 1, 5)))) build RFs:RF4 c_current_addr_sk->[ca_address_sk] +--------------------PhysicalProject +----------------------PhysicalOlapScan[customer_address] apply RFs: RF4 +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 ss_customer_sk->[c_customer_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[customer] apply RFs: RF3 +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF2 s_store_sk->[ss_store_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = store_sales.ss_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[ss_item_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 +------------------------------------PhysicalProject +--------------------------------------filter((item.i_manager_id = 14)) +----------------------------------------PhysicalOlapScan[item] +--------------------------------PhysicalProject +----------------------------------filter((date_dim.d_moy = 11) and (date_dim.d_year = 2002)) +------------------------------------PhysicalOlapScan[date_dim] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[store] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query2.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query2.out new file mode 100644 index 00000000000000..e73ae38ccf00ce --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query2.out @@ -0,0 +1,43 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_2_constraints -- +PhysicalCteAnchor ( cteId=CTEId#1 ) +--PhysicalCteProducer ( cteId=CTEId#1 ) +----hashAgg[GLOBAL] +------PhysicalDistribute[DistributionSpecHash] +--------hashAgg[LOCAL] +----------PhysicalProject +------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = wscs.sold_date_sk)) otherCondition=() build RFs:RF0 sold_date_sk->[d_date_sk] +--------------PhysicalProject +----------------PhysicalOlapScan[date_dim] apply RFs: RF0 +--------------PhysicalUnion +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecHash] +--------------------hashAgg[LOCAL] +----------------------PhysicalProject +------------------------PhysicalOlapScan[web_sales] +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecHash] +--------------------hashAgg[LOCAL] +----------------------PhysicalProject +------------------------PhysicalOlapScan[catalog_sales] +--PhysicalResultSink +----PhysicalQuickSort[MERGE_SORT] +------PhysicalDistribute[DistributionSpecGather] +--------PhysicalQuickSort[LOCAL_SORT] +----------PhysicalProject +------------hashJoin[INNER_JOIN broadcast] hashCondition=((expr_cast(d_week_seq1 as BIGINT) = expr_(cast(d_week_seq2 as BIGINT) - 53))) otherCondition=() build RFs:RF3 expr_(cast(d_week_seq2 as BIGINT) - 53)->[cast(d_week_seq as BIGINT)] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN shuffle] hashCondition=((date_dim.d_week_seq = d_week_seq1)) otherCondition=() build RFs:RF2 d_week_seq->[d_week_seq] +------------------PhysicalProject +--------------------PhysicalCteConsumer ( cteId=CTEId#1 ) apply RFs: RF2 RF3 +------------------PhysicalProject +--------------------filter((date_dim.d_year = 1998)) +----------------------PhysicalOlapScan[date_dim] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN shuffle] hashCondition=((date_dim.d_week_seq = d_week_seq2)) otherCondition=() build RFs:RF1 d_week_seq->[d_week_seq] +------------------PhysicalProject +--------------------PhysicalCteConsumer ( cteId=CTEId#1 ) apply RFs: RF1 +------------------PhysicalProject +--------------------filter((date_dim.d_year = 1999)) +----------------------PhysicalOlapScan[date_dim] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query20.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query20.out new file mode 100644 index 00000000000000..6ecf402a602799 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query20.out @@ -0,0 +1,29 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_20_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------PhysicalWindow +------------PhysicalQuickSort[LOCAL_SORT] +--------------PhysicalDistribute[DistributionSpecHash] +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecHash] +--------------------hashAgg[LOCAL] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((catalog_sales.cs_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[cs_item_sk] +------------------------------hashAgg[GLOBAL] +--------------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------------hashAgg[LOCAL] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 +------------------------------PhysicalProject +--------------------------------filter(i_category IN ('Books', 'Music', 'Sports')) +----------------------------------PhysicalOlapScan[item] +--------------------------PhysicalProject +----------------------------filter((date_dim.d_date <= '2002-07-18') and (date_dim.d_date >= '2002-06-18')) +------------------------------PhysicalOlapScan[date_dim] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query21.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query21.out new file mode 100644 index 00000000000000..0101aabc5533ed --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query21.out @@ -0,0 +1,26 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_21_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------filter(((cast(inv_after as DOUBLE) / cast(inv_before as DOUBLE)) <= 1.5) and (if((inv_before > 0), (cast(inv_after as DOUBLE) / cast(inv_before as DOUBLE)), NULL) >= cast((2.000000 / 3.0) as DOUBLE)) and (x.inv_before > 0)) +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((inventory.inv_warehouse_sk = warehouse.w_warehouse_sk)) otherCondition=() build RFs:RF2 w_warehouse_sk->[inv_warehouse_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((inventory.inv_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[inv_date_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((item.i_item_sk = inventory.inv_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[inv_item_sk] +----------------------------PhysicalOlapScan[inventory] apply RFs: RF0 RF1 RF2 +----------------------------PhysicalProject +------------------------------filter((item.i_current_price <= 1.49) and (item.i_current_price >= 0.99)) +--------------------------------PhysicalOlapScan[item] +------------------------PhysicalProject +--------------------------filter((date_dim.d_date <= '1999-07-22') and (date_dim.d_date >= '1999-05-23')) +----------------------------PhysicalOlapScan[date_dim] +--------------------PhysicalProject +----------------------PhysicalOlapScan[warehouse] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query22.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query22.out new file mode 100644 index 00000000000000..9897fa45cd4844 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query22.out @@ -0,0 +1,23 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_22_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalRepeat +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((inventory.inv_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[inv_item_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((inventory.inv_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[inv_date_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[inventory] apply RFs: RF0 RF1 +--------------------------PhysicalProject +----------------------------filter((date_dim.d_month_seq <= 1211) and (date_dim.d_month_seq >= 1200)) +------------------------------PhysicalOlapScan[date_dim] +----------------------PhysicalProject +------------------------PhysicalOlapScan[item] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query23.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query23.out new file mode 100644 index 00000000000000..d43981a6cea708 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query23.out @@ -0,0 +1,82 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_23_constraints -- +PhysicalCteAnchor ( cteId=CTEId#0 ) +--PhysicalCteProducer ( cteId=CTEId#0 ) +----PhysicalProject +------filter((cnt > 4)) +--------hashAgg[GLOBAL] +----------PhysicalProject +------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[ss_item_sk] +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 +------------------------PhysicalProject +--------------------------filter(d_year IN (2000, 2001, 2002, 2003)) +----------------------------PhysicalOlapScan[date_dim] +--------------PhysicalProject +----------------PhysicalOlapScan[item] +--PhysicalCteAnchor ( cteId=CTEId#2 ) +----PhysicalCteProducer ( cteId=CTEId#2 ) +------PhysicalProject +--------NestedLoopJoin[INNER_JOIN](cast(ssales as DECIMALV3(38, 6)) > (0.9500 * tpcds_cmax)) +----------PhysicalProject +------------hashAgg[GLOBAL] +--------------PhysicalDistribute[DistributionSpecHash] +----------------hashAgg[LOCAL] +------------------PhysicalProject +--------------------filter(( not ss_customer_sk IS NULL)) +----------------------PhysicalOlapScan[store_sales] +----------PhysicalProject +------------hashAgg[GLOBAL] +--------------PhysicalDistribute[DistributionSpecGather] +----------------hashAgg[LOCAL] +------------------PhysicalProject +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ss_sold_date_sk] +------------------------------PhysicalProject +--------------------------------filter(( not ss_customer_sk IS NULL)) +----------------------------------PhysicalOlapScan[store_sales] apply RFs: RF2 +------------------------------PhysicalProject +--------------------------------filter(d_year IN (2000, 2001, 2002, 2003)) +----------------------------------PhysicalOlapScan[date_dim] +----PhysicalResultSink +------PhysicalLimit[GLOBAL] +--------PhysicalLimit[LOCAL] +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecGather] +--------------hashAgg[LOCAL] +----------------PhysicalUnion +------------------PhysicalProject +--------------------hashJoin[RIGHT_SEMI_JOIN shuffle] hashCondition=((catalog_sales.cs_item_sk = frequent_ss_items.item_sk)) otherCondition=() build RFs:RF5 cs_item_sk->[item_sk] +----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 +----------------------PhysicalProject +------------------------hashJoin[LEFT_SEMI_JOIN broadcast] hashCondition=((catalog_sales.cs_bill_customer_sk = best_ss_customer.c_customer_sk)) otherCondition=() build RFs:RF4 c_customer_sk->[cs_bill_customer_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF3 d_date_sk->[cs_sold_date_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF3 RF4 +------------------------------PhysicalProject +--------------------------------filter((date_dim.d_moy = 7) and (date_dim.d_year = 2000)) +----------------------------------PhysicalOlapScan[date_dim] +--------------------------PhysicalCteConsumer ( cteId=CTEId#2 ) +------------------PhysicalProject +--------------------hashJoin[RIGHT_SEMI_JOIN shuffle] hashCondition=((web_sales.ws_item_sk = frequent_ss_items.item_sk)) otherCondition=() build RFs:RF8 ws_item_sk->[item_sk] +----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF8 +----------------------PhysicalProject +------------------------hashJoin[LEFT_SEMI_JOIN broadcast] hashCondition=((web_sales.ws_bill_customer_sk = best_ss_customer.c_customer_sk)) otherCondition=() build RFs:RF7 c_customer_sk->[ws_bill_customer_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF6 d_date_sk->[ws_sold_date_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[web_sales] apply RFs: RF6 RF7 +------------------------------PhysicalProject +--------------------------------filter((date_dim.d_moy = 7) and (date_dim.d_year = 2000)) +----------------------------------PhysicalOlapScan[date_dim] +--------------------------PhysicalCteConsumer ( cteId=CTEId#2 ) + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query24.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query24.out new file mode 100644 index 00000000000000..b34dbc56747a7a --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query24.out @@ -0,0 +1,52 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_24_constraints -- +PhysicalCteAnchor ( cteId=CTEId#0 ) +--PhysicalCteProducer ( cteId=CTEId#0 ) +----PhysicalProject +------hashAgg[GLOBAL] +--------PhysicalDistribute[DistributionSpecHash] +----------hashAgg[LOCAL] +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((store_sales.ss_item_sk = store_returns.sr_item_sk) and (store_sales.ss_ticket_number = store_returns.sr_ticket_number)) otherCondition=() build RFs:RF5 sr_ticket_number->[ss_ticket_number];RF6 sr_item_sk->[i_item_sk,ss_item_sk] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF4 i_item_sk->[ss_item_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store.s_zip = customer_address.ca_zip) and (store_sales.ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF2 ca_zip->[s_zip];RF3 c_customer_sk->[ss_customer_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF1 s_store_sk->[ss_store_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[store_sales] apply RFs: RF1 RF3 RF4 RF5 RF6 +----------------------------PhysicalProject +------------------------------filter((store.s_market_id = 5)) +--------------------------------PhysicalOlapScan[store] apply RFs: RF2 +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_current_addr_sk = customer_address.ca_address_sk)) otherCondition=(( not (c_birth_country = upper(ca_country)))) build RFs:RF0 ca_address_sk->[c_current_addr_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[customer] apply RFs: RF0 +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[customer_address] +--------------------PhysicalProject +----------------------PhysicalOlapScan[item] apply RFs: RF6 +----------------PhysicalProject +------------------PhysicalOlapScan[store_returns] +--PhysicalResultSink +----PhysicalQuickSort[MERGE_SORT] +------PhysicalDistribute[DistributionSpecGather] +--------PhysicalQuickSort[LOCAL_SORT] +----------PhysicalProject +------------NestedLoopJoin[INNER_JOIN](cast(paid as DECIMALV3(38, 6)) > 0.05*avg(netpaid)) +--------------PhysicalProject +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecHash] +--------------------hashAgg[LOCAL] +----------------------PhysicalDistribute[DistributionSpecExecutionAny] +------------------------PhysicalProject +--------------------------filter((ssales.i_color = 'aquamarine')) +----------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +--------------PhysicalProject +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecGather] +--------------------hashAgg[LOCAL] +----------------------PhysicalDistribute[DistributionSpecExecutionAny] +------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query25.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query25.out new file mode 100644 index 00000000000000..5c30986950ad1a --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query25.out @@ -0,0 +1,43 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_25_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_returns.sr_customer_sk = catalog_sales.cs_bill_customer_sk) and (store_returns.sr_item_sk = catalog_sales.cs_item_sk)) otherCondition=() build RFs:RF8 sr_customer_sk->[cs_bill_customer_sk];RF9 sr_item_sk->[cs_item_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = d3.d_date_sk)) otherCondition=() build RFs:RF7 d_date_sk->[cs_sold_date_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF7 RF8 RF9 +----------------------PhysicalProject +------------------------filter((d3.d_moy <= 10) and (d3.d_moy >= 4) and (d3.d_year = 1999)) +--------------------------PhysicalOlapScan[date_dim] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = store_sales.ss_item_sk)) otherCondition=() build RFs:RF6 i_item_sk->[sr_item_sk,ss_item_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store.s_store_sk = store_sales.ss_store_sk)) otherCondition=() build RFs:RF5 s_store_sk->[ss_store_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((store_sales.ss_customer_sk = store_returns.sr_customer_sk) and (store_sales.ss_item_sk = store_returns.sr_item_sk) and (store_sales.ss_ticket_number = store_returns.sr_ticket_number)) otherCondition=() build RFs:RF2 sr_customer_sk->[ss_customer_sk];RF3 sr_item_sk->[ss_item_sk];RF4 sr_ticket_number->[ss_ticket_number] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((d1.d_date_sk = store_sales.ss_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF1 RF2 RF3 RF4 RF5 RF6 +----------------------------------PhysicalProject +------------------------------------filter((d1.d_moy = 4) and (d1.d_year = 1999)) +--------------------------------------PhysicalOlapScan[date_dim] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_returns.sr_returned_date_sk = d2.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[sr_returned_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_returns] apply RFs: RF0 RF6 +----------------------------------PhysicalProject +------------------------------------filter((d2.d_moy <= 10) and (d2.d_moy >= 4) and (d2.d_year = 1999)) +--------------------------------------PhysicalOlapScan[date_dim] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[store] +----------------------PhysicalProject +------------------------PhysicalOlapScan[item] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query26.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query26.out new file mode 100644 index 00000000000000..04f9c7415c2876 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query26.out @@ -0,0 +1,31 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_26_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF3 i_item_sk->[cs_item_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_promo_sk = promotion.p_promo_sk)) otherCondition=() build RFs:RF2 p_promo_sk->[cs_promo_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_bill_cdemo_sk = customer_demographics.cd_demo_sk)) otherCondition=() build RFs:RF0 cd_demo_sk->[cs_bill_cdemo_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 RF2 RF3 +------------------------------PhysicalProject +--------------------------------filter((customer_demographics.cd_education_status = 'Unknown') and (customer_demographics.cd_gender = 'M') and (customer_demographics.cd_marital_status = 'W')) +----------------------------------PhysicalOlapScan[customer_demographics] +--------------------------PhysicalProject +----------------------------filter((date_dim.d_year = 2002)) +------------------------------PhysicalOlapScan[date_dim] +----------------------PhysicalProject +------------------------filter(OR[(promotion.p_channel_email = 'N'),(promotion.p_channel_event = 'N')]) +--------------------------PhysicalOlapScan[promotion] +------------------PhysicalProject +--------------------PhysicalOlapScan[item] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query27.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query27.out new file mode 100644 index 00000000000000..51864410881a23 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query27.out @@ -0,0 +1,33 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_27_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalRepeat +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN shuffle] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF3 i_item_sk->[ss_item_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ss_sold_date_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF1 s_store_sk->[ss_store_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_cdemo_sk = customer_demographics.cd_demo_sk)) otherCondition=() build RFs:RF0 cd_demo_sk->[ss_cdemo_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 RF3 +----------------------------------PhysicalProject +------------------------------------filter((customer_demographics.cd_education_status = 'Secondary') and (customer_demographics.cd_gender = 'M') and (customer_demographics.cd_marital_status = 'W')) +--------------------------------------PhysicalOlapScan[customer_demographics] +------------------------------PhysicalProject +--------------------------------filter((store.s_state = 'TN')) +----------------------------------PhysicalOlapScan[store] +--------------------------PhysicalProject +----------------------------filter((date_dim.d_year = 1999)) +------------------------------PhysicalOlapScan[date_dim] +----------------------PhysicalProject +------------------------PhysicalOlapScan[item] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query28.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query28.out new file mode 100644 index 00000000000000..48757163b603c0 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query28.out @@ -0,0 +1,75 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_28_constraints -- +PhysicalResultSink +--PhysicalLimit[GLOBAL] +----PhysicalLimit[LOCAL] +------NestedLoopJoin[CROSS_JOIN] +--------PhysicalLimit[LOCAL] +----------NestedLoopJoin[CROSS_JOIN] +------------PhysicalLimit[LOCAL] +--------------NestedLoopJoin[CROSS_JOIN] +----------------PhysicalLimit[LOCAL] +------------------NestedLoopJoin[CROSS_JOIN] +--------------------PhysicalLimit[LOCAL] +----------------------NestedLoopJoin[CROSS_JOIN] +------------------------PhysicalLimit[LOCAL] +--------------------------hashAgg[DISTINCT_GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecGather] +------------------------------hashAgg[DISTINCT_LOCAL] +--------------------------------hashAgg[GLOBAL] +----------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------hashAgg[LOCAL] +--------------------------------------PhysicalProject +----------------------------------------filter((store_sales.ss_quantity <= 5) and (store_sales.ss_quantity >= 0) and OR[AND[(store_sales.ss_list_price >= 107.00),(store_sales.ss_list_price <= 117.00)],AND[(store_sales.ss_coupon_amt >= 1319.00),(store_sales.ss_coupon_amt <= 2319.00)],AND[(store_sales.ss_wholesale_cost >= 60.00),(store_sales.ss_wholesale_cost <= 80.00)]]) +------------------------------------------PhysicalOlapScan[store_sales] +------------------------PhysicalLimit[LOCAL] +--------------------------hashAgg[DISTINCT_GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecGather] +------------------------------hashAgg[DISTINCT_LOCAL] +--------------------------------hashAgg[GLOBAL] +----------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------hashAgg[LOCAL] +--------------------------------------PhysicalProject +----------------------------------------filter((store_sales.ss_quantity <= 10) and (store_sales.ss_quantity >= 6) and OR[AND[(store_sales.ss_list_price >= 23.00),(store_sales.ss_list_price <= 33.00)],AND[(store_sales.ss_coupon_amt >= 825.00),(store_sales.ss_coupon_amt <= 1825.00)],AND[(store_sales.ss_wholesale_cost >= 43.00),(store_sales.ss_wholesale_cost <= 63.00)]]) +------------------------------------------PhysicalOlapScan[store_sales] +--------------------PhysicalLimit[LOCAL] +----------------------hashAgg[DISTINCT_GLOBAL] +------------------------PhysicalDistribute[DistributionSpecGather] +--------------------------hashAgg[DISTINCT_LOCAL] +----------------------------hashAgg[GLOBAL] +------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------hashAgg[LOCAL] +----------------------------------PhysicalProject +------------------------------------filter((store_sales.ss_quantity <= 15) and (store_sales.ss_quantity >= 11) and OR[AND[(store_sales.ss_list_price >= 74.00),(store_sales.ss_list_price <= 84.00)],AND[(store_sales.ss_coupon_amt >= 4381.00),(store_sales.ss_coupon_amt <= 5381.00)],AND[(store_sales.ss_wholesale_cost >= 57.00),(store_sales.ss_wholesale_cost <= 77.00)]]) +--------------------------------------PhysicalOlapScan[store_sales] +----------------PhysicalLimit[LOCAL] +------------------hashAgg[DISTINCT_GLOBAL] +--------------------PhysicalDistribute[DistributionSpecGather] +----------------------hashAgg[DISTINCT_LOCAL] +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------filter((store_sales.ss_quantity <= 20) and (store_sales.ss_quantity >= 16) and OR[AND[(store_sales.ss_list_price >= 89.00),(store_sales.ss_list_price <= 99.00)],AND[(store_sales.ss_coupon_amt >= 3117.00),(store_sales.ss_coupon_amt <= 4117.00)],AND[(store_sales.ss_wholesale_cost >= 68.00),(store_sales.ss_wholesale_cost <= 88.00)]]) +----------------------------------PhysicalOlapScan[store_sales] +------------PhysicalLimit[LOCAL] +--------------hashAgg[DISTINCT_GLOBAL] +----------------PhysicalDistribute[DistributionSpecGather] +------------------hashAgg[DISTINCT_LOCAL] +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalProject +----------------------------filter((store_sales.ss_quantity <= 25) and (store_sales.ss_quantity >= 21) and OR[AND[(store_sales.ss_list_price >= 58.00),(store_sales.ss_list_price <= 68.00)],AND[(store_sales.ss_coupon_amt >= 9402.00),(store_sales.ss_coupon_amt <= 10402.00)],AND[(store_sales.ss_wholesale_cost >= 38.00),(store_sales.ss_wholesale_cost <= 58.00)]]) +------------------------------PhysicalOlapScan[store_sales] +--------PhysicalLimit[LOCAL] +----------hashAgg[DISTINCT_GLOBAL] +------------PhysicalDistribute[DistributionSpecGather] +--------------hashAgg[DISTINCT_LOCAL] +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecHash] +--------------------hashAgg[LOCAL] +----------------------PhysicalProject +------------------------filter((store_sales.ss_quantity <= 30) and (store_sales.ss_quantity >= 26) and OR[AND[(store_sales.ss_list_price >= 64.00),(store_sales.ss_list_price <= 74.00)],AND[(store_sales.ss_coupon_amt >= 5792.00),(store_sales.ss_coupon_amt <= 6792.00)],AND[(store_sales.ss_wholesale_cost >= 73.00),(store_sales.ss_wholesale_cost <= 93.00)]]) +--------------------------PhysicalOlapScan[store_sales] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query29.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query29.out new file mode 100644 index 00000000000000..7bc207ac0c4247 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query29.out @@ -0,0 +1,43 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_29_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = d3.d_date_sk)) otherCondition=() build RFs:RF9 d_date_sk->[cs_sold_date_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_returns.sr_customer_sk = catalog_sales.cs_bill_customer_sk) and (store_returns.sr_item_sk = catalog_sales.cs_item_sk)) otherCondition=() build RFs:RF7 sr_customer_sk->[cs_bill_customer_sk];RF8 sr_item_sk->[cs_item_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF7 RF8 RF9 +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = store_sales.ss_item_sk)) otherCondition=() build RFs:RF6 i_item_sk->[sr_item_sk,ss_item_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store.s_store_sk = store_sales.ss_store_sk)) otherCondition=() build RFs:RF5 s_store_sk->[ss_store_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((store_sales.ss_customer_sk = store_returns.sr_customer_sk) and (store_sales.ss_item_sk = store_returns.sr_item_sk) and (store_sales.ss_ticket_number = store_returns.sr_ticket_number)) otherCondition=() build RFs:RF2 sr_customer_sk->[ss_customer_sk];RF3 sr_item_sk->[ss_item_sk];RF4 sr_ticket_number->[ss_ticket_number] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((d1.d_date_sk = store_sales.ss_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF1 RF2 RF3 RF4 RF5 RF6 +--------------------------------------PhysicalProject +----------------------------------------filter((d1.d_moy = 4) and (d1.d_year = 1998)) +------------------------------------------PhysicalOlapScan[date_dim] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_returns.sr_returned_date_sk = d2.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[sr_returned_date_sk] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[store_returns] apply RFs: RF0 RF6 +--------------------------------------PhysicalProject +----------------------------------------filter((d2.d_moy <= 7) and (d2.d_moy >= 4) and (d2.d_year = 1998)) +------------------------------------------PhysicalOlapScan[date_dim] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[store] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[item] +------------------PhysicalProject +--------------------filter(d_year IN (1998, 1999, 2000)) +----------------------PhysicalOlapScan[date_dim] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query3.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query3.out new file mode 100644 index 00000000000000..9ff575500dfabc --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query3.out @@ -0,0 +1,26 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_3_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[ss_item_sk] +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((dt.d_date_sk = store_sales.ss_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 +------------------------------PhysicalProject +--------------------------------filter((dt.d_moy = 11)) +----------------------------------PhysicalOlapScan[date_dim] +--------------------PhysicalProject +----------------------filter((item.i_manufact_id = 816)) +------------------------PhysicalOlapScan[item] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query30.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query30.out new file mode 100644 index 00000000000000..ee3c07d30a2dd4 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query30.out @@ -0,0 +1,43 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_30_constraints -- +PhysicalCteAnchor ( cteId=CTEId#0 ) +--PhysicalCteProducer ( cteId=CTEId#0 ) +----PhysicalProject +------hashAgg[GLOBAL] +--------PhysicalDistribute[DistributionSpecHash] +----------hashAgg[LOCAL] +------------PhysicalProject +--------------hashJoin[INNER_JOIN shuffle] hashCondition=((web_returns.wr_returning_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF1 ca_address_sk->[wr_returning_addr_sk] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_returns.wr_returned_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[wr_returned_date_sk] +--------------------PhysicalProject +----------------------PhysicalOlapScan[web_returns] apply RFs: RF0 RF1 +--------------------PhysicalProject +----------------------filter((date_dim.d_year = 2000)) +------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------PhysicalOlapScan[customer_address] +--PhysicalResultSink +----PhysicalProject +------PhysicalLazyMaterialize[materializedSlots:(customer.c_customer_id,ctr1.ctr_total_return) lazySlots:(customer.c_birth_country,customer.c_birth_day,customer.c_birth_month,customer.c_birth_year,customer.c_email_address,customer.c_first_name,customer.c_last_name,customer.c_last_review_date_sk,customer.c_login,customer.c_preferred_cust_flag,customer.c_salutation)] +--------PhysicalTopN[MERGE_SORT] +----------PhysicalDistribute[DistributionSpecGather] +------------PhysicalTopN[LOCAL_SORT] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((ctr1.ctr_state = ctr2.ctr_state)) otherCondition=((cast(ctr_total_return as DECIMALV3(38, 5)) > (avg(ctr_total_return) * 1.2))) build RFs:RF4 ctr_state->[ctr_state] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer_address.ca_address_sk = customer.c_current_addr_sk)) otherCondition=() build RFs:RF3 ca_address_sk->[c_current_addr_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((ctr1.ctr_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF2 ctr_customer_sk->[c_customer_sk] +--------------------------PhysicalProject +----------------------------PhysicalLazyMaterializeOlapScan[customer lazySlots:(customer.c_birth_month,customer.c_birth_year,customer.c_birth_country,customer.c_login,customer.c_email_address,customer.c_last_review_date_sk,customer.c_salutation,customer.c_first_name,customer.c_last_name,customer.c_preferred_cust_flag,customer.c_birth_day)] apply RFs: RF2 RF3 +--------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 +----------------------PhysicalProject +------------------------filter((customer_address.ca_state = 'AR')) +--------------------------PhysicalOlapScan[customer_address] +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalDistribute[DistributionSpecExecutionAny] +--------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query31.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query31.out new file mode 100644 index 00000000000000..de3af82706c279 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query31.out @@ -0,0 +1,73 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_31_constraints -- +PhysicalCteAnchor ( cteId=CTEId#0 ) +--PhysicalCteProducer ( cteId=CTEId#0 ) +----PhysicalProject +------hashAgg[GLOBAL] +--------PhysicalDistribute[DistributionSpecHash] +----------hashAgg[LOCAL] +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((store_sales.ss_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF1 ca_address_sk->[ss_addr_sk] +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecHash] +--------------------hashAgg[LOCAL] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 +--------------------------PhysicalProject +----------------------------filter((ss.d_year = 1999) and d_qoy IN (1, 2, 3)) +------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------PhysicalOlapScan[customer_address] +--PhysicalCteAnchor ( cteId=CTEId#1 ) +----PhysicalCteProducer ( cteId=CTEId#1 ) +------PhysicalProject +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((web_sales.ws_bill_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF3 ca_address_sk->[ws_bill_addr_sk] +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 +----------------------------PhysicalProject +------------------------------filter((ws.d_year = 1999) and d_qoy IN (1, 2, 3)) +--------------------------------PhysicalOlapScan[date_dim] +------------------PhysicalProject +--------------------PhysicalOlapScan[customer_address] +----PhysicalResultSink +------PhysicalQuickSort[MERGE_SORT] +--------PhysicalDistribute[DistributionSpecGather] +----------PhysicalQuickSort[LOCAL_SORT] +------------PhysicalProject +--------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ws1.ca_county = ws3.ca_county)) otherCondition=((if((web_sales > 0.00), (cast(web_sales as DECIMALV3(38, 8)) / web_sales), NULL) > if((store_sales > 0.00), (cast(store_sales as DECIMALV3(38, 8)) / store_sales), NULL))) build RFs:RF8 ca_county->[ca_county] +----------------PhysicalProject +------------------filter((ws3.d_qoy = 3) and (ws3.d_year = 1999)) +--------------------PhysicalCteConsumer ( cteId=CTEId#1 ) apply RFs: RF8 +----------------PhysicalProject +------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ws1.ca_county = ws2.ca_county)) otherCondition=((if((web_sales > 0.00), (cast(web_sales as DECIMALV3(38, 8)) / web_sales), NULL) > if((store_sales > 0.00), (cast(store_sales as DECIMALV3(38, 8)) / store_sales), NULL))) build RFs:RF7 ca_county->[ca_county] +--------------------PhysicalProject +----------------------filter((ws2.d_qoy = 2) and (ws2.d_year = 1999)) +------------------------PhysicalCteConsumer ( cteId=CTEId#1 ) apply RFs: RF7 +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss1.ca_county = ws1.ca_county)) otherCondition=() build RFs:RF6 ca_county->[ca_county,ca_county] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss2.ca_county = ss3.ca_county)) otherCondition=() build RFs:RF5 ca_county->[ca_county,ca_county] +--------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((ss1.ca_county = ss2.ca_county)) otherCondition=() build RFs:RF4 ca_county->[ca_county] +----------------------------PhysicalProject +------------------------------filter((ss1.d_qoy = 1) and (ss1.d_year = 1999)) +--------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 RF5 RF6 +----------------------------PhysicalProject +------------------------------filter((ss2.d_qoy = 2) and (ss2.d_year = 1999)) +--------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 RF6 +--------------------------PhysicalProject +----------------------------filter((ss3.d_qoy = 3) and (ss3.d_year = 1999)) +------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------PhysicalProject +------------------------filter((ws1.d_qoy = 1) and (ws1.d_year = 1999)) +--------------------------PhysicalCteConsumer ( cteId=CTEId#1 ) + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query32.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query32.out new file mode 100644 index 00000000000000..ef6189bd7c8237 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query32.out @@ -0,0 +1,26 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_32_constraints -- +PhysicalResultSink +--PhysicalLimit[GLOBAL] +----PhysicalLimit[LOCAL] +------hashAgg[GLOBAL] +--------PhysicalDistribute[DistributionSpecGather] +----------hashAgg[LOCAL] +------------PhysicalProject +--------------filter((cast(cs_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(cs_ext_discount_amt) OVER(PARTITION BY i_item_sk)))) +----------------PhysicalWindow +------------------PhysicalQuickSort[LOCAL_SORT] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = catalog_sales.cs_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[cs_item_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 +------------------------------PhysicalProject +--------------------------------filter((item.i_manufact_id = 722)) +----------------------------------PhysicalOlapScan[item] +--------------------------PhysicalProject +----------------------------filter((date_dim.d_date <= '2001-06-07') and (date_dim.d_date >= '2001-03-09')) +------------------------------PhysicalOlapScan[date_dim] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query33.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query33.out new file mode 100644 index 00000000000000..4ff77f043ca595 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query33.out @@ -0,0 +1,83 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_33_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalUnion +----------------PhysicalProject +------------------hashJoin[RIGHT_SEMI_JOIN shuffleBucket] hashCondition=((item.i_manufact_id = item.i_manufact_id)) otherCondition=() build RFs:RF3 i_manufact_id->[i_manufact_id] +--------------------PhysicalProject +----------------------filter((item.i_category = 'Books')) +------------------------PhysicalOlapScan[item] apply RFs: RF3 +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF2 i_item_sk->[ss_item_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF1 ca_address_sk->[ss_addr_sk] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 +--------------------------------------PhysicalProject +----------------------------------------filter((date_dim.d_moy = 3) and (date_dim.d_year = 2001)) +------------------------------------------PhysicalOlapScan[date_dim] +----------------------------------PhysicalProject +------------------------------------filter((customer_address.ca_gmt_offset = -5.00)) +--------------------------------------PhysicalOlapScan[customer_address] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[item] +----------------PhysicalProject +------------------hashJoin[RIGHT_SEMI_JOIN shuffleBucket] hashCondition=((item.i_manufact_id = item.i_manufact_id)) otherCondition=() build RFs:RF7 i_manufact_id->[i_manufact_id] +--------------------PhysicalProject +----------------------filter((item.i_category = 'Books')) +------------------------PhysicalOlapScan[item] apply RFs: RF7 +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF6 i_item_sk->[cs_item_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_bill_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF5 ca_address_sk->[cs_bill_addr_sk] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[cs_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF4 RF5 RF6 +--------------------------------------PhysicalProject +----------------------------------------filter((date_dim.d_moy = 3) and (date_dim.d_year = 2001)) +------------------------------------------PhysicalOlapScan[date_dim] +----------------------------------PhysicalProject +------------------------------------filter((customer_address.ca_gmt_offset = -5.00)) +--------------------------------------PhysicalOlapScan[customer_address] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[item] +----------------PhysicalProject +------------------hashJoin[RIGHT_SEMI_JOIN shuffleBucket] hashCondition=((item.i_manufact_id = item.i_manufact_id)) otherCondition=() build RFs:RF11 i_manufact_id->[i_manufact_id] +--------------------PhysicalProject +----------------------filter((item.i_category = 'Books')) +------------------------PhysicalOlapScan[item] apply RFs: RF11 +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((web_sales.ws_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF10 i_item_sk->[ws_item_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_bill_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF9 ca_address_sk->[ws_bill_addr_sk] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF8 d_date_sk->[ws_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF8 RF9 RF10 +--------------------------------------PhysicalProject +----------------------------------------filter((date_dim.d_moy = 3) and (date_dim.d_year = 2001)) +------------------------------------------PhysicalOlapScan[date_dim] +----------------------------------PhysicalProject +------------------------------------filter((customer_address.ca_gmt_offset = -5.00)) +--------------------------------------PhysicalOlapScan[customer_address] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[item] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query34.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query34.out new file mode 100644 index 00000000000000..fe0a567bd7d3f0 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query34.out @@ -0,0 +1,32 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_34_constraints -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[INNER_JOIN broadcast] hashCondition=((dn.ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 ss_customer_sk->[c_customer_sk] +------------PhysicalProject +--------------PhysicalOlapScan[customer] apply RFs: RF3 +------------filter((dn.cnt <= 20) and (dn.cnt >= 15)) +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk)) otherCondition=() build RFs:RF2 hd_demo_sk->[ss_hdemo_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF0 s_store_sk->[ss_store_sk] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 +--------------------------------PhysicalProject +----------------------------------filter((store.s_county = 'Williamson County')) +------------------------------------PhysicalOlapScan[store] +----------------------------PhysicalProject +------------------------------filter((date_dim.d_dom <= 28) and (date_dim.d_dom >= 1) and OR[(date_dim.d_dom <= 3),(date_dim.d_dom >= 25)] and d_year IN (2000, 2001, 2002)) +--------------------------------PhysicalOlapScan[date_dim] +------------------------PhysicalProject +--------------------------filter(((cast(hd_dep_count as DOUBLE) / cast(hd_vehicle_count as DOUBLE)) > 1.2) and (household_demographics.hd_vehicle_count > 0) and hd_buy_potential IN ('0-500', '1001-5000')) +----------------------------PhysicalOlapScan[household_demographics] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query35.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query35.out new file mode 100644 index 00000000000000..d953db10ed19b0 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query35.out @@ -0,0 +1,47 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_35_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------filter(OR[ifnull($c$1, FALSE),ifnull($c$2, FALSE)]) +--------------------hashJoin[RIGHT_SEMI_JOIN shuffleBucket] hashCondition=((c.c_customer_sk = catalog_sales.cs_ship_customer_sk)) otherCondition=() +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF5 d_date_sk->[cs_sold_date_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF5 +--------------------------PhysicalProject +----------------------------filter((date_dim.d_qoy < 4) and (date_dim.d_year = 1999)) +------------------------------PhysicalOlapScan[date_dim] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer_demographics.cd_demo_sk = c.c_current_cdemo_sk)) otherCondition=() build RFs:RF4 cd_demo_sk->[c_current_cdemo_sk] +--------------------------hashJoin[RIGHT_SEMI_JOIN shuffleBucket] hashCondition=((c.c_customer_sk = web_sales.ws_bill_customer_sk)) otherCondition=() +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF3 d_date_sk->[ws_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[web_sales] apply RFs: RF3 +--------------------------------PhysicalProject +----------------------------------filter((date_dim.d_qoy < 4) and (date_dim.d_year = 1999)) +------------------------------------PhysicalOlapScan[date_dim] +----------------------------hashJoin[RIGHT_SEMI_JOIN shuffle] hashCondition=((c.c_customer_sk = store_sales.ss_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[ss_customer_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF1 RF2 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_qoy < 4) and (date_dim.d_year = 1999)) +--------------------------------------PhysicalOlapScan[date_dim] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((c.c_current_addr_sk = ca.ca_address_sk)) otherCondition=() build RFs:RF0 ca_address_sk->[c_current_addr_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[customer] apply RFs: RF0 RF4 +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[customer_address] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[customer_demographics] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query36.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query36.out new file mode 100644 index 00000000000000..874799d6f83fab --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query36.out @@ -0,0 +1,33 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_36_constraints -- +PhysicalResultSink +--PhysicalProject +----PhysicalTopN[MERGE_SORT] +------PhysicalDistribute[DistributionSpecGather] +--------PhysicalTopN[LOCAL_SORT] +----------PhysicalProject +------------PhysicalWindow +--------------PhysicalQuickSort[LOCAL_SORT] +----------------PhysicalDistribute[DistributionSpecHash] +------------------PhysicalProject +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalRepeat +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = store_sales.ss_item_sk)) otherCondition=() build RFs:RF2 i_item_sk->[ss_item_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((d1.d_date_sk = store_sales.ss_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store.s_store_sk = store_sales.ss_store_sk)) otherCondition=() build RFs:RF0 s_store_sk->[ss_store_sk] +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 +----------------------------------------PhysicalProject +------------------------------------------filter((store.s_state = 'TN')) +--------------------------------------------PhysicalOlapScan[store] +------------------------------------PhysicalProject +--------------------------------------filter((d1.d_year = 2000)) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[item] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query37.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query37.out new file mode 100644 index 00000000000000..82e39c4a2161a7 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query37.out @@ -0,0 +1,31 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_37_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = inventory.inv_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[inv_date_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((inventory.inv_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[inv_item_sk] +----------------------hashAgg[GLOBAL] +------------------------PhysicalProject +--------------------------filter((inventory.inv_quantity_on_hand <= 500) and (inventory.inv_quantity_on_hand >= 100)) +----------------------------PhysicalOlapScan[inventory] apply RFs: RF1 RF2 +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((catalog_sales.cs_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[cs_item_sk] +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 +--------------------------PhysicalProject +----------------------------filter((item.i_current_price <= 59.00) and (item.i_current_price >= 29.00) and i_manufact_id IN (705, 742, 777, 944)) +------------------------------PhysicalOlapScan[item] +------------------PhysicalProject +--------------------filter((date_dim.d_date <= '2002-05-28') and (date_dim.d_date >= '2002-03-29')) +----------------------PhysicalOlapScan[date_dim] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query38.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query38.out new file mode 100644 index 00000000000000..ab1136dd14c85d --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query38.out @@ -0,0 +1,62 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_38_constraints -- +PhysicalResultSink +--PhysicalLimit[GLOBAL] +----PhysicalLimit[LOCAL] +------hashAgg[GLOBAL] +--------PhysicalDistribute[DistributionSpecGather] +----------hashAgg[LOCAL] +------------PhysicalProject +--------------PhysicalIntersect +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecHash] +--------------------hashAgg[LOCAL] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((web_sales.ws_bill_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF1 c_customer_sk->[ws_bill_customer_sk] +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_month_seq <= 1200) and (date_dim.d_month_seq >= 1189)) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[customer] +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecHash] +--------------------hashAgg[LOCAL] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((catalog_sales.cs_bill_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[cs_bill_customer_sk] +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[cs_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF2 RF3 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_month_seq <= 1200) and (date_dim.d_month_seq >= 1189)) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[customer] +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecHash] +--------------------hashAgg[LOCAL] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((store_sales.ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 c_customer_sk->[ss_customer_sk] +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ss_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 RF5 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_month_seq <= 1200) and (date_dim.d_month_seq >= 1189)) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[customer] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query39.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query39.out new file mode 100644 index 00000000000000..06af8423a07546 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query39.out @@ -0,0 +1,31 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_39_constraints -- +PhysicalCteAnchor ( cteId=CTEId#0 ) +--PhysicalCteProducer ( cteId=CTEId#0 ) +----PhysicalProject +------filter(( not (mean = 0.0)) and ((foo.stdev / foo.mean) > 1.0)) +--------hashAgg[GLOBAL] +----------PhysicalProject +------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((inventory.inv_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF2 i_item_sk->[inv_item_sk] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((inventory.inv_warehouse_sk = warehouse.w_warehouse_sk)) otherCondition=() build RFs:RF1 w_warehouse_sk->[inv_warehouse_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((inventory.inv_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[inv_date_sk] +----------------------PhysicalOlapScan[inventory] apply RFs: RF0 RF1 RF2 +----------------------PhysicalProject +------------------------filter((date_dim.d_year = 2000) and d_moy IN (1, 2)) +--------------------------PhysicalOlapScan[date_dim] +------------------PhysicalProject +--------------------PhysicalOlapScan[warehouse] +--------------PhysicalProject +----------------PhysicalOlapScan[item] +--PhysicalResultSink +----PhysicalQuickSort[MERGE_SORT] +------PhysicalDistribute[DistributionSpecGather] +--------PhysicalQuickSort[LOCAL_SORT] +----------hashJoin[INNER_JOIN shuffle] hashCondition=((inv1.i_item_sk = inv2.i_item_sk) and (inv1.w_warehouse_sk = inv2.w_warehouse_sk)) otherCondition=() build RFs:RF3 i_item_sk->[i_item_sk];RF4 w_warehouse_sk->[w_warehouse_sk] +------------filter((inv1.d_moy = 1)) +--------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF3 RF4 +------------filter((inv2.d_moy = 2)) +--------------PhysicalCteConsumer ( cteId=CTEId#0 ) + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query4.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query4.out new file mode 100644 index 00000000000000..027065903c59f4 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query4.out @@ -0,0 +1,74 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_4_constraints -- +PhysicalCteAnchor ( cteId=CTEId#0 ) +--PhysicalCteProducer ( cteId=CTEId#0 ) +----PhysicalProject +------hashJoin[INNER_JOIN shuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[cs_bill_customer_sk,ss_customer_sk,ws_bill_customer_sk] +--------PhysicalUnion +----------PhysicalProject +------------hashAgg[GLOBAL] +--------------PhysicalDistribute[DistributionSpecHash] +----------------hashAgg[LOCAL] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF3 +----------------------PhysicalProject +------------------------filter(d_year IN (1999, 2000)) +--------------------------PhysicalOlapScan[date_dim] +----------PhysicalProject +------------hashAgg[GLOBAL] +--------------PhysicalDistribute[DistributionSpecHash] +----------------hashAgg[LOCAL] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF1 RF3 +----------------------PhysicalProject +------------------------filter(d_year IN (1999, 2000)) +--------------------------PhysicalOlapScan[date_dim] +----------PhysicalProject +------------hashAgg[GLOBAL] +--------------PhysicalDistribute[DistributionSpecHash] +----------------hashAgg[LOCAL] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 +----------------------PhysicalProject +------------------------filter(d_year IN (1999, 2000)) +--------------------------PhysicalOlapScan[date_dim] +--------PhysicalProject +----------PhysicalOlapScan[customer] +--PhysicalResultSink +----PhysicalTopN[MERGE_SORT] +------PhysicalDistribute[DistributionSpecGather] +--------PhysicalTopN[LOCAL_SORT] +----------PhysicalProject +------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF8 customer_id->[customer_id] +--------------PhysicalProject +----------------filter((t_w_secyear.dyear = 2000) and (t_w_secyear.sale_type = 'w')) +------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF8 +--------------PhysicalProject +----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF7 customer_id->[customer_id,customer_id,customer_id,customer_id] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_c_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF6 customer_id->[customer_id] +----------------------PhysicalProject +------------------------filter((t_c_secyear.dyear = 2000) and (t_c_secyear.sale_type = 'c')) +--------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF6 RF7 +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_c_firstyear.customer_id)) otherCondition=() build RFs:RF5 customer_id->[customer_id,customer_id] +--------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id] +----------------------------PhysicalProject +------------------------------filter((t_s_secyear.dyear = 2000) and (t_s_secyear.sale_type = 's')) +--------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 RF5 RF7 +----------------------------PhysicalProject +------------------------------filter((t_s_firstyear.dyear = 1999) and (t_s_firstyear.sale_type = 's') and (t_s_firstyear.year_total > 0.000000)) +--------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 RF7 +--------------------------PhysicalProject +----------------------------filter((t_c_firstyear.dyear = 1999) and (t_c_firstyear.sale_type = 'c') and (t_c_firstyear.year_total > 0.000000)) +------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF7 +------------------PhysicalProject +--------------------filter((t_w_firstyear.dyear = 1999) and (t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year_total > 0.000000)) +----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query40.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query40.out new file mode 100644 index 00000000000000..15a85d5ffb8c78 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query40.out @@ -0,0 +1,30 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_40_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[RIGHT_OUTER_JOIN shuffle] hashCondition=((catalog_sales.cs_item_sk = catalog_returns.cr_item_sk) and (catalog_sales.cs_order_number = catalog_returns.cr_order_number)) otherCondition=() build RFs:RF3 cs_order_number->[cr_order_number];RF4 cs_item_sk->[cr_item_sk] +------------------PhysicalProject +--------------------PhysicalOlapScan[catalog_returns] apply RFs: RF3 RF4 +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_warehouse_sk = warehouse.w_warehouse_sk)) otherCondition=() build RFs:RF2 w_warehouse_sk->[cs_warehouse_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = catalog_sales.cs_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[cs_item_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 RF2 +------------------------------PhysicalProject +--------------------------------filter((item.i_current_price <= 1.49) and (item.i_current_price >= 0.99)) +----------------------------------PhysicalOlapScan[item] +--------------------------PhysicalProject +----------------------------filter((date_dim.d_date <= '2001-06-01') and (date_dim.d_date >= '2001-04-02')) +------------------------------PhysicalOlapScan[date_dim] +----------------------PhysicalProject +------------------------PhysicalOlapScan[warehouse] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query41.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query41.out new file mode 100644 index 00000000000000..70c883cb7bcc6e --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query41.out @@ -0,0 +1,23 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_41_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_manufact = i1.i_manufact)) otherCondition=() build RFs:RF0 i_manufact->[i_manufact] +------------------PhysicalProject +--------------------filter((i1.i_manufact_id <= 744) and (i1.i_manufact_id >= 704)) +----------------------PhysicalOlapScan[item] apply RFs: RF0 +------------------PhysicalProject +--------------------filter((item_cnt > 0)) +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------filter(OR[AND[(item.i_category = 'Men'),i_size IN ('N/A', 'economy', 'large', 'small'),OR[AND[i_size IN ('economy', 'small'),i_color IN ('firebrick', 'maroon', 'sienna', 'smoke'),i_units IN ('Case', 'Cup', 'Each', 'Ounce'),OR[AND[i_color IN ('maroon', 'smoke'),i_units IN ('Case', 'Ounce')],AND[i_color IN ('firebrick', 'sienna'),i_units IN ('Cup', 'Each')]]],AND[i_size IN ('N/A', 'large'),i_color IN ('papaya', 'peach', 'powder', 'sky'),i_units IN ('Bundle', 'Carton', 'Dozen', 'Lb'),OR[AND[i_color IN ('powder', 'sky'),i_units IN ('Dozen', 'Lb')],AND[i_color IN ('papaya', 'peach'),i_units IN ('Bundle', 'Carton')]]]]],AND[(item.i_category = 'Women'),i_size IN ('economy', 'extra large', 'petite', 'small'),OR[AND[i_size IN ('economy', 'small'),i_color IN ('aquamarine', 'dark', 'forest', 'lime'),i_units IN ('Pallet', 'Pound', 'Tbl', 'Ton'),OR[AND[i_color IN ('forest', 'lime'),i_units IN ('Pallet', 'Pound')],AND[i_color IN ('aquamarine', 'dark'),i_units IN ('Tbl', 'Ton')]]],AND[i_size IN ('extra large', 'petite'),i_color IN ('frosted', 'navy', 'plum', 'slate'),i_units IN ('Box', 'Bunch', 'Dram', 'Gross'),OR[AND[i_color IN ('navy', 'slate'),i_units IN ('Bunch', 'Gross')],AND[i_color IN ('frosted', 'plum'),i_units IN ('Box', 'Dram')]]]]]] and i_category IN ('Men', 'Women')) +--------------------------------PhysicalOlapScan[item] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query42.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query42.out new file mode 100644 index 00000000000000..24226364383fed --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query42.out @@ -0,0 +1,26 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_42_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[ss_item_sk] +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((dt.d_date_sk = store_sales.ss_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 +------------------------------PhysicalProject +--------------------------------filter((dt.d_moy = 11) and (dt.d_year = 1998)) +----------------------------------PhysicalOlapScan[date_dim] +--------------------PhysicalProject +----------------------filter((item.i_manager_id = 1)) +------------------------PhysicalOlapScan[item] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query43.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query43.out new file mode 100644 index 00000000000000..49114ccddc2d56 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query43.out @@ -0,0 +1,25 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_43_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((store.s_store_sk = store_sales.ss_store_sk)) otherCondition=() build RFs:RF1 s_store_sk->[ss_store_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((date_dim.d_date_sk = store_sales.ss_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 +----------------------PhysicalProject +------------------------filter((date_dim.d_year = 2000)) +--------------------------PhysicalOlapScan[date_dim] +------------------PhysicalProject +--------------------filter((store.s_gmt_offset = -5.00)) +----------------------PhysicalOlapScan[store] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query44.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query44.out new file mode 100644 index 00000000000000..f14c3f32e7c06f --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query44.out @@ -0,0 +1,71 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_44_constraints -- +PhysicalResultSink +--PhysicalProject +----PhysicalLazyMaterialize[materializedSlots:(asceding.rnk) lazySlots:(best_performing,worst_performing)] +------PhysicalTopN[MERGE_SORT] +--------PhysicalDistribute[DistributionSpecGather] +----------PhysicalTopN[LOCAL_SORT] +------------PhysicalProject +--------------hashJoin[INNER_JOIN broadcast] hashCondition=((asceding.rnk = descending.rnk)) otherCondition=() +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((i2.i_item_sk = descending.item_sk)) otherCondition=() build RFs:RF1 item_sk->[i_item_sk] +--------------------PhysicalProject +----------------------PhysicalLazyMaterializeOlapScan[item lazySlots:(i2.i_product_name)] apply RFs: RF1 +--------------------PhysicalProject +----------------------filter((V21.rnk < 11)) +------------------------PhysicalWindow +--------------------------PhysicalQuickSort[MERGE_SORT] +----------------------------PhysicalDistribute[DistributionSpecGather] +------------------------------PhysicalQuickSort[LOCAL_SORT] +--------------------------------PhysicalPartitionTopN +----------------------------------PhysicalProject +------------------------------------NestedLoopJoin[INNER_JOIN](cast(rank_col as DECIMALV3(38, 5)) > (0.9 * rank_col)) +--------------------------------------PhysicalProject +----------------------------------------hashAgg[GLOBAL] +------------------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------------------hashAgg[LOCAL] +----------------------------------------------PhysicalProject +------------------------------------------------filter((ss1.ss_store_sk = 4)) +--------------------------------------------------PhysicalOlapScan[store_sales] +--------------------------------------PhysicalProject +----------------------------------------PhysicalAssertNumRows +------------------------------------------PhysicalDistribute[DistributionSpecGather] +--------------------------------------------PhysicalProject +----------------------------------------------hashAgg[GLOBAL] +------------------------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------------------------hashAgg[LOCAL] +----------------------------------------------------PhysicalProject +------------------------------------------------------filter((store_sales.ss_store_sk = 4) and ss_hdemo_sk IS NULL) +--------------------------------------------------------PhysicalOlapScan[store_sales] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((i1.i_item_sk = asceding.item_sk)) otherCondition=() build RFs:RF0 item_sk->[i_item_sk] +--------------------PhysicalProject +----------------------PhysicalLazyMaterializeOlapScan[item lazySlots:(i1.i_product_name)] apply RFs: RF0 +--------------------PhysicalProject +----------------------filter((V11.rnk < 11)) +------------------------PhysicalWindow +--------------------------PhysicalQuickSort[MERGE_SORT] +----------------------------PhysicalDistribute[DistributionSpecGather] +------------------------------PhysicalQuickSort[LOCAL_SORT] +--------------------------------PhysicalPartitionTopN +----------------------------------PhysicalProject +------------------------------------NestedLoopJoin[INNER_JOIN](cast(rank_col as DECIMALV3(38, 5)) > (0.9 * rank_col)) +--------------------------------------PhysicalProject +----------------------------------------hashAgg[GLOBAL] +------------------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------------------hashAgg[LOCAL] +----------------------------------------------PhysicalProject +------------------------------------------------filter((ss1.ss_store_sk = 4)) +--------------------------------------------------PhysicalOlapScan[store_sales] +--------------------------------------PhysicalProject +----------------------------------------PhysicalAssertNumRows +------------------------------------------PhysicalDistribute[DistributionSpecGather] +--------------------------------------------PhysicalProject +----------------------------------------------hashAgg[GLOBAL] +------------------------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------------------------hashAgg[LOCAL] +----------------------------------------------------PhysicalProject +------------------------------------------------------filter((store_sales.ss_store_sk = 4) and ss_hdemo_sk IS NULL) +--------------------------------------------------------PhysicalOlapScan[store_sales] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query45.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query45.out new file mode 100644 index 00000000000000..1fc8145c502153 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query45.out @@ -0,0 +1,35 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_45_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------filter(OR[substring(ca_zip, 1, 5) IN ('80348', '81792', '83405', '85392', '85460', '85669', '86197', '86475', '88274'),$c$1]) +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF3 i_item_sk->[ws_item_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN shuffle] hashCondition=((web_sales.ws_bill_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[ws_bill_customer_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 RF2 RF3 +----------------------------PhysicalProject +------------------------------filter((date_dim.d_qoy = 1) and (date_dim.d_year = 2000)) +--------------------------------PhysicalOlapScan[date_dim] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_current_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF0 ca_address_sk->[c_current_addr_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[customer] apply RFs: RF0 +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[customer_address] +--------------------PhysicalProject +----------------------hashJoin[LEFT_SEMI_JOIN broadcast] hashCondition=((item.i_item_id = item.i_item_id)) otherCondition=() +------------------------PhysicalProject +--------------------------PhysicalOlapScan[item] +------------------------PhysicalProject +--------------------------filter(i_item_sk IN (11, 13, 17, 19, 2, 23, 29, 3, 5, 7)) +----------------------------PhysicalOlapScan[item] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query46.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query46.out new file mode 100644 index 00000000000000..6270892cfdaac9 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query46.out @@ -0,0 +1,38 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_46_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_current_addr_sk = current_addr.ca_address_sk)) otherCondition=(( not (ca_city = bought_city))) build RFs:RF5 ca_address_sk->[c_current_addr_sk] +------------PhysicalProject +--------------hashJoin[INNER_JOIN shuffle] hashCondition=((dn.ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF4 ss_customer_sk->[c_customer_sk] +----------------PhysicalProject +------------------PhysicalOlapScan[customer] apply RFs: RF4 RF5 +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN shuffle] hashCondition=((store_sales.ss_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF3 ca_address_sk->[ss_addr_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk)) otherCondition=() build RFs:RF2 hd_demo_sk->[ss_hdemo_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF0 s_store_sk->[ss_store_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 RF3 +------------------------------------PhysicalProject +--------------------------------------filter(s_city IN ('Fairview', 'Midway')) +----------------------------------------PhysicalOlapScan[store] +--------------------------------PhysicalProject +----------------------------------filter(d_dow IN (0, 6) and d_year IN (2000, 2001, 2002)) +------------------------------------PhysicalOlapScan[date_dim] +----------------------------PhysicalProject +------------------------------filter(OR[(household_demographics.hd_dep_count = 8),(household_demographics.hd_vehicle_count = 0)]) +--------------------------------PhysicalOlapScan[household_demographics] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[customer_address] +------------PhysicalProject +--------------PhysicalOlapScan[customer_address] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query47.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query47.out new file mode 100644 index 00000000000000..081714235f8625 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query47.out @@ -0,0 +1,43 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_47_constraints -- +PhysicalCteAnchor ( cteId=CTEId#0 ) +--PhysicalCteProducer ( cteId=CTEId#0 ) +----PhysicalProject +------PhysicalWindow +--------PhysicalQuickSort[LOCAL_SORT] +----------PhysicalWindow +------------PhysicalQuickSort[LOCAL_SORT] +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF2 i_item_sk->[ss_item_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF1 s_store_sk->[ss_store_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 +--------------------------------PhysicalProject +----------------------------------filter(OR[(date_dim.d_year = 2000),AND[(date_dim.d_year = 1999),(date_dim.d_moy = 12)],AND[(date_dim.d_year = 2001),(date_dim.d_moy = 1)]] and d_year IN (1999, 2000, 2001)) +------------------------------------PhysicalOlapScan[date_dim] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[store] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[item] +--PhysicalResultSink +----PhysicalProject +------PhysicalTopN[MERGE_SORT] +--------PhysicalDistribute[DistributionSpecGather] +----------PhysicalTopN[LOCAL_SORT] +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((v1.i_brand = v1_lead.i_brand) and (v1.i_category = v1_lead.i_category) and (v1.rn = expr_(rn - 1)) and (v1.s_company_name = v1_lead.s_company_name) and (v1.s_store_name = v1_lead.s_store_name)) otherCondition=() build RFs:RF8 i_category->[i_category,i_category];RF9 i_brand->[i_brand,i_brand];RF10 s_store_name->[s_store_name,s_store_name];RF11 s_company_name->[s_company_name,s_company_name];RF12 expr_(rn - 1)->[(rn + 1),rn] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN shuffle] hashCondition=((v1.i_brand = v1_lag.i_brand) and (v1.i_category = v1_lag.i_category) and (v1.rn = expr_(rn + 1)) and (v1.s_company_name = v1_lag.s_company_name) and (v1.s_store_name = v1_lag.s_store_name)) otherCondition=() build RFs:RF3 i_category->[i_category];RF4 i_brand->[i_brand];RF5 s_store_name->[s_store_name];RF6 s_company_name->[s_company_name];RF7 rn->[(rn + 1)] +--------------------PhysicalProject +----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF3 RF4 RF5 RF6 RF7 RF8 RF9 RF10 RF11 RF12 +--------------------filter(((cast(abs((sum_sales - cast(avg_monthly_sales as DECIMALV3(38, 2)))) as DECIMALV3(38, 10)) / v2.avg_monthly_sales) > 0.100000) and (v2.avg_monthly_sales > 0.0000) and (v2.d_year = 2000)) +----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF8 RF9 RF10 RF11 RF12 +----------------PhysicalProject +------------------PhysicalCteConsumer ( cteId=CTEId#0 ) + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query48.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query48.out new file mode 100644 index 00000000000000..a495ca7b9ad844 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query48.out @@ -0,0 +1,29 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_48_constraints -- +PhysicalResultSink +--hashAgg[GLOBAL] +----PhysicalDistribute[DistributionSpecGather] +------hashAgg[LOCAL] +--------PhysicalProject +----------hashJoin[INNER_JOIN broadcast] hashCondition=((store.s_store_sk = store_sales.ss_store_sk)) otherCondition=() build RFs:RF3 s_store_sk->[ss_store_sk] +------------PhysicalProject +--------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ss_sold_date_sk] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_addr_sk = customer_address.ca_address_sk)) otherCondition=(OR[AND[ca_state IN ('ND', 'NY', 'SD'),(store_sales.ss_net_profit <= 2000.00)],AND[ca_state IN ('GA', 'KS', 'MD'),(store_sales.ss_net_profit >= 150.00),(store_sales.ss_net_profit <= 3000.00)],AND[ca_state IN ('CO', 'MN', 'NC'),(store_sales.ss_net_profit >= 50.00)]]) build RFs:RF1 ca_address_sk->[ss_addr_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer_demographics.cd_demo_sk = store_sales.ss_cdemo_sk)) otherCondition=(OR[AND[(customer_demographics.cd_marital_status = 'S'),(customer_demographics.cd_education_status = 'Secondary'),(store_sales.ss_sales_price >= 100.00),(store_sales.ss_sales_price <= 150.00)],AND[(customer_demographics.cd_marital_status = 'M'),(customer_demographics.cd_education_status = '2 yr Degree'),(store_sales.ss_sales_price <= 100.00)],AND[(customer_demographics.cd_marital_status = 'D'),(customer_demographics.cd_education_status = 'Advanced Degree'),(store_sales.ss_sales_price >= 150.00)]]) build RFs:RF0 cd_demo_sk->[ss_cdemo_sk] +------------------------PhysicalProject +--------------------------filter((store_sales.ss_net_profit <= 25000.00) and (store_sales.ss_net_profit >= 0.00) and (store_sales.ss_sales_price <= 200.00) and (store_sales.ss_sales_price >= 50.00)) +----------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 RF3 +------------------------PhysicalProject +--------------------------filter(OR[AND[(customer_demographics.cd_marital_status = 'S'),(customer_demographics.cd_education_status = 'Secondary')],AND[(customer_demographics.cd_marital_status = 'M'),(customer_demographics.cd_education_status = '2 yr Degree')],AND[(customer_demographics.cd_marital_status = 'D'),(customer_demographics.cd_education_status = 'Advanced Degree')]] and cd_education_status IN ('2 yr Degree', 'Advanced Degree', 'Secondary') and cd_marital_status IN ('D', 'M', 'S')) +----------------------------PhysicalOlapScan[customer_demographics] +--------------------PhysicalProject +----------------------filter((customer_address.ca_country = 'United States') and ca_state IN ('CO', 'GA', 'KS', 'MD', 'MN', 'NC', 'ND', 'NY', 'SD')) +------------------------PhysicalOlapScan[customer_address] +----------------PhysicalProject +------------------filter((date_dim.d_year = 2001)) +--------------------PhysicalOlapScan[date_dim] +------------PhysicalProject +--------------PhysicalOlapScan[store] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query49.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query49.out new file mode 100644 index 00000000000000..e728fe89959d73 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query49.out @@ -0,0 +1,107 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_49_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalUnion +----------------PhysicalDistribute[DistributionSpecExecutionAny] +------------------PhysicalTopN[MERGE_SORT] +--------------------PhysicalDistribute[DistributionSpecGather] +----------------------PhysicalTopN[LOCAL_SORT] +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------filter(OR[(web.return_rank <= 10),(web.currency_rank <= 10)]) +----------------------------------PhysicalWindow +------------------------------------PhysicalQuickSort[LOCAL_SORT] +--------------------------------------PhysicalWindow +----------------------------------------PhysicalQuickSort[MERGE_SORT] +------------------------------------------PhysicalDistribute[DistributionSpecGather] +--------------------------------------------PhysicalQuickSort[LOCAL_SORT] +----------------------------------------------PhysicalProject +------------------------------------------------hashAgg[GLOBAL] +--------------------------------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------------------------------hashAgg[LOCAL] +------------------------------------------------------PhysicalProject +--------------------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((ws.ws_item_sk = wr.wr_item_sk) and (ws.ws_order_number = wr.wr_order_number)) otherCondition=() build RFs:RF1 ws_order_number->[wr_order_number];RF2 ws_item_sk->[wr_item_sk] +----------------------------------------------------------PhysicalProject +------------------------------------------------------------filter((wr.wr_return_amt > 10000.00)) +--------------------------------------------------------------PhysicalOlapScan[web_returns] apply RFs: RF1 RF2 +----------------------------------------------------------PhysicalProject +------------------------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((ws.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +--------------------------------------------------------------PhysicalProject +----------------------------------------------------------------filter((ws.ws_net_paid > 0.00) and (ws.ws_net_profit > 1.00) and (ws.ws_quantity > 0)) +------------------------------------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 +--------------------------------------------------------------PhysicalProject +----------------------------------------------------------------filter((date_dim.d_moy = 11) and (date_dim.d_year = 1998)) +------------------------------------------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalDistribute[DistributionSpecExecutionAny] +------------------PhysicalTopN[MERGE_SORT] +--------------------PhysicalDistribute[DistributionSpecGather] +----------------------PhysicalTopN[LOCAL_SORT] +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------filter(OR[(catalog.return_rank <= 10),(catalog.currency_rank <= 10)]) +----------------------------------PhysicalWindow +------------------------------------PhysicalQuickSort[LOCAL_SORT] +--------------------------------------PhysicalWindow +----------------------------------------PhysicalQuickSort[MERGE_SORT] +------------------------------------------PhysicalDistribute[DistributionSpecGather] +--------------------------------------------PhysicalQuickSort[LOCAL_SORT] +----------------------------------------------PhysicalProject +------------------------------------------------hashAgg[GLOBAL] +--------------------------------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------------------------------hashAgg[LOCAL] +------------------------------------------------------PhysicalProject +--------------------------------------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((cs.cs_item_sk = cr.cr_item_sk) and (cs.cs_order_number = cr.cr_order_number)) otherCondition=() build RFs:RF4 cs_order_number->[cr_order_number];RF5 cs_item_sk->[cr_item_sk] +----------------------------------------------------------PhysicalProject +------------------------------------------------------------filter((cr.cr_return_amount > 10000.00)) +--------------------------------------------------------------PhysicalOlapScan[catalog_returns] apply RFs: RF4 RF5 +----------------------------------------------------------PhysicalProject +------------------------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((cs.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF3 d_date_sk->[cs_sold_date_sk] +--------------------------------------------------------------PhysicalProject +----------------------------------------------------------------filter((cs.cs_net_paid > 0.00) and (cs.cs_net_profit > 1.00) and (cs.cs_quantity > 0)) +------------------------------------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF3 +--------------------------------------------------------------PhysicalProject +----------------------------------------------------------------filter((date_dim.d_moy = 11) and (date_dim.d_year = 1998)) +------------------------------------------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalDistribute[DistributionSpecExecutionAny] +------------------PhysicalTopN[MERGE_SORT] +--------------------PhysicalDistribute[DistributionSpecGather] +----------------------PhysicalTopN[LOCAL_SORT] +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------filter(OR[(store.return_rank <= 10),(store.currency_rank <= 10)]) +----------------------------------PhysicalWindow +------------------------------------PhysicalQuickSort[LOCAL_SORT] +--------------------------------------PhysicalWindow +----------------------------------------PhysicalQuickSort[MERGE_SORT] +------------------------------------------PhysicalDistribute[DistributionSpecGather] +--------------------------------------------PhysicalQuickSort[LOCAL_SORT] +----------------------------------------------PhysicalProject +------------------------------------------------hashAgg[GLOBAL] +--------------------------------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------------------------------hashAgg[LOCAL] +------------------------------------------------------PhysicalProject +--------------------------------------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((sts.ss_item_sk = sr.sr_item_sk) and (sts.ss_ticket_number = sr.sr_ticket_number)) otherCondition=() build RFs:RF7 ss_ticket_number->[sr_ticket_number];RF8 ss_item_sk->[sr_item_sk] +----------------------------------------------------------PhysicalProject +------------------------------------------------------------filter((sr.sr_return_amt > 10000.00)) +--------------------------------------------------------------PhysicalOlapScan[store_returns] apply RFs: RF7 RF8 +----------------------------------------------------------PhysicalProject +------------------------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((sts.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF6 d_date_sk->[ss_sold_date_sk] +--------------------------------------------------------------PhysicalProject +----------------------------------------------------------------filter((sts.ss_net_paid > 0.00) and (sts.ss_net_profit > 1.00) and (sts.ss_quantity > 0)) +------------------------------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF6 +--------------------------------------------------------------PhysicalProject +----------------------------------------------------------------filter((date_dim.d_moy = 11) and (date_dim.d_year = 1998)) +------------------------------------------------------------------PhysicalOlapScan[date_dim] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query5.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query5.out new file mode 100644 index 00000000000000..c3b9fbc4bdc9f1 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query5.out @@ -0,0 +1,85 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_5_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalRepeat +------------------PhysicalUnion +--------------------PhysicalProject +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((salesreturns.store_sk = store.s_store_sk)) otherCondition=() build RFs:RF1 s_store_sk->[sr_store_sk,ss_store_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((salesreturns.date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[sr_returned_date_sk,ss_sold_date_sk] +------------------------------------PhysicalUnion +--------------------------------------hashAgg[GLOBAL] +----------------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------------hashAgg[LOCAL] +--------------------------------------------PhysicalProject +----------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 +--------------------------------------hashAgg[GLOBAL] +----------------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------------hashAgg[LOCAL] +--------------------------------------------PhysicalProject +----------------------------------------------PhysicalOlapScan[store_returns] apply RFs: RF0 RF1 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_date <= '2000-09-02') and (date_dim.d_date >= '2000-08-19')) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[store] +--------------------PhysicalProject +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((salesreturns.page_sk = catalog_page.cp_catalog_page_sk)) otherCondition=() build RFs:RF3 cp_catalog_page_sk->[cr_catalog_page_sk,cs_catalog_page_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((salesreturns.date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[cr_returned_date_sk,cs_sold_date_sk] +------------------------------------PhysicalUnion +--------------------------------------hashAgg[GLOBAL] +----------------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------------hashAgg[LOCAL] +--------------------------------------------PhysicalProject +----------------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF2 RF3 +--------------------------------------hashAgg[GLOBAL] +----------------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------------hashAgg[LOCAL] +--------------------------------------------PhysicalProject +----------------------------------------------PhysicalOlapScan[catalog_returns] apply RFs: RF2 RF3 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_date <= '2000-09-02') and (date_dim.d_date >= '2000-08-19')) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[catalog_page] +--------------------PhysicalProject +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((salesreturns.wsr_web_site_sk = web_site.web_site_sk)) otherCondition=() build RFs:RF7 web_site_sk->[ws_web_site_sk,ws_web_site_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((salesreturns.date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF6 d_date_sk->[wr_returned_date_sk,ws_sold_date_sk] +------------------------------------PhysicalUnion +--------------------------------------PhysicalDistribute[DistributionSpecExecutionAny] +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF6 RF7 +--------------------------------------PhysicalDistribute[DistributionSpecExecutionAny] +----------------------------------------PhysicalProject +------------------------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((web_returns.wr_item_sk = web_sales.ws_item_sk) and (web_returns.wr_order_number = web_sales.ws_order_number)) otherCondition=() build RFs:RF4 wr_item_sk->[ws_item_sk];RF5 wr_order_number->[ws_order_number] +--------------------------------------------PhysicalProject +----------------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF4 RF5 RF7 +--------------------------------------------PhysicalProject +----------------------------------------------PhysicalOlapScan[web_returns] apply RFs: RF6 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_date <= '2000-09-02') and (date_dim.d_date >= '2000-08-19')) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[web_site] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query50.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query50.out new file mode 100644 index 00000000000000..ba3c7a3499e250 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query50.out @@ -0,0 +1,29 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_50_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF5 s_store_sk->[ss_store_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = d1.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ss_sold_date_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((store_sales.ss_customer_sk = store_returns.sr_customer_sk) and (store_sales.ss_item_sk = store_returns.sr_item_sk) and (store_sales.ss_ticket_number = store_returns.sr_ticket_number)) otherCondition=() build RFs:RF1 sr_ticket_number->[ss_ticket_number];RF2 sr_item_sk->[ss_item_sk];RF3 sr_customer_sk->[ss_customer_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[store_sales] apply RFs: RF1 RF2 RF3 RF4 RF5 +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_returns.sr_returned_date_sk = d2.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[sr_returned_date_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[store_returns] apply RFs: RF0 +------------------------------PhysicalProject +--------------------------------filter((d2.d_moy = 8) and (d2.d_year = 2001)) +----------------------------------PhysicalOlapScan[date_dim] +----------------------PhysicalProject +------------------------PhysicalOlapScan[date_dim] +------------------PhysicalProject +--------------------PhysicalOlapScan[store] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query51.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query51.out new file mode 100644 index 00000000000000..ae5582b0e306a1 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query51.out @@ -0,0 +1,40 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_51_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------filter((y.web_cumulative > y.store_cumulative)) +------------PhysicalWindow +--------------PhysicalQuickSort[LOCAL_SORT] +----------------PhysicalDistribute[DistributionSpecHash] +------------------PhysicalProject +--------------------hashJoin[FULL_OUTER_JOIN colocated] hashCondition=((web.d_date = store.d_date) and (web.item_sk = store.item_sk)) otherCondition=() +----------------------PhysicalProject +------------------------PhysicalWindow +--------------------------PhysicalQuickSort[LOCAL_SORT] +----------------------------hashAgg[GLOBAL] +------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------hashAgg[LOCAL] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 +--------------------------------------PhysicalProject +----------------------------------------filter((date_dim.d_month_seq <= 1223) and (date_dim.d_month_seq >= 1212)) +------------------------------------------PhysicalOlapScan[date_dim] +----------------------PhysicalProject +------------------------PhysicalWindow +--------------------------PhysicalQuickSort[LOCAL_SORT] +----------------------------hashAgg[GLOBAL] +------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------hashAgg[LOCAL] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 +--------------------------------------PhysicalProject +----------------------------------------filter((date_dim.d_month_seq <= 1223) and (date_dim.d_month_seq >= 1212)) +------------------------------------------PhysicalOlapScan[date_dim] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query52.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query52.out new file mode 100644 index 00000000000000..d5400483d01e63 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query52.out @@ -0,0 +1,26 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_52_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[ss_item_sk] +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((dt.d_date_sk = store_sales.ss_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 +------------------------------PhysicalProject +--------------------------------filter((dt.d_moy = 12) and (dt.d_year = 2000)) +----------------------------------PhysicalOlapScan[date_dim] +--------------------PhysicalProject +----------------------filter((item.i_manager_id = 1)) +------------------------PhysicalOlapScan[item] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query53.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query53.out new file mode 100644 index 00000000000000..4b75543adad72f --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query53.out @@ -0,0 +1,31 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_53_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------filter(((cast(abs((sum_sales - cast(avg_quarterly_sales as DECIMALV3(38, 2)))) as DECIMALV3(38, 10)) / tmp1.avg_quarterly_sales) > 0.100000) and (tmp1.avg_quarterly_sales > 0.0000)) +----------PhysicalWindow +------------PhysicalQuickSort[LOCAL_SORT] +--------------PhysicalDistribute[DistributionSpecHash] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF2 s_store_sk->[ss_store_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[ss_item_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 +------------------------------------PhysicalProject +--------------------------------------filter(OR[AND[i_category IN ('Books', 'Children', 'Electronics'),i_class IN ('personal', 'portable', 'reference', 'self-help'),i_brand IN ('exportiunivamalg #9', 'scholaramalgamalg #14', 'scholaramalgamalg #7', 'scholaramalgamalg #9')],AND[i_category IN ('Men', 'Music', 'Women'),i_class IN ('accessories', 'classical', 'fragrances', 'pants'),i_brand IN ('amalgimporto #1', 'edu packscholar #1', 'exportiimporto #1', 'importoamalg #1')]] and i_brand IN ('amalgimporto #1', 'edu packscholar #1', 'exportiimporto #1', 'exportiunivamalg #9', 'importoamalg #1', 'scholaramalgamalg #14', 'scholaramalgamalg #7', 'scholaramalgamalg #9') and i_category IN ('Books', 'Children', 'Electronics', 'Men', 'Music', 'Women') and i_class IN ('accessories', 'classical', 'fragrances', 'pants', 'personal', 'portable', 'reference', 'self-help')) +----------------------------------------PhysicalOlapScan[item] +--------------------------------PhysicalProject +----------------------------------filter(d_month_seq IN (1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197)) +------------------------------------PhysicalOlapScan[date_dim] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[store] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query54.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query54.out new file mode 100644 index 00000000000000..65a0c29e5ab7f5 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query54.out @@ -0,0 +1,74 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_54_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF16 d_date_sk->[ss_sold_date_sk];RF17 d_date_sk->[ss_sold_date_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((my_customers.c_customer_sk = store_sales.ss_customer_sk)) otherCondition=() build RFs:RF14 c_customer_sk->[ss_customer_sk];RF15 c_customer_sk->[ss_customer_sk] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[store_sales] apply RFs: RF14 RF15 RF16 RF17 +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer_address.ca_county = store.s_county) and (customer_address.ca_state = store.s_state)) otherCondition=() build RFs:RF10 s_county->[ca_county];RF11 s_county->[ca_county];RF12 s_state->[ca_state];RF13 s_state->[ca_state] +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((my_customers.c_current_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF8 c_current_addr_sk->[ca_address_sk];RF9 c_current_addr_sk->[ca_address_sk] +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[customer_address] apply RFs: RF8 RF9 RF10 RF11 RF12 RF13 +----------------------------------------PhysicalProject +------------------------------------------hashAgg[GLOBAL] +--------------------------------------------PhysicalProject +----------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer.c_customer_sk = cs_or_ws_sales.customer_sk)) otherCondition=() build RFs:RF6 customer_sk->[c_customer_sk];RF7 customer_sk->[c_customer_sk] +------------------------------------------------PhysicalProject +--------------------------------------------------PhysicalOlapScan[customer] apply RFs: RF6 RF7 +------------------------------------------------PhysicalProject +--------------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((cs_or_ws_sales.sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[cs_sold_date_sk,ws_sold_date_sk];RF5 d_date_sk->[cs_sold_date_sk,ws_sold_date_sk] +----------------------------------------------------PhysicalProject +------------------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((cs_or_ws_sales.item_sk = item.i_item_sk)) otherCondition=() build RFs:RF2 i_item_sk->[cs_item_sk,ws_item_sk];RF3 i_item_sk->[cs_item_sk,ws_item_sk] +--------------------------------------------------------PhysicalUnion +----------------------------------------------------------PhysicalDistribute[DistributionSpecExecutionAny] +------------------------------------------------------------PhysicalProject +--------------------------------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF2 RF3 RF4 RF5 +----------------------------------------------------------PhysicalDistribute[DistributionSpecExecutionAny] +------------------------------------------------------------PhysicalProject +--------------------------------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 RF4 RF5 +--------------------------------------------------------PhysicalProject +----------------------------------------------------------filter((item.i_category = 'Music') and (item.i_class = 'country')) +------------------------------------------------------------PhysicalOlapScan[item] +----------------------------------------------------PhysicalProject +------------------------------------------------------filter((date_dim.d_moy = 1) and (date_dim.d_year = 1999)) +--------------------------------------------------------PhysicalOlapScan[date_dim] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store] +----------------------------PhysicalProject +------------------------------NestedLoopJoin[INNER_JOIN](cast(d_month_seq as BIGINT) <= d_month_seq+3) build RFs:RF1 d_month_seq+3->[cast(d_month_seq as BIGINT)] +--------------------------------PhysicalProject +----------------------------------NestedLoopJoin[INNER_JOIN](cast(d_month_seq as BIGINT) >= d_month_seq+1) build RFs:RF0 d_month_seq+1->[cast(d_month_seq as BIGINT)] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[date_dim] apply RFs: RF0 RF1 +------------------------------------PhysicalAssertNumRows +--------------------------------------PhysicalDistribute[DistributionSpecGather] +----------------------------------------hashAgg[GLOBAL] +------------------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------------------hashAgg[LOCAL] +----------------------------------------------PhysicalProject +------------------------------------------------filter((date_dim.d_moy = 1) and (date_dim.d_year = 1999)) +--------------------------------------------------PhysicalOlapScan[date_dim] +--------------------------------PhysicalAssertNumRows +----------------------------------PhysicalDistribute[DistributionSpecGather] +------------------------------------hashAgg[GLOBAL] +--------------------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------------------hashAgg[LOCAL] +------------------------------------------PhysicalProject +--------------------------------------------filter((date_dim.d_moy = 1) and (date_dim.d_year = 1999)) +----------------------------------------------PhysicalOlapScan[date_dim] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query55.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query55.out new file mode 100644 index 00000000000000..c337029b89202d --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query55.out @@ -0,0 +1,26 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_55_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[ss_item_sk] +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = store_sales.ss_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 +------------------------------PhysicalProject +--------------------------------filter((date_dim.d_moy = 11) and (date_dim.d_year = 2000)) +----------------------------------PhysicalOlapScan[date_dim] +--------------------PhysicalProject +----------------------filter((item.i_manager_id = 52)) +------------------------PhysicalOlapScan[item] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query56.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query56.out new file mode 100644 index 00000000000000..25e6033ea7f841 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query56.out @@ -0,0 +1,83 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_56_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalUnion +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((store_sales.ss_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF3 ca_address_sk->[ss_addr_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF2 i_item_sk->[ss_item_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF1 RF2 RF3 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_moy = 3) and (date_dim.d_year = 2000)) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------------------hashJoin[LEFT_SEMI_JOIN broadcast] hashCondition=((item.i_item_id = item.i_item_id)) otherCondition=() build RFs:RF0 i_item_id->[i_item_id] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[item] apply RFs: RF0 +----------------------------------PhysicalProject +------------------------------------filter(i_color IN ('orchid', 'pink', 'powder')) +--------------------------------------PhysicalOlapScan[item] +----------------------------PhysicalProject +------------------------------filter((customer_address.ca_gmt_offset = -6.00)) +--------------------------------PhysicalOlapScan[customer_address] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((catalog_sales.cs_bill_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF7 ca_address_sk->[cs_bill_addr_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF6 i_item_sk->[cs_item_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF5 d_date_sk->[cs_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF5 RF6 RF7 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_moy = 3) and (date_dim.d_year = 2000)) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------------------hashJoin[LEFT_SEMI_JOIN broadcast] hashCondition=((item.i_item_id = item.i_item_id)) otherCondition=() build RFs:RF4 i_item_id->[i_item_id] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[item] apply RFs: RF4 +----------------------------------PhysicalProject +------------------------------------filter(i_color IN ('orchid', 'pink', 'powder')) +--------------------------------------PhysicalOlapScan[item] +----------------------------PhysicalProject +------------------------------filter((customer_address.ca_gmt_offset = -6.00)) +--------------------------------PhysicalOlapScan[customer_address] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((web_sales.ws_bill_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF11 ws_bill_addr_sk->[ca_address_sk] +----------------------------PhysicalProject +------------------------------filter((customer_address.ca_gmt_offset = -6.00)) +--------------------------------PhysicalOlapScan[customer_address] apply RFs: RF11 +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF10 i_item_sk->[ws_item_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF9 d_date_sk->[ws_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF9 RF10 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_moy = 3) and (date_dim.d_year = 2000)) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------------------hashJoin[LEFT_SEMI_JOIN broadcast] hashCondition=((item.i_item_id = item.i_item_id)) otherCondition=() build RFs:RF8 i_item_id->[i_item_id] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[item] apply RFs: RF8 +----------------------------------PhysicalProject +------------------------------------filter(i_color IN ('orchid', 'pink', 'powder')) +--------------------------------------PhysicalOlapScan[item] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query57.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query57.out new file mode 100644 index 00000000000000..bd7b04f934b59f --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query57.out @@ -0,0 +1,43 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_57_constraints -- +PhysicalCteAnchor ( cteId=CTEId#0 ) +--PhysicalCteProducer ( cteId=CTEId#0 ) +----PhysicalProject +------PhysicalWindow +--------PhysicalQuickSort[LOCAL_SORT] +----------PhysicalWindow +------------PhysicalQuickSort[LOCAL_SORT] +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF2 i_item_sk->[cs_item_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((call_center.cc_call_center_sk = catalog_sales.cs_call_center_sk)) otherCondition=() build RFs:RF1 cc_call_center_sk->[cs_call_center_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[cs_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 RF2 +--------------------------------PhysicalProject +----------------------------------filter(OR[(date_dim.d_year = 2001),AND[(date_dim.d_year = 2000),(date_dim.d_moy = 12)],AND[(date_dim.d_year = 2002),(date_dim.d_moy = 1)]] and d_year IN (2000, 2001, 2002)) +------------------------------------PhysicalOlapScan[date_dim] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[call_center] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[item] +--PhysicalResultSink +----PhysicalProject +------PhysicalTopN[MERGE_SORT] +--------PhysicalDistribute[DistributionSpecGather] +----------PhysicalTopN[LOCAL_SORT] +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((v1.cc_name = v1_lead.cc_name) and (v1.i_brand = v1_lead.i_brand) and (v1.i_category = v1_lead.i_category) and (v1.rn = expr_(rn - 1))) otherCondition=() build RFs:RF7 i_category->[i_category,i_category];RF8 i_brand->[i_brand,i_brand];RF9 cc_name->[cc_name,cc_name];RF10 expr_(rn - 1)->[(rn + 1),rn] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN shuffle] hashCondition=((v1.cc_name = v1_lag.cc_name) and (v1.i_brand = v1_lag.i_brand) and (v1.i_category = v1_lag.i_category) and (v1.rn = expr_(rn + 1))) otherCondition=() build RFs:RF3 i_category->[i_category];RF4 i_brand->[i_brand];RF5 cc_name->[cc_name];RF6 rn->[(rn + 1)] +--------------------PhysicalProject +----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF3 RF4 RF5 RF6 RF7 RF8 RF9 RF10 +--------------------filter(((cast(abs((sum_sales - cast(avg_monthly_sales as DECIMALV3(38, 2)))) as DECIMALV3(38, 10)) / v2.avg_monthly_sales) > 0.100000) and (v2.avg_monthly_sales > 0.0000) and (v2.d_year = 2001)) +----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF7 RF8 RF9 RF10 +----------------PhysicalProject +------------------PhysicalCteConsumer ( cteId=CTEId#0 ) + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query58.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query58.out new file mode 100644 index 00000000000000..91aae66901c7f8 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query58.out @@ -0,0 +1,86 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_58_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[INNER_JOIN colocated] hashCondition=((ss_items.item_id = ws_items.item_id)) otherCondition=((cast(cs_item_rev as DECIMALV3(38, 3)) <= (1.1 * ws_items.ws_item_rev)) and (cast(cs_item_rev as DECIMALV3(38, 3)) >= (0.9 * ws_items.ws_item_rev)) and (cast(ss_item_rev as DECIMALV3(38, 3)) <= (1.1 * ws_items.ws_item_rev)) and (cast(ss_item_rev as DECIMALV3(38, 3)) >= (0.9 * ws_items.ws_item_rev)) and (cast(ws_item_rev as DECIMALV3(38, 3)) <= (1.1 * cs_items.cs_item_rev)) and (cast(ws_item_rev as DECIMALV3(38, 3)) <= (1.1 * ss_items.ss_item_rev)) and (cast(ws_item_rev as DECIMALV3(38, 3)) >= (0.9 * cs_items.cs_item_rev)) and (cast(ws_item_rev as DECIMALV3(38, 3)) >= (0.9 * ss_items.ss_item_rev))) build RFs:RF13 item_id->[i_item_id] +------------PhysicalProject +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF12 i_item_sk->[ws_item_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF11 d_date_sk->[ws_sold_date_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF11 RF12 +----------------------------PhysicalProject +------------------------------hashJoin[LEFT_SEMI_JOIN broadcast] hashCondition=((date_dim.d_date = date_dim.d_date)) otherCondition=() build RFs:RF10 d_date->[d_date] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[date_dim] apply RFs: RF10 +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_week_seq = date_dim.d_week_seq)) otherCondition=() build RFs:RF9 d_week_seq->[d_week_seq] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[date_dim] apply RFs: RF9 +------------------------------------PhysicalAssertNumRows +--------------------------------------PhysicalDistribute[DistributionSpecGather] +----------------------------------------PhysicalProject +------------------------------------------filter((date_dim.d_date = '2001-06-16')) +--------------------------------------------PhysicalOlapScan[date_dim] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[item] apply RFs: RF13 +------------PhysicalProject +--------------hashJoin[INNER_JOIN colocated] hashCondition=((ss_items.item_id = cs_items.item_id)) otherCondition=((cast(cs_item_rev as DECIMALV3(38, 3)) <= (1.1 * ss_items.ss_item_rev)) and (cast(cs_item_rev as DECIMALV3(38, 3)) >= (0.9 * ss_items.ss_item_rev)) and (cast(ss_item_rev as DECIMALV3(38, 3)) <= (1.1 * cs_items.cs_item_rev)) and (cast(ss_item_rev as DECIMALV3(38, 3)) >= (0.9 * cs_items.cs_item_rev))) build RFs:RF8 item_id->[i_item_id] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF7 i_item_sk->[cs_item_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF6 d_date_sk->[cs_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF6 RF7 +--------------------------------PhysicalProject +----------------------------------hashJoin[LEFT_SEMI_JOIN broadcast] hashCondition=((date_dim.d_date = date_dim.d_date)) otherCondition=() build RFs:RF5 d_date->[d_date] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[date_dim] apply RFs: RF5 +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_week_seq = date_dim.d_week_seq)) otherCondition=() build RFs:RF4 d_week_seq->[d_week_seq] +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[date_dim] apply RFs: RF4 +----------------------------------------PhysicalAssertNumRows +------------------------------------------PhysicalDistribute[DistributionSpecGather] +--------------------------------------------PhysicalProject +----------------------------------------------filter((date_dim.d_date = '2001-06-16')) +------------------------------------------------PhysicalOlapScan[date_dim] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[item] apply RFs: RF8 +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF3 i_item_sk->[ss_item_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ss_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[store_sales] apply RFs: RF2 RF3 +--------------------------------PhysicalProject +----------------------------------hashJoin[LEFT_SEMI_JOIN broadcast] hashCondition=((date_dim.d_date = date_dim.d_date)) otherCondition=() build RFs:RF1 d_date->[d_date] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[date_dim] apply RFs: RF1 +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_week_seq = date_dim.d_week_seq)) otherCondition=() build RFs:RF0 d_week_seq->[d_week_seq] +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[date_dim] apply RFs: RF0 +----------------------------------------PhysicalAssertNumRows +------------------------------------------PhysicalDistribute[DistributionSpecGather] +--------------------------------------------PhysicalProject +----------------------------------------------filter((date_dim.d_date = '2001-06-16')) +------------------------------------------------PhysicalOlapScan[date_dim] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[item] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query59.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query59.out new file mode 100644 index 00000000000000..b2780ba63f92a3 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query59.out @@ -0,0 +1,45 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_59_constraints -- +PhysicalCteAnchor ( cteId=CTEId#0 ) +--PhysicalCteProducer ( cteId=CTEId#0 ) +----hashAgg[GLOBAL] +------PhysicalDistribute[DistributionSpecHash] +--------hashAgg[LOCAL] +----------PhysicalProject +------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((date_dim.d_date_sk = store_sales.ss_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] +--------------------PhysicalProject +----------------------PhysicalOlapScan[store_sales] apply RFs: RF0 +--------------PhysicalProject +----------------PhysicalOlapScan[date_dim] +--PhysicalResultSink +----PhysicalTopN[MERGE_SORT] +------PhysicalDistribute[DistributionSpecGather] +--------PhysicalTopN[LOCAL_SORT] +----------PhysicalProject +------------hashJoin[INNER_JOIN shuffle] hashCondition=((expr_cast(d_week_seq1 as BIGINT) = expr_(cast(d_week_seq2 as BIGINT) - 52)) and (y.s_store_id1 = x.s_store_id2)) otherCondition=() build RFs:RF5 s_store_id2->[s_store_id];RF6 expr_(cast(d_week_seq2 as BIGINT) - 52)->[cast(d_week_seq as BIGINT)] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((d.d_week_seq = d_week_seq1)) otherCondition=() build RFs:RF4 d_week_seq->[d_week_seq] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN shuffle] hashCondition=((wss.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF3 s_store_sk->[ss_store_sk] +----------------------PhysicalProject +------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF3 RF4 RF6 +----------------------PhysicalProject +------------------------PhysicalOlapScan[store] apply RFs: RF5 +------------------PhysicalProject +--------------------filter((d.d_month_seq <= 1206) and (d.d_month_seq >= 1195)) +----------------------PhysicalOlapScan[date_dim] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((d.d_week_seq = d_week_seq2)) otherCondition=() build RFs:RF2 d_week_seq->[d_week_seq] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN shuffle] hashCondition=((wss.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF1 s_store_sk->[ss_store_sk] +----------------------PhysicalProject +------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF1 RF2 +----------------------PhysicalProject +------------------------PhysicalOlapScan[store] +------------------PhysicalProject +--------------------filter((d.d_month_seq <= 1218) and (d.d_month_seq >= 1207)) +----------------------PhysicalOlapScan[date_dim] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query6.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query6.out new file mode 100644 index 00000000000000..728647a98d0be1 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query6.out @@ -0,0 +1,47 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_6_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------filter((cnt >= 10)) +------------hashAgg[GLOBAL] +--------------PhysicalDistribute[DistributionSpecHash] +----------------hashAgg[LOCAL] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((a.ca_address_sk = c.c_current_addr_sk)) otherCondition=() build RFs:RF5 c_current_addr_sk->[ca_address_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[customer_address] apply RFs: RF5 +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((c.c_customer_sk = s.ss_customer_sk)) otherCondition=() build RFs:RF4 ss_customer_sk->[c_customer_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[customer] apply RFs: RF4 +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((s.ss_item_sk = i.i_item_sk)) otherCondition=() build RFs:RF3 i_item_sk->[ss_item_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((s.ss_sold_date_sk = d.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ss_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF2 RF3 +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((d.d_month_seq = date_dim.d_month_seq)) otherCondition=() build RFs:RF1 d_month_seq->[d_month_seq] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[date_dim] apply RFs: RF1 +--------------------------------------PhysicalAssertNumRows +----------------------------------------PhysicalDistribute[DistributionSpecGather] +------------------------------------------hashAgg[GLOBAL] +--------------------------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------------------------hashAgg[LOCAL] +------------------------------------------------PhysicalProject +--------------------------------------------------filter((date_dim.d_moy = 3) and (date_dim.d_year = 2002)) +----------------------------------------------------PhysicalOlapScan[date_dim] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((j.i_category = i.i_category)) otherCondition=((cast(i_current_price as DECIMALV3(38, 5)) > (1.2 * avg(j.i_current_price)))) build RFs:RF0 i_category->[i_category] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[item] apply RFs: RF0 +----------------------------------hashAgg[GLOBAL] +------------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------------hashAgg[LOCAL] +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[item] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query60.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query60.out new file mode 100644 index 00000000000000..7c1a5de77399e1 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query60.out @@ -0,0 +1,83 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_60_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalUnion +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF3 i_item_sk->[ss_item_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF2 ca_address_sk->[ss_addr_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF1 RF2 RF3 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_moy = 10) and (date_dim.d_year = 2000)) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------------------PhysicalProject +----------------------------------filter((customer_address.ca_gmt_offset = -5.00)) +------------------------------------PhysicalOlapScan[customer_address] +----------------------------hashJoin[LEFT_SEMI_JOIN broadcast] hashCondition=((item.i_item_id = item.i_item_id)) otherCondition=() build RFs:RF0 i_item_id->[i_item_id] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[item] apply RFs: RF0 +------------------------------PhysicalProject +--------------------------------filter((item.i_category = 'Jewelry')) +----------------------------------PhysicalOlapScan[item] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF7 i_item_sk->[cs_item_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_bill_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF6 ca_address_sk->[cs_bill_addr_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF5 d_date_sk->[cs_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF5 RF6 RF7 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_moy = 10) and (date_dim.d_year = 2000)) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------------------PhysicalProject +----------------------------------filter((customer_address.ca_gmt_offset = -5.00)) +------------------------------------PhysicalOlapScan[customer_address] +----------------------------hashJoin[LEFT_SEMI_JOIN broadcast] hashCondition=((item.i_item_id = item.i_item_id)) otherCondition=() build RFs:RF4 i_item_id->[i_item_id] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[item] apply RFs: RF4 +------------------------------PhysicalProject +--------------------------------filter((item.i_category = 'Jewelry')) +----------------------------------PhysicalOlapScan[item] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((web_sales.ws_bill_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF11 ca_address_sk->[ws_bill_addr_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF10 i_item_sk->[ws_item_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF9 d_date_sk->[ws_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF9 RF10 RF11 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_moy = 10) and (date_dim.d_year = 2000)) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------------------hashJoin[LEFT_SEMI_JOIN broadcast] hashCondition=((item.i_item_id = item.i_item_id)) otherCondition=() build RFs:RF8 i_item_id->[i_item_id] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[item] apply RFs: RF8 +----------------------------------PhysicalProject +------------------------------------filter((item.i_category = 'Jewelry')) +--------------------------------------PhysicalOlapScan[item] +----------------------------PhysicalProject +------------------------------filter((customer_address.ca_gmt_offset = -5.00)) +--------------------------------PhysicalOlapScan[customer_address] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query61.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query61.out new file mode 100644 index 00000000000000..cabf732464f880 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query61.out @@ -0,0 +1,70 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_61_constraints -- +PhysicalResultSink +--PhysicalTopN[GATHER_SORT] +----PhysicalProject +------NestedLoopJoin[CROSS_JOIN] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecGather] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer_address.ca_address_sk = customer.c_current_addr_sk)) otherCondition=() build RFs:RF10 c_current_addr_sk->[ca_address_sk] +------------------PhysicalProject +--------------------filter((customer_address.ca_gmt_offset = -7.00)) +----------------------PhysicalOlapScan[customer_address] apply RFs: RF10 +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF9 ss_customer_sk->[c_customer_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[customer] apply RFs: RF9 +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF8 s_store_sk->[ss_store_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_promo_sk = promotion.p_promo_sk)) otherCondition=() build RFs:RF7 p_promo_sk->[ss_promo_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF6 i_item_sk->[ss_item_sk] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF5 d_date_sk->[ss_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF5 RF6 RF7 RF8 +--------------------------------------PhysicalProject +----------------------------------------filter((date_dim.d_moy = 12) and (date_dim.d_year = 2000)) +------------------------------------------PhysicalOlapScan[date_dim] +----------------------------------PhysicalProject +------------------------------------filter((item.i_category = 'Home')) +--------------------------------------PhysicalOlapScan[item] +------------------------------PhysicalProject +--------------------------------filter(OR[(promotion.p_channel_dmail = 'Y'),(promotion.p_channel_email = 'Y'),(promotion.p_channel_tv = 'Y')]) +----------------------------------PhysicalOlapScan[promotion] +--------------------------PhysicalProject +----------------------------filter((store.s_gmt_offset = -7.00)) +------------------------------PhysicalOlapScan[store] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecGather] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF4 s_store_sk->[ss_store_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN shuffle] hashCondition=((store_sales.ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[ss_customer_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF2 i_item_sk->[ss_item_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[store_sales] apply RFs: RF1 RF2 RF3 RF4 +------------------------------PhysicalProject +--------------------------------filter((date_dim.d_moy = 12) and (date_dim.d_year = 2000)) +----------------------------------PhysicalOlapScan[date_dim] +--------------------------PhysicalProject +----------------------------filter((item.i_category = 'Home')) +------------------------------PhysicalOlapScan[item] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer_address.ca_address_sk = customer.c_current_addr_sk)) otherCondition=() build RFs:RF0 ca_address_sk->[c_current_addr_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[customer] apply RFs: RF0 +--------------------------PhysicalProject +----------------------------filter((customer_address.ca_gmt_offset = -7.00)) +------------------------------PhysicalOlapScan[customer_address] +------------------PhysicalProject +--------------------filter((store.s_gmt_offset = -7.00)) +----------------------PhysicalOlapScan[store] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query62.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query62.out new file mode 100644 index 00000000000000..393f9d3cf52cb5 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query62.out @@ -0,0 +1,29 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_62_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_web_site_sk = web_site.web_site_sk)) otherCondition=() build RFs:RF3 web_site_sk->[ws_web_site_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_ship_mode_sk = ship_mode.sm_ship_mode_sk)) otherCondition=() build RFs:RF2 sm_ship_mode_sk->[ws_ship_mode_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_warehouse_sk = warehouse.w_warehouse_sk)) otherCondition=() build RFs:RF1 w_warehouse_sk->[ws_warehouse_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_ship_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_ship_date_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 RF2 RF3 +------------------------------PhysicalProject +--------------------------------filter((date_dim.d_month_seq <= 1234) and (date_dim.d_month_seq >= 1223)) +----------------------------------PhysicalOlapScan[date_dim] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[warehouse] +----------------------PhysicalProject +------------------------PhysicalOlapScan[ship_mode] +------------------PhysicalProject +--------------------PhysicalOlapScan[web_site] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query63.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query63.out new file mode 100644 index 00000000000000..56fd0e97f01eec --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query63.out @@ -0,0 +1,31 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_63_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------filter(((cast(abs((sum_sales - cast(avg_monthly_sales as DECIMALV3(38, 2)))) as DECIMALV3(38, 10)) / tmp1.avg_monthly_sales) > 0.100000) and (tmp1.avg_monthly_sales > 0.0000)) +----------PhysicalWindow +------------PhysicalQuickSort[LOCAL_SORT] +--------------PhysicalDistribute[DistributionSpecHash] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF2 s_store_sk->[ss_store_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[ss_item_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 +------------------------------------PhysicalProject +--------------------------------------filter(OR[AND[i_category IN ('Books', 'Children', 'Electronics'),i_class IN ('personal', 'portable', 'reference', 'self-help'),i_brand IN ('exportiunivamalg #9', 'scholaramalgamalg #14', 'scholaramalgamalg #7', 'scholaramalgamalg #9')],AND[i_category IN ('Men', 'Music', 'Women'),i_class IN ('accessories', 'classical', 'fragrances', 'pants'),i_brand IN ('amalgimporto #1', 'edu packscholar #1', 'exportiimporto #1', 'importoamalg #1')]] and i_brand IN ('amalgimporto #1', 'edu packscholar #1', 'exportiimporto #1', 'exportiunivamalg #9', 'importoamalg #1', 'scholaramalgamalg #14', 'scholaramalgamalg #7', 'scholaramalgamalg #9') and i_category IN ('Books', 'Children', 'Electronics', 'Men', 'Music', 'Women') and i_class IN ('accessories', 'classical', 'fragrances', 'pants', 'personal', 'portable', 'reference', 'self-help')) +----------------------------------------PhysicalOlapScan[item] +--------------------------------PhysicalProject +----------------------------------filter(d_month_seq IN (1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1230, 1231, 1232, 1233)) +------------------------------------PhysicalOlapScan[date_dim] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[store] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query64.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query64.out new file mode 100644 index 00000000000000..bf82282a6b7a37 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query64.out @@ -0,0 +1,101 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_64_constraints -- +PhysicalCteAnchor ( cteId=CTEId#1 ) +--PhysicalCteProducer ( cteId=CTEId#1 ) +----PhysicalProject +------hashAgg[GLOBAL] +--------PhysicalDistribute[DistributionSpecHash] +----------hashAgg[LOCAL] +------------PhysicalProject +--------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer.c_first_shipto_date_sk = d3.d_date_sk)) otherCondition=() build RFs:RF19 d_date_sk->[c_first_shipto_date_sk] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN shuffle] hashCondition=((store_sales.ss_customer_sk = customer.c_customer_sk)) otherCondition=(( not (cd_marital_status = cd_marital_status))) build RFs:RF18 ss_customer_sk->[c_customer_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_current_addr_sk = ad2.ca_address_sk)) otherCondition=() build RFs:RF17 ca_address_sk->[c_current_addr_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer.c_current_cdemo_sk = cd2.cd_demo_sk)) otherCondition=() build RFs:RF16 cd_demo_sk->[c_current_cdemo_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer.c_first_sales_date_sk = d2.d_date_sk)) otherCondition=() build RFs:RF15 d_date_sk->[c_first_sales_date_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer.c_current_hdemo_sk = hd2.hd_demo_sk)) otherCondition=() build RFs:RF14 hd_demo_sk->[c_current_hdemo_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[customer] apply RFs: RF14 RF15 RF16 RF17 RF18 RF19 +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((hd2.hd_income_band_sk = ib2.ib_income_band_sk)) otherCondition=() build RFs:RF13 ib_income_band_sk->[hd_income_band_sk] +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[household_demographics] apply RFs: RF13 +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[income_band] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[date_dim] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[customer_demographics] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[customer_address] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN shuffle] hashCondition=((store_sales.ss_addr_sk = ad1.ca_address_sk)) otherCondition=() build RFs:RF12 ca_address_sk->[ss_addr_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((store_sales.ss_item_sk = store_returns.sr_item_sk) and (store_sales.ss_ticket_number = store_returns.sr_ticket_number)) otherCondition=() build RFs:RF10 ss_item_sk->[sr_item_sk];RF11 ss_ticket_number->[sr_ticket_number] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[store_returns] apply RFs: RF10 RF11 +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_promo_sk = promotion.p_promo_sk)) otherCondition=() build RFs:RF9 p_promo_sk->[ss_promo_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_cdemo_sk = cd1.cd_demo_sk)) otherCondition=() build RFs:RF8 cd_demo_sk->[ss_cdemo_sk] +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF7 i_item_sk->[cr_item_sk,cs_item_sk,ss_item_sk] +--------------------------------------PhysicalProject +----------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF6 s_store_sk->[ss_store_sk] +------------------------------------------PhysicalProject +--------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((hd1.hd_income_band_sk = ib1.ib_income_band_sk)) otherCondition=() build RFs:RF5 ib_income_band_sk->[hd_income_band_sk] +----------------------------------------------PhysicalProject +------------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_hdemo_sk = hd1.hd_demo_sk)) otherCondition=() build RFs:RF4 hd_demo_sk->[ss_hdemo_sk] +--------------------------------------------------PhysicalProject +----------------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_item_sk = cs_ui.cs_item_sk)) otherCondition=() build RFs:RF3 cs_item_sk->[ss_item_sk] +------------------------------------------------------PhysicalProject +--------------------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = d1.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ss_sold_date_sk] +----------------------------------------------------------PhysicalProject +------------------------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF2 RF3 RF4 RF6 RF7 RF8 RF9 RF12 +----------------------------------------------------------PhysicalProject +------------------------------------------------------------filter(d_year IN (1999, 2000)) +--------------------------------------------------------------PhysicalOlapScan[date_dim] +------------------------------------------------------PhysicalProject +--------------------------------------------------------filter((sale > (2 * refund))) +----------------------------------------------------------hashAgg[GLOBAL] +------------------------------------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------------------------------------hashAgg[LOCAL] +----------------------------------------------------------------PhysicalProject +------------------------------------------------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((catalog_sales.cs_item_sk = catalog_returns.cr_item_sk) and (catalog_sales.cs_order_number = catalog_returns.cr_order_number)) otherCondition=() build RFs:RF0 cr_item_sk->[cs_item_sk];RF1 cr_order_number->[cs_order_number] +--------------------------------------------------------------------PhysicalProject +----------------------------------------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 RF7 +--------------------------------------------------------------------PhysicalProject +----------------------------------------------------------------------PhysicalOlapScan[catalog_returns] apply RFs: RF7 +--------------------------------------------------PhysicalProject +----------------------------------------------------PhysicalOlapScan[household_demographics] apply RFs: RF5 +----------------------------------------------PhysicalProject +------------------------------------------------PhysicalOlapScan[income_band] +------------------------------------------PhysicalProject +--------------------------------------------PhysicalOlapScan[store] +--------------------------------------PhysicalProject +----------------------------------------filter((item.i_current_price <= 58.00) and (item.i_current_price >= 49.00) and i_color IN ('blush', 'lace', 'lawn', 'misty', 'orange', 'pink')) +------------------------------------------PhysicalOlapScan[item] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[customer_demographics] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[promotion] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[customer_address] +----------------PhysicalProject +------------------PhysicalOlapScan[date_dim] +--PhysicalResultSink +----PhysicalQuickSort[MERGE_SORT] +------PhysicalDistribute[DistributionSpecGather] +--------PhysicalQuickSort[LOCAL_SORT] +----------PhysicalProject +------------hashJoin[INNER_JOIN shuffle] hashCondition=((cs1.item_sk = cs2.item_sk) and (cs1.store_name = cs2.store_name) and (cs1.store_zip = cs2.store_zip)) otherCondition=((cs2.cnt <= cs1.cnt)) build RFs:RF20 item_sk->[item_sk];RF21 store_name->[store_name];RF22 store_zip->[store_zip] +--------------PhysicalProject +----------------filter((cs1.syear = 1999)) +------------------PhysicalCteConsumer ( cteId=CTEId#1 ) apply RFs: RF20 RF21 RF22 +--------------PhysicalProject +----------------filter((cs2.syear = 2000)) +------------------PhysicalCteConsumer ( cteId=CTEId#1 ) + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query65.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query65.out new file mode 100644 index 00000000000000..0cd30be089a60b --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query65.out @@ -0,0 +1,43 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_65_constraints -- +PhysicalResultSink +--PhysicalProject +----PhysicalLazyMaterialize[materializedSlots:(store.s_store_name,item.i_item_desc,sc.revenue) lazySlots:(item.i_brand,item.i_current_price,item.i_wholesale_cost)] +------PhysicalTopN[MERGE_SORT] +--------PhysicalDistribute[DistributionSpecGather] +----------PhysicalTopN[LOCAL_SORT] +------------PhysicalProject +--------------hashJoin[INNER_JOIN broadcast] hashCondition=((sb.ss_store_sk = sc.ss_store_sk)) otherCondition=((cast(revenue as DECIMALV3(38, 5)) <= (0.1 * sb.ave))) build RFs:RF4 ss_store_sk->[s_store_sk,ss_store_sk] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store.s_store_sk = sc.ss_store_sk)) otherCondition=() build RFs:RF3 s_store_sk->[ss_store_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((item.i_item_sk = sc.ss_item_sk)) otherCondition=() build RFs:RF2 i_item_sk->[ss_item_sk] +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF1 RF2 RF3 RF4 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_month_seq <= 1187) and (date_dim.d_month_seq >= 1176)) +--------------------------------------PhysicalOlapScan[date_dim] +------------------------PhysicalProject +--------------------------PhysicalLazyMaterializeOlapScan[item lazySlots:(item.i_current_price,item.i_wholesale_cost,item.i_brand)] +--------------------PhysicalProject +----------------------PhysicalOlapScan[store] apply RFs: RF4 +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecHash] +--------------------hashAgg[LOCAL] +----------------------PhysicalProject +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_month_seq <= 1187) and (date_dim.d_month_seq >= 1176)) +--------------------------------------PhysicalOlapScan[date_dim] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query66.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query66.out new file mode 100644 index 00000000000000..bece921f61a67d --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query66.out @@ -0,0 +1,61 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_66_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------PhysicalUnion +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_warehouse_sk = warehouse.w_warehouse_sk)) otherCondition=() build RFs:RF3 w_warehouse_sk->[ws_warehouse_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_time_sk = time_dim.t_time_sk)) otherCondition=() build RFs:RF2 t_time_sk->[ws_sold_time_sk] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_ship_mode_sk = ship_mode.sm_ship_mode_sk)) otherCondition=() build RFs:RF0 sm_ship_mode_sk->[ws_ship_mode_sk] +------------------------------------------PhysicalProject +--------------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 RF2 RF3 +------------------------------------------PhysicalProject +--------------------------------------------filter(sm_carrier IN ('BOXBUNDLES', 'ORIENTAL')) +----------------------------------------------PhysicalOlapScan[ship_mode] +--------------------------------------PhysicalProject +----------------------------------------filter((date_dim.d_year = 2001)) +------------------------------------------PhysicalOlapScan[date_dim] +----------------------------------PhysicalProject +------------------------------------filter((time_dim.t_time <= 71770) and (time_dim.t_time >= 42970)) +--------------------------------------PhysicalOlapScan[time_dim] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[warehouse] +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_warehouse_sk = warehouse.w_warehouse_sk)) otherCondition=() build RFs:RF7 w_warehouse_sk->[cs_warehouse_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_time_sk = time_dim.t_time_sk)) otherCondition=() build RFs:RF6 t_time_sk->[cs_sold_time_sk] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF5 d_date_sk->[cs_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_ship_mode_sk = ship_mode.sm_ship_mode_sk)) otherCondition=() build RFs:RF4 sm_ship_mode_sk->[cs_ship_mode_sk] +------------------------------------------PhysicalProject +--------------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF4 RF5 RF6 RF7 +------------------------------------------PhysicalProject +--------------------------------------------filter(sm_carrier IN ('BOXBUNDLES', 'ORIENTAL')) +----------------------------------------------PhysicalOlapScan[ship_mode] +--------------------------------------PhysicalProject +----------------------------------------filter((date_dim.d_year = 2001)) +------------------------------------------PhysicalOlapScan[date_dim] +----------------------------------PhysicalProject +------------------------------------filter((time_dim.t_time <= 71770) and (time_dim.t_time >= 42970)) +--------------------------------------PhysicalOlapScan[time_dim] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[warehouse] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query67.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query67.out new file mode 100644 index 00000000000000..f3e2d4f679515a --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query67.out @@ -0,0 +1,42 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_67_constraints -- +PhysicalCteAnchor ( cteId=CTEId#0 ) +--PhysicalCteProducer ( cteId=CTEId#0 ) +----hashAgg[GLOBAL] +------PhysicalDistribute[DistributionSpecHash] +--------hashAgg[LOCAL] +----------PhysicalProject +------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF2 i_item_sk->[ss_item_sk] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF1 s_store_sk->[ss_store_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 +----------------------PhysicalProject +------------------------filter((date_dim.d_month_seq <= 1228) and (date_dim.d_month_seq >= 1217)) +--------------------------PhysicalOlapScan[date_dim] +------------------PhysicalProject +--------------------PhysicalOlapScan[store] +--------------PhysicalProject +----------------PhysicalOlapScan[item] +--PhysicalResultSink +----PhysicalTopN[MERGE_SORT] +------PhysicalDistribute[DistributionSpecGather] +--------PhysicalTopN[LOCAL_SORT] +----------filter((dw2.rk <= 100)) +------------PhysicalWindow +--------------PhysicalPartitionTopN +----------------PhysicalDistribute[DistributionSpecHash] +------------------PhysicalPartitionTopN +--------------------PhysicalUnion +----------------------PhysicalProject +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalRepeat +--------------------------------PhysicalDistribute[DistributionSpecExecutionAny] +----------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------PhysicalDistribute[DistributionSpecExecutionAny] +------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query68.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query68.out new file mode 100644 index 00000000000000..8b1ade7f9f911c --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query68.out @@ -0,0 +1,40 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_68_constraints -- +PhysicalResultSink +--PhysicalProject +----PhysicalLazyMaterialize[materializedSlots:(customer.c_last_name,current_addr.ca_city,dn.bought_city,dn.ss_ticket_number,dn.extended_price,dn.extended_tax,dn.list_price) lazySlots:(customer.c_first_name)] +------PhysicalTopN[MERGE_SORT] +--------PhysicalDistribute[DistributionSpecGather] +----------PhysicalTopN[LOCAL_SORT] +------------PhysicalProject +--------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_current_addr_sk = current_addr.ca_address_sk)) otherCondition=(( not (ca_city = bought_city))) build RFs:RF5 c_current_addr_sk->[ca_address_sk] +----------------PhysicalProject +------------------PhysicalOlapScan[customer_address] apply RFs: RF5 +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((dn.ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF4 ss_customer_sk->[c_customer_sk] +--------------------PhysicalProject +----------------------PhysicalLazyMaterializeOlapScan[customer lazySlots:(customer.c_first_name)] apply RFs: RF4 +--------------------PhysicalProject +----------------------hashAgg[GLOBAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((store_sales.ss_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF3 ss_addr_sk->[ca_address_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[customer_address] apply RFs: RF3 +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk)) otherCondition=() build RFs:RF2 hd_demo_sk->[ss_hdemo_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF1 s_store_sk->[ss_store_sk] +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 +----------------------------------------PhysicalProject +------------------------------------------filter((date_dim.d_dom <= 2) and (date_dim.d_dom >= 1) and d_year IN (1998, 1999, 2000)) +--------------------------------------------PhysicalOlapScan[date_dim] +------------------------------------PhysicalProject +--------------------------------------filter(s_city IN ('Fairview', 'Midway')) +----------------------------------------PhysicalOlapScan[store] +--------------------------------PhysicalProject +----------------------------------filter(OR[(household_demographics.hd_dep_count = 3),(household_demographics.hd_vehicle_count = 4)]) +------------------------------------PhysicalOlapScan[household_demographics] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query69.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query69.out new file mode 100644 index 00000000000000..04639a728c9fee --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query69.out @@ -0,0 +1,47 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_69_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------hashJoin[RIGHT_SEMI_JOIN shuffleBucket] hashCondition=((c.c_customer_sk = store_sales.ss_customer_sk)) otherCondition=() build RFs:RF7 c_customer_sk->[ss_customer_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF6 d_date_sk->[ss_sold_date_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[store_sales] apply RFs: RF6 RF7 +------------------------PhysicalProject +--------------------------filter((date_dim.d_moy <= 3) and (date_dim.d_moy >= 1) and (date_dim.d_year = 2002)) +----------------------------PhysicalOlapScan[date_dim] +--------------------hashJoin[RIGHT_ANTI_JOIN shuffle] hashCondition=((c.c_customer_sk = catalog_sales.cs_ship_customer_sk)) otherCondition=() build RFs:RF5 c_customer_sk->[cs_ship_customer_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[cs_sold_date_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF4 RF5 +--------------------------PhysicalProject +----------------------------filter((date_dim.d_moy <= 3) and (date_dim.d_moy >= 1) and (date_dim.d_year = 2002)) +------------------------------PhysicalOlapScan[date_dim] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer_demographics.cd_demo_sk = c.c_current_cdemo_sk)) otherCondition=() build RFs:RF3 c_current_cdemo_sk->[cd_demo_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[customer_demographics] apply RFs: RF3 +--------------------------hashJoin[RIGHT_ANTI_JOIN shuffle] hashCondition=((c.c_customer_sk = web_sales.ws_bill_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[ws_bill_customer_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 RF2 +--------------------------------PhysicalProject +----------------------------------filter((date_dim.d_moy <= 3) and (date_dim.d_moy >= 1) and (date_dim.d_year = 2002)) +------------------------------------PhysicalOlapScan[date_dim] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((c.c_current_addr_sk = ca.ca_address_sk)) otherCondition=() build RFs:RF0 ca_address_sk->[c_current_addr_sk] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[customer] apply RFs: RF0 +--------------------------------PhysicalProject +----------------------------------filter(ca_state IN ('IL', 'ME', 'TX')) +------------------------------------PhysicalOlapScan[customer_address] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query7.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query7.out new file mode 100644 index 00000000000000..d5acc0f672e672 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query7.out @@ -0,0 +1,31 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_7_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF3 i_item_sk->[ss_item_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_promo_sk = promotion.p_promo_sk)) otherCondition=() build RFs:RF2 p_promo_sk->[ss_promo_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_cdemo_sk = customer_demographics.cd_demo_sk)) otherCondition=() build RFs:RF0 cd_demo_sk->[ss_cdemo_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 RF3 +------------------------------PhysicalProject +--------------------------------filter((customer_demographics.cd_education_status = 'College') and (customer_demographics.cd_gender = 'F') and (customer_demographics.cd_marital_status = 'W')) +----------------------------------PhysicalOlapScan[customer_demographics] +--------------------------PhysicalProject +----------------------------filter((date_dim.d_year = 2001)) +------------------------------PhysicalOlapScan[date_dim] +----------------------PhysicalProject +------------------------filter(OR[(promotion.p_channel_email = 'N'),(promotion.p_channel_event = 'N')]) +--------------------------PhysicalOlapScan[promotion] +------------------PhysicalProject +--------------------PhysicalOlapScan[item] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query70.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query70.out new file mode 100644 index 00000000000000..a4b93723d79772 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query70.out @@ -0,0 +1,47 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_70_constraints -- +PhysicalResultSink +--PhysicalProject +----PhysicalTopN[MERGE_SORT] +------PhysicalDistribute[DistributionSpecGather] +--------PhysicalTopN[LOCAL_SORT] +----------PhysicalProject +------------PhysicalWindow +--------------PhysicalQuickSort[LOCAL_SORT] +----------------PhysicalDistribute[DistributionSpecHash] +------------------PhysicalProject +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalRepeat +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store.s_store_sk = store_sales.ss_store_sk)) otherCondition=() build RFs:RF4 s_store_sk->[ss_store_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((d1.d_date_sk = store_sales.ss_sold_date_sk)) otherCondition=() build RFs:RF3 d_date_sk->[ss_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF3 RF4 +------------------------------------PhysicalProject +--------------------------------------filter((d1.d_month_seq <= 1231) and (d1.d_month_seq >= 1220)) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------------------hashJoin[LEFT_SEMI_JOIN broadcast] hashCondition=((store.s_state = tmp1.s_state)) otherCondition=() build RFs:RF2 s_state->[s_state] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store] apply RFs: RF2 +----------------------------------PhysicalProject +------------------------------------hashAgg[GLOBAL] +--------------------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------------------hashAgg[LOCAL] +------------------------------------------PhysicalProject +--------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store.s_store_sk = store_sales.ss_store_sk)) otherCondition=() build RFs:RF1 s_store_sk->[ss_store_sk] +----------------------------------------------PhysicalProject +------------------------------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((date_dim.d_date_sk = store_sales.ss_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +--------------------------------------------------hashAgg[GLOBAL] +----------------------------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------------------------hashAgg[LOCAL] +--------------------------------------------------------PhysicalProject +----------------------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 +--------------------------------------------------PhysicalProject +----------------------------------------------------filter((date_dim.d_month_seq <= 1231) and (date_dim.d_month_seq >= 1220)) +------------------------------------------------------PhysicalOlapScan[date_dim] +----------------------------------------------PhysicalProject +------------------------------------------------PhysicalOlapScan[store] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query71.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query71.out new file mode 100644 index 00000000000000..e87b54e5260d4a --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query71.out @@ -0,0 +1,36 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_71_constraints -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((tmp.time_sk = time_dim.t_time_sk)) otherCondition=() build RFs:RF2 t_time_sk->[cs_sold_time_sk,ss_sold_time_sk,ws_sold_time_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk,ss_sold_date_sk,ws_sold_date_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((tmp.sold_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[cs_item_sk,ss_item_sk,ws_item_sk] +----------------------------PhysicalUnion +------------------------------PhysicalDistribute[DistributionSpecExecutionAny] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 RF2 +------------------------------PhysicalDistribute[DistributionSpecExecutionAny] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 RF2 +------------------------------PhysicalDistribute[DistributionSpecExecutionAny] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 +----------------------------PhysicalProject +------------------------------filter((item.i_manager_id = 1)) +--------------------------------PhysicalOlapScan[item] +------------------------PhysicalProject +--------------------------filter((date_dim.d_moy = 12) and (date_dim.d_year = 2002)) +----------------------------PhysicalOlapScan[date_dim] +--------------------PhysicalProject +----------------------filter(t_meal_time IN ('breakfast', 'dinner')) +------------------------PhysicalOlapScan[time_dim] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query72.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query72.out new file mode 100644 index 00000000000000..de0642d56d88d5 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query72.out @@ -0,0 +1,58 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_72_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((warehouse.w_warehouse_sk = inventory.inv_warehouse_sk)) otherCondition=() build RFs:RF10 w_warehouse_sk->[inv_warehouse_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((catalog_sales.cs_item_sk = inventory.inv_item_sk) and (inventory.inv_date_sk = d2.d_date_sk)) otherCondition=((inventory.inv_quantity_on_hand < catalog_sales.cs_quantity)) build RFs:RF8 d_date_sk->[inv_date_sk];RF9 cs_item_sk->[inv_item_sk] +----------------------PhysicalOlapScan[inventory] apply RFs: RF8 RF9 RF10 +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((item.i_item_sk = catalog_sales.cs_item_sk)) otherCondition=() build RFs:RF7 i_item_sk->[cs_item_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((d1.d_week_seq = d2.d_week_seq)) otherCondition=() build RFs:RF6 d_week_seq->[d_week_seq] +------------------------------PhysicalProject +--------------------------------hashJoin[RIGHT_OUTER_JOIN shuffle] hashCondition=((catalog_returns.cr_item_sk = catalog_sales.cs_item_sk) and (catalog_returns.cr_order_number = catalog_sales.cs_order_number)) otherCondition=() build RFs:RF4 cs_item_sk->[cr_item_sk];RF5 cs_order_number->[cr_order_number] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[catalog_returns] apply RFs: RF4 RF5 +----------------------------------PhysicalProject +------------------------------------hashJoin[LEFT_OUTER_JOIN broadcast] hashCondition=((catalog_sales.cs_promo_sk = promotion.p_promo_sk)) otherCondition=() +--------------------------------------PhysicalProject +----------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_bill_cdemo_sk = customer_demographics.cd_demo_sk)) otherCondition=() build RFs:RF3 cd_demo_sk->[cs_bill_cdemo_sk] +------------------------------------------PhysicalProject +--------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_bill_hdemo_sk = household_demographics.hd_demo_sk)) otherCondition=() build RFs:RF2 hd_demo_sk->[cs_bill_hdemo_sk] +----------------------------------------------PhysicalProject +------------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_ship_date_sk = d3.d_date_sk) and (catalog_sales.cs_sold_date_sk = d1.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[cs_ship_date_sk];RF1 d_date_sk->[cs_sold_date_sk] +--------------------------------------------------PhysicalProject +----------------------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 RF2 RF3 RF7 +--------------------------------------------------PhysicalProject +----------------------------------------------------NestedLoopJoin[INNER_JOIN](d3.d_date > days_add(d_date, INTERVAL 5 DAY)) +------------------------------------------------------PhysicalProject +--------------------------------------------------------PhysicalOlapScan[date_dim] +------------------------------------------------------PhysicalProject +--------------------------------------------------------filter((d1.d_year = 1998)) +----------------------------------------------------------PhysicalOlapScan[date_dim] apply RFs: RF6 +----------------------------------------------PhysicalProject +------------------------------------------------filter((household_demographics.hd_buy_potential = '1001-5000')) +--------------------------------------------------PhysicalOlapScan[household_demographics] +------------------------------------------PhysicalProject +--------------------------------------------filter((customer_demographics.cd_marital_status = 'S')) +----------------------------------------------PhysicalOlapScan[customer_demographics] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[promotion] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[date_dim] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[item] +------------------PhysicalProject +--------------------PhysicalOlapScan[warehouse] + + + + group expression count exceeds memo_max_group_expression_size(10000) + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query73.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query73.out new file mode 100644 index 00000000000000..d174310dfd5410 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query73.out @@ -0,0 +1,32 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_73_constraints -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[INNER_JOIN broadcast] hashCondition=((dj.ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 ss_customer_sk->[c_customer_sk] +------------PhysicalProject +--------------PhysicalOlapScan[customer] apply RFs: RF3 +------------filter((dj.cnt <= 5) and (dj.cnt >= 1)) +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk)) otherCondition=() build RFs:RF2 hd_demo_sk->[ss_hdemo_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF1 s_store_sk->[ss_store_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 +--------------------------------PhysicalProject +----------------------------------filter((date_dim.d_dom <= 2) and (date_dim.d_dom >= 1) and d_year IN (2000, 2001, 2002)) +------------------------------------PhysicalOlapScan[date_dim] +----------------------------PhysicalProject +------------------------------filter((store.s_county = 'Williamson County')) +--------------------------------PhysicalOlapScan[store] +------------------------PhysicalProject +--------------------------filter(((cast(hd_dep_count as DOUBLE) / cast(hd_vehicle_count as DOUBLE)) > 1.0) and (household_demographics.hd_vehicle_count > 0) and hd_buy_potential IN ('1001-5000', '5001-10000')) +----------------------------PhysicalOlapScan[household_demographics] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query74.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query74.out new file mode 100644 index 00000000000000..42c170b4928afd --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query74.out @@ -0,0 +1,53 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_74_constraints -- +PhysicalCteAnchor ( cteId=CTEId#0 ) +--PhysicalCteProducer ( cteId=CTEId#0 ) +----PhysicalProject +------hashJoin[INNER_JOIN shuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[ss_customer_sk,ws_bill_customer_sk] +--------PhysicalUnion +----------PhysicalProject +------------hashAgg[GLOBAL] +--------------PhysicalDistribute[DistributionSpecHash] +----------------hashAgg[LOCAL] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF2 +----------------------PhysicalProject +------------------------filter(d_year IN (1999, 2000)) +--------------------------PhysicalOlapScan[date_dim] +----------PhysicalProject +------------hashAgg[GLOBAL] +--------------PhysicalDistribute[DistributionSpecHash] +----------------hashAgg[LOCAL] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 RF2 +----------------------PhysicalProject +------------------------filter(d_year IN (1999, 2000)) +--------------------------PhysicalOlapScan[date_dim] +--------PhysicalProject +----------PhysicalOlapScan[customer] +--PhysicalResultSink +----PhysicalTopN[MERGE_SORT] +------PhysicalDistribute[DistributionSpecGather] +--------PhysicalTopN[LOCAL_SORT] +----------PhysicalProject +------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(13, 8)) / year_total), NULL) > if((year_total > 0.00), (cast(year_total as DECIMALV3(13, 8)) / year_total), NULL))) build RFs:RF5 customer_id->[customer_id] +--------------PhysicalProject +----------------filter((t_w_secyear.sale_type = 'w') and (t_w_secyear.year = 2000)) +------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 +--------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id] +----------------PhysicalProject +------------------filter((t_s_secyear.sale_type = 's') and (t_s_secyear.year = 2000)) +--------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 +----------------PhysicalProject +------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF3 customer_id->[customer_id] +--------------------PhysicalProject +----------------------filter((t_s_firstyear.sale_type = 's') and (t_s_firstyear.year = 1999) and (t_s_firstyear.year_total > 0.00)) +------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF3 +--------------------PhysicalProject +----------------------filter((t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year = 1999) and (t_w_firstyear.year_total > 0.00)) +------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query75.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query75.out new file mode 100644 index 00000000000000..4ad8bad1c09827 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query75.out @@ -0,0 +1,68 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_75_constraints -- +PhysicalCteAnchor ( cteId=CTEId#0 ) +--PhysicalCteProducer ( cteId=CTEId#0 ) +----hashAgg[GLOBAL] +------hashAgg[GLOBAL] +--------PhysicalDistribute[DistributionSpecHash] +----------hashAgg[LOCAL] +------------PhysicalUnion +--------------PhysicalProject +----------------hashJoin[RIGHT_OUTER_JOIN shuffle] hashCondition=((catalog_sales.cs_item_sk = catalog_returns.cr_item_sk) and (catalog_sales.cs_order_number = catalog_returns.cr_order_number)) otherCondition=() build RFs:RF2 cs_order_number->[cr_order_number];RF3 cs_item_sk->[cr_item_sk] +------------------PhysicalProject +--------------------PhysicalOlapScan[catalog_returns] apply RFs: RF2 RF3 +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = catalog_sales.cs_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[cs_item_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 +--------------------------PhysicalProject +----------------------------filter((item.i_category = 'Sports')) +------------------------------PhysicalOlapScan[item] +----------------------PhysicalProject +------------------------filter(d_year IN (2001, 2002)) +--------------------------PhysicalOlapScan[date_dim] +--------------PhysicalProject +----------------hashJoin[RIGHT_OUTER_JOIN shuffle] hashCondition=((store_sales.ss_item_sk = store_returns.sr_item_sk) and (store_sales.ss_ticket_number = store_returns.sr_ticket_number)) otherCondition=() build RFs:RF6 ss_ticket_number->[sr_ticket_number];RF7 ss_item_sk->[sr_item_sk] +------------------PhysicalProject +--------------------PhysicalOlapScan[store_returns] apply RFs: RF6 RF7 +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = store_sales.ss_sold_date_sk)) otherCondition=() build RFs:RF5 d_date_sk->[ss_sold_date_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = store_sales.ss_item_sk)) otherCondition=() build RFs:RF4 i_item_sk->[ss_item_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 RF5 +--------------------------PhysicalProject +----------------------------filter((item.i_category = 'Sports')) +------------------------------PhysicalOlapScan[item] +----------------------PhysicalProject +------------------------filter(d_year IN (2001, 2002)) +--------------------------PhysicalOlapScan[date_dim] +--------------PhysicalProject +----------------hashJoin[RIGHT_OUTER_JOIN shuffle] hashCondition=((web_sales.ws_item_sk = web_returns.wr_item_sk) and (web_sales.ws_order_number = web_returns.wr_order_number)) otherCondition=() build RFs:RF10 ws_order_number->[wr_order_number];RF11 ws_item_sk->[wr_item_sk] +------------------PhysicalProject +--------------------PhysicalOlapScan[web_returns] apply RFs: RF10 RF11 +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF9 d_date_sk->[ws_sold_date_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = web_sales.ws_item_sk)) otherCondition=() build RFs:RF8 i_item_sk->[ws_item_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[web_sales] apply RFs: RF8 RF9 +--------------------------PhysicalProject +----------------------------filter((item.i_category = 'Sports')) +------------------------------PhysicalOlapScan[item] +----------------------PhysicalProject +------------------------filter(d_year IN (2001, 2002)) +--------------------------PhysicalOlapScan[date_dim] +--PhysicalResultSink +----PhysicalTopN[MERGE_SORT] +------PhysicalDistribute[DistributionSpecGather] +--------PhysicalTopN[LOCAL_SORT] +----------PhysicalProject +------------hashJoin[INNER_JOIN shuffle] hashCondition=((curr_yr.i_brand_id = prev_yr.i_brand_id) and (curr_yr.i_category_id = prev_yr.i_category_id) and (curr_yr.i_class_id = prev_yr.i_class_id) and (curr_yr.i_manufact_id = prev_yr.i_manufact_id)) otherCondition=(((cast(cast(sales_cnt as DECIMALV3(17, 2)) as DECIMALV3(23, 8)) / cast(sales_cnt as DECIMALV3(17, 2))) < 0.900000)) build RFs:RF12 i_brand_id->[i_brand_id];RF13 i_class_id->[i_class_id];RF14 i_category_id->[i_category_id];RF15 i_manufact_id->[i_manufact_id] +--------------filter((curr_yr.d_year = 2002)) +----------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF12 RF13 RF14 RF15 +--------------filter((prev_yr.d_year = 2001)) +----------------PhysicalCteConsumer ( cteId=CTEId#0 ) + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query76.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query76.out new file mode 100644 index 00000000000000..47b4e401542d1e --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query76.out @@ -0,0 +1,38 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_76_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF3 d_date_sk->[cs_sold_date_sk,ss_sold_date_sk,ws_sold_date_sk] +------------------PhysicalUnion +--------------------PhysicalDistribute[DistributionSpecExecutionAny] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[ss_item_sk] +--------------------------PhysicalProject +----------------------------filter(ss_customer_sk IS NULL) +------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF3 +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[item] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN shuffle] hashCondition=((web_sales.ws_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF1 ws_item_sk->[i_item_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[item] apply RFs: RF1 +------------------------PhysicalProject +--------------------------filter(ws_promo_sk IS NULL) +----------------------------PhysicalOlapScan[web_sales] apply RFs: RF3 +--------------------PhysicalDistribute[DistributionSpecExecutionAny] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF2 i_item_sk->[cs_item_sk] +--------------------------PhysicalProject +----------------------------filter(cs_bill_customer_sk IS NULL) +------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF2 RF3 +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[item] +------------------PhysicalProject +--------------------PhysicalOlapScan[date_dim] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query77.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query77.out new file mode 100644 index 00000000000000..9ed69e514ebe8f --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query77.out @@ -0,0 +1,101 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_77_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalRepeat +------------------PhysicalUnion +--------------------PhysicalProject +----------------------hashJoin[LEFT_OUTER_JOIN colocated] hashCondition=((ss.s_store_sk = sr.s_store_sk)) otherCondition=() +------------------------PhysicalProject +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF3 s_store_sk->[ss_store_sk] +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ss_sold_date_sk] +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF2 RF3 +----------------------------------------PhysicalProject +------------------------------------------filter((date_dim.d_date <= '2000-09-09') and (date_dim.d_date >= '2000-08-10')) +--------------------------------------------PhysicalOlapScan[date_dim] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store] +------------------------PhysicalProject +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_returns.sr_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF1 s_store_sk->[sr_store_sk] +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_returns.sr_returned_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[sr_returned_date_sk] +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[store_returns] apply RFs: RF0 RF1 +----------------------------------------PhysicalProject +------------------------------------------filter((date_dim.d_date <= '2000-09-09') and (date_dim.d_date >= '2000-08-10')) +--------------------------------------------PhysicalOlapScan[date_dim] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store] +--------------------PhysicalProject +----------------------NestedLoopJoin[CROSS_JOIN] +------------------------PhysicalProject +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF5 d_date_sk->[cs_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF5 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_date <= '2000-09-09') and (date_dim.d_date >= '2000-08-10')) +----------------------------------------PhysicalOlapScan[date_dim] +------------------------PhysicalProject +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_returns.cr_returned_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[cr_returned_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[catalog_returns] apply RFs: RF4 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_date <= '2000-09-09') and (date_dim.d_date >= '2000-08-10')) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------PhysicalProject +----------------------hashJoin[LEFT_OUTER_JOIN colocated] hashCondition=((ws.wp_web_page_sk = wr.wp_web_page_sk)) otherCondition=() +------------------------PhysicalProject +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_web_page_sk = web_page.wp_web_page_sk)) otherCondition=() build RFs:RF9 wp_web_page_sk->[ws_web_page_sk] +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF8 d_date_sk->[ws_sold_date_sk] +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF8 RF9 +----------------------------------------PhysicalProject +------------------------------------------filter((date_dim.d_date <= '2000-09-09') and (date_dim.d_date >= '2000-08-10')) +--------------------------------------------PhysicalOlapScan[date_dim] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[web_page] +------------------------PhysicalProject +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_returns.wr_web_page_sk = web_page.wp_web_page_sk)) otherCondition=() build RFs:RF7 wp_web_page_sk->[wr_web_page_sk] +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_returns.wr_returned_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF6 d_date_sk->[wr_returned_date_sk] +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[web_returns] apply RFs: RF6 RF7 +----------------------------------------PhysicalProject +------------------------------------------filter((date_dim.d_date <= '2000-09-09') and (date_dim.d_date >= '2000-08-10')) +--------------------------------------------PhysicalOlapScan[date_dim] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[web_page] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query78.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query78.out new file mode 100644 index 00000000000000..4f0e9d9de0ae0e --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query78.out @@ -0,0 +1,57 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_78_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------filter(OR[(coalesce(ws_qty, 0) > 0),(coalesce(cs_qty, 0) > 0)]) +------------hashJoin[LEFT_OUTER_JOIN colocated] hashCondition=((cs.cs_customer_sk = ss.ss_customer_sk) and (cs.cs_item_sk = ss.ss_item_sk) and (cs.cs_sold_year = ss.ss_sold_year)) otherCondition=() +--------------PhysicalProject +----------------hashJoin[LEFT_OUTER_JOIN colocated] hashCondition=((ws.ws_customer_sk = ss.ss_customer_sk) and (ws.ws_item_sk = ss.ss_item_sk) and (ws.ws_sold_year = ss.ss_sold_year)) otherCondition=() +------------------PhysicalProject +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ss_sold_date_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[LEFT_ANTI_JOIN bucketShuffle] hashCondition=((store_returns.sr_ticket_number = store_sales.ss_ticket_number) and (store_sales.ss_item_sk = store_returns.sr_item_sk)) otherCondition=() +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF2 +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_returns] +------------------------------PhysicalProject +--------------------------------filter((date_dim.d_year = 1998)) +----------------------------------PhysicalOlapScan[date_dim] +------------------PhysicalProject +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[LEFT_ANTI_JOIN bucketShuffle] hashCondition=((web_returns.wr_order_number = web_sales.ws_order_number) and (web_sales.ws_item_sk = web_returns.wr_item_sk)) otherCondition=() +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[web_returns] +------------------------------PhysicalProject +--------------------------------filter((date_dim.d_year = 1998)) +----------------------------------PhysicalOlapScan[date_dim] +--------------PhysicalProject +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecHash] +--------------------hashAgg[LOCAL] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[cs_sold_date_sk] +--------------------------PhysicalProject +----------------------------hashJoin[LEFT_ANTI_JOIN bucketShuffle] hashCondition=((catalog_returns.cr_order_number = catalog_sales.cs_order_number) and (catalog_sales.cs_item_sk = catalog_returns.cr_item_sk)) otherCondition=() +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[catalog_returns] +--------------------------PhysicalProject +----------------------------filter((date_dim.d_year = 1998)) +------------------------------PhysicalOlapScan[date_dim] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query79.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query79.out new file mode 100644 index 00000000000000..c95a1351f77f9f --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query79.out @@ -0,0 +1,32 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_79_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ms.ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[ss_customer_sk] +------------PhysicalProject +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF2 s_store_sk->[ss_store_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk)) otherCondition=() build RFs:RF1 hd_demo_sk->[ss_hdemo_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 RF3 +--------------------------------PhysicalProject +----------------------------------filter((date_dim.d_dow = 1) and d_year IN (2000, 2001, 2002)) +------------------------------------PhysicalOlapScan[date_dim] +----------------------------PhysicalProject +------------------------------filter(OR[(household_demographics.hd_dep_count = 7),(household_demographics.hd_vehicle_count > -1)]) +--------------------------------PhysicalOlapScan[household_demographics] +------------------------PhysicalProject +--------------------------filter((store.s_number_employees <= 295) and (store.s_number_employees >= 200)) +----------------------------PhysicalOlapScan[store] +------------PhysicalProject +--------------PhysicalOlapScan[customer] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query8.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query8.out new file mode 100644 index 00000000000000..fb9e4a72d0e1d9 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query8.out @@ -0,0 +1,48 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_8_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((expr_substring(s_zip, 1, 2) = expr_substring(ca_zip, 1, 2))) otherCondition=() +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF2 ss_store_sk->[s_store_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[store] apply RFs: RF2 +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[store_sales] apply RFs: RF1 +--------------------------------PhysicalProject +----------------------------------filter((date_dim.d_qoy = 2) and (date_dim.d_year = 1998)) +------------------------------------PhysicalOlapScan[date_dim] +------------------PhysicalProject +--------------------PhysicalIntersect RFV2: RF3[ca_zip->substring(ca_zip, 1, 5)] +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------filter(substring(ca_zip, 1, 5) IN ('10298', '10374', '10425', '11340', '11489', '11618', '11652', '11686', '11855', '11912', '12197', '12318', '12320', '12350', '13086', '13123', '13261', '13338', '13376', '13378', '13443', '13844', '13869', '13918', '14073', '14155', '14196', '14242', '14312', '14440', '14530', '14851', '15371', '15475', '15543', '15734', '15751', '15782', '15794', '16005', '16226', '16364', '16515', '16704', '16791', '16891', '17167', '17193', '17291', '17672', '17819', '17879', '17895', '18218', '18360', '18367', '18410', '18421', '18434', '18569', '18700', '18767', '18829', '18884', '19326', '19444', '19489', '19753', '19833', '19988', '20244', '20317', '20534', '20601', '20712', '21060', '21094', '21204', '21231', '21343', '21727', '21800', '21814', '22728', '22815', '22911', '23065', '23952', '24227', '24255', '24286', '24594', '24660', '24891', '24987', '25115', '25178', '25214', '25264', '25333', '25494', '25717', '25973', '26217', '26689', '27052', '27116', '27156', '27287', '27369', '27385', '27413', '27642', '27700', '28055', '28239', '28571', '28577', '28810', '29086', '29392', '29450', '29752', '29818', '30106', '30415', '30621', '31013', '31016', '31655', '31830', '32489', '32669', '32754', '32919', '32958', '32961', '33113', '33122', '33159', '33467', '33562', '33773', '33869', '34306', '34473', '34594', '34948', '34972', '35076', '35390', '35834', '35863', '35926', '36201', '36335', '36430', '36479', '37119', '37788', '37914', '38353', '38607', '38919', '39214', '39459', '39500', '39503', '40146', '40936', '40979', '41162', '41232', '41255', '41331', '41351', '41352', '41419', '41807', '41836', '41967', '42361', '43432', '43639', '43830', '43933', '44529', '45266', '45484', '45533', '45645', '45676', '45859', '46081', '46131', '46507', '47289', '47369', '47529', '47602', '47770', '48017', '48162', '48333', '48530', '48567', '49101', '49130', '49140', '49211', '49230', '49254', '49472', '50412', '50632', '50636', '50679', '50788', '51089', '51184', '51195', '51634', '51717', '51766', '51782', '51793', '51933', '52094', '52301', '52389', '52868', '53163', '53535', '53565', '54010', '54207', '54364', '54558', '54585', '55233', '55349', '56224', '56355', '56436', '56455', '56600', '56877', '57025', '57553', '57631', '57649', '57839', '58032', '58058', '58062', '58117', '58218', '58412', '58454', '58581', '59004', '59080', '59130', '59226', '59345', '59386', '59494', '59852', '60083', '60298', '60560', '60624', '60736', '61527', '61794', '61860', '61997', '62361', '62585', '62878', '63073', '63180', '63193', '63294', '63792', '63991', '64592', '65148', '65177', '65501', '66057', '66943', '67881', '67975', '67998', '68101', '68293', '68341', '68605', '68730', '68770', '68843', '68852', '68908', '69280', '69952', '69998', '70041', '70070', '70073', '70450', '71144', '71256', '71286', '71836', '71948', '71954', '71997', '72592', '72991', '73021', '73108', '73134', '73146', '73219', '73873', '74686', '75660', '75675', '75742', '75752', '77454', '77817', '78093', '78366', '79077', '79658', '80332', '80846', '81003', '81070', '81084', '81335', '81504', '81755', '81963', '82080', '82602', '82620', '83041', '83086', '83583', '83647', '83833', '83910', '83986', '84247', '84680', '84844', '84919', '85066', '85761', '86057', '86379', '86709', '88086', '88137', '88217', '89193', '89338', '90209', '90229', '90669', '91110', '91894', '92292', '92380', '92645', '92696', '93498', '94791', '94835', '94898', '95042', '95430', '95464', '95694', '96435', '96560', '97173', '97462', '98069', '98072', '98338', '98533', '98569', '98584', '98862', '99060', '99132')) +--------------------------------PhysicalOlapScan[customer_address] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------PhysicalProject +--------------------------filter((cnt > 10)) +----------------------------hashAgg[GLOBAL] +------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------hashAgg[LOCAL] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer_address.ca_address_sk = customer.c_current_addr_sk)) otherCondition=() build RFs:RF0 ca_address_sk->[c_current_addr_sk] +--------------------------------------PhysicalProject +----------------------------------------filter((customer.c_preferred_cust_flag = 'Y')) +------------------------------------------PhysicalOlapScan[customer] apply RFs: RF0 +--------------------------------------PhysicalProject +----------------------------------------filter(substring(ca_zip, 1, 5) IN ('10298', '10374', '10425', '11340', '11489', '11618', '11652', '11686', '11855', '11912', '12197', '12318', '12320', '12350', '13086', '13123', '13261', '13338', '13376', '13378', '13443', '13844', '13869', '13918', '14073', '14155', '14196', '14242', '14312', '14440', '14530', '14851', '15371', '15475', '15543', '15734', '15751', '15782', '15794', '16005', '16226', '16364', '16515', '16704', '16791', '16891', '17167', '17193', '17291', '17672', '17819', '17879', '17895', '18218', '18360', '18367', '18410', '18421', '18434', '18569', '18700', '18767', '18829', '18884', '19326', '19444', '19489', '19753', '19833', '19988', '20244', '20317', '20534', '20601', '20712', '21060', '21094', '21204', '21231', '21343', '21727', '21800', '21814', '22728', '22815', '22911', '23065', '23952', '24227', '24255', '24286', '24594', '24660', '24891', '24987', '25115', '25178', '25214', '25264', '25333', '25494', '25717', '25973', '26217', '26689', '27052', '27116', '27156', '27287', '27369', '27385', '27413', '27642', '27700', '28055', '28239', '28571', '28577', '28810', '29086', '29392', '29450', '29752', '29818', '30106', '30415', '30621', '31013', '31016', '31655', '31830', '32489', '32669', '32754', '32919', '32958', '32961', '33113', '33122', '33159', '33467', '33562', '33773', '33869', '34306', '34473', '34594', '34948', '34972', '35076', '35390', '35834', '35863', '35926', '36201', '36335', '36430', '36479', '37119', '37788', '37914', '38353', '38607', '38919', '39214', '39459', '39500', '39503', '40146', '40936', '40979', '41162', '41232', '41255', '41331', '41351', '41352', '41419', '41807', '41836', '41967', '42361', '43432', '43639', '43830', '43933', '44529', '45266', '45484', '45533', '45645', '45676', '45859', '46081', '46131', '46507', '47289', '47369', '47529', '47602', '47770', '48017', '48162', '48333', '48530', '48567', '49101', '49130', '49140', '49211', '49230', '49254', '49472', '50412', '50632', '50636', '50679', '50788', '51089', '51184', '51195', '51634', '51717', '51766', '51782', '51793', '51933', '52094', '52301', '52389', '52868', '53163', '53535', '53565', '54010', '54207', '54364', '54558', '54585', '55233', '55349', '56224', '56355', '56436', '56455', '56600', '56877', '57025', '57553', '57631', '57649', '57839', '58032', '58058', '58062', '58117', '58218', '58412', '58454', '58581', '59004', '59080', '59130', '59226', '59345', '59386', '59494', '59852', '60083', '60298', '60560', '60624', '60736', '61527', '61794', '61860', '61997', '62361', '62585', '62878', '63073', '63180', '63193', '63294', '63792', '63991', '64592', '65148', '65177', '65501', '66057', '66943', '67881', '67975', '67998', '68101', '68293', '68341', '68605', '68730', '68770', '68843', '68852', '68908', '69280', '69952', '69998', '70041', '70070', '70073', '70450', '71144', '71256', '71286', '71836', '71948', '71954', '71997', '72592', '72991', '73021', '73108', '73134', '73146', '73219', '73873', '74686', '75660', '75675', '75742', '75752', '77454', '77817', '78093', '78366', '79077', '79658', '80332', '80846', '81003', '81070', '81084', '81335', '81504', '81755', '81963', '82080', '82602', '82620', '83041', '83086', '83583', '83647', '83833', '83910', '83986', '84247', '84680', '84844', '84919', '85066', '85761', '86057', '86379', '86709', '88086', '88137', '88217', '89193', '89338', '90209', '90229', '90669', '91110', '91894', '92292', '92380', '92645', '92696', '93498', '94791', '94835', '94898', '95042', '95430', '95464', '95694', '96435', '96560', '97173', '97462', '98069', '98072', '98338', '98533', '98569', '98584', '98862', '99060', '99132')) +------------------------------------------PhysicalOlapScan[customer_address] RFV2: RF3 + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query80.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query80.out new file mode 100644 index 00000000000000..b32612e13a5096 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query80.out @@ -0,0 +1,100 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_80_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalRepeat +------------------PhysicalUnion +--------------------PhysicalProject +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------hashJoin[RIGHT_OUTER_JOIN shuffle] hashCondition=((store_sales.ss_item_sk = store_returns.sr_item_sk) and (store_sales.ss_ticket_number = store_returns.sr_ticket_number)) otherCondition=() build RFs:RF4 ss_item_sk->[sr_item_sk];RF5 ss_ticket_number->[sr_ticket_number] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[store_returns] apply RFs: RF4 RF5 +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF3 s_store_sk->[ss_store_sk] +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF2 i_item_sk->[ss_item_sk] +----------------------------------------PhysicalProject +------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_promo_sk = promotion.p_promo_sk)) otherCondition=() build RFs:RF1 p_promo_sk->[ss_promo_sk] +--------------------------------------------PhysicalProject +----------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +------------------------------------------------PhysicalProject +--------------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 RF3 +------------------------------------------------PhysicalProject +--------------------------------------------------filter((date_dim.d_date <= '2002-09-13') and (date_dim.d_date >= '2002-08-14')) +----------------------------------------------------PhysicalOlapScan[date_dim] +--------------------------------------------PhysicalProject +----------------------------------------------filter((promotion.p_channel_tv = 'N')) +------------------------------------------------PhysicalOlapScan[promotion] +----------------------------------------PhysicalProject +------------------------------------------filter((item.i_current_price > 50.00)) +--------------------------------------------PhysicalOlapScan[item] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store] +--------------------PhysicalProject +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_catalog_page_sk = catalog_page.cp_catalog_page_sk)) otherCondition=() build RFs:RF11 cp_catalog_page_sk->[cs_catalog_page_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[RIGHT_OUTER_JOIN shuffle] hashCondition=((catalog_sales.cs_item_sk = catalog_returns.cr_item_sk) and (catalog_sales.cs_order_number = catalog_returns.cr_order_number)) otherCondition=() build RFs:RF9 cs_item_sk->[cr_item_sk];RF10 cs_order_number->[cr_order_number] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[catalog_returns] apply RFs: RF9 RF10 +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF8 i_item_sk->[cs_item_sk] +----------------------------------------PhysicalProject +------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_promo_sk = promotion.p_promo_sk)) otherCondition=() build RFs:RF7 p_promo_sk->[cs_promo_sk] +--------------------------------------------PhysicalProject +----------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF6 d_date_sk->[cs_sold_date_sk] +------------------------------------------------PhysicalProject +--------------------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF6 RF7 RF8 RF11 +------------------------------------------------PhysicalProject +--------------------------------------------------filter((date_dim.d_date <= '2002-09-13') and (date_dim.d_date >= '2002-08-14')) +----------------------------------------------------PhysicalOlapScan[date_dim] +--------------------------------------------PhysicalProject +----------------------------------------------filter((promotion.p_channel_tv = 'N')) +------------------------------------------------PhysicalOlapScan[promotion] +----------------------------------------PhysicalProject +------------------------------------------filter((item.i_current_price > 50.00)) +--------------------------------------------PhysicalOlapScan[item] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[catalog_page] +--------------------PhysicalProject +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------hashJoin[RIGHT_OUTER_JOIN shuffle] hashCondition=((web_sales.ws_item_sk = web_returns.wr_item_sk) and (web_sales.ws_order_number = web_returns.wr_order_number)) otherCondition=() build RFs:RF16 ws_item_sk->[wr_item_sk];RF17 ws_order_number->[wr_order_number] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[web_returns] apply RFs: RF16 RF17 +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_web_site_sk = web_site.web_site_sk)) otherCondition=() build RFs:RF15 web_site_sk->[ws_web_site_sk] +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF14 i_item_sk->[ws_item_sk] +----------------------------------------PhysicalProject +------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_promo_sk = promotion.p_promo_sk)) otherCondition=() build RFs:RF13 p_promo_sk->[ws_promo_sk] +--------------------------------------------PhysicalProject +----------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF12 d_date_sk->[ws_sold_date_sk] +------------------------------------------------PhysicalProject +--------------------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF12 RF13 RF14 RF15 +------------------------------------------------PhysicalProject +--------------------------------------------------filter((date_dim.d_date <= '2002-09-13') and (date_dim.d_date >= '2002-08-14')) +----------------------------------------------------PhysicalOlapScan[date_dim] +--------------------------------------------PhysicalProject +----------------------------------------------filter((promotion.p_channel_tv = 'N')) +------------------------------------------------PhysicalOlapScan[promotion] +----------------------------------------PhysicalProject +------------------------------------------filter((item.i_current_price > 50.00)) +--------------------------------------------PhysicalOlapScan[item] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[web_site] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query81.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query81.out new file mode 100644 index 00000000000000..e652b43e859ef1 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query81.out @@ -0,0 +1,43 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_81_constraints -- +PhysicalCteAnchor ( cteId=CTEId#0 ) +--PhysicalCteProducer ( cteId=CTEId#0 ) +----PhysicalProject +------hashAgg[GLOBAL] +--------PhysicalDistribute[DistributionSpecHash] +----------hashAgg[LOCAL] +------------PhysicalProject +--------------hashJoin[INNER_JOIN shuffle] hashCondition=((catalog_returns.cr_returning_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF1 ca_address_sk->[cr_returning_addr_sk] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_returns.cr_returned_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[cr_returned_date_sk] +--------------------PhysicalProject +----------------------PhysicalOlapScan[catalog_returns] apply RFs: RF0 RF1 +--------------------PhysicalProject +----------------------filter((date_dim.d_year = 2001)) +------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------PhysicalOlapScan[customer_address] +--PhysicalResultSink +----PhysicalProject +------PhysicalLazyMaterialize[materializedSlots:(customer.c_customer_id,customer_address.ca_street_number,customer_address.ca_street_name,customer_address.ca_street_type,customer_address.ca_suite_number,customer_address.ca_city,customer_address.ca_county,customer_address.ca_state,customer_address.ca_zip,customer_address.ca_country,customer_address.ca_gmt_offset,customer_address.ca_location_type,ctr1.ctr_total_return) lazySlots:(customer.c_first_name,customer.c_last_name,customer.c_salutation)] +--------PhysicalTopN[MERGE_SORT] +----------PhysicalDistribute[DistributionSpecGather] +------------PhysicalTopN[LOCAL_SORT] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((ctr1.ctr_state = ctr2.ctr_state)) otherCondition=((cast(ctr_total_return as DECIMALV3(38, 5)) > (avg(ctr_total_return) * 1.2))) build RFs:RF4 ctr_state->[ctr_state] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer_address.ca_address_sk = customer.c_current_addr_sk)) otherCondition=() build RFs:RF3 ca_address_sk->[c_current_addr_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((ctr1.ctr_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[ctr_customer_sk] +--------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF2 RF4 +--------------------------PhysicalProject +----------------------------PhysicalLazyMaterializeOlapScan[customer lazySlots:(customer.c_last_name,customer.c_salutation,customer.c_first_name)] apply RFs: RF3 +----------------------PhysicalProject +------------------------filter((customer_address.ca_state = 'TN')) +--------------------------PhysicalOlapScan[customer_address] +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalDistribute[DistributionSpecExecutionAny] +--------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query82.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query82.out new file mode 100644 index 00000000000000..2104e57fbe6076 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query82.out @@ -0,0 +1,31 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_82_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = inventory.inv_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[inv_date_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((inventory.inv_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[inv_item_sk] +----------------------hashAgg[GLOBAL] +------------------------PhysicalProject +--------------------------filter((inventory.inv_quantity_on_hand <= 500) and (inventory.inv_quantity_on_hand >= 100)) +----------------------------PhysicalOlapScan[inventory] apply RFs: RF1 RF2 +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[ss_item_sk] +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 +--------------------------PhysicalProject +----------------------------filter((item.i_current_price <= 88.00) and (item.i_current_price >= 58.00) and i_manufact_id IN (259, 485, 559, 580)) +------------------------------PhysicalOlapScan[item] +------------------PhysicalProject +--------------------filter((date_dim.d_date <= '2001-03-14') and (date_dim.d_date >= '2001-01-13')) +----------------------PhysicalOlapScan[date_dim] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query83.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query83.out new file mode 100644 index 00000000000000..c704d4162b17cd --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query83.out @@ -0,0 +1,89 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_83_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[INNER_JOIN colocated] hashCondition=((sr_items.item_id = wr_items.item_id)) otherCondition=() build RFs:RF13 item_id->[i_item_id,i_item_id] +------------PhysicalProject +--------------hashJoin[INNER_JOIN colocated] hashCondition=((sr_items.item_id = cr_items.item_id)) otherCondition=() build RFs:RF12 item_id->[i_item_id] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_returns.sr_returned_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF11 d_date_sk->[sr_returned_date_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((store_returns.sr_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF10 i_item_sk->[sr_item_sk] +--------------------------------hashAgg[GLOBAL] +----------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------hashAgg[LOCAL] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[store_returns] apply RFs: RF10 RF11 +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[item] apply RFs: RF12 RF13 +----------------------------PhysicalProject +------------------------------hashJoin[LEFT_SEMI_JOIN broadcast] hashCondition=((date_dim.d_date = date_dim.d_date)) otherCondition=() build RFs:RF9 d_date->[d_date] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[date_dim] apply RFs: RF9 +--------------------------------PhysicalProject +----------------------------------hashJoin[LEFT_SEMI_JOIN broadcast] hashCondition=((date_dim.d_week_seq = date_dim.d_week_seq)) otherCondition=() build RFs:RF8 d_week_seq->[d_week_seq] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[date_dim] apply RFs: RF8 +------------------------------------PhysicalProject +--------------------------------------filter(d_date IN ('2001-07-13', '2001-09-10', '2001-11-16')) +----------------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_returns.cr_returned_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF7 d_date_sk->[cr_returned_date_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((catalog_returns.cr_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF6 i_item_sk->[cr_item_sk] +--------------------------------hashAgg[GLOBAL] +----------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------hashAgg[LOCAL] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[catalog_returns] apply RFs: RF6 RF7 +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[item] apply RFs: RF13 +----------------------------PhysicalProject +------------------------------hashJoin[LEFT_SEMI_JOIN broadcast] hashCondition=((date_dim.d_date = date_dim.d_date)) otherCondition=() build RFs:RF5 d_date->[d_date] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[date_dim] apply RFs: RF5 +--------------------------------PhysicalProject +----------------------------------hashJoin[LEFT_SEMI_JOIN broadcast] hashCondition=((date_dim.d_week_seq = date_dim.d_week_seq)) otherCondition=() build RFs:RF4 d_week_seq->[d_week_seq] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[date_dim] apply RFs: RF4 +------------------------------------PhysicalProject +--------------------------------------filter(d_date IN ('2001-07-13', '2001-09-10', '2001-11-16')) +----------------------------------------PhysicalOlapScan[date_dim] +------------PhysicalProject +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_returns.wr_returned_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF3 d_date_sk->[wr_returned_date_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((web_returns.wr_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF2 i_item_sk->[wr_item_sk] +----------------------------hashAgg[GLOBAL] +------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------hashAgg[LOCAL] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[web_returns] apply RFs: RF2 RF3 +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[item] +------------------------PhysicalProject +--------------------------hashJoin[LEFT_SEMI_JOIN broadcast] hashCondition=((date_dim.d_date = date_dim.d_date)) otherCondition=() build RFs:RF1 d_date->[d_date] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[date_dim] apply RFs: RF1 +----------------------------PhysicalProject +------------------------------hashJoin[LEFT_SEMI_JOIN broadcast] hashCondition=((date_dim.d_week_seq = date_dim.d_week_seq)) otherCondition=() build RFs:RF0 d_week_seq->[d_week_seq] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[date_dim] apply RFs: RF0 +--------------------------------PhysicalProject +----------------------------------filter(d_date IN ('2001-07-13', '2001-09-10', '2001-11-16')) +------------------------------------PhysicalOlapScan[date_dim] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query84.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query84.out new file mode 100644 index 00000000000000..41b5f86ad07457 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query84.out @@ -0,0 +1,31 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_84_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[INNER_JOIN broadcast] hashCondition=((store_returns.sr_cdemo_sk = customer_demographics.cd_demo_sk)) otherCondition=() build RFs:RF4 cd_demo_sk->[sr_cdemo_sk] +------------PhysicalProject +--------------PhysicalOlapScan[store_returns] apply RFs: RF4 +------------PhysicalProject +--------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer_demographics.cd_demo_sk = customer.c_current_cdemo_sk)) otherCondition=() build RFs:RF3 c_current_cdemo_sk->[cd_demo_sk] +----------------PhysicalProject +------------------PhysicalOlapScan[customer_demographics] apply RFs: RF3 +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((household_demographics.hd_demo_sk = customer.c_current_hdemo_sk)) otherCondition=() build RFs:RF2 hd_demo_sk->[c_current_hdemo_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer.c_current_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF1 ca_address_sk->[c_current_addr_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[customer] apply RFs: RF1 RF2 +------------------------PhysicalProject +--------------------------filter((customer_address.ca_city = 'Woodland')) +----------------------------PhysicalOlapScan[customer_address] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((income_band.ib_income_band_sk = household_demographics.hd_income_band_sk)) otherCondition=() build RFs:RF0 ib_income_band_sk->[hd_income_band_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[household_demographics] apply RFs: RF0 +------------------------PhysicalProject +--------------------------filter((income_band.ib_lower_bound >= 60306) and (income_band.ib_upper_bound <= 110306)) +----------------------------PhysicalOlapScan[income_band] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query85.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query85.out new file mode 100644 index 00000000000000..fbb48317afe370 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query85.out @@ -0,0 +1,46 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_85_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((reason.r_reason_sk = web_returns.wr_reason_sk)) otherCondition=() build RFs:RF9 r_reason_sk->[wr_reason_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((cd1.cd_education_status = cd2.cd_education_status) and (cd1.cd_marital_status = cd2.cd_marital_status) and (cd2.cd_demo_sk = web_returns.wr_returning_cdemo_sk)) otherCondition=() build RFs:RF6 wr_returning_cdemo_sk->[cd_demo_sk];RF7 cd_marital_status->[cd_marital_status];RF8 cd_education_status->[cd_education_status] +------------------------PhysicalProject +--------------------------filter(cd_education_status IN ('Advanced Degree', 'College', 'Primary') and cd_marital_status IN ('D', 'S', 'U')) +----------------------------PhysicalOlapScan[customer_demographics] apply RFs: RF6 RF7 RF8 +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_web_page_sk = web_page.wp_web_page_sk)) otherCondition=() build RFs:RF5 wp_web_page_sk->[ws_web_page_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer_address.ca_address_sk = web_returns.wr_refunded_addr_sk)) otherCondition=(OR[AND[ca_state IN ('IA', 'NC', 'TX'),(web_sales.ws_net_profit >= 100.00),(web_sales.ws_net_profit <= 200.00)],AND[ca_state IN ('GA', 'WI', 'WV'),(web_sales.ws_net_profit >= 150.00)],AND[ca_state IN ('KY', 'OK', 'VA'),(web_sales.ws_net_profit <= 250.00)]]) build RFs:RF4 wr_refunded_addr_sk->[ca_address_sk] +--------------------------------PhysicalProject +----------------------------------filter((customer_address.ca_country = 'United States') and ca_state IN ('GA', 'IA', 'KY', 'NC', 'OK', 'TX', 'VA', 'WI', 'WV')) +------------------------------------PhysicalOlapScan[customer_address] apply RFs: RF4 +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((cd1.cd_demo_sk = web_returns.wr_refunded_cdemo_sk)) otherCondition=(OR[AND[(cd1.cd_marital_status = 'D'),(cd1.cd_education_status = 'Primary'),(web_sales.ws_sales_price >= 100.00),(web_sales.ws_sales_price <= 150.00)],AND[(cd1.cd_marital_status = 'S'),(cd1.cd_education_status = 'College'),(web_sales.ws_sales_price <= 100.00)],AND[(cd1.cd_marital_status = 'U'),(cd1.cd_education_status = 'Advanced Degree'),(web_sales.ws_sales_price >= 150.00)]]) build RFs:RF3 cd_demo_sk->[wr_refunded_cdemo_sk] +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_item_sk = web_returns.wr_item_sk) and (web_sales.ws_order_number = web_returns.wr_order_number)) otherCondition=() build RFs:RF1 ws_item_sk->[wr_item_sk];RF2 ws_order_number->[wr_order_number] +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[web_returns] apply RFs: RF1 RF2 RF3 RF9 +----------------------------------------PhysicalProject +------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +--------------------------------------------PhysicalProject +----------------------------------------------filter((web_sales.ws_net_profit <= 300.00) and (web_sales.ws_net_profit >= 50.00) and (web_sales.ws_sales_price <= 200.00) and (web_sales.ws_sales_price >= 50.00)) +------------------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF5 +--------------------------------------------PhysicalProject +----------------------------------------------filter((date_dim.d_year = 1998)) +------------------------------------------------PhysicalOlapScan[date_dim] +------------------------------------PhysicalProject +--------------------------------------filter(OR[AND[(cd1.cd_marital_status = 'D'),(cd1.cd_education_status = 'Primary')],AND[(cd1.cd_marital_status = 'S'),(cd1.cd_education_status = 'College')],AND[(cd1.cd_marital_status = 'U'),(cd1.cd_education_status = 'Advanced Degree')]] and cd_education_status IN ('Advanced Degree', 'College', 'Primary') and cd_marital_status IN ('D', 'S', 'U')) +----------------------------------------PhysicalOlapScan[customer_demographics] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[web_page] +--------------------PhysicalProject +----------------------PhysicalOlapScan[reason] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query86.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query86.out new file mode 100644 index 00000000000000..85c7a026fb9a34 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query86.out @@ -0,0 +1,28 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_86_constraints -- +PhysicalResultSink +--PhysicalProject +----PhysicalTopN[MERGE_SORT] +------PhysicalDistribute[DistributionSpecGather] +--------PhysicalTopN[LOCAL_SORT] +----------PhysicalProject +------------PhysicalWindow +--------------PhysicalQuickSort[LOCAL_SORT] +----------------PhysicalDistribute[DistributionSpecHash] +------------------PhysicalProject +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalRepeat +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = web_sales.ws_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[ws_item_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((d1.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 +------------------------------------PhysicalProject +--------------------------------------filter((d1.d_month_seq <= 1197) and (d1.d_month_seq >= 1186)) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[item] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query87.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query87.out new file mode 100644 index 00000000000000..42ef577e4784d9 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query87.out @@ -0,0 +1,60 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_87_constraints -- +PhysicalResultSink +--hashAgg[GLOBAL] +----PhysicalDistribute[DistributionSpecGather] +------hashAgg[LOCAL] +--------PhysicalProject +----------PhysicalExcept +------------hashAgg[GLOBAL] +--------------PhysicalDistribute[DistributionSpecHash] +----------------hashAgg[LOCAL] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((store_sales.ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF1 c_customer_sk->[ss_customer_sk] +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 +--------------------------------PhysicalProject +----------------------------------filter((date_dim.d_month_seq <= 1213) and (date_dim.d_month_seq >= 1202)) +------------------------------------PhysicalOlapScan[date_dim] +----------------------PhysicalProject +------------------------PhysicalOlapScan[customer] +------------hashAgg[GLOBAL] +--------------PhysicalDistribute[DistributionSpecHash] +----------------hashAgg[LOCAL] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((catalog_sales.cs_bill_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[cs_bill_customer_sk] +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[cs_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF2 RF3 +--------------------------------PhysicalProject +----------------------------------filter((date_dim.d_month_seq <= 1213) and (date_dim.d_month_seq >= 1202)) +------------------------------------PhysicalOlapScan[date_dim] +----------------------PhysicalProject +------------------------PhysicalOlapScan[customer] +------------hashAgg[GLOBAL] +--------------PhysicalDistribute[DistributionSpecHash] +----------------hashAgg[LOCAL] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((web_sales.ws_bill_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 c_customer_sk->[ws_bill_customer_sk] +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ws_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[web_sales] apply RFs: RF4 RF5 +--------------------------------PhysicalProject +----------------------------------filter((date_dim.d_month_seq <= 1213) and (date_dim.d_month_seq >= 1202)) +------------------------------------PhysicalOlapScan[date_dim] +----------------------PhysicalProject +------------------------PhysicalOlapScan[customer] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query88.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query88.out new file mode 100644 index 00000000000000..bd8aa8ebd2c381 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query88.out @@ -0,0 +1,171 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_88_constraints -- +PhysicalResultSink +--NestedLoopJoin[CROSS_JOIN] +----NestedLoopJoin[CROSS_JOIN] +------NestedLoopJoin[CROSS_JOIN] +--------NestedLoopJoin[CROSS_JOIN] +----------NestedLoopJoin[CROSS_JOIN] +------------NestedLoopJoin[CROSS_JOIN] +--------------NestedLoopJoin[CROSS_JOIN] +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecGather] +--------------------hashAgg[LOCAL] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF23 s_store_sk->[ss_store_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk)) otherCondition=() build RFs:RF22 hd_demo_sk->[ss_hdemo_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_time_sk = time_dim.t_time_sk)) otherCondition=() build RFs:RF21 t_time_sk->[ss_sold_time_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF21 RF22 RF23 +----------------------------------PhysicalProject +------------------------------------filter((time_dim.t_hour = 8) and (time_dim.t_minute >= 30)) +--------------------------------------PhysicalOlapScan[time_dim] +------------------------------PhysicalProject +--------------------------------filter((household_demographics.hd_vehicle_count <= 5) and OR[AND[(household_demographics.hd_dep_count = 0),(household_demographics.hd_vehicle_count <= 2)],AND[(household_demographics.hd_dep_count = -1),(household_demographics.hd_vehicle_count <= 1)],(household_demographics.hd_dep_count = 3)] and hd_dep_count IN (-1, 0, 3)) +----------------------------------PhysicalOlapScan[household_demographics] +--------------------------PhysicalProject +----------------------------filter((store.s_store_name = 'ese')) +------------------------------PhysicalOlapScan[store] +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecGather] +--------------------hashAgg[LOCAL] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF20 s_store_sk->[ss_store_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk)) otherCondition=() build RFs:RF19 hd_demo_sk->[ss_hdemo_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_time_sk = time_dim.t_time_sk)) otherCondition=() build RFs:RF18 t_time_sk->[ss_sold_time_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF18 RF19 RF20 +----------------------------------PhysicalProject +------------------------------------filter((time_dim.t_hour = 9) and (time_dim.t_minute < 30)) +--------------------------------------PhysicalOlapScan[time_dim] +------------------------------PhysicalProject +--------------------------------filter((household_demographics.hd_vehicle_count <= 5) and OR[AND[(household_demographics.hd_dep_count = 0),(household_demographics.hd_vehicle_count <= 2)],AND[(household_demographics.hd_dep_count = -1),(household_demographics.hd_vehicle_count <= 1)],(household_demographics.hd_dep_count = 3)] and hd_dep_count IN (-1, 0, 3)) +----------------------------------PhysicalOlapScan[household_demographics] +--------------------------PhysicalProject +----------------------------filter((store.s_store_name = 'ese')) +------------------------------PhysicalOlapScan[store] +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecGather] +------------------hashAgg[LOCAL] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF17 s_store_sk->[ss_store_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk)) otherCondition=() build RFs:RF16 hd_demo_sk->[ss_hdemo_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_time_sk = time_dim.t_time_sk)) otherCondition=() build RFs:RF15 t_time_sk->[ss_sold_time_sk] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[store_sales] apply RFs: RF15 RF16 RF17 +--------------------------------PhysicalProject +----------------------------------filter((time_dim.t_hour = 9) and (time_dim.t_minute >= 30)) +------------------------------------PhysicalOlapScan[time_dim] +----------------------------PhysicalProject +------------------------------filter((household_demographics.hd_vehicle_count <= 5) and OR[AND[(household_demographics.hd_dep_count = 0),(household_demographics.hd_vehicle_count <= 2)],AND[(household_demographics.hd_dep_count = -1),(household_demographics.hd_vehicle_count <= 1)],(household_demographics.hd_dep_count = 3)] and hd_dep_count IN (-1, 0, 3)) +--------------------------------PhysicalOlapScan[household_demographics] +------------------------PhysicalProject +--------------------------filter((store.s_store_name = 'ese')) +----------------------------PhysicalOlapScan[store] +------------hashAgg[GLOBAL] +--------------PhysicalDistribute[DistributionSpecGather] +----------------hashAgg[LOCAL] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF14 s_store_sk->[ss_store_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk)) otherCondition=() build RFs:RF13 hd_demo_sk->[ss_hdemo_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_time_sk = time_dim.t_time_sk)) otherCondition=() build RFs:RF12 t_time_sk->[ss_sold_time_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[store_sales] apply RFs: RF12 RF13 RF14 +------------------------------PhysicalProject +--------------------------------filter((time_dim.t_hour = 10) and (time_dim.t_minute < 30)) +----------------------------------PhysicalOlapScan[time_dim] +--------------------------PhysicalProject +----------------------------filter((household_demographics.hd_vehicle_count <= 5) and OR[AND[(household_demographics.hd_dep_count = 0),(household_demographics.hd_vehicle_count <= 2)],AND[(household_demographics.hd_dep_count = -1),(household_demographics.hd_vehicle_count <= 1)],(household_demographics.hd_dep_count = 3)] and hd_dep_count IN (-1, 0, 3)) +------------------------------PhysicalOlapScan[household_demographics] +----------------------PhysicalProject +------------------------filter((store.s_store_name = 'ese')) +--------------------------PhysicalOlapScan[store] +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecGather] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF11 s_store_sk->[ss_store_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk)) otherCondition=() build RFs:RF10 hd_demo_sk->[ss_hdemo_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_time_sk = time_dim.t_time_sk)) otherCondition=() build RFs:RF9 t_time_sk->[ss_sold_time_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[store_sales] apply RFs: RF9 RF10 RF11 +----------------------------PhysicalProject +------------------------------filter((time_dim.t_hour = 10) and (time_dim.t_minute >= 30)) +--------------------------------PhysicalOlapScan[time_dim] +------------------------PhysicalProject +--------------------------filter((household_demographics.hd_vehicle_count <= 5) and OR[AND[(household_demographics.hd_dep_count = 0),(household_demographics.hd_vehicle_count <= 2)],AND[(household_demographics.hd_dep_count = -1),(household_demographics.hd_vehicle_count <= 1)],(household_demographics.hd_dep_count = 3)] and hd_dep_count IN (-1, 0, 3)) +----------------------------PhysicalOlapScan[household_demographics] +--------------------PhysicalProject +----------------------filter((store.s_store_name = 'ese')) +------------------------PhysicalOlapScan[store] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecGather] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF8 s_store_sk->[ss_store_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk)) otherCondition=() build RFs:RF7 hd_demo_sk->[ss_hdemo_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_time_sk = time_dim.t_time_sk)) otherCondition=() build RFs:RF6 t_time_sk->[ss_sold_time_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[store_sales] apply RFs: RF6 RF7 RF8 +--------------------------PhysicalProject +----------------------------filter((time_dim.t_hour = 11) and (time_dim.t_minute < 30)) +------------------------------PhysicalOlapScan[time_dim] +----------------------PhysicalProject +------------------------filter((household_demographics.hd_vehicle_count <= 5) and OR[AND[(household_demographics.hd_dep_count = 0),(household_demographics.hd_vehicle_count <= 2)],AND[(household_demographics.hd_dep_count = -1),(household_demographics.hd_vehicle_count <= 1)],(household_demographics.hd_dep_count = 3)] and hd_dep_count IN (-1, 0, 3)) +--------------------------PhysicalOlapScan[household_demographics] +------------------PhysicalProject +--------------------filter((store.s_store_name = 'ese')) +----------------------PhysicalOlapScan[store] +------hashAgg[GLOBAL] +--------PhysicalDistribute[DistributionSpecGather] +----------hashAgg[LOCAL] +------------PhysicalProject +--------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF5 s_store_sk->[ss_store_sk] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk)) otherCondition=() build RFs:RF4 hd_demo_sk->[ss_hdemo_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_time_sk = time_dim.t_time_sk)) otherCondition=() build RFs:RF3 t_time_sk->[ss_sold_time_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[store_sales] apply RFs: RF3 RF4 RF5 +------------------------PhysicalProject +--------------------------filter((time_dim.t_hour = 11) and (time_dim.t_minute >= 30)) +----------------------------PhysicalOlapScan[time_dim] +--------------------PhysicalProject +----------------------filter((household_demographics.hd_vehicle_count <= 5) and OR[AND[(household_demographics.hd_dep_count = 0),(household_demographics.hd_vehicle_count <= 2)],AND[(household_demographics.hd_dep_count = -1),(household_demographics.hd_vehicle_count <= 1)],(household_demographics.hd_dep_count = 3)] and hd_dep_count IN (-1, 0, 3)) +------------------------PhysicalOlapScan[household_demographics] +----------------PhysicalProject +------------------filter((store.s_store_name = 'ese')) +--------------------PhysicalOlapScan[store] +----hashAgg[GLOBAL] +------PhysicalDistribute[DistributionSpecGather] +--------hashAgg[LOCAL] +----------PhysicalProject +------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF2 s_store_sk->[ss_store_sk] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk)) otherCondition=() build RFs:RF1 hd_demo_sk->[ss_hdemo_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_time_sk = time_dim.t_time_sk)) otherCondition=() build RFs:RF0 t_time_sk->[ss_sold_time_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 +----------------------PhysicalProject +------------------------filter((time_dim.t_hour = 12) and (time_dim.t_minute < 30)) +--------------------------PhysicalOlapScan[time_dim] +------------------PhysicalProject +--------------------filter((household_demographics.hd_vehicle_count <= 5) and OR[AND[(household_demographics.hd_dep_count = 0),(household_demographics.hd_vehicle_count <= 2)],AND[(household_demographics.hd_dep_count = -1),(household_demographics.hd_vehicle_count <= 1)],(household_demographics.hd_dep_count = 3)] and hd_dep_count IN (-1, 0, 3)) +----------------------PhysicalOlapScan[household_demographics] +--------------PhysicalProject +----------------filter((store.s_store_name = 'ese')) +------------------PhysicalOlapScan[store] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query89.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query89.out new file mode 100644 index 00000000000000..432498de4e9739 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query89.out @@ -0,0 +1,31 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_89_constraints -- +PhysicalResultSink +--PhysicalProject +----PhysicalTopN[MERGE_SORT] +------PhysicalDistribute[DistributionSpecGather] +--------PhysicalTopN[LOCAL_SORT] +----------PhysicalProject +------------filter(( not (avg_monthly_sales = 0.0000)) and ((cast(abs((sum_sales - cast(avg_monthly_sales as DECIMALV3(38, 2)))) as DECIMALV3(38, 10)) / tmp1.avg_monthly_sales) > 0.100000)) +--------------PhysicalWindow +----------------PhysicalQuickSort[LOCAL_SORT] +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF2 s_store_sk->[ss_store_sk] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[ss_item_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 +------------------------------------PhysicalProject +--------------------------------------filter(OR[AND[i_category IN ('Books', 'Children', 'Electronics'),i_class IN ('audio', 'history', 'school-uniforms')],AND[i_category IN ('Men', 'Shoes', 'Sports'),i_class IN ('pants', 'tennis', 'womens')]] and i_category IN ('Books', 'Children', 'Electronics', 'Men', 'Shoes', 'Sports') and i_class IN ('audio', 'history', 'pants', 'school-uniforms', 'tennis', 'womens')) +----------------------------------------PhysicalOlapScan[item] +--------------------------------PhysicalProject +----------------------------------filter((date_dim.d_year = 2001)) +------------------------------------PhysicalOlapScan[date_dim] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[store] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query9.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query9.out new file mode 100644 index 00000000000000..8f6d851b0713e2 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query9.out @@ -0,0 +1,115 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_9_constraints -- +PhysicalResultSink +--PhysicalDistribute[DistributionSpecGather] +----PhysicalProject +------NestedLoopJoin[CROSS_JOIN] +--------NestedLoopJoin[CROSS_JOIN] +----------NestedLoopJoin[CROSS_JOIN] +------------NestedLoopJoin[CROSS_JOIN] +--------------NestedLoopJoin[CROSS_JOIN] +----------------NestedLoopJoin[CROSS_JOIN] +------------------NestedLoopJoin[CROSS_JOIN] +--------------------NestedLoopJoin[CROSS_JOIN] +----------------------NestedLoopJoin[CROSS_JOIN] +------------------------NestedLoopJoin[CROSS_JOIN] +--------------------------NestedLoopJoin[CROSS_JOIN] +----------------------------NestedLoopJoin[CROSS_JOIN] +------------------------------NestedLoopJoin[CROSS_JOIN] +--------------------------------NestedLoopJoin[CROSS_JOIN] +----------------------------------PhysicalProject +------------------------------------NestedLoopJoin[CROSS_JOIN] +--------------------------------------PhysicalProject +----------------------------------------filter((reason.r_reason_sk = 1)) +------------------------------------------PhysicalOlapScan[reason] +--------------------------------------hashAgg[GLOBAL] +----------------------------------------PhysicalDistribute[DistributionSpecGather] +------------------------------------------hashAgg[LOCAL] +--------------------------------------------PhysicalProject +----------------------------------------------filter((store_sales.ss_quantity <= 20) and (store_sales.ss_quantity >= 1)) +------------------------------------------------PhysicalOlapScan[store_sales] +----------------------------------hashAgg[GLOBAL] +------------------------------------PhysicalDistribute[DistributionSpecGather] +--------------------------------------hashAgg[LOCAL] +----------------------------------------PhysicalProject +------------------------------------------filter((store_sales.ss_quantity <= 20) and (store_sales.ss_quantity >= 1)) +--------------------------------------------PhysicalOlapScan[store_sales] +--------------------------------hashAgg[GLOBAL] +----------------------------------PhysicalDistribute[DistributionSpecGather] +------------------------------------hashAgg[LOCAL] +--------------------------------------PhysicalProject +----------------------------------------filter((store_sales.ss_quantity <= 20) and (store_sales.ss_quantity >= 1)) +------------------------------------------PhysicalOlapScan[store_sales] +------------------------------hashAgg[GLOBAL] +--------------------------------PhysicalDistribute[DistributionSpecGather] +----------------------------------hashAgg[LOCAL] +------------------------------------PhysicalProject +--------------------------------------filter((store_sales.ss_quantity <= 40) and (store_sales.ss_quantity >= 21)) +----------------------------------------PhysicalOlapScan[store_sales] +----------------------------hashAgg[GLOBAL] +------------------------------PhysicalDistribute[DistributionSpecGather] +--------------------------------hashAgg[LOCAL] +----------------------------------PhysicalProject +------------------------------------filter((store_sales.ss_quantity <= 40) and (store_sales.ss_quantity >= 21)) +--------------------------------------PhysicalOlapScan[store_sales] +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecGather] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------filter((store_sales.ss_quantity <= 40) and (store_sales.ss_quantity >= 21)) +------------------------------------PhysicalOlapScan[store_sales] +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecGather] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------filter((store_sales.ss_quantity <= 60) and (store_sales.ss_quantity >= 41)) +----------------------------------PhysicalOlapScan[store_sales] +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecGather] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------filter((store_sales.ss_quantity <= 60) and (store_sales.ss_quantity >= 41)) +--------------------------------PhysicalOlapScan[store_sales] +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecGather] +------------------------hashAgg[LOCAL] +--------------------------PhysicalProject +----------------------------filter((store_sales.ss_quantity <= 60) and (store_sales.ss_quantity >= 41)) +------------------------------PhysicalOlapScan[store_sales] +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecGather] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------filter((store_sales.ss_quantity <= 80) and (store_sales.ss_quantity >= 61)) +----------------------------PhysicalOlapScan[store_sales] +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecGather] +--------------------hashAgg[LOCAL] +----------------------PhysicalProject +------------------------filter((store_sales.ss_quantity <= 80) and (store_sales.ss_quantity >= 61)) +--------------------------PhysicalOlapScan[store_sales] +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecGather] +------------------hashAgg[LOCAL] +--------------------PhysicalProject +----------------------filter((store_sales.ss_quantity <= 80) and (store_sales.ss_quantity >= 61)) +------------------------PhysicalOlapScan[store_sales] +------------hashAgg[GLOBAL] +--------------PhysicalDistribute[DistributionSpecGather] +----------------hashAgg[LOCAL] +------------------PhysicalProject +--------------------filter((store_sales.ss_quantity <= 100) and (store_sales.ss_quantity >= 81)) +----------------------PhysicalOlapScan[store_sales] +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecGather] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------filter((store_sales.ss_quantity <= 100) and (store_sales.ss_quantity >= 81)) +--------------------PhysicalOlapScan[store_sales] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecGather] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------filter((store_sales.ss_quantity <= 100) and (store_sales.ss_quantity >= 81)) +------------------PhysicalOlapScan[store_sales] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query90.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query90.out new file mode 100644 index 00000000000000..74179463a22685 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query90.out @@ -0,0 +1,47 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_90_constraints -- +PhysicalResultSink +--PhysicalTopN[GATHER_SORT] +----PhysicalProject +------NestedLoopJoin[CROSS_JOIN] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecGather] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_web_page_sk = web_page.wp_web_page_sk)) otherCondition=() build RFs:RF5 wp_web_page_sk->[ws_web_page_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_ship_hdemo_sk = household_demographics.hd_demo_sk)) otherCondition=() build RFs:RF4 hd_demo_sk->[ws_ship_hdemo_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_time_sk = time_dim.t_time_sk)) otherCondition=() build RFs:RF3 t_time_sk->[ws_sold_time_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[web_sales] apply RFs: RF3 RF4 RF5 +--------------------------PhysicalProject +----------------------------filter((time_dim.t_hour <= 13) and (time_dim.t_hour >= 12)) +------------------------------PhysicalOlapScan[time_dim] +----------------------PhysicalProject +------------------------filter((household_demographics.hd_dep_count = 6)) +--------------------------PhysicalOlapScan[household_demographics] +------------------PhysicalProject +--------------------filter((web_page.wp_char_count <= 5200) and (web_page.wp_char_count >= 5000)) +----------------------PhysicalOlapScan[web_page] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecGather] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_web_page_sk = web_page.wp_web_page_sk)) otherCondition=() build RFs:RF2 wp_web_page_sk->[ws_web_page_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_ship_hdemo_sk = household_demographics.hd_demo_sk)) otherCondition=() build RFs:RF1 hd_demo_sk->[ws_ship_hdemo_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_time_sk = time_dim.t_time_sk)) otherCondition=() build RFs:RF0 t_time_sk->[ws_sold_time_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 RF2 +--------------------------PhysicalProject +----------------------------filter((time_dim.t_hour <= 15) and (time_dim.t_hour >= 14)) +------------------------------PhysicalOlapScan[time_dim] +----------------------PhysicalProject +------------------------filter((household_demographics.hd_dep_count = 6)) +--------------------------PhysicalOlapScan[household_demographics] +------------------PhysicalProject +--------------------filter((web_page.wp_char_count <= 5200) and (web_page.wp_char_count >= 5000)) +----------------------PhysicalOlapScan[web_page] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query91.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query91.out new file mode 100644 index 00000000000000..736f1c52f44f96 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query91.out @@ -0,0 +1,41 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_91_constraints -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_returns.cr_call_center_sk = call_center.cc_call_center_sk)) otherCondition=() build RFs:RF5 cc_call_center_sk->[cr_call_center_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_returns.cr_returned_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[cr_returned_date_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_returns.cr_returning_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[cr_returning_customer_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[catalog_returns] apply RFs: RF3 RF4 RF5 +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer_address.ca_address_sk = customer.c_current_addr_sk)) otherCondition=() build RFs:RF2 c_current_addr_sk->[ca_address_sk] +--------------------------------PhysicalProject +----------------------------------filter((customer_address.ca_gmt_offset = -7.00)) +------------------------------------PhysicalOlapScan[customer_address] apply RFs: RF2 +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((household_demographics.hd_demo_sk = customer.c_current_hdemo_sk)) otherCondition=() build RFs:RF1 hd_demo_sk->[c_current_hdemo_sk] +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer_demographics.cd_demo_sk = customer.c_current_cdemo_sk)) otherCondition=() build RFs:RF0 cd_demo_sk->[c_current_cdemo_sk] +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[customer] apply RFs: RF0 RF1 +----------------------------------------PhysicalProject +------------------------------------------filter(OR[AND[(customer_demographics.cd_marital_status = 'M'),(customer_demographics.cd_education_status = 'Unknown')],AND[(customer_demographics.cd_marital_status = 'W'),(customer_demographics.cd_education_status = 'Advanced Degree')]] and cd_education_status IN ('Advanced Degree', 'Unknown') and cd_marital_status IN ('M', 'W')) +--------------------------------------------PhysicalOlapScan[customer_demographics] +------------------------------------PhysicalProject +--------------------------------------filter((hd_buy_potential like 'Unknown%')) +----------------------------------------PhysicalOlapScan[household_demographics] +------------------------PhysicalProject +--------------------------filter((date_dim.d_moy = 12) and (date_dim.d_year = 2000)) +----------------------------PhysicalOlapScan[date_dim] +--------------------PhysicalProject +----------------------PhysicalOlapScan[call_center] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query92.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query92.out new file mode 100644 index 00000000000000..7703b53d615986 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query92.out @@ -0,0 +1,25 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_92_constraints -- +PhysicalResultSink +--PhysicalTopN[GATHER_SORT] +----hashAgg[GLOBAL] +------PhysicalDistribute[DistributionSpecGather] +--------hashAgg[LOCAL] +----------PhysicalProject +------------filter((cast(ws_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(ws_ext_discount_amt) OVER(PARTITION BY i_item_sk)))) +--------------PhysicalWindow +----------------PhysicalQuickSort[LOCAL_SORT] +------------------PhysicalDistribute[DistributionSpecHash] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = web_sales.ws_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[ws_item_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 +----------------------------PhysicalProject +------------------------------filter((item.i_manufact_id = 714)) +--------------------------------PhysicalOlapScan[item] +------------------------PhysicalProject +--------------------------filter((date_dim.d_date <= '2000-05-01') and (date_dim.d_date >= '2000-02-01')) +----------------------------PhysicalOlapScan[date_dim] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query93.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query93.out new file mode 100644 index 00000000000000..489512843e2513 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query93.out @@ -0,0 +1,21 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_93_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((store_returns.sr_item_sk = store_sales.ss_item_sk) and (store_returns.sr_ticket_number = store_sales.ss_ticket_number)) otherCondition=() build RFs:RF1 sr_item_sk->[ss_item_sk];RF2 sr_ticket_number->[ss_ticket_number] +------------------PhysicalProject +--------------------PhysicalOlapScan[store_sales] apply RFs: RF1 RF2 +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_returns.sr_reason_sk = reason.r_reason_sk)) otherCondition=() build RFs:RF0 r_reason_sk->[sr_reason_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[store_returns] apply RFs: RF0 +----------------------PhysicalProject +------------------------filter((reason.r_reason_desc = 'reason 58')) +--------------------------PhysicalOlapScan[reason] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query94.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query94.out new file mode 100644 index 00000000000000..d2e32764ac35a6 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query94.out @@ -0,0 +1,35 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_94_constraints -- +PhysicalResultSink +--PhysicalLimit[GLOBAL] +----PhysicalLimit[LOCAL] +------hashAgg[DISTINCT_GLOBAL] +--------PhysicalDistribute[DistributionSpecGather] +----------hashAgg[DISTINCT_LOCAL] +------------hashAgg[GLOBAL] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------hashJoin[RIGHT_SEMI_JOIN shuffleBucket] hashCondition=((ws1.ws_order_number = ws2.ws_order_number)) otherCondition=(( not (ws_warehouse_sk = ws_warehouse_sk))) build RFs:RF4 ws_order_number->[ws_order_number] +--------------------PhysicalProject +----------------------PhysicalOlapScan[web_sales] apply RFs: RF4 +--------------------hashJoin[RIGHT_ANTI_JOIN shuffle] hashCondition=((ws1.ws_order_number = wr1.wr_order_number)) otherCondition=() build RFs:RF3 ws_order_number->[wr_order_number] +----------------------PhysicalProject +------------------------PhysicalOlapScan[web_returns] apply RFs: RF3 +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((ws1.ws_web_site_sk = web_site.web_site_sk)) otherCondition=() build RFs:RF2 web_site_sk->[ws_web_site_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((ws1.ws_ship_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_ship_date_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((ws1.ws_ship_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF0 ca_address_sk->[ws_ship_addr_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 RF2 +----------------------------------PhysicalProject +------------------------------------filter((customer_address.ca_state = 'OK')) +--------------------------------------PhysicalOlapScan[customer_address] +------------------------------PhysicalProject +--------------------------------filter((date_dim.d_date <= '2002-06-30') and (date_dim.d_date >= '2002-05-01')) +----------------------------------PhysicalOlapScan[date_dim] +--------------------------PhysicalProject +----------------------------filter((web_site.web_company_name = 'pri')) +------------------------------PhysicalOlapScan[web_site] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query95.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query95.out new file mode 100644 index 00000000000000..6f2387bf13d7ba --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query95.out @@ -0,0 +1,44 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_95_constraints -- +PhysicalCteAnchor ( cteId=CTEId#0 ) +--PhysicalCteProducer ( cteId=CTEId#0 ) +----PhysicalProject +------hashJoin[INNER_JOIN shuffle] hashCondition=((ws1.ws_order_number = ws2.ws_order_number)) otherCondition=(( not (ws_warehouse_sk = ws_warehouse_sk))) build RFs:RF0 ws_order_number->[ws_order_number] +--------PhysicalProject +----------PhysicalOlapScan[web_sales] apply RFs: RF0 RF7 +--------PhysicalProject +----------PhysicalOlapScan[web_sales] apply RFs: RF7 +--PhysicalResultSink +----PhysicalLimit[GLOBAL] +------PhysicalLimit[LOCAL] +--------hashAgg[DISTINCT_GLOBAL] +----------PhysicalDistribute[DistributionSpecGather] +------------hashAgg[DISTINCT_LOCAL] +--------------hashAgg[GLOBAL] +----------------hashAgg[LOCAL] +------------------hashJoin[RIGHT_SEMI_JOIN colocated] hashCondition=((ws1.ws_order_number = web_returns.wr_order_number)) otherCondition=() build RFs:RF6 ws_order_number->[wr_order_number,ws_order_number] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN shuffle] hashCondition=((web_returns.wr_order_number = ws_wh.ws_order_number)) otherCondition=() build RFs:RF5 wr_order_number->[ws_order_number] +------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 RF6 +------------------------PhysicalProject +--------------------------PhysicalOlapScan[web_returns] apply RFs: RF6 +--------------------hashJoin[RIGHT_SEMI_JOIN shuffle] hashCondition=((ws1.ws_order_number = ws_wh.ws_order_number)) otherCondition=() build RFs:RF7 ws_order_number->[ws_order_number,ws_order_number] +----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((ws1.ws_web_site_sk = web_site.web_site_sk)) otherCondition=() build RFs:RF3 web_site_sk->[ws_web_site_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((ws1.ws_ship_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_ship_date_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((ws1.ws_ship_addr_sk = customer_address.ca_address_sk)) otherCondition=() build RFs:RF1 ca_address_sk->[ws_ship_addr_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 RF2 RF3 +----------------------------------PhysicalProject +------------------------------------filter((customer_address.ca_state = 'VA')) +--------------------------------------PhysicalOlapScan[customer_address] +------------------------------PhysicalProject +--------------------------------filter((date_dim.d_date <= '2001-05-31') and (date_dim.d_date >= '2001-04-01')) +----------------------------------PhysicalOlapScan[date_dim] +--------------------------PhysicalProject +----------------------------filter((web_site.web_company_name = 'pri')) +------------------------------PhysicalOlapScan[web_site] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query96.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query96.out new file mode 100644 index 00000000000000..cec35cc022e70c --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query96.out @@ -0,0 +1,26 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_96_constraints -- +PhysicalResultSink +--PhysicalLimit[GLOBAL] +----PhysicalLimit[LOCAL] +------hashAgg[GLOBAL] +--------PhysicalDistribute[DistributionSpecGather] +----------hashAgg[LOCAL] +------------PhysicalProject +--------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() build RFs:RF2 s_store_sk->[ss_store_sk] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk)) otherCondition=() build RFs:RF1 hd_demo_sk->[ss_hdemo_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_time_sk = time_dim.t_time_sk)) otherCondition=() build RFs:RF0 t_time_sk->[ss_sold_time_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 RF2 +------------------------PhysicalProject +--------------------------filter((time_dim.t_hour = 8) and (time_dim.t_minute >= 30)) +----------------------------PhysicalOlapScan[time_dim] +--------------------PhysicalProject +----------------------filter((household_demographics.hd_dep_count = 0)) +------------------------PhysicalOlapScan[household_demographics] +----------------PhysicalProject +------------------filter((store.s_store_name = 'ese')) +--------------------PhysicalOlapScan[store] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query97.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query97.out new file mode 100644 index 00000000000000..4466a5ad525ba4 --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query97.out @@ -0,0 +1,35 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_97_constraints -- +PhysicalResultSink +--PhysicalLimit[GLOBAL] +----PhysicalLimit[LOCAL] +------hashAgg[GLOBAL] +--------PhysicalDistribute[DistributionSpecGather] +----------hashAgg[LOCAL] +------------PhysicalProject +--------------hashJoin[FULL_OUTER_JOIN colocated] hashCondition=((ssci.customer_sk = csci.customer_sk) and (ssci.item_sk = csci.item_sk)) otherCondition=() +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +----------------------------PhysicalProject +------------------------------filter(( not ss_sold_date_sk IS NULL)) +--------------------------------PhysicalOlapScan[store_sales] apply RFs: RF1 +----------------------------PhysicalProject +------------------------------filter((date_dim.d_month_seq <= 1210) and (date_dim.d_month_seq >= 1199)) +--------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[cs_sold_date_sk] +----------------------------PhysicalProject +------------------------------filter(( not cs_sold_date_sk IS NULL)) +--------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 +----------------------------PhysicalProject +------------------------------filter((date_dim.d_month_seq <= 1210) and (date_dim.d_month_seq >= 1199)) +--------------------------------PhysicalOlapScan[date_dim] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query98.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query98.out new file mode 100644 index 00000000000000..5e10447562a51b --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query98.out @@ -0,0 +1,29 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_98_constraints -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------PhysicalProject +----------PhysicalWindow +------------PhysicalQuickSort[LOCAL_SORT] +--------------PhysicalDistribute[DistributionSpecHash] +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecHash] +--------------------hashAgg[LOCAL] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[ss_item_sk] +------------------------------hashAgg[GLOBAL] +--------------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------------hashAgg[LOCAL] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 +------------------------------PhysicalProject +--------------------------------filter(i_category IN ('Jewelry', 'Men', 'Sports')) +----------------------------------PhysicalOlapScan[item] +--------------------------PhysicalProject +----------------------------filter((date_dim.d_date <= '1999-03-07') and (date_dim.d_date >= '1999-02-05')) +------------------------------PhysicalOlapScan[date_dim] + diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query99.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query99.out new file mode 100644 index 00000000000000..a1b32ec0b25e5a --- /dev/null +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query99.out @@ -0,0 +1,29 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !ds_shape_99_constraints -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_call_center_sk = call_center.cc_call_center_sk)) otherCondition=() build RFs:RF3 cc_call_center_sk->[cs_call_center_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_ship_mode_sk = ship_mode.sm_ship_mode_sk)) otherCondition=() build RFs:RF2 sm_ship_mode_sk->[cs_ship_mode_sk] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_warehouse_sk = warehouse.w_warehouse_sk)) otherCondition=() build RFs:RF1 w_warehouse_sk->[cs_warehouse_sk] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_ship_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[cs_ship_date_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 RF2 RF3 +------------------------------PhysicalProject +--------------------------------filter((date_dim.d_month_seq <= 1205) and (date_dim.d_month_seq >= 1194)) +----------------------------------PhysicalOlapScan[date_dim] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[warehouse] +----------------------PhysicalProject +------------------------PhysicalOlapScan[ship_mode] +------------------PhysicalProject +--------------------PhysicalOlapScan[call_center] + diff --git a/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query32.out b/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query32.out index b08ae2d4c58926..cf1b7ad8b62cdc 100644 --- a/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query32.out +++ b/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query32.out @@ -7,19 +7,26 @@ PhysicalResultSink --------PhysicalDistribute[DistributionSpecGather] ----------hashAgg[LOCAL] ------------PhysicalProject ---------------filter((cast(cs_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(cs_ext_discount_amt) OVER(PARTITION BY i_item_sk)))) -----------------PhysicalWindow -------------------PhysicalQuickSort[LOCAL_SORT] ---------------------PhysicalDistribute[DistributionSpecHash] +--------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((catalog_sales.cs_item_sk = item.i_item_sk)) otherCondition=((cast(cs_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(cs_ext_discount_amt)))) build RFs:RF3 cs_item_sk->[cs_item_sk,i_item_sk] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[cs_sold_date_sk] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = catalog_sales.cs_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[cs_item_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF1 RF2 RF3 +------------------------PhysicalProject +--------------------------filter((item.i_manufact_id = 66)) +----------------------------PhysicalOlapScan[item] apply RFs: RF3 +--------------------PhysicalProject +----------------------filter((date_dim.d_date <= '2002-06-27') and (date_dim.d_date >= '2002-03-29')) +------------------------PhysicalOlapScan[date_dim] +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecHash] +--------------------hashAgg[LOCAL] ----------------------PhysicalProject -------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk] +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = catalog_sales.cs_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[cs_sold_date_sk] --------------------------PhysicalProject -----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = catalog_sales.cs_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[cs_item_sk] -------------------------------PhysicalProject ---------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 -------------------------------PhysicalProject ---------------------------------filter((item.i_manufact_id = 66)) -----------------------------------PhysicalOlapScan[item] +----------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 --------------------------PhysicalProject ----------------------------filter((date_dim.d_date <= '2002-06-27') and (date_dim.d_date >= '2002-03-29')) ------------------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query92.out b/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query92.out index bea3077e4fef9d..9137e13b593527 100644 --- a/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query92.out +++ b/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query92.out @@ -6,19 +6,26 @@ PhysicalResultSink ------PhysicalDistribute[DistributionSpecGather] --------hashAgg[LOCAL] ----------PhysicalProject -------------filter((cast(ws_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(ws_ext_discount_amt) OVER(PARTITION BY i_item_sk)))) ---------------PhysicalWindow -----------------PhysicalQuickSort[LOCAL_SORT] -------------------PhysicalDistribute[DistributionSpecHash] +------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((web_sales.ws_item_sk = item.i_item_sk)) otherCondition=((cast(ws_ext_discount_amt as DECIMALV3(38, 5)) > (1.3 * avg(ws_ext_discount_amt)))) build RFs:RF3 ws_item_sk->[i_item_sk,ws_item_sk] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = web_sales.ws_item_sk)) otherCondition=() build RFs:RF1 i_item_sk->[ws_item_sk] +----------------------PhysicalProject +------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 RF2 RF3 +----------------------PhysicalProject +------------------------filter((item.i_manufact_id = 356)) +--------------------------PhysicalOlapScan[item] apply RFs: RF3 +------------------PhysicalProject +--------------------filter((date_dim.d_date <= '2001-06-10') and (date_dim.d_date >= '2001-03-12')) +----------------------PhysicalOlapScan[date_dim] +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] --------------------PhysicalProject -----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((date_dim.d_date_sk = web_sales.ws_sold_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] ------------------------PhysicalProject ---------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((item.i_item_sk = web_sales.ws_item_sk)) otherCondition=() build RFs:RF0 i_item_sk->[ws_item_sk] -----------------------------PhysicalProject -------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 -----------------------------PhysicalProject -------------------------------filter((item.i_manufact_id = 356)) ---------------------------------PhysicalOlapScan[item] +--------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 ------------------------PhysicalProject --------------------------filter((date_dim.d_date <= '2001-06-10') and (date_dim.d_date >= '2001-03-12')) ----------------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpch_sf1000/hint/q17.out b/regression-test/data/shape_check/tpch_sf1000/hint/q17.out index 7846d2f3b5e569..a695fae4aa8e20 100644 --- a/regression-test/data/shape_check/tpch_sf1000/hint/q17.out +++ b/regression-test/data/shape_check/tpch_sf1000/hint/q17.out @@ -6,17 +6,19 @@ PhysicalResultSink ------PhysicalDistribute[DistributionSpecGather] --------hashAgg[LOCAL] ----------PhysicalProject -------------filter((cast(l_quantity as DECIMALV3(38, 5)) < (0.2 * avg(l_quantity) OVER(PARTITION BY p_partkey)))) ---------------PhysicalWindow -----------------PhysicalQuickSort[LOCAL_SORT] -------------------PhysicalDistribute[DistributionSpecHash] +------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((lineitem.l_partkey = part.p_partkey)) otherCondition=((cast(l_quantity as DECIMALV3(38, 5)) < (0.2 * avg(l_quantity)))) +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((part.p_partkey = lineitem.l_partkey)) otherCondition=() +------------------PhysicalProject +--------------------PhysicalOlapScan[lineitem] +------------------PhysicalProject +--------------------filter((part.p_brand = 'Brand#23') and (part.p_container = 'MED BOX')) +----------------------PhysicalOlapScan[part] +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] --------------------PhysicalProject -----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((part.p_partkey = lineitem.l_partkey)) otherCondition=() -------------------------PhysicalProject ---------------------------PhysicalOlapScan[lineitem] -------------------------PhysicalProject ---------------------------filter((part.p_brand = 'Brand#23') and (part.p_container = 'MED BOX')) -----------------------------PhysicalOlapScan[part] +----------------------PhysicalOlapScan[lineitem] Hint log: Used: leading(lineitem broadcast part ) diff --git a/regression-test/data/shape_check/tpch_sf1000/nostats_rf_prune/q17.out b/regression-test/data/shape_check/tpch_sf1000/nostats_rf_prune/q17.out index 6c1bc1d0fe8fe1..ace325ed81a6a4 100644 --- a/regression-test/data/shape_check/tpch_sf1000/nostats_rf_prune/q17.out +++ b/regression-test/data/shape_check/tpch_sf1000/nostats_rf_prune/q17.out @@ -6,14 +6,17 @@ PhysicalResultSink ------PhysicalDistribute[DistributionSpecGather] --------hashAgg[LOCAL] ----------PhysicalProject -------------filter((cast(l_quantity as DECIMALV3(38, 5)) < (0.2 * avg(l_quantity) OVER(PARTITION BY p_partkey)))) ---------------PhysicalWindow -----------------PhysicalQuickSort[LOCAL_SORT] +------------hashJoin[INNER_JOIN colocated] hashCondition=((lineitem.l_partkey = part.p_partkey)) otherCondition=((cast(l_quantity as DECIMALV3(38, 5)) < (0.2 * avg(l_quantity)))) +--------------PhysicalProject +----------------hashJoin[INNER_JOIN shuffle] hashCondition=((part.p_partkey = lineitem.l_partkey)) otherCondition=() build RFs:RF0 p_partkey->[l_partkey] ------------------PhysicalProject ---------------------hashJoin[INNER_JOIN shuffle] hashCondition=((part.p_partkey = lineitem.l_partkey)) otherCondition=() build RFs:RF0 p_partkey->[l_partkey] -----------------------PhysicalProject -------------------------PhysicalOlapScan[lineitem] apply RFs: RF0 -----------------------PhysicalProject -------------------------filter((part.p_brand = 'Brand#23') and (part.p_container = 'MED BOX')) ---------------------------PhysicalOlapScan[part] +--------------------PhysicalOlapScan[lineitem] apply RFs: RF0 +------------------PhysicalProject +--------------------filter((part.p_brand = 'Brand#23') and (part.p_container = 'MED BOX')) +----------------------PhysicalOlapScan[part] +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] +--------------------PhysicalProject +----------------------PhysicalOlapScan[lineitem] diff --git a/regression-test/data/shape_check/tpch_sf1000/nostats_rf_prune/q2.out b/regression-test/data/shape_check/tpch_sf1000/nostats_rf_prune/q2.out index 2bbd70beab96a1..c67285aeb01263 100644 --- a/regression-test/data/shape_check/tpch_sf1000/nostats_rf_prune/q2.out +++ b/regression-test/data/shape_check/tpch_sf1000/nostats_rf_prune/q2.out @@ -7,26 +7,40 @@ PhysicalResultSink --------PhysicalDistribute[DistributionSpecGather] ----------PhysicalTopN[LOCAL_SORT] ------------PhysicalProject ---------------filter((partsupp.ps_supplycost = min(ps_supplycost) OVER(PARTITION BY p_partkey))) -----------------PhysicalWindow -------------------PhysicalQuickSort[LOCAL_SORT] +--------------hashJoin[INNER_JOIN colocated] hashCondition=((part.p_partkey = partsupp.ps_partkey) and (partsupp.ps_supplycost = min(ps_supplycost))) otherCondition=() build RFs:RF7 min(ps_supplycost)->[ps_supplycost];RF8 ps_partkey->[p_partkey,ps_partkey] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((nation.n_regionkey = region.r_regionkey)) otherCondition=() build RFs:RF6 r_regionkey->[n_regionkey] --------------------PhysicalProject -----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((nation.n_regionkey = region.r_regionkey)) otherCondition=() build RFs:RF3 r_regionkey->[n_regionkey] +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF5 n_nationkey->[s_nationkey] ------------------------PhysicalProject ---------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF2 n_nationkey->[s_nationkey] +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_suppkey = partsupp.ps_suppkey)) otherCondition=() ----------------------------PhysicalProject -------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_suppkey = partsupp.ps_suppkey)) otherCondition=() +------------------------------hashJoin[INNER_JOIN colocated] hashCondition=((part.p_partkey = partsupp.ps_partkey)) otherCondition=() build RFs:RF3 p_partkey->[ps_partkey] --------------------------------PhysicalProject -----------------------------------hashJoin[INNER_JOIN colocated] hashCondition=((part.p_partkey = partsupp.ps_partkey)) otherCondition=() build RFs:RF0 p_partkey->[ps_partkey] -------------------------------------PhysicalProject ---------------------------------------PhysicalOlapScan[partsupp] apply RFs: RF0 -------------------------------------PhysicalProject ---------------------------------------filter((p_type like '%BRASS') and (part.p_size = 15)) -----------------------------------------PhysicalLazyMaterializeOlapScan[part lazySlots:(part.p_mfgr)] ---------------------------------PhysicalLazyMaterializeOlapScan[supplier lazySlots:(supplier.s_address,supplier.s_phone,supplier.s_comment)] apply RFs: RF2 -----------------------------PhysicalProject -------------------------------PhysicalOlapScan[nation] apply RFs: RF3 +----------------------------------PhysicalOlapScan[partsupp] apply RFs: RF3 RF7 RF8 +--------------------------------PhysicalProject +----------------------------------filter((p_type like '%BRASS') and (part.p_size = 15)) +------------------------------------PhysicalLazyMaterializeOlapScan[part lazySlots:(part.p_mfgr)] apply RFs: RF8 +----------------------------PhysicalLazyMaterializeOlapScan[supplier lazySlots:(supplier.s_address,supplier.s_phone,supplier.s_comment)] apply RFs: RF5 ------------------------PhysicalProject ---------------------------filter((region.r_name = 'EUROPE')) -----------------------------PhysicalOlapScan[region] +--------------------------PhysicalOlapScan[nation] apply RFs: RF6 +--------------------PhysicalProject +----------------------filter((region.r_name = 'EUROPE')) +------------------------PhysicalOlapScan[region] +----------------hashAgg[GLOBAL] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((nation.n_regionkey = region.r_regionkey)) otherCondition=() build RFs:RF2 r_regionkey->[n_regionkey] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF1 n_nationkey->[s_nationkey] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_suppkey = partsupp.ps_suppkey)) otherCondition=() build RFs:RF0 s_suppkey->[ps_suppkey] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[partsupp] apply RFs: RF0 +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[supplier] apply RFs: RF1 +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[nation] apply RFs: RF2 +----------------------PhysicalProject +------------------------filter((region.r_name = 'EUROPE')) +--------------------------PhysicalOlapScan[region] diff --git a/regression-test/data/shape_check/tpch_sf1000/rf_prune/q17.out b/regression-test/data/shape_check/tpch_sf1000/rf_prune/q17.out index 1fe52b08aa8035..261fc69b55e0f8 100644 --- a/regression-test/data/shape_check/tpch_sf1000/rf_prune/q17.out +++ b/regression-test/data/shape_check/tpch_sf1000/rf_prune/q17.out @@ -6,15 +6,17 @@ PhysicalResultSink ------PhysicalDistribute[DistributionSpecGather] --------hashAgg[LOCAL] ----------PhysicalProject -------------filter((cast(l_quantity as DECIMALV3(38, 5)) < (0.2 * avg(l_quantity) OVER(PARTITION BY p_partkey)))) ---------------PhysicalWindow -----------------PhysicalQuickSort[LOCAL_SORT] -------------------PhysicalDistribute[DistributionSpecHash] ---------------------PhysicalProject -----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((part.p_partkey = lineitem.l_partkey)) otherCondition=() build RFs:RF0 p_partkey->[l_partkey] +------------hashJoin[INNER_JOIN broadcast] hashCondition=((part.p_partkey = lineitem.l_partkey)) otherCondition=((cast(l_quantity as DECIMALV3(38, 5)) < (0.2 * avg(l_quantity)))) build RFs:RF1 p_partkey->[l_partkey] +--------------PhysicalProject +----------------PhysicalOlapScan[lineitem] apply RFs: RF1 +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((lineitem.l_partkey = part.p_partkey)) otherCondition=() build RFs:RF0 p_partkey->[l_partkey] +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] ------------------------PhysicalProject --------------------------PhysicalOlapScan[lineitem] apply RFs: RF0 -------------------------PhysicalProject ---------------------------filter((part.p_brand = 'Brand#23') and (part.p_container = 'MED BOX')) -----------------------------PhysicalOlapScan[part] +------------------PhysicalProject +--------------------filter((part.p_brand = 'Brand#23') and (part.p_container = 'MED BOX')) +----------------------PhysicalOlapScan[part] diff --git a/regression-test/data/shape_check/tpch_sf1000/rf_prune/q2.out b/regression-test/data/shape_check/tpch_sf1000/rf_prune/q2.out index 2a4aed95629cb3..7a4d0f7ce7bd2b 100644 --- a/regression-test/data/shape_check/tpch_sf1000/rf_prune/q2.out +++ b/regression-test/data/shape_check/tpch_sf1000/rf_prune/q2.out @@ -7,27 +7,40 @@ PhysicalResultSink --------PhysicalDistribute[DistributionSpecGather] ----------PhysicalTopN[LOCAL_SORT] ------------PhysicalProject ---------------filter((partsupp.ps_supplycost = min(ps_supplycost) OVER(PARTITION BY p_partkey))) -----------------PhysicalWindow -------------------PhysicalQuickSort[LOCAL_SORT] ---------------------PhysicalDistribute[DistributionSpecHash] +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((part.p_partkey = partsupp.ps_partkey) and (partsupp.ps_supplycost = min(ps_supplycost))) otherCondition=() build RFs:RF7 p_partkey->[ps_partkey] +----------------hashAgg[GLOBAL] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_suppkey = partsupp.ps_suppkey)) otherCondition=() build RFs:RF6 s_suppkey->[ps_suppkey] ----------------------PhysicalProject -------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((supplier.s_suppkey = partsupp.ps_suppkey)) otherCondition=() build RFs:RF3 ps_suppkey->[s_suppkey] +------------------------PhysicalOlapScan[partsupp] apply RFs: RF6 RF7 +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF5 n_nationkey->[s_nationkey] --------------------------PhysicalProject -----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF2 n_nationkey->[s_nationkey] -------------------------------PhysicalLazyMaterializeOlapScan[supplier lazySlots:(supplier.s_address,supplier.s_phone,supplier.s_comment)] apply RFs: RF2 RF3 -------------------------------PhysicalProject ---------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((nation.n_regionkey = region.r_regionkey)) otherCondition=() build RFs:RF1 r_regionkey->[n_regionkey] -----------------------------------PhysicalProject -------------------------------------PhysicalOlapScan[nation] apply RFs: RF1 -----------------------------------PhysicalProject -------------------------------------filter((region.r_name = 'EUROPE')) ---------------------------------------PhysicalOlapScan[region] +----------------------------PhysicalOlapScan[supplier] apply RFs: RF5 --------------------------PhysicalProject -----------------------------hashJoin[INNER_JOIN colocated] hashCondition=((part.p_partkey = partsupp.ps_partkey)) otherCondition=() build RFs:RF0 p_partkey->[ps_partkey] +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((nation.n_regionkey = region.r_regionkey)) otherCondition=() build RFs:RF4 r_regionkey->[n_regionkey] ------------------------------PhysicalProject ---------------------------------PhysicalOlapScan[partsupp] apply RFs: RF0 +--------------------------------PhysicalOlapScan[nation] apply RFs: RF4 ------------------------------PhysicalProject ---------------------------------filter((p_type like '%BRASS') and (part.p_size = 15)) -----------------------------------PhysicalLazyMaterializeOlapScan[part lazySlots:(part.p_mfgr)] +--------------------------------filter((region.r_name = 'EUROPE')) +----------------------------------PhysicalOlapScan[region] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((supplier.s_suppkey = partsupp.ps_suppkey)) otherCondition=() build RFs:RF3 ps_suppkey->[s_suppkey] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF2 n_nationkey->[s_nationkey] +------------------------PhysicalLazyMaterializeOlapScan[supplier lazySlots:(supplier.s_address,supplier.s_phone,supplier.s_comment)] apply RFs: RF2 RF3 +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((nation.n_regionkey = region.r_regionkey)) otherCondition=() build RFs:RF1 r_regionkey->[n_regionkey] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[nation] apply RFs: RF1 +----------------------------PhysicalProject +------------------------------filter((region.r_name = 'EUROPE')) +--------------------------------PhysicalOlapScan[region] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN colocated] hashCondition=((part.p_partkey = partsupp.ps_partkey)) otherCondition=() build RFs:RF0 p_partkey->[ps_partkey] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[partsupp] apply RFs: RF0 +------------------------PhysicalProject +--------------------------filter((p_type like '%BRASS') and (part.p_size = 15)) +----------------------------PhysicalLazyMaterializeOlapScan[part lazySlots:(part.p_mfgr)] diff --git a/regression-test/data/shape_check/tpch_sf1000/shape/q17.out b/regression-test/data/shape_check/tpch_sf1000/shape/q17.out index 1fe52b08aa8035..261fc69b55e0f8 100644 --- a/regression-test/data/shape_check/tpch_sf1000/shape/q17.out +++ b/regression-test/data/shape_check/tpch_sf1000/shape/q17.out @@ -6,15 +6,17 @@ PhysicalResultSink ------PhysicalDistribute[DistributionSpecGather] --------hashAgg[LOCAL] ----------PhysicalProject -------------filter((cast(l_quantity as DECIMALV3(38, 5)) < (0.2 * avg(l_quantity) OVER(PARTITION BY p_partkey)))) ---------------PhysicalWindow -----------------PhysicalQuickSort[LOCAL_SORT] -------------------PhysicalDistribute[DistributionSpecHash] ---------------------PhysicalProject -----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((part.p_partkey = lineitem.l_partkey)) otherCondition=() build RFs:RF0 p_partkey->[l_partkey] +------------hashJoin[INNER_JOIN broadcast] hashCondition=((part.p_partkey = lineitem.l_partkey)) otherCondition=((cast(l_quantity as DECIMALV3(38, 5)) < (0.2 * avg(l_quantity)))) build RFs:RF1 p_partkey->[l_partkey] +--------------PhysicalProject +----------------PhysicalOlapScan[lineitem] apply RFs: RF1 +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((lineitem.l_partkey = part.p_partkey)) otherCondition=() build RFs:RF0 p_partkey->[l_partkey] +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] ------------------------PhysicalProject --------------------------PhysicalOlapScan[lineitem] apply RFs: RF0 -------------------------PhysicalProject ---------------------------filter((part.p_brand = 'Brand#23') and (part.p_container = 'MED BOX')) -----------------------------PhysicalOlapScan[part] +------------------PhysicalProject +--------------------filter((part.p_brand = 'Brand#23') and (part.p_container = 'MED BOX')) +----------------------PhysicalOlapScan[part] diff --git a/regression-test/data/shape_check/tpch_sf1000/shape/q2.out b/regression-test/data/shape_check/tpch_sf1000/shape/q2.out index 2a4aed95629cb3..7a4d0f7ce7bd2b 100644 --- a/regression-test/data/shape_check/tpch_sf1000/shape/q2.out +++ b/regression-test/data/shape_check/tpch_sf1000/shape/q2.out @@ -7,27 +7,40 @@ PhysicalResultSink --------PhysicalDistribute[DistributionSpecGather] ----------PhysicalTopN[LOCAL_SORT] ------------PhysicalProject ---------------filter((partsupp.ps_supplycost = min(ps_supplycost) OVER(PARTITION BY p_partkey))) -----------------PhysicalWindow -------------------PhysicalQuickSort[LOCAL_SORT] ---------------------PhysicalDistribute[DistributionSpecHash] +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((part.p_partkey = partsupp.ps_partkey) and (partsupp.ps_supplycost = min(ps_supplycost))) otherCondition=() build RFs:RF7 p_partkey->[ps_partkey] +----------------hashAgg[GLOBAL] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_suppkey = partsupp.ps_suppkey)) otherCondition=() build RFs:RF6 s_suppkey->[ps_suppkey] ----------------------PhysicalProject -------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((supplier.s_suppkey = partsupp.ps_suppkey)) otherCondition=() build RFs:RF3 ps_suppkey->[s_suppkey] +------------------------PhysicalOlapScan[partsupp] apply RFs: RF6 RF7 +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF5 n_nationkey->[s_nationkey] --------------------------PhysicalProject -----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF2 n_nationkey->[s_nationkey] -------------------------------PhysicalLazyMaterializeOlapScan[supplier lazySlots:(supplier.s_address,supplier.s_phone,supplier.s_comment)] apply RFs: RF2 RF3 -------------------------------PhysicalProject ---------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((nation.n_regionkey = region.r_regionkey)) otherCondition=() build RFs:RF1 r_regionkey->[n_regionkey] -----------------------------------PhysicalProject -------------------------------------PhysicalOlapScan[nation] apply RFs: RF1 -----------------------------------PhysicalProject -------------------------------------filter((region.r_name = 'EUROPE')) ---------------------------------------PhysicalOlapScan[region] +----------------------------PhysicalOlapScan[supplier] apply RFs: RF5 --------------------------PhysicalProject -----------------------------hashJoin[INNER_JOIN colocated] hashCondition=((part.p_partkey = partsupp.ps_partkey)) otherCondition=() build RFs:RF0 p_partkey->[ps_partkey] +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((nation.n_regionkey = region.r_regionkey)) otherCondition=() build RFs:RF4 r_regionkey->[n_regionkey] ------------------------------PhysicalProject ---------------------------------PhysicalOlapScan[partsupp] apply RFs: RF0 +--------------------------------PhysicalOlapScan[nation] apply RFs: RF4 ------------------------------PhysicalProject ---------------------------------filter((p_type like '%BRASS') and (part.p_size = 15)) -----------------------------------PhysicalLazyMaterializeOlapScan[part lazySlots:(part.p_mfgr)] +--------------------------------filter((region.r_name = 'EUROPE')) +----------------------------------PhysicalOlapScan[region] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((supplier.s_suppkey = partsupp.ps_suppkey)) otherCondition=() build RFs:RF3 ps_suppkey->[s_suppkey] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF2 n_nationkey->[s_nationkey] +------------------------PhysicalLazyMaterializeOlapScan[supplier lazySlots:(supplier.s_address,supplier.s_phone,supplier.s_comment)] apply RFs: RF2 RF3 +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((nation.n_regionkey = region.r_regionkey)) otherCondition=() build RFs:RF1 r_regionkey->[n_regionkey] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[nation] apply RFs: RF1 +----------------------------PhysicalProject +------------------------------filter((region.r_name = 'EUROPE')) +--------------------------------PhysicalOlapScan[region] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN colocated] hashCondition=((part.p_partkey = partsupp.ps_partkey)) otherCondition=() build RFs:RF0 p_partkey->[ps_partkey] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[partsupp] apply RFs: RF0 +------------------------PhysicalProject +--------------------------filter((p_type like '%BRASS') and (part.p_size = 15)) +----------------------------PhysicalLazyMaterializeOlapScan[part lazySlots:(part.p_mfgr)] diff --git a/regression-test/data/shape_check/tpch_sf1000/shape_no_stats/q17.out b/regression-test/data/shape_check/tpch_sf1000/shape_no_stats/q17.out index 6c1bc1d0fe8fe1..4a28c9e2d3bd72 100644 --- a/regression-test/data/shape_check/tpch_sf1000/shape_no_stats/q17.out +++ b/regression-test/data/shape_check/tpch_sf1000/shape_no_stats/q17.out @@ -6,14 +6,17 @@ PhysicalResultSink ------PhysicalDistribute[DistributionSpecGather] --------hashAgg[LOCAL] ----------PhysicalProject -------------filter((cast(l_quantity as DECIMALV3(38, 5)) < (0.2 * avg(l_quantity) OVER(PARTITION BY p_partkey)))) ---------------PhysicalWindow -----------------PhysicalQuickSort[LOCAL_SORT] +------------hashJoin[INNER_JOIN colocated] hashCondition=((lineitem.l_partkey = part.p_partkey)) otherCondition=((cast(l_quantity as DECIMALV3(38, 5)) < (0.2 * avg(l_quantity)))) build RFs:RF1 l_partkey->[l_partkey,p_partkey] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN shuffle] hashCondition=((part.p_partkey = lineitem.l_partkey)) otherCondition=() build RFs:RF0 p_partkey->[l_partkey] ------------------PhysicalProject ---------------------hashJoin[INNER_JOIN shuffle] hashCondition=((part.p_partkey = lineitem.l_partkey)) otherCondition=() build RFs:RF0 p_partkey->[l_partkey] -----------------------PhysicalProject -------------------------PhysicalOlapScan[lineitem] apply RFs: RF0 -----------------------PhysicalProject -------------------------filter((part.p_brand = 'Brand#23') and (part.p_container = 'MED BOX')) ---------------------------PhysicalOlapScan[part] +--------------------PhysicalOlapScan[lineitem] apply RFs: RF0 RF1 +------------------PhysicalProject +--------------------filter((part.p_brand = 'Brand#23') and (part.p_container = 'MED BOX')) +----------------------PhysicalOlapScan[part] apply RFs: RF1 +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] +--------------------PhysicalProject +----------------------PhysicalOlapScan[lineitem] diff --git a/regression-test/data/shape_check/tpch_sf1000/shape_no_stats/q2.out b/regression-test/data/shape_check/tpch_sf1000/shape_no_stats/q2.out index f65137169a261c..fcac7fdcbfc207 100644 --- a/regression-test/data/shape_check/tpch_sf1000/shape_no_stats/q2.out +++ b/regression-test/data/shape_check/tpch_sf1000/shape_no_stats/q2.out @@ -7,26 +7,40 @@ PhysicalResultSink --------PhysicalDistribute[DistributionSpecGather] ----------PhysicalTopN[LOCAL_SORT] ------------PhysicalProject ---------------filter((partsupp.ps_supplycost = min(ps_supplycost) OVER(PARTITION BY p_partkey))) -----------------PhysicalWindow -------------------PhysicalQuickSort[LOCAL_SORT] +--------------hashJoin[INNER_JOIN colocated] hashCondition=((part.p_partkey = partsupp.ps_partkey) and (partsupp.ps_supplycost = min(ps_supplycost))) otherCondition=() build RFs:RF7 min(ps_supplycost)->[ps_supplycost];RF8 ps_partkey->[p_partkey,ps_partkey] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((nation.n_regionkey = region.r_regionkey)) otherCondition=() build RFs:RF6 r_regionkey->[n_regionkey] --------------------PhysicalProject -----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((nation.n_regionkey = region.r_regionkey)) otherCondition=() build RFs:RF3 r_regionkey->[n_regionkey] +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF5 n_nationkey->[s_nationkey] ------------------------PhysicalProject ---------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF2 n_nationkey->[s_nationkey] +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_suppkey = partsupp.ps_suppkey)) otherCondition=() build RFs:RF4 s_suppkey->[ps_suppkey] ----------------------------PhysicalProject -------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_suppkey = partsupp.ps_suppkey)) otherCondition=() build RFs:RF1 s_suppkey->[ps_suppkey] +------------------------------hashJoin[INNER_JOIN colocated] hashCondition=((part.p_partkey = partsupp.ps_partkey)) otherCondition=() build RFs:RF3 p_partkey->[ps_partkey] --------------------------------PhysicalProject -----------------------------------hashJoin[INNER_JOIN colocated] hashCondition=((part.p_partkey = partsupp.ps_partkey)) otherCondition=() build RFs:RF0 p_partkey->[ps_partkey] -------------------------------------PhysicalProject ---------------------------------------PhysicalOlapScan[partsupp] apply RFs: RF0 RF1 -------------------------------------PhysicalProject ---------------------------------------filter((p_type like '%BRASS') and (part.p_size = 15)) -----------------------------------------PhysicalLazyMaterializeOlapScan[part lazySlots:(part.p_mfgr)] ---------------------------------PhysicalLazyMaterializeOlapScan[supplier lazySlots:(supplier.s_address,supplier.s_phone,supplier.s_comment)] apply RFs: RF2 -----------------------------PhysicalProject -------------------------------PhysicalOlapScan[nation] apply RFs: RF3 +----------------------------------PhysicalOlapScan[partsupp] apply RFs: RF3 RF4 RF7 RF8 +--------------------------------PhysicalProject +----------------------------------filter((p_type like '%BRASS') and (part.p_size = 15)) +------------------------------------PhysicalLazyMaterializeOlapScan[part lazySlots:(part.p_mfgr)] apply RFs: RF8 +----------------------------PhysicalLazyMaterializeOlapScan[supplier lazySlots:(supplier.s_address,supplier.s_phone,supplier.s_comment)] apply RFs: RF5 ------------------------PhysicalProject ---------------------------filter((region.r_name = 'EUROPE')) -----------------------------PhysicalOlapScan[region] +--------------------------PhysicalOlapScan[nation] apply RFs: RF6 +--------------------PhysicalProject +----------------------filter((region.r_name = 'EUROPE')) +------------------------PhysicalOlapScan[region] +----------------hashAgg[GLOBAL] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((nation.n_regionkey = region.r_regionkey)) otherCondition=() build RFs:RF2 r_regionkey->[n_regionkey] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF1 n_nationkey->[s_nationkey] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_suppkey = partsupp.ps_suppkey)) otherCondition=() build RFs:RF0 s_suppkey->[ps_suppkey] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[partsupp] apply RFs: RF0 +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[supplier] apply RFs: RF1 +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[nation] apply RFs: RF2 +----------------------PhysicalProject +------------------------filter((region.r_name = 'EUROPE')) +--------------------------PhysicalOlapScan[region] diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q1.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q1.out new file mode 100644 index 00000000000000..22f0777694a7ce --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q1.out @@ -0,0 +1,13 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------filter((lineitem.l_shipdate <= '1998-09-02')) +------------------PhysicalOlapScan[lineitem] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q10.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q10.out new file mode 100644 index 00000000000000..50ae9202d68a69 --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q10.out @@ -0,0 +1,29 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalProject +----PhysicalLazyMaterialize[materializedSlots:(revenue,customer.c_custkey) lazySlots:(customer.c_acctbal,customer.c_address,customer.c_comment,customer.c_name,customer.c_phone,nation.n_name)] +------PhysicalTopN[MERGE_SORT] +--------PhysicalDistribute[DistributionSpecGather] +----------PhysicalTopN[LOCAL_SORT] +------------PhysicalProject +--------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer.c_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF2 n_nationkey->[c_nationkey] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((customer.c_custkey = orders.o_custkey)) otherCondition=() build RFs:RF1 o_custkey->[c_custkey] +--------------------PhysicalProject +----------------------PhysicalLazyMaterializeOlapScan[customer lazySlots:(customer.c_name,customer.c_address,customer.c_phone,customer.c_acctbal,customer.c_comment)] apply RFs: RF1 RF2 +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN colocated] hashCondition=((lineitem.l_orderkey = orders.o_orderkey)) otherCondition=() build RFs:RF0 o_orderkey->[l_orderkey] +------------------------------hashAgg[GLOBAL] +--------------------------------PhysicalProject +----------------------------------filter((lineitem.l_returnflag = 'R')) +------------------------------------PhysicalOlapScan[lineitem] apply RFs: RF0 +------------------------------PhysicalProject +--------------------------------filter((orders.o_orderdate < '1994-01-01') and (orders.o_orderdate >= '1993-10-01')) +----------------------------------PhysicalOlapScan[orders] +----------------PhysicalProject +------------------PhysicalLazyMaterializeOlapScan[nation lazySlots:(nation.n_name)] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q11.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q11.out new file mode 100644 index 00000000000000..32ac3f813c6280 --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q11.out @@ -0,0 +1,37 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------PhysicalProject +----------NestedLoopJoin[INNER_JOIN](cast(value as DECIMALV3(38, 6)) > sum(ps_supplycost * ps_availqty) * 0.000002) +------------PhysicalProject +--------------hashAgg[GLOBAL] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((partsupp.ps_suppkey = supplier.s_suppkey)) otherCondition=() build RFs:RF3 s_suppkey->[ps_suppkey] +--------------------PhysicalProject +----------------------PhysicalOlapScan[partsupp] apply RFs: RF3 +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF2 n_nationkey->[s_nationkey] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[supplier] apply RFs: RF2 +------------------------PhysicalProject +--------------------------filter((nation.n_name = 'GERMANY')) +----------------------------PhysicalOlapScan[nation] +------------PhysicalProject +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecGather] +------------------hashAgg[LOCAL] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((partsupp.ps_suppkey = supplier.s_suppkey)) otherCondition=() build RFs:RF1 s_suppkey->[ps_suppkey] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[partsupp] apply RFs: RF1 +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF0 n_nationkey->[s_nationkey] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[supplier] apply RFs: RF0 +----------------------------PhysicalProject +------------------------------filter((nation.n_name = 'GERMANY')) +--------------------------------PhysicalOlapScan[nation] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q12.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q12.out new file mode 100644 index 00000000000000..8df830dd428e58 --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q12.out @@ -0,0 +1,17 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN colocated] hashCondition=((orders.o_orderkey = lineitem.l_orderkey)) otherCondition=() build RFs:RF0 l_orderkey->[o_orderkey] +------------------PhysicalProject +--------------------PhysicalOlapScan[orders] apply RFs: RF0 +------------------PhysicalProject +--------------------filter((lineitem.l_commitdate < lineitem.l_receiptdate) and (lineitem.l_receiptdate < '1995-01-01') and (lineitem.l_receiptdate >= '1994-01-01') and (lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate < lineitem.l_commitdate) and l_shipmode IN ('MAIL', 'SHIP')) +----------------------PhysicalOlapScan[lineitem] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q13.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q13.out new file mode 100644 index 00000000000000..a9c26e203f3c44 --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q13.out @@ -0,0 +1,22 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashAgg[GLOBAL] +------------------PhysicalProject +--------------------hashJoin[LEFT_OUTER_JOIN bucketShuffle] hashCondition=((customer.c_custkey = orders.o_custkey)) otherCondition=() +----------------------PhysicalProject +------------------------PhysicalOlapScan[customer] +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------filter(( not (o_comment like '%special%requests%'))) +--------------------------------PhysicalOlapScan[orders] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q14.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q14.out new file mode 100644 index 00000000000000..6df1a05fa3b57f --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q14.out @@ -0,0 +1,15 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalProject +----hashAgg[GLOBAL] +------PhysicalDistribute[DistributionSpecGather] +--------hashAgg[LOCAL] +----------PhysicalProject +------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((lineitem.l_partkey = part.p_partkey)) otherCondition=() build RFs:RF0 l_partkey->[p_partkey] +--------------PhysicalProject +----------------PhysicalOlapScan[part] apply RFs: RF0 +--------------PhysicalProject +----------------filter((lineitem.l_shipdate < '1995-10-01') and (lineitem.l_shipdate >= '1995-09-01')) +------------------PhysicalOlapScan[lineitem] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q15.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q15.out new file mode 100644 index 00000000000000..e9b45b5888ce54 --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q15.out @@ -0,0 +1,30 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[INNER_JOIN broadcast] hashCondition=((revenue0.total_revenue = max(total_revenue))) otherCondition=() +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((supplier.s_suppkey = revenue0.supplier_no)) otherCondition=() build RFs:RF0 s_suppkey->[l_suppkey] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------filter((lineitem.l_shipdate < '1996-04-01') and (lineitem.l_shipdate >= '1996-01-01')) +----------------------------PhysicalOlapScan[lineitem] apply RFs: RF0 +----------------PhysicalProject +------------------PhysicalOlapScan[supplier] +------------hashAgg[GLOBAL] +--------------PhysicalDistribute[DistributionSpecGather] +----------------hashAgg[LOCAL] +------------------PhysicalProject +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalProject +----------------------------filter((lineitem.l_shipdate < '1996-04-01') and (lineitem.l_shipdate >= '1996-01-01')) +------------------------------PhysicalOlapScan[lineitem] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q16.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q16.out new file mode 100644 index 00000000000000..5fe9babe975e0c --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q16.out @@ -0,0 +1,22 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------hashJoin[LEFT_ANTI_JOIN broadcast] hashCondition=((partsupp.ps_suppkey = supplier.s_suppkey)) otherCondition=() +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN colocated] hashCondition=((part.p_partkey = partsupp.ps_partkey)) otherCondition=() build RFs:RF0 p_partkey->[ps_partkey] +----------------------PhysicalProject +------------------------PhysicalOlapScan[partsupp] apply RFs: RF0 +----------------------PhysicalProject +------------------------filter(( not (p_brand = 'Brand#45')) and ( not (p_type like 'MEDIUM POLISHED%')) and p_size IN (14, 19, 23, 3, 36, 45, 49, 9)) +--------------------------PhysicalOlapScan[part] +------------------PhysicalProject +--------------------filter((s_comment like '%Customer%Complaints%')) +----------------------PhysicalOlapScan[supplier] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q17.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q17.out new file mode 100644 index 00000000000000..1fe52b08aa8035 --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q17.out @@ -0,0 +1,20 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalProject +----hashAgg[GLOBAL] +------PhysicalDistribute[DistributionSpecGather] +--------hashAgg[LOCAL] +----------PhysicalProject +------------filter((cast(l_quantity as DECIMALV3(38, 5)) < (0.2 * avg(l_quantity) OVER(PARTITION BY p_partkey)))) +--------------PhysicalWindow +----------------PhysicalQuickSort[LOCAL_SORT] +------------------PhysicalDistribute[DistributionSpecHash] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((part.p_partkey = lineitem.l_partkey)) otherCondition=() build RFs:RF0 p_partkey->[l_partkey] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[lineitem] apply RFs: RF0 +------------------------PhysicalProject +--------------------------filter((part.p_brand = 'Brand#23') and (part.p_container = 'MED BOX')) +----------------------------PhysicalOlapScan[part] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q18.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q18.out new file mode 100644 index 00000000000000..a0ad2d8828e460 --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q18.out @@ -0,0 +1,26 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalProject +----PhysicalLazyMaterialize[materializedSlots:(orders.o_orderkey,orders.o_orderdate,orders.o_totalprice,sum(l_quantity),customer.c_custkey) lazySlots:(customer.c_name)] +------PhysicalTopN[MERGE_SORT] +--------PhysicalDistribute[DistributionSpecGather] +----------PhysicalTopN[LOCAL_SORT] +------------PhysicalProject +--------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_custkey = orders.o_custkey)) otherCondition=() build RFs:RF2 c_custkey->[o_custkey] +----------------hashAgg[GLOBAL] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN colocated] hashCondition=((orders.o_orderkey = lineitem.l_orderkey)) otherCondition=() build RFs:RF1 o_orderkey->[l_orderkey] +----------------------PhysicalProject +------------------------PhysicalOlapScan[lineitem] apply RFs: RF1 +----------------------hashJoin[LEFT_SEMI_JOIN colocated] hashCondition=((orders.o_orderkey = lineitem.l_orderkey)) otherCondition=() build RFs:RF0 l_orderkey->[o_orderkey] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[orders] apply RFs: RF0 RF2 +------------------------PhysicalProject +--------------------------filter((sum(l_quantity) > 300.00)) +----------------------------hashAgg[GLOBAL] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[lineitem] +----------------PhysicalProject +------------------PhysicalLazyMaterializeOlapScan[customer lazySlots:(customer.c_name)] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q19.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q19.out new file mode 100644 index 00000000000000..78faf3234691b3 --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q19.out @@ -0,0 +1,15 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--hashAgg[GLOBAL] +----PhysicalDistribute[DistributionSpecGather] +------hashAgg[LOCAL] +--------PhysicalProject +----------hashJoin[INNER_JOIN broadcast] hashCondition=((part.p_partkey = lineitem.l_partkey)) otherCondition=(OR[AND[(part.p_brand = 'Brand#12'),p_container IN ('SM BOX', 'SM CASE', 'SM PACK', 'SM PKG'),(lineitem.l_quantity <= 11.00),(part.p_size <= 5)],AND[(part.p_brand = 'Brand#23'),p_container IN ('MED BAG', 'MED BOX', 'MED PACK', 'MED PKG'),(lineitem.l_quantity >= 10.00),(lineitem.l_quantity <= 20.00),(part.p_size <= 10)],AND[(part.p_brand = 'Brand#34'),p_container IN ('LG BOX', 'LG CASE', 'LG PACK', 'LG PKG'),(lineitem.l_quantity >= 20.00)]]) build RFs:RF0 p_partkey->[l_partkey] +------------PhysicalProject +--------------filter((lineitem.l_quantity <= 30.00) and (lineitem.l_quantity >= 1.00) and (lineitem.l_shipinstruct = 'DELIVER IN PERSON') and l_shipmode IN ('AIR REG', 'AIR')) +----------------PhysicalOlapScan[lineitem] apply RFs: RF0 +------------PhysicalProject +--------------filter((part.p_size <= 15) and (part.p_size >= 1) and OR[AND[(part.p_brand = 'Brand#12'),p_container IN ('SM BOX', 'SM CASE', 'SM PACK', 'SM PKG'),(part.p_size <= 5)],AND[(part.p_brand = 'Brand#23'),p_container IN ('MED BAG', 'MED BOX', 'MED PACK', 'MED PKG'),(part.p_size <= 10)],AND[(part.p_brand = 'Brand#34'),p_container IN ('LG BOX', 'LG CASE', 'LG PACK', 'LG PKG')]] and p_brand IN ('Brand#12', 'Brand#23', 'Brand#34') and p_container IN ('LG BOX', 'LG CASE', 'LG PACK', 'LG PKG', 'MED BAG', 'MED BOX', 'MED PACK', 'MED PKG', 'SM BOX', 'SM CASE', 'SM PACK', 'SM PKG')) +----------------PhysicalOlapScan[part] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q2.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q2.out new file mode 100644 index 00000000000000..2a4aed95629cb3 --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q2.out @@ -0,0 +1,33 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalProject +----PhysicalLazyMaterialize[materializedSlots:(supplier.s_acctbal,supplier.s_name,nation.n_name,part.p_partkey) lazySlots:(part.p_mfgr,supplier.s_address,supplier.s_comment,supplier.s_phone)] +------PhysicalTopN[MERGE_SORT] +--------PhysicalDistribute[DistributionSpecGather] +----------PhysicalTopN[LOCAL_SORT] +------------PhysicalProject +--------------filter((partsupp.ps_supplycost = min(ps_supplycost) OVER(PARTITION BY p_partkey))) +----------------PhysicalWindow +------------------PhysicalQuickSort[LOCAL_SORT] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((supplier.s_suppkey = partsupp.ps_suppkey)) otherCondition=() build RFs:RF3 ps_suppkey->[s_suppkey] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF2 n_nationkey->[s_nationkey] +------------------------------PhysicalLazyMaterializeOlapScan[supplier lazySlots:(supplier.s_address,supplier.s_phone,supplier.s_comment)] apply RFs: RF2 RF3 +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((nation.n_regionkey = region.r_regionkey)) otherCondition=() build RFs:RF1 r_regionkey->[n_regionkey] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[nation] apply RFs: RF1 +----------------------------------PhysicalProject +------------------------------------filter((region.r_name = 'EUROPE')) +--------------------------------------PhysicalOlapScan[region] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN colocated] hashCondition=((part.p_partkey = partsupp.ps_partkey)) otherCondition=() build RFs:RF0 p_partkey->[ps_partkey] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[partsupp] apply RFs: RF0 +------------------------------PhysicalProject +--------------------------------filter((p_type like '%BRASS') and (part.p_size = 15)) +----------------------------------PhysicalLazyMaterializeOlapScan[part lazySlots:(part.p_mfgr)] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q20-rewrite.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q20-rewrite.out new file mode 100644 index 00000000000000..3c5d16708be512 --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q20-rewrite.out @@ -0,0 +1,31 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[RIGHT_SEMI_JOIN shuffle] hashCondition=((supplier.s_suppkey = t3.ps_suppkey)) otherCondition=() build RFs:RF4 s_suppkey->[l_suppkey,ps_suppkey] +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t2.l_partkey = t1.ps_partkey) and (t2.l_suppkey = t1.ps_suppkey)) otherCondition=((cast(ps_availqty as DECIMALV3(38, 3)) > t2.l_q)) build RFs:RF2 ps_partkey->[l_partkey];RF3 ps_suppkey->[l_suppkey] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------filter((lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate >= '1994-01-01')) +----------------------------PhysicalOlapScan[lineitem] apply RFs: RF2 RF3 RF4 +----------------hashJoin[LEFT_SEMI_JOIN colocated] hashCondition=((partsupp.ps_partkey = part.p_partkey)) otherCondition=() build RFs:RF1 p_partkey->[ps_partkey] +------------------PhysicalProject +--------------------PhysicalOlapScan[partsupp] apply RFs: RF1 RF4 +------------------PhysicalProject +--------------------filter((p_name like 'forest%')) +----------------------PhysicalOlapScan[part] +------------PhysicalProject +--------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF0 n_nationkey->[s_nationkey] +----------------PhysicalProject +------------------PhysicalOlapScan[supplier] apply RFs: RF0 +----------------PhysicalProject +------------------filter((nation.n_name = 'CANADA')) +--------------------PhysicalOlapScan[nation] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q20.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q20.out new file mode 100644 index 00000000000000..38ecc268fdf8a0 --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q20.out @@ -0,0 +1,30 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[RIGHT_SEMI_JOIN shuffle] hashCondition=((supplier.s_suppkey = partsupp.ps_suppkey)) otherCondition=() build RFs:RF4 s_suppkey->[l_suppkey,ps_suppkey] +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((lineitem.l_partkey = partsupp.ps_partkey) and (lineitem.l_suppkey = partsupp.ps_suppkey)) otherCondition=((cast(ps_availqty as DECIMALV3(38, 3)) > (0.5 * sum(l_quantity)))) build RFs:RF2 ps_partkey->[l_partkey];RF3 ps_suppkey->[l_suppkey] +----------------hashAgg[GLOBAL] +------------------PhysicalDistribute[DistributionSpecHash] +--------------------hashAgg[LOCAL] +----------------------PhysicalProject +------------------------filter((lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate >= '1994-01-01')) +--------------------------PhysicalOlapScan[lineitem] apply RFs: RF2 RF3 RF4 +----------------hashJoin[LEFT_SEMI_JOIN colocated] hashCondition=((partsupp.ps_partkey = part.p_partkey)) otherCondition=() build RFs:RF1 p_partkey->[ps_partkey] +------------------PhysicalProject +--------------------PhysicalOlapScan[partsupp] apply RFs: RF1 RF4 +------------------PhysicalProject +--------------------filter((p_name like 'forest%')) +----------------------PhysicalOlapScan[part] +------------PhysicalProject +--------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF0 n_nationkey->[s_nationkey] +----------------PhysicalProject +------------------PhysicalOlapScan[supplier] apply RFs: RF0 +----------------PhysicalProject +------------------filter((nation.n_name = 'CANADA')) +--------------------PhysicalOlapScan[nation] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q21.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q21.out new file mode 100644 index 00000000000000..0436a7b245b174 --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q21.out @@ -0,0 +1,35 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[RIGHT_SEMI_JOIN colocated] hashCondition=((l2.l_orderkey = l1.l_orderkey)) otherCondition=(( not (l_suppkey = l_suppkey))) build RFs:RF4 l_orderkey->[l_orderkey] +------------------PhysicalProject +--------------------PhysicalOlapScan[lineitem] apply RFs: RF4 +------------------hashJoin[RIGHT_ANTI_JOIN colocated] hashCondition=((l3.l_orderkey = l1.l_orderkey)) otherCondition=(( not (l_suppkey = l_suppkey))) build RFs:RF3 l_orderkey->[l_orderkey] +--------------------PhysicalProject +----------------------filter((l3.l_receiptdate > l3.l_commitdate)) +------------------------PhysicalOlapScan[lineitem] apply RFs: RF3 +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN colocated] hashCondition=((orders.o_orderkey = l1.l_orderkey)) otherCondition=() build RFs:RF2 l_orderkey->[o_orderkey] +------------------------PhysicalProject +--------------------------filter((orders.o_orderstatus = 'F')) +----------------------------PhysicalOlapScan[orders] apply RFs: RF2 +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_suppkey = l1.l_suppkey)) otherCondition=() build RFs:RF1 s_suppkey->[l_suppkey] +----------------------------PhysicalProject +------------------------------filter((l1.l_receiptdate > l1.l_commitdate)) +--------------------------------PhysicalOlapScan[lineitem] apply RFs: RF1 +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF0 n_nationkey->[s_nationkey] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[supplier] apply RFs: RF0 +--------------------------------PhysicalProject +----------------------------------filter((nation.n_name = 'SAUDI ARABIA')) +------------------------------------PhysicalOlapScan[nation] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q22.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q22.out new file mode 100644 index 00000000000000..5f75b319bf08a6 --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q22.out @@ -0,0 +1,25 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[RIGHT_ANTI_JOIN shuffle] hashCondition=((orders.o_custkey = customer.c_custkey)) otherCondition=() build RFs:RF0 c_custkey->[o_custkey] +------------------PhysicalProject +--------------------PhysicalOlapScan[orders] apply RFs: RF0 +------------------PhysicalProject +--------------------NestedLoopJoin[INNER_JOIN](cast(c_acctbal as DECIMALV3(38, 4)) > avg(c_acctbal)) +----------------------PhysicalProject +------------------------filter(substring(c_phone, 1, 2) IN ('13', '17', '18', '23', '29', '30', '31')) +--------------------------PhysicalOlapScan[customer] +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecGather] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------filter((customer.c_acctbal > 0.00) and substring(c_phone, 1, 2) IN ('13', '17', '18', '23', '29', '30', '31')) +--------------------------------PhysicalOlapScan[customer] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q3.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q3.out new file mode 100644 index 00000000000000..4b45fb5d8de73b --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q3.out @@ -0,0 +1,22 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalProject +------------hashJoin[INNER_JOIN colocated] hashCondition=((lineitem.l_orderkey = orders.o_orderkey)) otherCondition=() build RFs:RF1 o_orderkey->[l_orderkey] +--------------hashAgg[GLOBAL] +----------------PhysicalProject +------------------filter((lineitem.l_shipdate > '1995-03-15')) +--------------------PhysicalOlapScan[lineitem] apply RFs: RF1 +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer.c_custkey = orders.o_custkey)) otherCondition=() build RFs:RF0 c_custkey->[o_custkey] +------------------PhysicalProject +--------------------filter((orders.o_orderdate < '1995-03-15')) +----------------------PhysicalOlapScan[orders] apply RFs: RF0 +------------------PhysicalProject +--------------------filter((customer.c_mktsegment = 'BUILDING')) +----------------------PhysicalOlapScan[customer] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q4.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q4.out new file mode 100644 index 00000000000000..19b73f24dc3315 --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q4.out @@ -0,0 +1,18 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[RIGHT_SEMI_JOIN colocated] hashCondition=((lineitem.l_orderkey = orders.o_orderkey)) otherCondition=() build RFs:RF0 o_orderkey->[l_orderkey] +------------------PhysicalProject +--------------------filter((lineitem.l_commitdate < lineitem.l_receiptdate)) +----------------------PhysicalOlapScan[lineitem] apply RFs: RF0 +------------------PhysicalProject +--------------------filter((orders.o_orderdate < '1993-10-01') and (orders.o_orderdate >= '1993-07-01')) +----------------------PhysicalOlapScan[orders] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q5.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q5.out new file mode 100644 index 00000000000000..9d05d167d12ad6 --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q5.out @@ -0,0 +1,34 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((customer.c_custkey = orders.o_custkey) and (customer.c_nationkey = supplier.s_nationkey)) otherCondition=() build RFs:RF4 s_nationkey->[c_nationkey];RF5 o_custkey->[c_custkey] +------------------PhysicalProject +--------------------PhysicalOlapScan[customer] apply RFs: RF4 RF5 +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((lineitem.l_suppkey = supplier.s_suppkey)) otherCondition=() build RFs:RF3 s_suppkey->[l_suppkey] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN colocated] hashCondition=((lineitem.l_orderkey = orders.o_orderkey)) otherCondition=() build RFs:RF2 o_orderkey->[l_orderkey] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[lineitem] apply RFs: RF2 RF3 +--------------------------PhysicalProject +----------------------------filter((orders.o_orderdate < '1995-01-01') and (orders.o_orderdate >= '1994-01-01')) +------------------------------PhysicalOlapScan[orders] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF1 n_nationkey->[s_nationkey] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[supplier] apply RFs: RF1 +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((nation.n_regionkey = region.r_regionkey)) otherCondition=() build RFs:RF0 r_regionkey->[n_regionkey] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[nation] apply RFs: RF0 +------------------------------PhysicalProject +--------------------------------filter((region.r_name = 'ASIA')) +----------------------------------PhysicalOlapScan[region] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q6.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q6.out new file mode 100644 index 00000000000000..f1f764bec09499 --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q6.out @@ -0,0 +1,10 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--hashAgg[GLOBAL] +----PhysicalDistribute[DistributionSpecGather] +------hashAgg[LOCAL] +--------PhysicalProject +----------filter((lineitem.l_discount <= 0.07) and (lineitem.l_discount >= 0.05) and (lineitem.l_quantity < 24.00) and (lineitem.l_shipdate < '1995-01-01') and (lineitem.l_shipdate >= '1994-01-01')) +------------PhysicalOlapScan[lineitem] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q7.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q7.out new file mode 100644 index 00000000000000..957b17a7402749 --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q7.out @@ -0,0 +1,35 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer.c_custkey = orders.o_custkey)) otherCondition=(OR[AND[(n1.n_name = 'FRANCE'),(n2.n_name = 'GERMANY')],AND[(n1.n_name = 'GERMANY'),(n2.n_name = 'FRANCE')]]) build RFs:RF4 c_custkey->[o_custkey] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN colocated] hashCondition=((orders.o_orderkey = lineitem.l_orderkey)) otherCondition=() build RFs:RF3 l_orderkey->[o_orderkey] +----------------------PhysicalProject +------------------------PhysicalOlapScan[orders] apply RFs: RF3 RF4 +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_suppkey = lineitem.l_suppkey)) otherCondition=() build RFs:RF2 s_suppkey->[l_suppkey] +--------------------------PhysicalProject +----------------------------filter((lineitem.l_shipdate <= '1996-12-31') and (lineitem.l_shipdate >= '1995-01-01')) +------------------------------PhysicalOlapScan[lineitem] apply RFs: RF2 +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = n1.n_nationkey)) otherCondition=() build RFs:RF1 n_nationkey->[s_nationkey] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[supplier] apply RFs: RF1 +------------------------------PhysicalProject +--------------------------------filter(n_name IN ('FRANCE', 'GERMANY')) +----------------------------------PhysicalOlapScan[nation] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer.c_nationkey = n2.n_nationkey)) otherCondition=() build RFs:RF0 n_nationkey->[c_nationkey] +----------------------PhysicalProject +------------------------PhysicalOlapScan[customer] apply RFs: RF0 +----------------------PhysicalProject +------------------------filter(n_name IN ('FRANCE', 'GERMANY')) +--------------------------PhysicalOlapScan[nation] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q8.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q8.out new file mode 100644 index 00000000000000..04c25aa5b1223f --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q8.out @@ -0,0 +1,44 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------PhysicalProject +----------hashAgg[GLOBAL] +------------PhysicalDistribute[DistributionSpecHash] +--------------hashAgg[LOCAL] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = n2.n_nationkey)) otherCondition=() build RFs:RF6 n_nationkey->[s_nationkey] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN shuffle] hashCondition=((supplier.s_suppkey = lineitem.l_suppkey)) otherCondition=() build RFs:RF5 l_suppkey->[s_suppkey] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[supplier] apply RFs: RF5 RF6 +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((orders.o_custkey = customer.c_custkey)) otherCondition=() build RFs:RF4 o_custkey->[c_custkey] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((customer.c_nationkey = n1.n_nationkey)) otherCondition=() build RFs:RF3 n_nationkey->[c_nationkey] +--------------------------------PhysicalProject +----------------------------------PhysicalOlapScan[customer] apply RFs: RF3 RF4 +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((n1.n_regionkey = region.r_regionkey)) otherCondition=() build RFs:RF2 r_regionkey->[n_regionkey] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[nation] apply RFs: RF2 +------------------------------------PhysicalProject +--------------------------------------filter((region.r_name = 'AMERICA')) +----------------------------------------PhysicalOlapScan[region] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN colocated] hashCondition=((lineitem.l_orderkey = orders.o_orderkey)) otherCondition=() build RFs:RF1 l_orderkey->[o_orderkey] +--------------------------------PhysicalProject +----------------------------------filter((orders.o_orderdate <= '1996-12-31') and (orders.o_orderdate >= '1995-01-01')) +------------------------------------PhysicalOlapScan[orders] apply RFs: RF1 +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((part.p_partkey = lineitem.l_partkey)) otherCondition=() build RFs:RF0 p_partkey->[l_partkey] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[lineitem] apply RFs: RF0 +------------------------------------PhysicalProject +--------------------------------------filter((part.p_type = 'ECONOMY ANODIZED STEEL')) +----------------------------------------PhysicalOlapScan[part] +--------------------PhysicalProject +----------------------PhysicalOlapScan[nation] + diff --git a/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q9.out b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q9.out new file mode 100644 index 00000000000000..bee3d7f4b52394 --- /dev/null +++ b/regression-test/data/shape_check/tpch_sf1000_constraints/shape/q9.out @@ -0,0 +1,33 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +PhysicalResultSink +--PhysicalQuickSort[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalQuickSort[LOCAL_SORT] +--------hashAgg[GLOBAL] +----------PhysicalDistribute[DistributionSpecHash] +------------hashAgg[LOCAL] +--------------PhysicalProject +----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((partsupp.ps_partkey = lineitem.l_partkey) and (partsupp.ps_suppkey = lineitem.l_suppkey)) otherCondition=() build RFs:RF4 ps_suppkey->[l_suppkey,s_suppkey];RF5 ps_partkey->[l_partkey,p_partkey] +------------------PhysicalProject +--------------------hashJoin[INNER_JOIN shuffle] hashCondition=((supplier.s_suppkey = lineitem.l_suppkey)) otherCondition=() build RFs:RF3 s_suppkey->[l_suppkey] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((orders.o_orderkey = lineitem.l_orderkey)) otherCondition=() build RFs:RF2 l_orderkey->[o_orderkey] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[orders] apply RFs: RF2 +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((part.p_partkey = lineitem.l_partkey)) otherCondition=() build RFs:RF1 p_partkey->[l_partkey] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[lineitem] apply RFs: RF1 RF3 RF4 RF5 +------------------------------PhysicalProject +--------------------------------filter((p_name like '%green%')) +----------------------------------PhysicalOlapScan[part] apply RFs: RF5 +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((supplier.s_nationkey = nation.n_nationkey)) otherCondition=() build RFs:RF0 n_nationkey->[s_nationkey] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[supplier] apply RFs: RF0 RF4 +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[nation] +------------------PhysicalProject +--------------------PhysicalOlapScan[partsupp] + diff --git a/regression-test/suites/nereids_rules_p0/mv/tpch/mv_tpch_test.groovy b/regression-test/suites/nereids_rules_p0/mv/tpch/mv_tpch_test.groovy index 335ecb7e6446e7..c78f2e84f6b1f5 100644 --- a/regression-test/suites/nereids_rules_p0/mv/tpch/mv_tpch_test.groovy +++ b/regression-test/suites/nereids_rules_p0/mv/tpch/mv_tpch_test.groovy @@ -226,9 +226,8 @@ suite("mv_tpch_test") { p_partkey LIMIT 100; """ - // contains limit, doesn't support now - order_qt_query2_before "${query2}" - async_mv_rewrite_success(db, mv2, query2, "mv2") + // contains multi join cluster, not support now + async_mv_rewrite_fail(db, mv2, query2, "mv2") order_qt_query2_after "${query2}" sql """ DROP MATERIALIZED VIEW IF EXISTS mv2""" @@ -1231,10 +1230,8 @@ suite("mv_tpch_test") { l_partkey = p_partkey ) """ - // agg under join should rewrite successfully, - // but because AGG_SCALAR_SUBQUERY_TO_WINDOW_FUNCTION rule - // would rewrite to agg-window-join, so now doesn't support - async_mv_rewrite_fail(db, mv17, query17, "mv17") + order_qt_query17_before "${query17}" + async_mv_rewrite_success(db, mv17, query17, "mv17") order_qt_query17_after "${query17}" sql """ DROP MATERIALIZED VIEW IF EXISTS mv17""" diff --git a/regression-test/suites/nereids_rules_p0/subquery_to_window_function/correlated_scalar_subquery_to_window_function.groovy b/regression-test/suites/nereids_rules_p0/subquery_to_window_function/correlated_scalar_subquery_to_window_function.groovy new file mode 100644 index 00000000000000..08d155811a3bf4 --- /dev/null +++ b/regression-test/suites/nereids_rules_p0/subquery_to_window_function/correlated_scalar_subquery_to_window_function.groovy @@ -0,0 +1,313 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("correlated_scalar_subquery_to_window_function") { + if (isCloudMode()) { + return + } + multi_sql """ + set exec_mem_limit=21G; + set be_number_for_test=3; + set enable_runtime_filter_prune=false; + set parallel_pipeline_task_num=8; + set forbid_unknown_col_stats=false; + set enable_stats=true; + set runtime_filter_type=8; + set broadcast_row_count_limit = 0; + set enable_nereids_timeout = false; + set enable_pipeline_engine = true; + set disable_nereids_rules='PRUNE_EMPTY_PARTITION'; + set push_topn_to_agg = true; + set topn_opt_limit_threshold=1024; + """ + + sql "DROP TABLE IF EXISTS fact FORCE" + sql "DROP TABLE IF EXISTS dim FORCE" + sql "DROP TABLE IF EXISTS dim_unique FORCE" + + sql """ + CREATE TABLE fact ( + id INT, + k INT, + v INT + ) ENGINE=OLAP + DUPLICATE KEY(id) + DISTRIBUTED BY HASH(id) BUCKETS 1 + PROPERTIES ('replication_num' = '1') + """ + + sql """ + CREATE TABLE dim ( + did INT, + k INT, + tag INT + ) ENGINE=OLAP + DUPLICATE KEY(did) + DISTRIBUTED BY HASH(did) BUCKETS 1 + PROPERTIES ('replication_num' = '1') + """ + + // dim_unique: UNIQUE KEY on k so the correlated outer-only slot is unique + // and non-null. This table exercises the AggScalarSubQueryToWindowFunction + // rewrite path (WinMagic). + sql """ + CREATE TABLE dim_unique ( + k INT NOT NULL, + did INT, + tag INT + ) ENGINE=OLAP + UNIQUE KEY(k) + DISTRIBUTED BY HASH(k) BUCKETS 1 + PROPERTIES ('replication_num' = '1') + """ + + sql """ALTER TABLE dim_unique ADD CONSTRAINT uq_dim_unique_k UNIQUE (k)""" + + sql """ + insert into fact values + (1, 1, 5), + (2, 1, 7), + (3, 2, 4), + (4, 2, 10), + (5, 3, 8), + (10, 1, 6), + (11, 2, 6) + """ + + sql """ + insert into dim values + (10, 1, 1), + (11, 1, 1), + (20, 2, 1), + (30, 3, 0), + (31, null, 1) + """ + + sql """ + insert into dim_unique values + (1, 10, 1), + (2, 20, 1), + (3, 30, 0), + (4, 40, 3) + """ + + // Positive case: dim_unique has UNIQUE KEY(k), so the correlated slot is + // unique + non-null and the rule rewrites the scalar subquery to a window + // function. + order_qt_d26072_unique """ + SELECT d.did, f.id, f.k, f.v + FROM fact f, dim_unique d + WHERE f.k = d.k + AND f.v * 2 > ( + SELECT SUM(f2.v) + FROM fact f2 + WHERE f2.k = d.k + ) + ORDER BY d.did, f.id + """ + + // Negative case (no rewrite): dim is DUPLICATE KEY(did) – k is neither + // unique nor guaranteed non-null, so the rule must not rewrite this to a + // window function. The query validates the original scalar-subquery plan. + order_qt_d26072 """ + SELECT d.did, f.id, f.k, f.v + FROM fact f, dim d + WHERE f.k = d.k + AND f.v * 2 > ( + SELECT SUM(f2.v) + FROM fact f2 + WHERE f2.k = d.k + ) + ORDER BY d.did, f.id + """ + + // Negative case (no rewrite): the outer-only relation output is pruned + // (dim columns are projected away in the subquery), so the rule cannot + // establish the outer-only table and must not rewrite. + order_qt_d26072_no_change """ + SELECT t.id, t.k, t.v + FROM ( + SELECT f.id, d.k, f.v + FROM fact f, dim d + WHERE f.k = d.k + ) t + WHERE t.v * 2 > ( + SELECT SUM(f2.v) + FROM fact f2 + WHERE f2.k = t.k + ) + ORDER BY t.id, t.k, t.v + """ + + // Shape plan: positive case — dim_unique has UNIQUE KEY(k), the rewrite + // should produce a LogicalWindow node. + qt_d26072_unique_shape """ + explain shape plan + SELECT d.did, f.id, f.k, f.v + FROM fact f, dim_unique d + WHERE f.k = d.k + AND f.v * 2 > ( + SELECT SUM(f2.v) + FROM fact f2 + WHERE f2.k = d.k + ) + ORDER BY d.did, f.id + """ + + // Shape plan: negative case — dim is DUPLICATE KEY(did), no rewrite, + // LogicalWindow must NOT appear. + qt_d26072_shape """ + explain shape plan + SELECT d.did, f.id, f.k, f.v + FROM fact f, dim d + WHERE f.k = d.k + AND f.v * 2 > ( + SELECT SUM(f2.v) + FROM fact f2 + WHERE f2.k = d.k + ) + ORDER BY d.did, f.id + """ + + // ------ Shared-table predicate must stay above the window ------ + // f.v > 5 references only the shared table (fact). It must stay ABOVE + // the window so the window function aggregates ALL fact rows per key, + // not just the filtered subset. + // + // fact rows per key: k=1 → v=5,7,6 (sum=18); k=2 → v=4,10,6 (sum=20) + // With f.v > 5 above window: k=1 sum=18, none of (7,6) pass 2*v>18; + // k=2 sum=20, only v=10 passes 20>20→false. Results: none. + // Bug behavior (f.v > 5 below window): k=1 sum over v>5=7+6=13, + // v=7→14>13 true; k=2 sum over v>5=10+6=16, v=10→20>16 true. + // Both rows incorrectly returned. + order_qt_shared_filter_above_window """ + SELECT d.did, f.id, f.k, f.v + FROM fact f, dim_unique d + WHERE f.k = d.k + AND f.v > 5 + AND f.v * 2 > ( + SELECT SUM(f2.v) + FROM fact f2 + WHERE f2.k = d.k + ) + ORDER BY d.did, f.id + """ + + // Shape: shared-filter rewrite — LogicalWindow must be present. + qt_shared_filter_above_window_shape """ + explain shape plan + SELECT d.did, f.id, f.k, f.v + FROM fact f, dim_unique d + WHERE f.k = d.k + AND f.v > 5 + AND f.v * 2 > ( + SELECT SUM(f2.v) + FROM fact f2 + WHERE f2.k = d.k + ) + ORDER BY d.did, f.id + """ + + // ------ Mixed predicate f.v > d.tag must stay above the window ------ + // f.v > d.tag references both shared (f.v) and outer-only (d.tag) columns. + // It must stay ABOVE so the window computes over all joined rows. + // + // fact: k=1→v=5,7,6; k=2→v=4,10,6 + // dim_unique: k=1 tag=1; k=2 tag=1; k=3 tag=0; k=4 tag=3 + // + // k=1: all fact rows: 5>1✓, 7>1✓, 6>1✓; sum=18; 2*v > 18: 14>18✗, 12>18✗ + // k=2: all fact rows: 4>1✓, 10>1✓, 6>1✓; sum=20; 2*v > 20: 20>20✗, 12>20✗ + // k=3: only fact v=8, 8>0✓; sum=8; 2*8>8✓ → (30, 5, 3, 8) + // k=4: 5>3✓, 7>3✓, 6>3✓; sum=18; 2*v>18: none pass + // Also: fact row with k=1 joins dim_unique k=3? No — join is f.k=d.k. + // Expected: k=3 row only: (30, 5, 3, 8) + order_qt_mixed_above_window """ + SELECT d.did, f.id, f.k, f.v + FROM fact f, dim_unique d + WHERE f.k = d.k + AND f.v > d.tag + AND f.v * 2 > ( + SELECT SUM(f2.v) + FROM fact f2 + WHERE f2.k = d.k + ) + ORDER BY d.did, f.id + """ + + // Shape: mixed predicate rewrite — LogicalWindow must be present. + qt_mixed_above_window_shape """ + explain shape plan + SELECT d.did, f.id, f.k, f.v + FROM fact f, dim_unique d + WHERE f.k = d.k + AND f.v > d.tag + AND f.v * 2 > ( + SELECT SUM(f2.v) + FROM fact f2 + WHERE f2.k = d.k + ) + ORDER BY d.did, f.id + """ + + // ------ Inner filter conjunct stays below the window ------ + // The inner subquery has f2.v < 10. checkFilter() matches this against + // the outer conjunct f.v < 10. The matched conjunct must stay BELOW + // the window because it's semantically part of the inner aggregate's filter. + // + // fact: k=1→v=5,7,6; k=2→v=4,10,6; k=3→v=8 + // Inner agg over f2.v < 10: k=1→5,7,6 sum=18; k=2→4,6 sum=10 (v=10 excluded); + // k=3→8 sum=8 + // Outer: f.v < 10 excludes v=10. f.v*2 > sum: k=1→14>18✗,12>18✗,10>18✗; + // k=2→8>10✗,12>10✓ → (20, 11, 2, 6); k=3→16>8✓ → (30, 5, 3, 8) + // Expected: (20, 11, 2, 6), (30, 5, 3, 8) + // + // Note: When the inner filter f2.v < 10 is kept as a separate LogicalFilter + // (not pushed into the scan), the rewrite SHOULD match per the UT tests. + // In the full optimizer pipeline, PullUpCorrelatedFilterUnderApplyAggregateProject + // may restructure the plan so the pattern no longer matches. The result + // data is verified regardless; the shape documents the actual plan. + order_qt_inner_filter_below_window """ + SELECT d.did, f.id, f.k, f.v + FROM fact f, dim_unique d + WHERE f.k = d.k + AND f.v < 10 + AND f.v * 2 > ( + SELECT SUM(f2.v) + FROM fact f2 + WHERE f2.k = d.k + AND f2.v < 10 + ) + ORDER BY d.did, f.id + """ + + // Shape: inner filter conjunct rewrite — LogicalWindow must be present + // when the rule matches. Documents the actual plan produced. + qt_inner_filter_below_window_shape """ + explain shape plan + SELECT d.did, f.id, f.k, f.v + FROM fact f, dim_unique d + WHERE f.k = d.k + AND f.v < 10 + AND f.v * 2 > ( + SELECT SUM(f2.v) + FROM fact f2 + WHERE f2.k = d.k + AND f2.v < 10 + ) + ORDER BY d.did, f.id + """ +} \ No newline at end of file diff --git a/regression-test/suites/shape_check/tpcds_sf1000/hint/query64.groovy b/regression-test/suites/shape_check/tpcds_sf1000/hint/query64.groovy index 875421bbb7d3bb..96c7797dde198f 100644 --- a/regression-test/suites/shape_check/tpcds_sf1000/hint/query64.groovy +++ b/regression-test/suites/shape_check/tpcds_sf1000/hint/query64.groovy @@ -35,7 +35,6 @@ suite("query64") { sql 'set runtime_filter_type=8' sql 'set dump_nereids_memo=false' sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" - sql "set memo_max_group_expression_size = 1000000" def ds = """with cs_ui as diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/load.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/load.groovy new file mode 100644 index 00000000000000..bb95ede94b45e7 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/load.groovy @@ -0,0 +1,2528 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("load") { + String database = context.config.getDbNameByFile(context.file) + sql "drop database if exists ${database}" + sql "create database ${database}" + sql "use ${database}" + + sql ''' + drop table if exists customer_demographics + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS customer_demographics ( + cd_demo_sk int not null, + cd_gender varchar(1), + cd_marital_status varchar(1), + cd_education_status varchar(20), + cd_purchase_estimate integer, + cd_credit_rating varchar(10), + cd_dep_count integer, + cd_dep_employed_count integer, + cd_dep_college_count integer + ) + DUPLICATE KEY(cd_demo_sk) + DISTRIBUTED BY HASH(cd_demo_sk) BUCKETS 9 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists reason + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS reason ( + r_reason_sk int not null, + r_reason_id varchar(16) not null, + r_reason_desc varchar(100) + ) + DUPLICATE KEY(r_reason_sk) + DISTRIBUTED BY HASH(r_reason_sk) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists date_dim + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS date_dim ( + d_date_sk int not null, + d_date_id varchar(16) not null, + d_date datev2, + d_month_seq integer, + d_week_seq integer, + d_quarter_seq integer, + d_year integer, + d_dow integer, + d_moy integer, + d_dom integer, + d_qoy integer, + d_fy_year integer, + d_fy_quarter_seq integer, + d_fy_week_seq integer, + d_day_name varchar(9), + d_quarter_name varchar(6), + d_holiday varchar(1), + d_weekend varchar(1), + d_following_holiday varchar(1), + d_first_dom integer, + d_last_dom integer, + d_same_day_ly integer, + d_same_day_lq integer, + d_current_day varchar(1), + d_current_week varchar(1), + d_current_month varchar(1), + d_current_quarter varchar(1), + d_current_year varchar(1) + ) + DUPLICATE KEY(d_date_sk) + DISTRIBUTED BY HASH(d_date_sk) BUCKETS 9 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists warehouse + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS warehouse ( + w_warehouse_sk int not null, + w_warehouse_id varchar(16) not null, + w_warehouse_name varchar(20), + w_warehouse_sq_ft integer, + w_street_number varchar(10), + w_street_name varchar(60), + w_street_type varchar(15), + w_suite_number varchar(10), + w_city varchar(60), + w_county varchar(30), + w_state varchar(2), + w_zip varchar(10), + w_country varchar(20), + w_gmt_offset decimalv3(5,2) + ) + DUPLICATE KEY(w_warehouse_sk) + DISTRIBUTED BY HASH(w_warehouse_sk) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists catalog_sales + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS catalog_sales ( + cs_sold_date_sk int, + cs_item_sk int not null, + cs_order_number int not null, + cs_sold_time_sk int, + cs_ship_date_sk int, + cs_bill_customer_sk int, + cs_bill_cdemo_sk int, + cs_bill_hdemo_sk int, + cs_bill_addr_sk int, + cs_ship_customer_sk int, + cs_ship_cdemo_sk int, + cs_ship_hdemo_sk int, + cs_ship_addr_sk int, + cs_call_center_sk int, + cs_catalog_page_sk int, + cs_ship_mode_sk int, + cs_warehouse_sk int, + cs_promo_sk int, + cs_quantity int, + cs_wholesale_cost decimalv3(7,2), + cs_list_price decimalv3(7,2), + cs_sales_price decimalv3(7,2), + cs_ext_discount_amt decimalv3(7,2), + cs_ext_sales_price decimalv3(7,2), + cs_ext_wholesale_cost decimalv3(7,2), + cs_ext_list_price decimalv3(7,2), + cs_ext_tax decimalv3(7,2), + cs_coupon_amt decimalv3(7,2), + cs_ext_ship_cost decimalv3(7,2), + cs_net_paid decimalv3(7,2), + cs_net_paid_inc_tax decimalv3(7,2), + cs_net_paid_inc_ship decimalv3(7,2), + cs_net_paid_inc_ship_tax decimalv3(7,2), + cs_net_profit decimalv3(7,2) + ) + DUPLICATE KEY(`cs_sold_date_sk`, `cs_item_sk`, `cs_order_number`) + DISTRIBUTED BY HASH(cs_item_sk, cs_order_number) BUCKETS 261 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists call_center + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS call_center ( + cc_call_center_sk int not null, + cc_call_center_id varchar(16) not null, + cc_rec_start_date date, + cc_rec_end_date date, + cc_closed_date_sk integer, + cc_open_date_sk integer, + cc_name varchar(50), + cc_class varchar(50), + cc_employees integer, + cc_sq_ft integer, + cc_hours varchar(20), + cc_manager varchar(40), + cc_mkt_id integer, + cc_mkt_class varchar(50), + cc_mkt_desc varchar(100), + cc_market_manager varchar(40), + cc_division integer, + cc_division_name varchar(50), + cc_company integer, + cc_company_name varchar(50), + cc_street_number varchar(10), + cc_street_name varchar(60), + cc_street_type varchar(15), + cc_suite_number varchar(10), + cc_city varchar(60), + cc_county varchar(30), + cc_state varchar(2), + cc_zip varchar(10), + cc_country varchar(20), + cc_gmt_offset decimalv3(5,2), + cc_tax_percentage decimalv3(5,2) + ) + DUPLICATE KEY(cc_call_center_sk) + DISTRIBUTED BY HASH(cc_call_center_sk) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists inventory + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS inventory ( + inv_date_sk int not null, + inv_item_sk int not null, + inv_warehouse_sk int, + inv_quantity_on_hand integer + ) + DUPLICATE KEY(inv_date_sk, inv_item_sk, inv_warehouse_sk) + DISTRIBUTED BY HASH(inv_item_sk) BUCKETS 63 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists catalog_returns + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS catalog_returns ( + cr_returned_date_sk int, + cr_item_sk int not null, + cr_order_number int not null, + cr_returned_time_sk int, + cr_refunded_customer_sk int, + cr_refunded_cdemo_sk int, + cr_refunded_hdemo_sk int, + cr_refunded_addr_sk int, + cr_returning_customer_sk int, + cr_returning_cdemo_sk int, + cr_returning_hdemo_sk int, + cr_returning_addr_sk int, + cr_call_center_sk int, + cr_catalog_page_sk int, + cr_ship_mode_sk int, + cr_warehouse_sk int, + cr_reason_sk int, + cr_return_quantity integer, + cr_return_amount decimalv3(7,2), + cr_return_tax decimalv3(7,2), + cr_return_amt_inc_tax decimalv3(7,2), + cr_fee decimalv3(7,2), + cr_return_ship_cost decimalv3(7,2), + cr_refunded_cash decimalv3(7,2), + cr_reversed_charge decimalv3(7,2), + cr_store_credit decimalv3(7,2), + cr_net_loss decimalv3(7,2) + ) + DUPLICATE KEY(`cr_returned_date_sk`, `cr_item_sk`, `cr_order_number`) + DISTRIBUTED BY HASH(cr_item_sk, cr_order_number) BUCKETS 36 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists household_demographics + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS household_demographics ( + hd_demo_sk int not null, + hd_income_band_sk int, + hd_buy_potential varchar(15), + hd_dep_count integer, + hd_vehicle_count integer + ) + DUPLICATE KEY(hd_demo_sk) + DISTRIBUTED BY HASH(hd_demo_sk) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists customer_address + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS customer_address ( + ca_address_sk int not null, + ca_address_id varchar(16) not null, + ca_street_number varchar(10), + ca_street_name varchar(60), + ca_street_type varchar(15), + ca_suite_number varchar(10), + ca_city varchar(60), + ca_county varchar(30), + ca_state varchar(2), + ca_zip varchar(10), + ca_country varchar(20), + ca_gmt_offset decimalv3(5,2), + ca_location_type varchar(20) + ) + DUPLICATE KEY(ca_address_sk) + DISTRIBUTED BY HASH(ca_address_sk) BUCKETS 18 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists income_band + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS income_band ( + ib_income_band_sk int not null, + ib_lower_bound integer, + ib_upper_bound integer + ) + DUPLICATE KEY(ib_income_band_sk) + DISTRIBUTED BY HASH(ib_income_band_sk) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists catalog_page + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS catalog_page ( + cp_catalog_page_sk int not null, + cp_catalog_page_id varchar(16) not null, + cp_start_date_sk integer, + cp_end_date_sk integer, + cp_department varchar(50), + cp_catalog_number integer, + cp_catalog_page_number integer, + cp_description varchar(100), + cp_type varchar(100) + ) + DUPLICATE KEY(cp_catalog_page_sk) + DISTRIBUTED BY HASH(cp_catalog_page_sk) BUCKETS 3 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists item + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS item ( + i_item_sk int not null, + i_item_id varchar(16) not null, + i_rec_start_date datev2, + i_rec_end_date datev2, + i_item_desc varchar(200), + i_current_price decimalv3(7,2), + i_wholesale_cost decimalv3(7,2), + i_brand_id integer, + i_brand varchar(50), + i_class_id integer, + i_class char(50), + i_category_id integer, + i_category varchar(50), + i_manufact_id integer, + i_manufact varchar(50), + i_size varchar(20), + i_formulation varchar(20), + i_color varchar(20), + i_units varchar(10), + i_container varchar(10), + i_manager_id integer, + i_product_name varchar(50) + ) + DUPLICATE KEY(i_item_sk) + DISTRIBUTED BY HASH(i_item_sk) BUCKETS 9 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists web_returns + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS web_returns ( + wr_returned_date_sk int, + wr_item_sk int not null, + wr_order_number int not null, + wr_returned_time_sk int, + wr_refunded_customer_sk int, + wr_refunded_cdemo_sk int, + wr_refunded_hdemo_sk int, + wr_refunded_addr_sk int, + wr_returning_customer_sk int, + wr_returning_cdemo_sk int, + wr_returning_hdemo_sk int, + wr_returning_addr_sk int, + wr_web_page_sk int, + wr_reason_sk int, + wr_return_quantity integer, + wr_return_amt decimalv3(7,2), + wr_return_tax decimalv3(7,2), + wr_return_amt_inc_tax decimalv3(7,2), + wr_fee decimalv3(7,2), + wr_return_ship_cost decimalv3(7,2), + wr_refunded_cash decimalv3(7,2), + wr_reversed_charge decimalv3(7,2), + wr_account_credit decimalv3(7,2), + wr_net_loss decimalv3(7,2) + ) + DUPLICATE KEY(`wr_returned_date_sk`, `wr_item_sk`, `wr_order_number`) + DISTRIBUTED BY HASH(`wr_item_sk`, `wr_order_number`) BUCKETS 18 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists web_site + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS web_site ( + web_site_sk int not null, + web_site_id varchar(16) not null, + web_rec_start_date datev2, + web_rec_end_date datev2, + web_name varchar(50), + web_open_date_sk int, + web_close_date_sk int, + web_class varchar(50), + web_manager varchar(40), + web_mkt_id integer, + web_mkt_class varchar(50), + web_mkt_desc varchar(100), + web_market_manager varchar(40), + web_company_id integer, + web_company_name varchar(50), + web_street_number varchar(10), + web_street_name varchar(60), + web_street_type varchar(15), + web_suite_number varchar(10), + web_city varchar(60), + web_county varchar(30), + web_state varchar(2), + web_zip varchar(10), + web_country varchar(20), + web_gmt_offset decimalv3(5,2), + web_tax_percentage decimalv3(5,2) + ) + DUPLICATE KEY(web_site_sk) + DISTRIBUTED BY HASH(web_site_sk) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists promotion + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS promotion ( + p_promo_sk int not null, + p_promo_id varchar(16) not null, + p_start_date_sk int, + p_end_date_sk int, + p_item_sk int, + p_cost decimalv3(15,2), + p_response_targe integer, + p_promo_name varchar(50), + p_channel_dmail varchar(1), + p_channel_email varchar(1), + p_channel_catalog varchar(1), + p_channel_tv varchar(1), + p_channel_radio varchar(1), + p_channel_press varchar(1), + p_channel_event varchar(1), + p_channel_demo varchar(1), + p_channel_details varchar(100), + p_purpose varchar(15), + p_discount_active varchar(1) + ) + DUPLICATE KEY(p_promo_sk) + DISTRIBUTED BY HASH(p_promo_sk) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists web_sales + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS web_sales ( + ws_sold_date_sk int, + ws_item_sk int not null, + ws_order_number int not null, + ws_sold_time_sk int, + ws_ship_date_sk int, + ws_bill_customer_sk int, + ws_bill_cdemo_sk int, + ws_bill_hdemo_sk int, + ws_bill_addr_sk int, + ws_ship_customer_sk int, + ws_ship_cdemo_sk int, + ws_ship_hdemo_sk int, + ws_ship_addr_sk int, + ws_web_page_sk int, + ws_web_site_sk int, + ws_ship_mode_sk int, + ws_warehouse_sk int, + ws_promo_sk int, + ws_quantity integer, + ws_wholesale_cost decimalv3(7,2), + ws_list_price decimalv3(7,2), + ws_sales_price decimalv3(7,2), + ws_ext_discount_amt decimalv3(7,2), + ws_ext_sales_price decimalv3(7,2), + ws_ext_wholesale_cost decimalv3(7,2), + ws_ext_list_price decimalv3(7,2), + ws_ext_tax decimalv3(7,2), + ws_coupon_amt decimalv3(7,2), + ws_ext_ship_cost decimalv3(7,2), + ws_net_paid decimalv3(7,2), + ws_net_paid_inc_tax decimalv3(7,2), + ws_net_paid_inc_ship decimalv3(7,2), + ws_net_paid_inc_ship_tax decimalv3(7,2), + ws_net_profit decimalv3(7,2) + ) + DUPLICATE KEY(`ws_sold_date_sk`, `ws_item_sk`, `ws_order_number`) + DISTRIBUTED BY HASH(ws_item_sk, ws_order_number) BUCKETS 126 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists store + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS store ( + s_store_sk int not null, + s_store_id varchar(16) not null, + s_rec_start_date datev2, + s_rec_end_date datev2, + s_closed_date_sk int, + s_store_name varchar(50), + s_number_employees integer, + s_floor_space integer, + s_hours varchar(20), + s_manager varchar(40), + s_market_id integer, + s_geography_class varchar(100), + s_market_desc varchar(100), + s_market_manager varchar(40), + s_division_id integer, + s_division_name varchar(50), + s_company_id integer, + s_company_name varchar(50), + s_street_number varchar(10), + s_street_name varchar(60), + s_street_type varchar(15), + s_suite_number varchar(10), + s_city varchar(60), + s_county varchar(30), + s_state varchar(2), + s_zip varchar(10), + s_country varchar(20), + s_gmt_offset decimalv3(5,2), + s_tax_percentage decimalv3(5,2) + ) + DUPLICATE KEY(s_store_sk) + DISTRIBUTED BY HASH(s_store_sk) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists time_dim + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS time_dim ( + t_time_sk int not null, + t_time_id varchar(16) not null, + t_time integer, + t_hour integer, + t_minute integer, + t_second integer, + t_am_pm varchar(2), + t_shift varchar(20), + t_sub_shift varchar(20), + t_meal_time varchar(20) + ) + DUPLICATE KEY(t_time_sk) + DISTRIBUTED BY HASH(t_time_sk) BUCKETS 9 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists web_page + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS web_page ( + wp_web_page_sk int not null, + wp_web_page_id varchar(16) not null, + wp_rec_start_date datev2, + wp_rec_end_date datev2, + wp_creation_date_sk int, + wp_access_date_sk int, + wp_autogen_flag varchar(1), + wp_customer_sk int, + wp_url varchar(100), + wp_type varchar(50), + wp_char_count integer, + wp_link_count integer, + wp_image_count integer, + wp_max_ad_count integer + ) + DUPLICATE KEY(wp_web_page_sk) + DISTRIBUTED BY HASH(wp_web_page_sk) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists store_returns + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS store_returns ( + sr_returned_date_sk int, + sr_item_sk int not null, + sr_ticket_number int not null, + sr_return_time_sk int, + sr_customer_sk int, + sr_cdemo_sk int, + sr_hdemo_sk int, + sr_addr_sk int, + sr_store_sk int, + sr_reason_sk int, + sr_return_quantity integer, + sr_return_amt decimalv3(7,2), + sr_return_tax decimalv3(7,2), + sr_return_amt_inc_tax decimalv3(7,2), + sr_fee decimalv3(7,2), + sr_return_ship_cost decimalv3(7,2), + sr_refunded_cash decimalv3(7,2), + sr_reversed_charge decimalv3(7,2), + sr_store_credit decimalv3(7,2), + sr_net_loss decimalv3(7,2) + ) + duplicate key(`sr_returned_date_sk`, `sr_item_sk`, `sr_ticket_number`) + distributed by hash (sr_item_sk, sr_ticket_number) buckets 36 + properties ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists store_sales + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS store_sales ( + ss_sold_date_sk int, + ss_item_sk int not null, + ss_ticket_number int not null, + ss_sold_time_sk int, + ss_customer_sk int, + ss_cdemo_sk int, + ss_hdemo_sk int, + ss_addr_sk int, + ss_store_sk int, + ss_promo_sk int, + ss_quantity integer, + ss_wholesale_cost decimalv3(7,2), + ss_list_price decimalv3(7,2), + ss_sales_price decimalv3(7,2), + ss_ext_discount_amt decimalv3(7,2), + ss_ext_sales_price decimalv3(7,2), + ss_ext_wholesale_cost decimalv3(7,2), + ss_ext_list_price decimalv3(7,2), + ss_ext_tax decimalv3(7,2), + ss_coupon_amt decimalv3(7,2), + ss_net_paid decimalv3(7,2), + ss_net_paid_inc_tax decimalv3(7,2), + ss_net_profit decimalv3(7,2) + ) + DUPLICATE KEY(`ss_sold_date_sk`, `ss_item_sk`, `ss_ticket_number`) + DISTRIBUTED BY HASH(ss_item_sk, ss_ticket_number) BUCKETS 261 + PROPERTIES ( + "replication_num" = "1", + "colocate_with" = "store" + ) + ''' + + sql ''' + drop table if exists ship_mode + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS ship_mode ( + sm_ship_mode_sk int not null, + sm_ship_mode_id varchar(16) not null, + sm_type varchar(30), + sm_code varchar(10), + sm_carrier varchar(20), + sm_contract varchar(20) + ) + DUPLICATE KEY(sm_ship_mode_sk) + DISTRIBUTED BY HASH(sm_ship_mode_sk) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists customer + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS customer ( + c_customer_sk int not null, + c_customer_id varchar(16) not null, + c_current_cdemo_sk int, + c_current_hdemo_sk int, + c_current_addr_sk int, + c_first_shipto_date_sk int, + c_first_sales_date_sk int, + c_salutation varchar(10), + c_first_name varchar(20), + c_last_name varchar(30), + c_preferred_cust_flag varchar(1), + c_birth_day integer, + c_birth_month integer, + c_birth_year integer, + c_birth_country varchar(20), + c_login varchar(13), + c_email_address varchar(50), + c_last_review_date_sk int + ) + DUPLICATE KEY(c_customer_sk) + DISTRIBUTED BY HASH(c_customer_sk) BUCKETS 18 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql ''' + drop table if exists dbgen_version + ''' + + sql ''' + CREATE TABLE IF NOT EXISTS dbgen_version + ( + dv_version varchar(16) , + dv_create_date datev2 , + dv_create_time datetime , + dv_cmdline_args varchar(200) + ) + DUPLICATE KEY(dv_version) + DISTRIBUTED BY HASH(dv_version) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ) + ''' + + sql """ + alter table customer_demographics modify column cd_dep_employed_count set stats ('row_count'='1920800', 'ndv'='7', 'num_nulls'='0', 'min_value'='0', 'max_value'='6', 'data_size'='7683200') + """ + + sql """ + alter table date_dim modify column d_day_name set stats ('row_count'='73049', 'ndv'='7', 'num_nulls'='0', 'min_value'='Friday', 'max_value'='Wednesday', 'data_size'='521779') + """ + + sql """ + alter table date_dim modify column d_following_holiday set stats ('row_count'='73049', 'ndv'='2', 'num_nulls'='0', 'min_value'='N', 'max_value'='Y', 'data_size'='73049') + """ + + sql """ + alter table date_dim modify column d_same_day_ly set stats ('row_count'='73049', 'ndv'='72450', 'num_nulls'='0', 'min_value'='2414657', 'max_value'='2487705', 'data_size'='292196') + """ + + sql """ + alter table warehouse modify column w_city set stats ('row_count'='20', 'ndv'='12', 'num_nulls'='0', 'min_value'='Fairview', 'max_value'='Shiloh', 'data_size'='183') + """ + + sql """ + alter table warehouse modify column w_street_type set stats ('row_count'='20', 'ndv'='14', 'num_nulls'='0', 'min_value'='', 'max_value'='Wy', 'data_size'='71') + """ + + sql """ + alter table catalog_sales modify column cs_call_center_sk set stats ('row_count'='1439980416', 'ndv'='42', 'num_nulls'='7199711', 'min_value'='1', 'max_value'='42', 'data_size'='11519843328') + """ + + sql """ + alter table catalog_sales modify column cs_net_paid_inc_ship set stats ('row_count'='1439980416', 'ndv'='2505826', 'num_nulls'='0', 'min_value'='0.00', 'max_value'='43956.00', 'data_size'='5759921664') + """ + + sql """ + alter table catalog_sales modify column cs_sales_price set stats ('row_count'='1439980416', 'ndv'='29306', 'num_nulls'='7200276', 'min_value'='0.00', 'max_value'='300.00', 'data_size'='5759921664') + """ + + sql """ + alter table call_center modify column cc_class set stats ('row_count'='42', 'ndv'='3', 'num_nulls'='0', 'min_value'='large', 'max_value'='small', 'data_size'='226') + """ + + sql """ + alter table call_center modify column cc_country set stats ('row_count'='42', 'ndv'='1', 'num_nulls'='0', 'min_value'='United States', 'max_value'='United States', 'data_size'='546') + """ + + sql """ + alter table call_center modify column cc_county set stats ('row_count'='42', 'ndv'='16', 'num_nulls'='0', 'min_value'='Barrow County', 'max_value'='Williamson County', 'data_size'='627') + """ + + sql """ + alter table call_center modify column cc_mkt_class set stats ('row_count'='42', 'ndv'='36', 'num_nulls'='0', 'min_value'='A bit narrow forms matter animals. Consist', 'max_value'='Yesterday new men can make moreov', 'data_size'='1465') + """ + + sql """ + alter table call_center modify column cc_sq_ft set stats ('row_count'='42', 'ndv'='31', 'num_nulls'='0', 'min_value'='-1890660328', 'max_value'='2122480316', 'data_size'='168') + """ + + sql """ + alter table call_center modify column cc_state set stats ('row_count'='42', 'ndv'='14', 'num_nulls'='0', 'min_value'='FL', 'max_value'='WV', 'data_size'='84') + """ + + sql """ + alter table inventory modify column inv_warehouse_sk set stats ('row_count'='783000000', 'ndv'='20', 'num_nulls'='0', 'min_value'='1', 'max_value'='20', 'data_size'='6264000000') + """ + + sql """ + alter table catalog_returns modify column cr_refunded_addr_sk set stats ('row_count'='143996756', 'ndv'='6015811', 'num_nulls'='2881609', 'min_value'='1', 'max_value'='6000000', 'data_size'='1151974048') + """ + + sql """ + alter table catalog_returns modify column cr_refunded_cash set stats ('row_count'='143996756', 'ndv'='1107525', 'num_nulls'='2879192', 'min_value'='0.00', 'max_value'='26955.24', 'data_size'='575987024') + """ + + sql """ + alter table catalog_returns modify column cr_refunded_cdemo_sk set stats ('row_count'='143996756', 'ndv'='1916366', 'num_nulls'='2881314', 'min_value'='1', 'max_value'='1920800', 'data_size'='1151974048') + """ + + sql """ + alter table catalog_returns modify column cr_return_amt_inc_tax set stats ('row_count'='143996756', 'ndv'='1544502', 'num_nulls'='2881886', 'min_value'='0.00', 'max_value'='30418.06', 'data_size'='575987024') + """ + + sql """ + alter table catalog_returns modify column cr_returning_addr_sk set stats ('row_count'='143996756', 'ndv'='6015811', 'num_nulls'='2883215', 'min_value'='1', 'max_value'='6000000', 'data_size'='1151974048') + """ + + sql """ + alter table household_demographics modify column hd_buy_potential set stats ('row_count'='7200', 'ndv'='6', 'num_nulls'='0', 'min_value'='0-500', 'max_value'='Unknown', 'data_size'='54000') + """ + + sql """ + alter table customer_address modify column ca_address_id set stats ('row_count'='6000000', 'ndv'='5984931', 'num_nulls'='0', 'min_value'='AAAAAAAAAAAAABAA', 'max_value'='AAAAAAAAPPPPPEAA', 'data_size'='96000000') + """ + + sql """ + alter table customer_address modify column ca_address_sk set stats ('row_count'='6000000', 'ndv'='6015811', 'num_nulls'='0', 'min_value'='1', 'max_value'='6000000', 'data_size'='48000000') + """ + + sql """ + alter table customer_address modify column ca_country set stats ('row_count'='6000000', 'ndv'='2', 'num_nulls'='0', 'min_value'='', 'max_value'='United States', 'data_size'='75661794') + """ + + sql """ + alter table customer_address modify column ca_location_type set stats ('row_count'='6000000', 'ndv'='4', 'num_nulls'='0', 'min_value'='', 'max_value'='single family', 'data_size'='52372545') + """ + + sql """ + alter table customer_address modify column ca_street_number set stats ('row_count'='6000000', 'ndv'='1002', 'num_nulls'='0', 'min_value'='', 'max_value'='999', 'data_size'='16837336') + """ + + sql """ + alter table customer_address modify column ca_suite_number set stats ('row_count'='6000000', 'ndv'='76', 'num_nulls'='0', 'min_value'='', 'max_value'='Suite Y', 'data_size'='45911575') + """ + + sql """ + alter table catalog_page modify column cp_catalog_page_id set stats ('row_count'='30000', 'ndv'='29953', 'num_nulls'='0', 'min_value'='AAAAAAAAAAABAAAA', 'max_value'='AAAAAAAAPPPGAAAA', 'data_size'='480000') + """ + + sql """ + alter table item modify column i_rec_end_date set stats ('row_count'='300000', 'ndv'='3', 'num_nulls'='150000', 'min_value'='1999-10-27', 'max_value'='2001-10-26', 'data_size'='1200000') + """ + + sql """ + alter table web_returns modify column wr_refunded_addr_sk set stats ('row_count'='71997522', 'ndv'='6015811', 'num_nulls'='3239971', 'min_value'='1', 'max_value'='6000000', 'data_size'='575980176') + """ + + sql """ + alter table web_returns modify column wr_reversed_charge set stats ('row_count'='71997522', 'ndv'='692680', 'num_nulls'='3239546', 'min_value'='0.00', 'max_value'='23194.77', 'data_size'='287990088') + """ + + sql """ + alter table web_site modify column web_state set stats ('row_count'='54', 'ndv'='18', 'num_nulls'='0', 'min_value'='AL', 'max_value'='WV', 'data_size'='108') + """ + + sql """ + alter table promotion modify column p_end_date_sk set stats ('row_count'='1500', 'ndv'='683', 'num_nulls'='18', 'min_value'='2450113', 'max_value'='2450967', 'data_size'='12000') + """ + + sql """ + alter table web_sales modify column ws_bill_hdemo_sk set stats ('row_count'='720000376', 'ndv'='7251', 'num_nulls'='180139', 'min_value'='1', 'max_value'='7200', 'data_size'='5760003008') + """ + + sql """ + alter table web_sales modify column ws_ext_ship_cost set stats ('row_count'='720000376', 'ndv'='567477', 'num_nulls'='180084', 'min_value'='0.00', 'max_value'='14950.00', 'data_size'='2880001504') + """ + + sql """ + alter table web_sales modify column ws_ship_addr_sk set stats ('row_count'='720000376', 'ndv'='6015811', 'num_nulls'='179848', 'min_value'='1', 'max_value'='6000000', 'data_size'='5760003008') + """ + + sql """ + alter table web_sales modify column ws_ship_mode_sk set stats ('row_count'='720000376', 'ndv'='20', 'num_nulls'='180017', 'min_value'='1', 'max_value'='20', 'data_size'='5760003008') + """ + + sql """ + alter table web_sales modify column ws_warehouse_sk set stats ('row_count'='720000376', 'ndv'='20', 'num_nulls'='180105', 'min_value'='1', 'max_value'='20', 'data_size'='5760003008') + """ + + sql """ + alter table store modify column s_company_name set stats ('row_count'='1002', 'ndv'='2', 'num_nulls'='0', 'min_value'='', 'max_value'='Unknown', 'data_size'='6965') + """ + + sql """ + alter table store modify column s_gmt_offset set stats ('row_count'='1002', 'ndv'='4', 'num_nulls'='6', 'min_value'='-8.00', 'max_value'='-5.00', 'data_size'='4008') + """ + + sql """ + alter table store modify column s_manager set stats ('row_count'='1002', 'ndv'='739', 'num_nulls'='0', 'min_value'='', 'max_value'='Zane Clifton', 'data_size'='12649') + """ + + sql """ + alter table store modify column s_street_number set stats ('row_count'='1002', 'ndv'='521', 'num_nulls'='0', 'min_value'='', 'max_value'='999', 'data_size'='2874') + """ + + sql """ + alter table time_dim modify column t_meal_time set stats ('row_count'='86400', 'ndv'='4', 'num_nulls'='0', 'min_value'='', 'max_value'='lunch', 'data_size'='248400') + """ + + sql """ + alter table time_dim modify column t_time set stats ('row_count'='86400', 'ndv'='86684', 'num_nulls'='0', 'min_value'='0', 'max_value'='86399', 'data_size'='345600') + """ + + sql """ + alter table web_page modify column wp_creation_date_sk set stats ('row_count'='3000', 'ndv'='199', 'num_nulls'='33', 'min_value'='2450604', 'max_value'='2450815', 'data_size'='24000') + """ + + sql """ + alter table web_page modify column wp_customer_sk set stats ('row_count'='3000', 'ndv'='713', 'num_nulls'='2147', 'min_value'='9522', 'max_value'='11995685', 'data_size'='24000') + """ + + sql """ + alter table web_page modify column wp_max_ad_count set stats ('row_count'='3000', 'ndv'='5', 'num_nulls'='31', 'min_value'='0', 'max_value'='4', 'data_size'='12000') + """ + + sql """ + alter table web_page modify column wp_url set stats ('row_count'='3000', 'ndv'='2', 'num_nulls'='0', 'min_value'='', 'max_value'='http://www.foo.com', 'data_size'='53406') + """ + + sql """ + alter table store_returns modify column sr_refunded_cash set stats ('row_count'='287999764', 'ndv'='928470', 'num_nulls'='10081294', 'min_value'='0.00', 'max_value'='18173.96', 'data_size'='1151999056') + """ + + sql """ + alter table store_returns modify column sr_return_tax set stats ('row_count'='287999764', 'ndv'='117247', 'num_nulls'='10081332', 'min_value'='0.00', 'max_value'='1682.04', 'data_size'='1151999056') + """ + + sql """ + alter table store_sales modify column ss_customer_sk set stats ('row_count'='2879987999', 'ndv'='12157481', 'num_nulls'='129590766', 'min_value'='1', 'max_value'='12000000', 'data_size'='23039903992') + """ + + sql """ + alter table store_sales modify column ss_hdemo_sk set stats ('row_count'='2879987999', 'ndv'='7251', 'num_nulls'='129594559', 'min_value'='1', 'max_value'='7200', 'data_size'='23039903992') + """ + + sql """ + alter table store_sales modify column ss_store_sk set stats ('row_count'='2879987999', 'ndv'='499', 'num_nulls'='129572050', 'min_value'='1', 'max_value'='1000', 'data_size'='23039903992') + """ + + sql """ + alter table ship_mode modify column sm_ship_mode_id set stats ('row_count'='20', 'ndv'='20', 'num_nulls'='0', 'min_value'='AAAAAAAAABAAAAAA', 'max_value'='AAAAAAAAPAAAAAAA', 'data_size'='320') + """ + + sql """ + alter table ship_mode modify column sm_ship_mode_sk set stats ('row_count'='20', 'ndv'='20', 'num_nulls'='0', 'min_value'='1', 'max_value'='20', 'data_size'='160') + """ + + sql """ + alter table customer modify column c_first_name set stats ('row_count'='12000000', 'ndv'='5140', 'num_nulls'='0', 'min_value'='', 'max_value'='Zulma', 'data_size'='67593278') + """ + + sql """ + alter table customer modify column c_first_sales_date_sk set stats ('row_count'='12000000', 'ndv'='3644', 'num_nulls'='419856', 'min_value'='2448998', 'max_value'='2452648', 'data_size'='96000000') + """ + + sql """ + alter table customer modify column c_first_shipto_date_sk set stats ('row_count'='12000000', 'ndv'='3644', 'num_nulls'='420769', 'min_value'='2449028', 'max_value'='2452678', 'data_size'='96000000') + """ + + sql """ + alter table customer_demographics modify column cd_dep_college_count set stats ('row_count'='1920800', 'ndv'='7', 'num_nulls'='0', 'min_value'='0', 'max_value'='6', 'data_size'='7683200') + """ + + sql """ + alter table date_dim modify column d_dow set stats ('row_count'='73049', 'ndv'='7', 'num_nulls'='0', 'min_value'='0', 'max_value'='6', 'data_size'='292196') + """ + + sql """ + alter table date_dim modify column d_fy_quarter_seq set stats ('row_count'='73049', 'ndv'='801', 'num_nulls'='0', 'min_value'='1', 'max_value'='801', 'data_size'='292196') + """ + + sql """ + alter table date_dim modify column d_qoy set stats ('row_count'='73049', 'ndv'='4', 'num_nulls'='0', 'min_value'='1', 'max_value'='4', 'data_size'='292196') + """ + + sql """ + alter table date_dim modify column d_quarter_seq set stats ('row_count'='73049', 'ndv'='801', 'num_nulls'='0', 'min_value'='1', 'max_value'='801', 'data_size'='292196') + """ + + sql """ + alter table warehouse modify column w_street_name set stats ('row_count'='20', 'ndv'='20', 'num_nulls'='0', 'min_value'='', 'max_value'='Wilson Elm', 'data_size'='176') + """ + + sql """ + alter table warehouse modify column w_suite_number set stats ('row_count'='20', 'ndv'='18', 'num_nulls'='0', 'min_value'='', 'max_value'='Suite X', 'data_size'='150') + """ + + sql """ + alter table catalog_sales modify column cs_bill_cdemo_sk set stats ('row_count'='1439980416', 'ndv'='1916366', 'num_nulls'='7202134', 'min_value'='1', 'max_value'='1920800', 'data_size'='11519843328') + """ + + sql """ + alter table catalog_sales modify column cs_bill_hdemo_sk set stats ('row_count'='1439980416', 'ndv'='7251', 'num_nulls'='7198837', 'min_value'='1', 'max_value'='7200', 'data_size'='11519843328') + """ + + sql """ + alter table catalog_sales modify column cs_ext_ship_cost set stats ('row_count'='1439980416', 'ndv'='573238', 'num_nulls'='7202537', 'min_value'='0.00', 'max_value'='14994.00', 'data_size'='5759921664') + """ + + sql """ + alter table call_center modify column cc_name set stats ('row_count'='42', 'ndv'='21', 'num_nulls'='0', 'min_value'='California', 'max_value'='Pacific Northwest_2', 'data_size'='572') + """ + + sql """ + alter table call_center modify column cc_street_name set stats ('row_count'='42', 'ndv'='21', 'num_nulls'='0', 'min_value'='1st', 'max_value'='Willow', 'data_size'='356') + """ + + sql """ + alter table call_center modify column cc_zip set stats ('row_count'='42', 'ndv'='19', 'num_nulls'='0', 'min_value'='18605', 'max_value'='98048', 'data_size'='210') + """ + + sql """ + alter table inventory modify column inv_quantity_on_hand set stats ('row_count'='783000000', 'ndv'='1006', 'num_nulls'='39153758', 'min_value'='0', 'max_value'='1000', 'data_size'='3132000000') + """ + + sql """ + alter table catalog_returns modify column cr_catalog_page_sk set stats ('row_count'='143996756', 'ndv'='17005', 'num_nulls'='2882502', 'min_value'='1', 'max_value'='25207', 'data_size'='1151974048') + """ + + sql """ + alter table household_demographics modify column hd_income_band_sk set stats ('row_count'='7200', 'ndv'='20', 'num_nulls'='0', 'min_value'='1', 'max_value'='20', 'data_size'='57600') + """ + + sql """ + alter table catalog_page modify column cp_description set stats ('row_count'='30000', 'ndv'='30141', 'num_nulls'='0', 'min_value'='', 'max_value'='Youngsters worry both workers. Fascinating characters take cheap never alive studies. Direct, old', 'data_size'='2215634') + """ + + sql """ + alter table item modify column i_item_id set stats ('row_count'='300000', 'ndv'='150851', 'num_nulls'='0', 'min_value'='AAAAAAAAAAAABAAA', 'max_value'='AAAAAAAAPPPPBAAA', 'data_size'='4800000') + """ + + sql """ + alter table web_returns modify column wr_account_credit set stats ('row_count'='71997522', 'ndv'='683955', 'num_nulls'='3241972', 'min_value'='0.00', 'max_value'='23166.33', 'data_size'='287990088') + """ + + sql """ + alter table web_returns modify column wr_net_loss set stats ('row_count'='71997522', 'ndv'='815608', 'num_nulls'='3240573', 'min_value'='0.50', 'max_value'='15887.84', 'data_size'='287990088') + """ + + sql """ + alter table web_returns modify column wr_return_amt set stats ('row_count'='71997522', 'ndv'='808311', 'num_nulls'='3238405', 'min_value'='0.00', 'max_value'='29191.00', 'data_size'='287990088') + """ + + sql """ + alter table web_returns modify column wr_return_amt_inc_tax set stats ('row_count'='71997522', 'ndv'='1359913', 'num_nulls'='3239765', 'min_value'='0.00', 'max_value'='30393.01', 'data_size'='287990088') + """ + + sql """ + alter table web_returns modify column wr_return_quantity set stats ('row_count'='71997522', 'ndv'='100', 'num_nulls'='3238643', 'min_value'='1', 'max_value'='100', 'data_size'='287990088') + """ + + sql """ + alter table web_returns modify column wr_returning_addr_sk set stats ('row_count'='71997522', 'ndv'='6015811', 'num_nulls'='3239658', 'min_value'='1', 'max_value'='6000000', 'data_size'='575980176') + """ + + sql """ + alter table web_returns modify column wr_returning_customer_sk set stats ('row_count'='71997522', 'ndv'='12119220', 'num_nulls'='3237281', 'min_value'='1', 'max_value'='12000000', 'data_size'='575980176') + """ + + sql """ + alter table web_site modify column web_mkt_desc set stats ('row_count'='54', 'ndv'='38', 'num_nulls'='0', 'min_value'='Acres see else children. Mutual too', 'max_value'='Windows increase to a differences. Other parties might in', 'data_size'='3473') + """ + + sql """ + alter table web_site modify column web_mkt_id set stats ('row_count'='54', 'ndv'='6', 'num_nulls'='1', 'min_value'='1', 'max_value'='6', 'data_size'='216') + """ + + sql """ + alter table web_site modify column web_rec_end_date set stats ('row_count'='54', 'ndv'='3', 'num_nulls'='27', 'min_value'='1999-08-16', 'max_value'='2001-08-15', 'data_size'='216') + """ + + sql """ + alter table web_site modify column web_site_id set stats ('row_count'='54', 'ndv'='27', 'num_nulls'='0', 'min_value'='AAAAAAAAABAAAAAA', 'max_value'='AAAAAAAAPBAAAAAA', 'data_size'='864') + """ + + sql """ + alter table web_site modify column web_street_type set stats ('row_count'='54', 'ndv'='20', 'num_nulls'='0', 'min_value'='Ave', 'max_value'='Wy', 'data_size'='208') + """ + + sql """ + alter table promotion modify column p_channel_demo set stats ('row_count'='1500', 'ndv'='2', 'num_nulls'='0', 'min_value'='', 'max_value'='N', 'data_size'='1479') + """ + + sql """ + alter table promotion modify column p_channel_details set stats ('row_count'='1500', 'ndv'='1490', 'num_nulls'='0', 'min_value'='', 'max_value'='Young, valuable companies watch walls. Payments can flour', 'data_size'='59126') + """ + + sql """ + alter table promotion modify column p_channel_event set stats ('row_count'='1500', 'ndv'='2', 'num_nulls'='0', 'min_value'='', 'max_value'='N', 'data_size'='1482') + """ + + sql """ + alter table promotion modify column p_discount_active set stats ('row_count'='1500', 'ndv'='2', 'num_nulls'='0', 'min_value'='', 'max_value'='N', 'data_size'='1473') + """ + + sql """ + alter table promotion modify column p_promo_sk set stats ('row_count'='1500', 'ndv'='1489', 'num_nulls'='0', 'min_value'='1', 'max_value'='1500', 'data_size'='12000') + """ + + sql """ + alter table promotion modify column p_purpose set stats ('row_count'='1500', 'ndv'='2', 'num_nulls'='0', 'min_value'='', 'max_value'='Unknown', 'data_size'='10374') + """ + + sql """ + alter table web_sales modify column ws_bill_cdemo_sk set stats ('row_count'='720000376', 'ndv'='1916366', 'num_nulls'='179788', 'min_value'='1', 'max_value'='1920800', 'data_size'='5760003008') + """ + + sql """ + alter table web_sales modify column ws_sold_date_sk set stats ('row_count'='720000376', 'ndv'='1820', 'num_nulls'='179921', 'min_value'='2450816', 'max_value'='2452642', 'data_size'='5760003008') + """ + + sql """ + alter table web_sales modify column ws_web_site_sk set stats ('row_count'='720000376', 'ndv'='54', 'num_nulls'='179930', 'min_value'='1', 'max_value'='54', 'data_size'='5760003008') + """ + + sql """ + alter table store modify column s_city set stats ('row_count'='1002', 'ndv'='55', 'num_nulls'='0', 'min_value'='', 'max_value'='Woodlawn', 'data_size'='9238') + """ + + sql """ + alter table store modify column s_company_id set stats ('row_count'='1002', 'ndv'='1', 'num_nulls'='7', 'min_value'='1', 'max_value'='1', 'data_size'='4008') + """ + + sql """ + alter table store modify column s_county set stats ('row_count'='1002', 'ndv'='28', 'num_nulls'='0', 'min_value'='', 'max_value'='Ziebach County', 'data_size'='14291') + """ + + sql """ + alter table store modify column s_geography_class set stats ('row_count'='1002', 'ndv'='2', 'num_nulls'='0', 'min_value'='', 'max_value'='Unknown', 'data_size'='6972') + """ + + sql """ + alter table store modify column s_hours set stats ('row_count'='1002', 'ndv'='4', 'num_nulls'='0', 'min_value'='', 'max_value'='8AM-8AM', 'data_size'='7088') + """ + + sql """ + alter table store modify column s_store_id set stats ('row_count'='1002', 'ndv'='501', 'num_nulls'='0', 'min_value'='AAAAAAAAAABAAAAA', 'max_value'='AAAAAAAAPPBAAAAA', 'data_size'='16032') + """ + + sql """ + alter table store modify column s_zip set stats ('row_count'='1002', 'ndv'='354', 'num_nulls'='0', 'min_value'='', 'max_value'='99454', 'data_size'='4975') + """ + + sql """ + alter table time_dim modify column t_am_pm set stats ('row_count'='86400', 'ndv'='2', 'num_nulls'='0', 'min_value'='AM', 'max_value'='PM', 'data_size'='172800') + """ + + sql """ + alter table time_dim modify column t_minute set stats ('row_count'='86400', 'ndv'='60', 'num_nulls'='0', 'min_value'='0', 'max_value'='59', 'data_size'='345600') + """ + + sql """ + alter table web_page modify column wp_web_page_id set stats ('row_count'='3000', 'ndv'='1501', 'num_nulls'='0', 'min_value'='AAAAAAAAAABAAAAA', 'max_value'='AAAAAAAAPPKAAAAA', 'data_size'='48000') + """ + + sql """ + alter table web_page modify column wp_web_page_sk set stats ('row_count'='3000', 'ndv'='2984', 'num_nulls'='0', 'min_value'='1', 'max_value'='3000', 'data_size'='24000') + """ + + sql """ + alter table store_returns modify column sr_return_amt set stats ('row_count'='287999764', 'ndv'='671228', 'num_nulls'='10080055', 'min_value'='0.00', 'max_value'='19434.00', 'data_size'='1151999056') + """ + + sql """ + alter table store_returns modify column sr_returned_date_sk set stats ('row_count'='287999764', 'ndv'='2010', 'num_nulls'='10079607', 'min_value'='2450820', 'max_value'='2452822', 'data_size'='2303998112') + """ + + sql """ + alter table store_sales modify column ss_ext_tax set stats ('row_count'='2879987999', 'ndv'='149597', 'num_nulls'='129588732', 'min_value'='0.00', 'max_value'='1797.48', 'data_size'='11519951996') + """ + + sql """ + alter table customer modify column c_current_cdemo_sk set stats ('row_count'='12000000', 'ndv'='1913901', 'num_nulls'='419895', 'min_value'='1', 'max_value'='1920800', 'data_size'='96000000') + """ + + sql """ + alter table customer modify column c_customer_id set stats ('row_count'='12000000', 'ndv'='11921032', 'num_nulls'='0', 'min_value'='AAAAAAAAAAAAABAA', 'max_value'='AAAAAAAAPPPPPKAA', 'data_size'='192000000') + """ + + sql """ + alter table date_dim modify column d_current_day set stats ('row_count'='73049', 'ndv'='1', 'num_nulls'='0', 'min_value'='N', 'max_value'='N', 'data_size'='73049') + """ + + sql """ + alter table date_dim modify column d_current_month set stats ('row_count'='73049', 'ndv'='2', 'num_nulls'='0', 'min_value'='N', 'max_value'='Y', 'data_size'='73049') + """ + + sql """ + alter table date_dim modify column d_date set stats ('row_count'='73049', 'ndv'='73250', 'num_nulls'='0', 'min_value'='1900-01-02', 'max_value'='2100-01-01', 'data_size'='292196') + """ + + sql """ + alter table date_dim modify column d_moy set stats ('row_count'='73049', 'ndv'='12', 'num_nulls'='0', 'min_value'='1', 'max_value'='12', 'data_size'='292196') + """ + + sql """ + alter table warehouse modify column w_gmt_offset set stats ('row_count'='20', 'ndv'='3', 'num_nulls'='1', 'min_value'='-7.00', 'max_value'='-5.00', 'data_size'='80') + """ + + sql """ + alter table warehouse modify column w_warehouse_sk set stats ('row_count'='20', 'ndv'='20', 'num_nulls'='0', 'min_value'='1', 'max_value'='20', 'data_size'='160') + """ + + sql """ + alter table warehouse modify column w_warehouse_sq_ft set stats ('row_count'='20', 'ndv'='19', 'num_nulls'='1', 'min_value'='73065', 'max_value'='977787', 'data_size'='80') + """ + + sql """ + alter table catalog_sales modify column cs_ext_sales_price set stats ('row_count'='1439980416', 'ndv'='1100662', 'num_nulls'='7199625', 'min_value'='0.00', 'max_value'='29943.00', 'data_size'='5759921664') + """ + + sql """ + alter table catalog_sales modify column cs_ext_wholesale_cost set stats ('row_count'='1439980416', 'ndv'='393180', 'num_nulls'='7199876', 'min_value'='1.00', 'max_value'='10000.00', 'data_size'='5759921664') + """ + + sql """ + alter table catalog_sales modify column cs_item_sk set stats ('row_count'='1439980416', 'ndv'='295433', 'num_nulls'='0', 'min_value'='1', 'max_value'='300000', 'data_size'='11519843328') + """ + + sql """ + alter table catalog_sales modify column cs_net_paid_inc_tax set stats ('row_count'='1439980416', 'ndv'='2422238', 'num_nulls'='7200702', 'min_value'='0.00', 'max_value'='32376.27', 'data_size'='5759921664') + """ + + sql """ + alter table catalog_sales modify column cs_ship_date_sk set stats ('row_count'='1439980416', 'ndv'='1933', 'num_nulls'='7200707', 'min_value'='2450817', 'max_value'='2452744', 'data_size'='11519843328') + """ + + sql """ + alter table catalog_sales modify column cs_warehouse_sk set stats ('row_count'='1439980416', 'ndv'='20', 'num_nulls'='7200688', 'min_value'='1', 'max_value'='20', 'data_size'='11519843328') + """ + + sql """ + alter table call_center modify column cc_division set stats ('row_count'='42', 'ndv'='6', 'num_nulls'='0', 'min_value'='1', 'max_value'='6', 'data_size'='168') + """ + + sql """ + alter table call_center modify column cc_division_name set stats ('row_count'='42', 'ndv'='6', 'num_nulls'='0', 'min_value'='able', 'max_value'='pri', 'data_size'='164') + """ + + sql """ + alter table call_center modify column cc_manager set stats ('row_count'='42', 'ndv'='28', 'num_nulls'='0', 'min_value'='Alden Snyder', 'max_value'='Wayne Ray', 'data_size'='519') + """ + + sql """ + alter table call_center modify column cc_rec_start_date set stats ('row_count'='42', 'ndv'='4', 'num_nulls'='0', 'min_value'='1998-01-01', 'max_value'='2002-01-01', 'data_size'='168') + """ + + sql """ + alter table catalog_returns modify column cr_call_center_sk set stats ('row_count'='143996756', 'ndv'='42', 'num_nulls'='2881668', 'min_value'='1', 'max_value'='42', 'data_size'='1151974048') + """ + + sql """ + alter table catalog_returns modify column cr_net_loss set stats ('row_count'='143996756', 'ndv'='911034', 'num_nulls'='2881704', 'min_value'='0.50', 'max_value'='16095.08', 'data_size'='575987024') + """ + + sql """ + alter table catalog_returns modify column cr_refunded_customer_sk set stats ('row_count'='143996756', 'ndv'='12156363', 'num_nulls'='2879017', 'min_value'='1', 'max_value'='12000000', 'data_size'='1151974048') + """ + + sql """ + alter table catalog_returns modify column cr_refunded_hdemo_sk set stats ('row_count'='143996756', 'ndv'='7251', 'num_nulls'='2882107', 'min_value'='1', 'max_value'='7200', 'data_size'='1151974048') + """ + + sql """ + alter table catalog_returns modify column cr_returning_customer_sk set stats ('row_count'='143996756', 'ndv'='12157481', 'num_nulls'='2879023', 'min_value'='1', 'max_value'='12000000', 'data_size'='1151974048') + """ + + sql """ + alter table customer_address modify column ca_gmt_offset set stats ('row_count'='6000000', 'ndv'='6', 'num_nulls'='180219', 'min_value'='-10.00', 'max_value'='-5.00', 'data_size'='24000000') + """ + + sql """ + alter table item modify column i_color set stats ('row_count'='300000', 'ndv'='93', 'num_nulls'='0', 'min_value'='', 'max_value'='yellow', 'data_size'='1610293') + """ + + sql """ + alter table item modify column i_manufact set stats ('row_count'='300000', 'ndv'='1004', 'num_nulls'='0', 'min_value'='', 'max_value'='pripripri', 'data_size'='3379693') + """ + + sql """ + alter table item modify column i_product_name set stats ('row_count'='300000', 'ndv'='294994', 'num_nulls'='0', 'min_value'='', 'max_value'='pripripripripriought', 'data_size'='6849199') + """ + + sql """ + alter table web_returns modify column wr_returned_time_sk set stats ('row_count'='71997522', 'ndv'='87677', 'num_nulls'='3238574', 'min_value'='0', 'max_value'='86399', 'data_size'='575980176') + """ + + sql """ + alter table web_site modify column web_manager set stats ('row_count'='54', 'ndv'='40', 'num_nulls'='0', 'min_value'='', 'max_value'='William Young', 'data_size'='658') + """ + + sql """ + alter table web_site modify column web_mkt_class set stats ('row_count'='54', 'ndv'='40', 'num_nulls'='0', 'min_value'='', 'max_value'='Written, political plans show to the models. T', 'data_size'='1822') + """ + + sql """ + alter table web_site modify column web_rec_start_date set stats ('row_count'='54', 'ndv'='4', 'num_nulls'='2', 'min_value'='1997-08-16', 'max_value'='2001-08-16', 'data_size'='216') + """ + + sql """ + alter table web_site modify column web_street_number set stats ('row_count'='54', 'ndv'='36', 'num_nulls'='0', 'min_value'='', 'max_value'='983', 'data_size'='154') + """ + + sql """ + alter table promotion modify column p_channel_catalog set stats ('row_count'='1500', 'ndv'='2', 'num_nulls'='0', 'min_value'='', 'max_value'='N', 'data_size'='1482') + """ + + sql """ + alter table promotion modify column p_promo_id set stats ('row_count'='1500', 'ndv'='1519', 'num_nulls'='0', 'min_value'='AAAAAAAAAABAAAAA', 'max_value'='AAAAAAAAPPEAAAAA', 'data_size'='24000') + """ + + sql """ + alter table web_sales modify column ws_bill_customer_sk set stats ('row_count'='720000376', 'ndv'='12103729', 'num_nulls'='179817', 'min_value'='1', 'max_value'='12000000', 'data_size'='5760003008') + """ + + sql """ + alter table web_sales modify column ws_list_price set stats ('row_count'='720000376', 'ndv'='29396', 'num_nulls'='180053', 'min_value'='1.00', 'max_value'='300.00', 'data_size'='2880001504') + """ + + sql """ + alter table web_sales modify column ws_sales_price set stats ('row_count'='720000376', 'ndv'='29288', 'num_nulls'='180005', 'min_value'='0.00', 'max_value'='300.00', 'data_size'='2880001504') + """ + + sql """ + alter table web_sales modify column ws_ship_hdemo_sk set stats ('row_count'='720000376', 'ndv'='7251', 'num_nulls'='179824', 'min_value'='1', 'max_value'='7200', 'data_size'='5760003008') + """ + + sql """ + alter table store modify column s_closed_date_sk set stats ('row_count'='1002', 'ndv'='163', 'num_nulls'='729', 'min_value'='2450820', 'max_value'='2451313', 'data_size'='8016') + """ + + sql """ + alter table store modify column s_division_id set stats ('row_count'='1002', 'ndv'='1', 'num_nulls'='6', 'min_value'='1', 'max_value'='1', 'data_size'='4008') + """ + + sql """ + alter table store modify column s_market_desc set stats ('row_count'='1002', 'ndv'='765', 'num_nulls'='0', 'min_value'='', 'max_value'='Yesterday left factors handle continuing co', 'data_size'='57638') + """ + + sql """ + alter table store modify column s_market_id set stats ('row_count'='1002', 'ndv'='10', 'num_nulls'='8', 'min_value'='1', 'max_value'='10', 'data_size'='4008') + """ + + sql """ + alter table store modify column s_state set stats ('row_count'='1002', 'ndv'='22', 'num_nulls'='0', 'min_value'='', 'max_value'='WV', 'data_size'='1994') + """ + + sql """ + alter table store modify column s_store_sk set stats ('row_count'='1002', 'ndv'='988', 'num_nulls'='0', 'min_value'='1', 'max_value'='1002', 'data_size'='8016') + """ + + sql """ + alter table store modify column s_street_name set stats ('row_count'='1002', 'ndv'='549', 'num_nulls'='0', 'min_value'='', 'max_value'='Woodland Oak', 'data_size'='8580') + """ + + sql """ + alter table web_page modify column wp_access_date_sk set stats ('row_count'='3000', 'ndv'='101', 'num_nulls'='31', 'min_value'='2452548', 'max_value'='2452648', 'data_size'='24000') + """ + + sql """ + alter table web_page modify column wp_char_count set stats ('row_count'='3000', 'ndv'='1883', 'num_nulls'='42', 'min_value'='303', 'max_value'='8523', 'data_size'='12000') + """ + + sql """ + alter table store_returns modify column sr_addr_sk set stats ('row_count'='287999764', 'ndv'='6015811', 'num_nulls'='10082311', 'min_value'='1', 'max_value'='6000000', 'data_size'='2303998112') + """ + + sql """ + alter table store_returns modify column sr_return_time_sk set stats ('row_count'='287999764', 'ndv'='32660', 'num_nulls'='10082805', 'min_value'='28799', 'max_value'='61199', 'data_size'='2303998112') + """ + + sql """ + alter table store_returns modify column sr_store_sk set stats ('row_count'='287999764', 'ndv'='499', 'num_nulls'='10081871', 'min_value'='1', 'max_value'='1000', 'data_size'='2303998112') + """ + + sql """ + alter table store_sales modify column ss_coupon_amt set stats ('row_count'='2879987999', 'ndv'='1161208', 'num_nulls'='129609101', 'min_value'='0.00', 'max_value'='19778.00', 'data_size'='11519951996') + """ + + sql """ + alter table store_sales modify column ss_sales_price set stats ('row_count'='2879987999', 'ndv'='19780', 'num_nulls'='129598061', 'min_value'='0.00', 'max_value'='200.00', 'data_size'='11519951996') + """ + + sql """ + alter table customer modify column c_birth_country set stats ('row_count'='12000000', 'ndv'='211', 'num_nulls'='0', 'min_value'='', 'max_value'='ZIMBABWE', 'data_size'='100750845') + """ + + sql """ + alter table customer modify column c_birth_month set stats ('row_count'='12000000', 'ndv'='12', 'num_nulls'='419629', 'min_value'='1', 'max_value'='12', 'data_size'='48000000') + """ + + sql """ + alter table customer modify column c_customer_sk set stats ('row_count'='12000000', 'ndv'='12157481', 'num_nulls'='0', 'min_value'='1', 'max_value'='12000000', 'data_size'='96000000') + """ + + sql """ + alter table customer modify column c_email_address set stats ('row_count'='12000000', 'ndv'='11642077', 'num_nulls'='0', 'min_value'='', 'max_value'='Zulma.Young@aDhzZzCzYN.edu', 'data_size'='318077849') + """ + + sql """ + alter table customer modify column c_last_review_date_sk set stats ('row_count'='12000000', 'ndv'='366', 'num_nulls'='419900', 'min_value'='2452283', 'max_value'='2452648', 'data_size'='96000000') + """ + + sql """ + alter table customer modify column c_preferred_cust_flag set stats ('row_count'='12000000', 'ndv'='3', 'num_nulls'='0', 'min_value'='', 'max_value'='Y', 'data_size'='11580510') + """ + + sql """ + alter table dbgen_version modify column dv_version set stats ('row_count'='1', 'ndv'='1', 'num_nulls'='0', 'min_value'='3.2.0', 'max_value'='3.2.0', 'data_size'='5') + """ + + sql """ + alter table customer_demographics modify column cd_purchase_estimate set stats ('row_count'='1920800', 'ndv'='20', 'num_nulls'='0', 'min_value'='500', 'max_value'='10000', 'data_size'='7683200') + """ + + sql """ + alter table reason modify column r_reason_id set stats ('row_count'='65', 'ndv'='65', 'num_nulls'='0', 'min_value'='AAAAAAAAABAAAAAA', 'max_value'='AAAAAAAAPDAAAAAA', 'data_size'='1040') + """ + + sql """ + alter table reason modify column r_reason_sk set stats ('row_count'='65', 'ndv'='65', 'num_nulls'='0', 'min_value'='1', 'max_value'='65', 'data_size'='520') + """ + + sql """ + alter table date_dim modify column d_current_week set stats ('row_count'='73049', 'ndv'='1', 'num_nulls'='0', 'min_value'='N', 'max_value'='N', 'data_size'='73049') + """ + + sql """ + alter table date_dim modify column d_first_dom set stats ('row_count'='73049', 'ndv'='2410', 'num_nulls'='0', 'min_value'='2415021', 'max_value'='2488070', 'data_size'='292196') + """ + + sql """ + alter table date_dim modify column d_fy_year set stats ('row_count'='73049', 'ndv'='202', 'num_nulls'='0', 'min_value'='1900', 'max_value'='2100', 'data_size'='292196') + """ + + sql """ + alter table date_dim modify column d_last_dom set stats ('row_count'='73049', 'ndv'='2419', 'num_nulls'='0', 'min_value'='2415020', 'max_value'='2488372', 'data_size'='292196') + """ + + sql """ + alter table date_dim modify column d_month_seq set stats ('row_count'='73049', 'ndv'='2398', 'num_nulls'='0', 'min_value'='0', 'max_value'='2400', 'data_size'='292196') + """ + + sql """ + alter table date_dim modify column d_quarter_name set stats ('row_count'='73049', 'ndv'='799', 'num_nulls'='0', 'min_value'='1900Q1', 'max_value'='2100Q1', 'data_size'='438294') + """ + + sql """ + alter table warehouse modify column w_county set stats ('row_count'='20', 'ndv'='14', 'num_nulls'='0', 'min_value'='Bronx County', 'max_value'='Ziebach County', 'data_size'='291') + """ + + sql """ + alter table warehouse modify column w_street_number set stats ('row_count'='20', 'ndv'='19', 'num_nulls'='0', 'min_value'='', 'max_value'='957', 'data_size'='54') + """ + + sql """ + alter table warehouse modify column w_warehouse_name set stats ('row_count'='20', 'ndv'='20', 'num_nulls'='0', 'min_value'='', 'max_value'='Therefore urg', 'data_size'='307') + """ + + sql """ + alter table catalog_sales modify column cs_ext_discount_amt set stats ('row_count'='1439980416', 'ndv'='1100115', 'num_nulls'='7201054', 'min_value'='0.00', 'max_value'='29982.00', 'data_size'='5759921664') + """ + + sql """ + alter table catalog_sales modify column cs_net_paid_inc_ship_tax set stats ('row_count'='1439980416', 'ndv'='3312360', 'num_nulls'='0', 'min_value'='0.00', 'max_value'='46593.36', 'data_size'='5759921664') + """ + + sql """ + alter table catalog_sales modify column cs_promo_sk set stats ('row_count'='1439980416', 'ndv'='1489', 'num_nulls'='7202844', 'min_value'='1', 'max_value'='1500', 'data_size'='11519843328') + """ + + sql """ + alter table call_center modify column cc_call_center_id set stats ('row_count'='42', 'ndv'='21', 'num_nulls'='0', 'min_value'='AAAAAAAAABAAAAAA', 'max_value'='AAAAAAAAPBAAAAAA', 'data_size'='672') + """ + + sql """ + alter table call_center modify column cc_employees set stats ('row_count'='42', 'ndv'='30', 'num_nulls'='0', 'min_value'='69020', 'max_value'='6879074', 'data_size'='168') + """ + + sql """ + alter table call_center modify column cc_suite_number set stats ('row_count'='42', 'ndv'='18', 'num_nulls'='0', 'min_value'='Suite 0', 'max_value'='Suite W', 'data_size'='326') + """ + + sql """ + alter table catalog_returns modify column cr_item_sk set stats ('row_count'='143996756', 'ndv'='295433', 'num_nulls'='0', 'min_value'='1', 'max_value'='300000', 'data_size'='1151974048') + """ + + sql """ + alter table catalog_returns modify column cr_reason_sk set stats ('row_count'='143996756', 'ndv'='65', 'num_nulls'='2881950', 'min_value'='1', 'max_value'='65', 'data_size'='1151974048') + """ + + sql """ + alter table catalog_returns modify column cr_return_ship_cost set stats ('row_count'='143996756', 'ndv'='483467', 'num_nulls'='2883436', 'min_value'='0.00', 'max_value'='14273.28', 'data_size'='575987024') + """ + + sql """ + alter table catalog_returns modify column cr_ship_mode_sk set stats ('row_count'='143996756', 'ndv'='20', 'num_nulls'='2879879', 'min_value'='1', 'max_value'='20', 'data_size'='1151974048') + """ + + sql """ + alter table catalog_returns modify column cr_store_credit set stats ('row_count'='143996756', 'ndv'='802237', 'num_nulls'='2880469', 'min_value'='0.00', 'max_value'='23215.15', 'data_size'='575987024') + """ + + sql """ + alter table customer_address modify column ca_city set stats ('row_count'='6000000', 'ndv'='977', 'num_nulls'='0', 'min_value'='', 'max_value'='Zion', 'data_size'='52096290') + """ + + sql """ + alter table customer_address modify column ca_state set stats ('row_count'='6000000', 'ndv'='52', 'num_nulls'='0', 'min_value'='', 'max_value'='WY', 'data_size'='11640128') + """ + + sql """ + alter table customer_address modify column ca_street_name set stats ('row_count'='6000000', 'ndv'='8173', 'num_nulls'='0', 'min_value'='', 'max_value'='Woodland Woodland', 'data_size'='50697257') + """ + + sql """ + alter table customer_address modify column ca_street_type set stats ('row_count'='6000000', 'ndv'='21', 'num_nulls'='0', 'min_value'='', 'max_value'='Wy', 'data_size'='24441630') + """ + + sql """ + alter table catalog_page modify column cp_catalog_number set stats ('row_count'='30000', 'ndv'='109', 'num_nulls'='297', 'min_value'='1', 'max_value'='109', 'data_size'='120000') + """ + + sql """ + alter table catalog_page modify column cp_catalog_page_number set stats ('row_count'='30000', 'ndv'='279', 'num_nulls'='294', 'min_value'='1', 'max_value'='277', 'data_size'='120000') + """ + + sql """ + alter table catalog_page modify column cp_catalog_page_sk set stats ('row_count'='30000', 'ndv'='30439', 'num_nulls'='0', 'min_value'='1', 'max_value'='30000', 'data_size'='240000') + """ + + sql """ + alter table catalog_page modify column cp_start_date_sk set stats ('row_count'='30000', 'ndv'='91', 'num_nulls'='286', 'min_value'='2450815', 'max_value'='2453005', 'data_size'='120000') + """ + + sql """ + alter table item modify column i_rec_start_date set stats ('row_count'='300000', 'ndv'='4', 'num_nulls'='784', 'min_value'='1997-10-27', 'max_value'='2001-10-27', 'data_size'='1200000') + """ + + sql """ + alter table item modify column i_units set stats ('row_count'='300000', 'ndv'='22', 'num_nulls'='0', 'min_value'='', 'max_value'='Unknown', 'data_size'='1253652') + """ + + sql """ + alter table web_returns modify column wr_refunded_hdemo_sk set stats ('row_count'='71997522', 'ndv'='7251', 'num_nulls'='3238545', 'min_value'='1', 'max_value'='7200', 'data_size'='575980176') + """ + + sql """ + alter table web_returns modify column wr_return_ship_cost set stats ('row_count'='71997522', 'ndv'='451263', 'num_nulls'='3239048', 'min_value'='0.00', 'max_value'='14352.10', 'data_size'='287990088') + """ + + sql """ + alter table web_returns modify column wr_returned_date_sk set stats ('row_count'='71997522', 'ndv'='2188', 'num_nulls'='3239259', 'min_value'='2450819', 'max_value'='2453002', 'data_size'='575980176') + """ + + sql """ + alter table web_returns modify column wr_returning_cdemo_sk set stats ('row_count'='71997522', 'ndv'='1916366', 'num_nulls'='3239192', 'min_value'='1', 'max_value'='1920800', 'data_size'='575980176') + """ + + sql """ + alter table web_site modify column web_suite_number set stats ('row_count'='54', 'ndv'='38', 'num_nulls'='0', 'min_value'='Suite 100', 'max_value'='Suite Y', 'data_size'='430') + """ + + sql """ + alter table promotion modify column p_start_date_sk set stats ('row_count'='1500', 'ndv'='685', 'num_nulls'='23', 'min_value'='2450096', 'max_value'='2450915', 'data_size'='12000') + """ + + sql """ + alter table web_sales modify column ws_coupon_amt set stats ('row_count'='720000376', 'ndv'='1505315', 'num_nulls'='179933', 'min_value'='0.00', 'max_value'='28824.00', 'data_size'='2880001504') + """ + + sql """ + alter table web_sales modify column ws_ext_wholesale_cost set stats ('row_count'='720000376', 'ndv'='393180', 'num_nulls'='180060', 'min_value'='1.00', 'max_value'='10000.00', 'data_size'='2880001504') + """ + + sql """ + alter table web_sales modify column ws_net_paid_inc_ship set stats ('row_count'='720000376', 'ndv'='2414838', 'num_nulls'='0', 'min_value'='0.00', 'max_value'='44263.00', 'data_size'='2880001504') + """ + + sql """ + alter table web_sales modify column ws_ship_date_sk set stats ('row_count'='720000376', 'ndv'='1952', 'num_nulls'='180011', 'min_value'='2450817', 'max_value'='2452762', 'data_size'='5760003008') + """ + + sql """ + alter table web_sales modify column ws_web_page_sk set stats ('row_count'='720000376', 'ndv'='2984', 'num_nulls'='179732', 'min_value'='1', 'max_value'='3000', 'data_size'='5760003008') + """ + + sql """ + alter table store modify column s_country set stats ('row_count'='1002', 'ndv'='2', 'num_nulls'='0', 'min_value'='', 'max_value'='United States', 'data_size'='12961') + """ + + sql """ + alter table store modify column s_store_name set stats ('row_count'='1002', 'ndv'='11', 'num_nulls'='0', 'min_value'='', 'max_value'='pri', 'data_size'='3916') + """ + + sql """ + alter table time_dim modify column t_second set stats ('row_count'='86400', 'ndv'='60', 'num_nulls'='0', 'min_value'='0', 'max_value'='59', 'data_size'='345600') + """ + + sql """ + alter table time_dim modify column t_sub_shift set stats ('row_count'='86400', 'ndv'='4', 'num_nulls'='0', 'min_value'='afternoon', 'max_value'='night', 'data_size'='597600') + """ + + sql """ + alter table web_page modify column wp_image_count set stats ('row_count'='3000', 'ndv'='7', 'num_nulls'='26', 'min_value'='1', 'max_value'='7', 'data_size'='12000') + """ + + sql """ + alter table web_page modify column wp_type set stats ('row_count'='3000', 'ndv'='8', 'num_nulls'='0', 'min_value'='', 'max_value'='welcome', 'data_size'='18867') + """ + + sql """ + alter table store_returns modify column sr_customer_sk set stats ('row_count'='287999764', 'ndv'='12157481', 'num_nulls'='10081624', 'min_value'='1', 'max_value'='12000000', 'data_size'='2303998112') + """ + + sql """ + alter table store_returns modify column sr_hdemo_sk set stats ('row_count'='287999764', 'ndv'='7251', 'num_nulls'='10083275', 'min_value'='1', 'max_value'='7200', 'data_size'='2303998112') + """ + + sql """ + alter table store_sales modify column ss_addr_sk set stats ('row_count'='2879987999', 'ndv'='6015811', 'num_nulls'='129589799', 'min_value'='1', 'max_value'='6000000', 'data_size'='23039903992') + """ + + sql """ + alter table store_sales modify column ss_item_sk set stats ('row_count'='2879987999', 'ndv'='295433', 'num_nulls'='0', 'min_value'='1', 'max_value'='300000', 'data_size'='23039903992') + """ + + sql """ + alter table store_sales modify column ss_quantity set stats ('row_count'='2879987999', 'ndv'='100', 'num_nulls'='129584258', 'min_value'='1', 'max_value'='100', 'data_size'='11519951996') + """ + + sql """ + alter table store_sales modify column ss_ticket_number set stats ('row_count'='2879987999', 'ndv'='238830448', 'num_nulls'='0', 'min_value'='1', 'max_value'='240000000', 'data_size'='23039903992') + """ + + sql """ + alter table store_sales modify column ss_wholesale_cost set stats ('row_count'='2879987999', 'ndv'='9905', 'num_nulls'='129590273', 'min_value'='1.00', 'max_value'='100.00', 'data_size'='11519951996') + """ + + sql """ + alter table ship_mode modify column sm_type set stats ('row_count'='20', 'ndv'='6', 'num_nulls'='0', 'min_value'='EXPRESS', 'max_value'='TWO DAY', 'data_size'='150') + """ + + sql """ + alter table customer modify column c_current_addr_sk set stats ('row_count'='12000000', 'ndv'='5243359', 'num_nulls'='0', 'min_value'='3', 'max_value'='6000000', 'data_size'='96000000') + """ + + sql """ + alter table customer modify column c_last_name set stats ('row_count'='12000000', 'ndv'='4990', 'num_nulls'='0', 'min_value'='', 'max_value'='Zuniga', 'data_size'='70991730') + """ + + sql """ + alter table dbgen_version modify column dv_cmdline_args set stats ('row_count'='1', 'ndv'='1', 'num_nulls'='0', 'min_value'='-SCALE 1000 -PARALLEL 64 -CHILD 1 -TERMINATE N -DIR /mnt/datadisk0/tpcds1t/tpcds-data', 'max_value'='-SCALE 1000 -PARALLEL 64 -CHILD 1 -TERMINATE N -DIR /mnt/datadisk0/tpcds1t/tpcds-data', 'data_size'='86') + """ + + sql """ + alter table date_dim modify column d_current_quarter set stats ('row_count'='73049', 'ndv'='2', 'num_nulls'='0', 'min_value'='N', 'max_value'='Y', 'data_size'='73049') + """ + + sql """ + alter table date_dim modify column d_date_sk set stats ('row_count'='73049', 'ndv'='73042', 'num_nulls'='0', 'min_value'='2415022', 'max_value'='2488070', 'data_size'='584392') + """ + + sql """ + alter table date_dim modify column d_holiday set stats ('row_count'='73049', 'ndv'='2', 'num_nulls'='0', 'min_value'='N', 'max_value'='Y', 'data_size'='73049') + """ + + sql """ + alter table warehouse modify column w_country set stats ('row_count'='20', 'ndv'='1', 'num_nulls'='0', 'min_value'='United States', 'max_value'='United States', 'data_size'='260') + """ + + sql """ + alter table warehouse modify column w_state set stats ('row_count'='20', 'ndv'='13', 'num_nulls'='0', 'min_value'='AL', 'max_value'='TN', 'data_size'='40') + """ + + sql """ + alter table catalog_sales modify column cs_bill_addr_sk set stats ('row_count'='1439980416', 'ndv'='6015811', 'num_nulls'='7199539', 'min_value'='1', 'max_value'='6000000', 'data_size'='11519843328') + """ + + sql """ + alter table catalog_sales modify column cs_bill_customer_sk set stats ('row_count'='1439980416', 'ndv'='12157481', 'num_nulls'='7201919', 'min_value'='1', 'max_value'='12000000', 'data_size'='11519843328') + """ + + sql """ + alter table catalog_sales modify column cs_net_paid set stats ('row_count'='1439980416', 'ndv'='1809875', 'num_nulls'='7197668', 'min_value'='0.00', 'max_value'='29943.00', 'data_size'='5759921664') + """ + + sql """ + alter table catalog_sales modify column cs_ship_addr_sk set stats ('row_count'='1439980416', 'ndv'='6015811', 'num_nulls'='7198232', 'min_value'='1', 'max_value'='6000000', 'data_size'='11519843328') + """ + + sql """ + alter table catalog_sales modify column cs_ship_mode_sk set stats ('row_count'='1439980416', 'ndv'='20', 'num_nulls'='7201083', 'min_value'='1', 'max_value'='20', 'data_size'='11519843328') + """ + + sql """ + alter table catalog_sales modify column cs_sold_date_sk set stats ('row_count'='1439980416', 'ndv'='1835', 'num_nulls'='7203326', 'min_value'='2450815', 'max_value'='2452654', 'data_size'='11519843328') + """ + + sql """ + alter table catalog_sales modify column cs_sold_time_sk set stats ('row_count'='1439980416', 'ndv'='87677', 'num_nulls'='7201329', 'min_value'='0', 'max_value'='86399', 'data_size'='11519843328') + """ + + sql """ + alter table catalog_sales modify column cs_wholesale_cost set stats ('row_count'='1439980416', 'ndv'='9905', 'num_nulls'='7201098', 'min_value'='1.00', 'max_value'='100.00', 'data_size'='5759921664') + """ + + sql """ + alter table call_center modify column cc_company_name set stats ('row_count'='42', 'ndv'='6', 'num_nulls'='0', 'min_value'='able', 'max_value'='pri', 'data_size'='160') + """ + + sql """ + alter table call_center modify column cc_market_manager set stats ('row_count'='42', 'ndv'='35', 'num_nulls'='0', 'min_value'='Cesar Allen', 'max_value'='William Larsen', 'data_size'='524') + """ + + sql """ + alter table call_center modify column cc_mkt_id set stats ('row_count'='42', 'ndv'='6', 'num_nulls'='0', 'min_value'='1', 'max_value'='6', 'data_size'='168') + """ + + sql """ + alter table call_center modify column cc_street_type set stats ('row_count'='42', 'ndv'='11', 'num_nulls'='0', 'min_value'='Avenue', 'max_value'='Way', 'data_size'='184') + """ + + sql """ + alter table catalog_returns modify column cr_return_tax set stats ('row_count'='143996756', 'ndv'='149828', 'num_nulls'='2881611', 'min_value'='0.00', 'max_value'='2511.58', 'data_size'='575987024') + """ + + sql """ + alter table catalog_returns modify column cr_returning_cdemo_sk set stats ('row_count'='143996756', 'ndv'='1916366', 'num_nulls'='2880543', 'min_value'='1', 'max_value'='1920800', 'data_size'='1151974048') + """ + + sql """ + alter table catalog_returns modify column cr_returning_hdemo_sk set stats ('row_count'='143996756', 'ndv'='7251', 'num_nulls'='2882692', 'min_value'='1', 'max_value'='7200', 'data_size'='1151974048') + """ + + sql """ + alter table catalog_returns modify column cr_reversed_charge set stats ('row_count'='143996756', 'ndv'='802509', 'num_nulls'='2881215', 'min_value'='0.00', 'max_value'='24033.84', 'data_size'='575987024') + """ + + sql """ + alter table catalog_returns modify column cr_warehouse_sk set stats ('row_count'='143996756', 'ndv'='20', 'num_nulls'='2882192', 'min_value'='1', 'max_value'='20', 'data_size'='1151974048') + """ + + sql """ + alter table household_demographics modify column hd_demo_sk set stats ('row_count'='7200', 'ndv'='7251', 'num_nulls'='0', 'min_value'='1', 'max_value'='7200', 'data_size'='57600') + """ + + sql """ + alter table household_demographics modify column hd_vehicle_count set stats ('row_count'='7200', 'ndv'='6', 'num_nulls'='0', 'min_value'='-1', 'max_value'='4', 'data_size'='28800') + """ + + sql """ + alter table customer_address modify column ca_zip set stats ('row_count'='6000000', 'ndv'='9253', 'num_nulls'='0', 'min_value'='', 'max_value'='99981', 'data_size'='29097610') + """ + + sql """ + alter table income_band modify column ib_income_band_sk set stats ('row_count'='20', 'ndv'='20', 'num_nulls'='0', 'min_value'='1', 'max_value'='20', 'data_size'='160') + """ + + sql """ + alter table catalog_page modify column cp_type set stats ('row_count'='30000', 'ndv'='4', 'num_nulls'='0', 'min_value'='', 'max_value'='quarterly', 'data_size'='227890') + """ + + sql """ + alter table item modify column i_brand set stats ('row_count'='300000', 'ndv'='714', 'num_nulls'='0', 'min_value'='', 'max_value'='univunivamalg #9', 'data_size'='4834917') + """ + + sql """ + alter table item modify column i_formulation set stats ('row_count'='300000', 'ndv'='224757', 'num_nulls'='0', 'min_value'='', 'max_value'='yellow98911509228741', 'data_size'='5984460') + """ + + sql """ + alter table item modify column i_item_desc set stats ('row_count'='300000', 'ndv'='217721', 'num_nulls'='0', 'min_value'='', 'max_value'='Youngsters used to save quite colour', 'data_size'='30093342') + """ + + sql """ + alter table web_returns modify column wr_fee set stats ('row_count'='71997522', 'ndv'='9958', 'num_nulls'='3238926', 'min_value'='0.50', 'max_value'='100.00', 'data_size'='287990088') + """ + + sql """ + alter table web_returns modify column wr_item_sk set stats ('row_count'='71997522', 'ndv'='295433', 'num_nulls'='0', 'min_value'='1', 'max_value'='300000', 'data_size'='575980176') + """ + + sql """ + alter table web_returns modify column wr_reason_sk set stats ('row_count'='71997522', 'ndv'='65', 'num_nulls'='3238897', 'min_value'='1', 'max_value'='65', 'data_size'='575980176') + """ + + sql """ + alter table web_returns modify column wr_refunded_customer_sk set stats ('row_count'='71997522', 'ndv'='12117831', 'num_nulls'='3242433', 'min_value'='1', 'max_value'='12000000', 'data_size'='575980176') + """ + + sql """ + alter table web_site modify column web_city set stats ('row_count'='54', 'ndv'='31', 'num_nulls'='0', 'min_value'='', 'max_value'='Woodlawn', 'data_size'='491') + """ + + sql """ + alter table web_site modify column web_close_date_sk set stats ('row_count'='54', 'ndv'='18', 'num_nulls'='10', 'min_value'='2441265', 'max_value'='2446218', 'data_size'='432') + """ + + sql """ + alter table web_site modify column web_company_id set stats ('row_count'='54', 'ndv'='6', 'num_nulls'='0', 'min_value'='1', 'max_value'='6', 'data_size'='216') + """ + + sql """ + alter table web_site modify column web_company_name set stats ('row_count'='54', 'ndv'='7', 'num_nulls'='0', 'min_value'='', 'max_value'='pri', 'data_size'='203') + """ + + sql """ + alter table web_site modify column web_county set stats ('row_count'='54', 'ndv'='25', 'num_nulls'='0', 'min_value'='', 'max_value'='Williamson County', 'data_size'='762') + """ + + sql """ + alter table web_site modify column web_name set stats ('row_count'='54', 'ndv'='10', 'num_nulls'='0', 'min_value'='', 'max_value'='site_8', 'data_size'='312') + """ + + sql """ + alter table web_site modify column web_open_date_sk set stats ('row_count'='54', 'ndv'='27', 'num_nulls'='1', 'min_value'='2450373', 'max_value'='2450807', 'data_size'='432') + """ + + sql """ + alter table promotion modify column p_channel_dmail set stats ('row_count'='1500', 'ndv'='3', 'num_nulls'='0', 'min_value'='', 'max_value'='Y', 'data_size'='1483') + """ + + sql """ + alter table promotion modify column p_channel_press set stats ('row_count'='1500', 'ndv'='2', 'num_nulls'='0', 'min_value'='', 'max_value'='N', 'data_size'='1481') + """ + + sql """ + alter table promotion modify column p_channel_radio set stats ('row_count'='1500', 'ndv'='2', 'num_nulls'='0', 'min_value'='', 'max_value'='N', 'data_size'='1479') + """ + + sql """ + alter table promotion modify column p_cost set stats ('row_count'='1500', 'ndv'='1', 'num_nulls'='18', 'min_value'='1000.00', 'max_value'='1000.00', 'data_size'='12000') + """ + + sql """ + alter table web_sales modify column ws_ext_tax set stats ('row_count'='720000376', 'ndv'='211413', 'num_nulls'='179695', 'min_value'='0.00', 'max_value'='2682.90', 'data_size'='2880001504') + """ + + sql """ + alter table web_sales modify column ws_item_sk set stats ('row_count'='720000376', 'ndv'='295433', 'num_nulls'='0', 'min_value'='1', 'max_value'='300000', 'data_size'='5760003008') + """ + + sql """ + alter table web_sales modify column ws_net_paid set stats ('row_count'='720000376', 'ndv'='1749360', 'num_nulls'='179970', 'min_value'='0.00', 'max_value'='29810.00', 'data_size'='2880001504') + """ + + sql """ + alter table web_sales modify column ws_net_paid_inc_ship_tax set stats ('row_count'='720000376', 'ndv'='3224829', 'num_nulls'='0', 'min_value'='0.00', 'max_value'='46004.19', 'data_size'='2880001504') + """ + + sql """ + alter table web_sales modify column ws_net_paid_inc_tax set stats ('row_count'='720000376', 'ndv'='2354996', 'num_nulls'='179972', 'min_value'='0.00', 'max_value'='32492.90', 'data_size'='2880001504') + """ + + sql """ + alter table web_sales modify column ws_order_number set stats ('row_count'='720000376', 'ndv'='60401176', 'num_nulls'='0', 'min_value'='1', 'max_value'='60000000', 'data_size'='5760003008') + """ + + sql """ + alter table web_sales modify column ws_quantity set stats ('row_count'='720000376', 'ndv'='100', 'num_nulls'='179781', 'min_value'='1', 'max_value'='100', 'data_size'='2880001504') + """ + + sql """ + alter table web_sales modify column ws_ship_cdemo_sk set stats ('row_count'='720000376', 'ndv'='1916366', 'num_nulls'='180290', 'min_value'='1', 'max_value'='1920800', 'data_size'='5760003008') + """ + + sql """ + alter table web_sales modify column ws_sold_time_sk set stats ('row_count'='720000376', 'ndv'='87677', 'num_nulls'='179980', 'min_value'='0', 'max_value'='86399', 'data_size'='5760003008') + """ + + sql """ + alter table store modify column s_street_type set stats ('row_count'='1002', 'ndv'='21', 'num_nulls'='0', 'min_value'='', 'max_value'='Wy', 'data_size'='4189') + """ + + sql """ + alter table web_page modify column wp_autogen_flag set stats ('row_count'='3000', 'ndv'='3', 'num_nulls'='0', 'min_value'='', 'max_value'='Y', 'data_size'='2962') + """ + + sql """ + alter table web_page modify column wp_rec_start_date set stats ('row_count'='3000', 'ndv'='4', 'num_nulls'='29', 'min_value'='1997-09-03', 'max_value'='2001-09-03', 'data_size'='12000') + """ + + sql """ + alter table store_returns modify column sr_net_loss set stats ('row_count'='287999764', 'ndv'='714210', 'num_nulls'='10080716', 'min_value'='0.50', 'max_value'='10776.08', 'data_size'='1151999056') + """ + + sql """ + alter table store_returns modify column sr_return_amt_inc_tax set stats ('row_count'='287999764', 'ndv'='1259368', 'num_nulls'='10076879', 'min_value'='0.00', 'max_value'='20454.63', 'data_size'='1151999056') + """ + + sql """ + alter table store_returns modify column sr_return_quantity set stats ('row_count'='287999764', 'ndv'='100', 'num_nulls'='10082815', 'min_value'='1', 'max_value'='100', 'data_size'='1151999056') + """ + + sql """ + alter table store_returns modify column sr_return_ship_cost set stats ('row_count'='287999764', 'ndv'='355844', 'num_nulls'='10081927', 'min_value'='0.00', 'max_value'='9767.34', 'data_size'='1151999056') + """ + + sql """ + alter table store_returns modify column sr_reversed_charge set stats ('row_count'='287999764', 'ndv'='700618', 'num_nulls'='10085976', 'min_value'='0.00', 'max_value'='17339.42', 'data_size'='1151999056') + """ + + sql """ + alter table store_sales modify column ss_net_paid_inc_tax set stats ('row_count'='2879987999', 'ndv'='1681767', 'num_nulls'='129609050', 'min_value'='0.00', 'max_value'='21769.48', 'data_size'='11519951996') + """ + + sql """ + alter table customer modify column c_birth_day set stats ('row_count'='12000000', 'ndv'='31', 'num_nulls'='420361', 'min_value'='1', 'max_value'='31', 'data_size'='48000000') + """ + + sql """ + alter table customer_demographics modify column cd_credit_rating set stats ('row_count'='1920800', 'ndv'='4', 'num_nulls'='0', 'min_value'='Good', 'max_value'='Unknown', 'data_size'='13445600') + """ + + sql """ + alter table customer_demographics modify column cd_demo_sk set stats ('row_count'='1920800', 'ndv'='1916366', 'num_nulls'='0', 'min_value'='1', 'max_value'='1920800', 'data_size'='15366400') + """ + + sql """ + alter table customer_demographics modify column cd_dep_count set stats ('row_count'='1920800', 'ndv'='7', 'num_nulls'='0', 'min_value'='0', 'max_value'='6', 'data_size'='7683200') + """ + + sql """ + alter table customer_demographics modify column cd_education_status set stats ('row_count'='1920800', 'ndv'='7', 'num_nulls'='0', 'min_value'='2 yr Degree', 'max_value'='Unknown', 'data_size'='18384800') + """ + + sql """ + alter table customer_demographics modify column cd_gender set stats ('row_count'='1920800', 'ndv'='2', 'num_nulls'='0', 'min_value'='F', 'max_value'='M', 'data_size'='1920800') + """ + + sql """ + alter table customer_demographics modify column cd_marital_status set stats ('row_count'='1920800', 'ndv'='5', 'num_nulls'='0', 'min_value'='D', 'max_value'='W', 'data_size'='1920800') + """ + + sql """ + alter table date_dim modify column d_date_id set stats ('row_count'='73049', 'ndv'='72907', 'num_nulls'='0', 'min_value'='AAAAAAAAAAAAFCAA', 'max_value'='AAAAAAAAPPPPECAA', 'data_size'='1168784') + """ + + sql """ + alter table date_dim modify column d_fy_week_seq set stats ('row_count'='73049', 'ndv'='10448', 'num_nulls'='0', 'min_value'='1', 'max_value'='10436', 'data_size'='292196') + """ + + sql """ + alter table date_dim modify column d_year set stats ('row_count'='73049', 'ndv'='202', 'num_nulls'='0', 'min_value'='1900', 'max_value'='2100', 'data_size'='292196') + """ + + sql """ + alter table warehouse modify column w_warehouse_id set stats ('row_count'='20', 'ndv'='20', 'num_nulls'='0', 'min_value'='AAAAAAAAABAAAAAA', 'max_value'='AAAAAAAAPAAAAAAA', 'data_size'='320') + """ + + sql """ + alter table catalog_sales modify column cs_ext_list_price set stats ('row_count'='1439980416', 'ndv'='1160303', 'num_nulls'='7199542', 'min_value'='1.00', 'max_value'='30000.00', 'data_size'='5759921664') + """ + + sql """ + alter table catalog_sales modify column cs_ext_tax set stats ('row_count'='1439980416', 'ndv'='215267', 'num_nulls'='7200412', 'min_value'='0.00', 'max_value'='2673.27', 'data_size'='5759921664') + """ + + sql """ + alter table catalog_sales modify column cs_quantity set stats ('row_count'='1439980416', 'ndv'='100', 'num_nulls'='7202885', 'min_value'='1', 'max_value'='100', 'data_size'='5759921664') + """ + + sql """ + alter table catalog_sales modify column cs_ship_cdemo_sk set stats ('row_count'='1439980416', 'ndv'='1916366', 'num_nulls'='7200151', 'min_value'='1', 'max_value'='1920800', 'data_size'='11519843328') + """ + + sql """ + alter table catalog_sales modify column cs_ship_customer_sk set stats ('row_count'='1439980416', 'ndv'='12157481', 'num_nulls'='7201507', 'min_value'='1', 'max_value'='12000000', 'data_size'='11519843328') + """ + + sql """ + alter table call_center modify column cc_company set stats ('row_count'='42', 'ndv'='6', 'num_nulls'='0', 'min_value'='1', 'max_value'='6', 'data_size'='168') + """ + + sql """ + alter table call_center modify column cc_mkt_desc set stats ('row_count'='42', 'ndv'='33', 'num_nulls'='0', 'min_value'='Arms increase controversial, present so', 'max_value'='Young tests could buy comfortable, local users; o', 'data_size'='2419') + """ + + sql """ + alter table call_center modify column cc_open_date_sk set stats ('row_count'='42', 'ndv'='21', 'num_nulls'='0', 'min_value'='2450794', 'max_value'='2451146', 'data_size'='168') + """ + + sql """ + alter table call_center modify column cc_rec_end_date set stats ('row_count'='42', 'ndv'='3', 'num_nulls'='21', 'min_value'='2000-01-01', 'max_value'='2001-12-31', 'data_size'='168') + """ + + sql """ + alter table catalog_returns modify column cr_order_number set stats ('row_count'='143996756', 'ndv'='93476424', 'num_nulls'='0', 'min_value'='2', 'max_value'='160000000', 'data_size'='1151974048') + """ + + sql """ + alter table catalog_returns modify column cr_return_amount set stats ('row_count'='143996756', 'ndv'='882831', 'num_nulls'='2880424', 'min_value'='0.00', 'max_value'='28805.04', 'data_size'='575987024') + """ + + sql """ + alter table catalog_returns modify column cr_returned_date_sk set stats ('row_count'='143996756', 'ndv'='2108', 'num_nulls'='0', 'min_value'='2450821', 'max_value'='2452924', 'data_size'='1151974048') + """ + + sql """ + alter table income_band modify column ib_upper_bound set stats ('row_count'='20', 'ndv'='20', 'num_nulls'='0', 'min_value'='10000', 'max_value'='200000', 'data_size'='80') + """ + + sql """ + alter table catalog_page modify column cp_department set stats ('row_count'='30000', 'ndv'='2', 'num_nulls'='0', 'min_value'='', 'max_value'='DEPARTMENT', 'data_size'='297110') + """ + + sql """ + alter table catalog_page modify column cp_end_date_sk set stats ('row_count'='30000', 'ndv'='97', 'num_nulls'='302', 'min_value'='2450844', 'max_value'='2453186', 'data_size'='120000') + """ + + sql """ + alter table item modify column i_brand_id set stats ('row_count'='300000', 'ndv'='951', 'num_nulls'='763', 'min_value'='1001001', 'max_value'='10016017', 'data_size'='1200000') + """ + + sql """ + alter table item modify column i_category set stats ('row_count'='300000', 'ndv'='11', 'num_nulls'='0', 'min_value'='', 'max_value'='Women', 'data_size'='1766742') + """ + + sql """ + alter table item modify column i_class_id set stats ('row_count'='300000', 'ndv'='16', 'num_nulls'='722', 'min_value'='1', 'max_value'='16', 'data_size'='1200000') + """ + + sql """ + alter table item modify column i_item_sk set stats ('row_count'='300000', 'ndv'='295433', 'num_nulls'='0', 'min_value'='1', 'max_value'='300000', 'data_size'='2400000') + """ + + sql """ + alter table item modify column i_manufact_id set stats ('row_count'='300000', 'ndv'='1005', 'num_nulls'='761', 'min_value'='1', 'max_value'='1000', 'data_size'='1200000') + """ + + sql """ + alter table item modify column i_wholesale_cost set stats ('row_count'='300000', 'ndv'='7243', 'num_nulls'='740', 'min_value'='0.02', 'max_value'='89.49', 'data_size'='1200000') + """ + + sql """ + alter table web_returns modify column wr_refunded_cdemo_sk set stats ('row_count'='71997522', 'ndv'='1916366', 'num_nulls'='3240352', 'min_value'='1', 'max_value'='1920800', 'data_size'='575980176') + """ + + sql """ + alter table web_returns modify column wr_return_tax set stats ('row_count'='71997522', 'ndv'='137392', 'num_nulls'='3237729', 'min_value'='0.00', 'max_value'='2551.16', 'data_size'='287990088') + """ + + sql """ + alter table web_returns modify column wr_returning_hdemo_sk set stats ('row_count'='71997522', 'ndv'='7251', 'num_nulls'='3238239', 'min_value'='1', 'max_value'='7200', 'data_size'='575980176') + """ + + sql """ + alter table web_returns modify column wr_web_page_sk set stats ('row_count'='71997522', 'ndv'='2984', 'num_nulls'='3240387', 'min_value'='1', 'max_value'='3000', 'data_size'='575980176') + """ + + sql """ + alter table web_site modify column web_class set stats ('row_count'='54', 'ndv'='2', 'num_nulls'='0', 'min_value'='', 'max_value'='Unknown', 'data_size'='371') + """ + + sql """ + alter table web_site modify column web_zip set stats ('row_count'='54', 'ndv'='32', 'num_nulls'='0', 'min_value'='14593', 'max_value'='99431', 'data_size'='270') + """ + + sql """ + alter table promotion modify column p_channel_email set stats ('row_count'='1500', 'ndv'='2', 'num_nulls'='0', 'min_value'='', 'max_value'='N', 'data_size'='1480') + """ + + sql """ + alter table promotion modify column p_item_sk set stats ('row_count'='1500', 'ndv'='1467', 'num_nulls'='19', 'min_value'='184', 'max_value'='299990', 'data_size'='12000') + """ + + sql """ + alter table promotion modify column p_promo_name set stats ('row_count'='1500', 'ndv'='11', 'num_nulls'='0', 'min_value'='', 'max_value'='pri', 'data_size'='5896') + """ + + sql """ + alter table web_sales modify column ws_ext_discount_amt set stats ('row_count'='720000376', 'ndv'='1093513', 'num_nulls'='179851', 'min_value'='0.00', 'max_value'='29982.00', 'data_size'='2880001504') + """ + + sql """ + alter table web_sales modify column ws_ext_list_price set stats ('row_count'='720000376', 'ndv'='1160303', 'num_nulls'='179866', 'min_value'='1.00', 'max_value'='30000.00', 'data_size'='2880001504') + """ + + sql """ + alter table web_sales modify column ws_wholesale_cost set stats ('row_count'='720000376', 'ndv'='9905', 'num_nulls'='179834', 'min_value'='1.00', 'max_value'='100.00', 'data_size'='2880001504') + """ + + sql """ + alter table store modify column s_market_manager set stats ('row_count'='1002', 'ndv'='732', 'num_nulls'='0', 'min_value'='', 'max_value'='Zane Perez', 'data_size'='12823') + """ + + sql """ + alter table store modify column s_number_employees set stats ('row_count'='1002', 'ndv'='101', 'num_nulls'='8', 'min_value'='200', 'max_value'='300', 'data_size'='4008') + """ + + sql """ + alter table store modify column s_rec_end_date set stats ('row_count'='1002', 'ndv'='3', 'num_nulls'='501', 'min_value'='1999-03-13', 'max_value'='2001-03-12', 'data_size'='4008') + """ + + sql """ + alter table store modify column s_rec_start_date set stats ('row_count'='1002', 'ndv'='4', 'num_nulls'='7', 'min_value'='1997-03-13', 'max_value'='2001-03-13', 'data_size'='4008') + """ + + sql """ + alter table store modify column s_suite_number set stats ('row_count'='1002', 'ndv'='76', 'num_nulls'='0', 'min_value'='', 'max_value'='Suite Y', 'data_size'='7866') + """ + + sql """ + alter table time_dim modify column t_hour set stats ('row_count'='86400', 'ndv'='24', 'num_nulls'='0', 'min_value'='0', 'max_value'='23', 'data_size'='345600') + """ + + sql """ + alter table time_dim modify column t_shift set stats ('row_count'='86400', 'ndv'='3', 'num_nulls'='0', 'min_value'='first', 'max_value'='third', 'data_size'='460800') + """ + + sql """ + alter table web_page modify column wp_link_count set stats ('row_count'='3000', 'ndv'='24', 'num_nulls'='27', 'min_value'='2', 'max_value'='25', 'data_size'='12000') + """ + + sql """ + alter table web_page modify column wp_rec_end_date set stats ('row_count'='3000', 'ndv'='3', 'num_nulls'='1500', 'min_value'='1999-09-03', 'max_value'='2001-09-02', 'data_size'='12000') + """ + + sql """ + alter table store_returns modify column sr_cdemo_sk set stats ('row_count'='287999764', 'ndv'='1916366', 'num_nulls'='10076902', 'min_value'='1', 'max_value'='1920800', 'data_size'='2303998112') + """ + + sql """ + alter table store_returns modify column sr_item_sk set stats ('row_count'='287999764', 'ndv'='295433', 'num_nulls'='0', 'min_value'='1', 'max_value'='300000', 'data_size'='2303998112') + """ + + sql """ + alter table store_sales modify column ss_cdemo_sk set stats ('row_count'='2879987999', 'ndv'='1916366', 'num_nulls'='129602155', 'min_value'='1', 'max_value'='1920800', 'data_size'='23039903992') + """ + + sql """ + alter table store_sales modify column ss_ext_discount_amt set stats ('row_count'='2879987999', 'ndv'='1161208', 'num_nulls'='129609101', 'min_value'='0.00', 'max_value'='19778.00', 'data_size'='11519951996') + """ + + sql """ + alter table store_sales modify column ss_ext_wholesale_cost set stats ('row_count'='2879987999', 'ndv'='393180', 'num_nulls'='129595018', 'min_value'='1.00', 'max_value'='10000.00', 'data_size'='11519951996') + """ + + sql """ + alter table store_sales modify column ss_list_price set stats ('row_count'='2879987999', 'ndv'='19640', 'num_nulls'='129597020', 'min_value'='1.00', 'max_value'='200.00', 'data_size'='11519951996') + """ + + sql """ + alter table store_sales modify column ss_net_paid set stats ('row_count'='2879987999', 'ndv'='1288646', 'num_nulls'='129599407', 'min_value'='0.00', 'max_value'='19972.00', 'data_size'='11519951996') + """ + + sql """ + alter table store_sales modify column ss_sold_date_sk set stats ('row_count'='2879987999', 'ndv'='1820', 'num_nulls'='129600843', 'min_value'='2450816', 'max_value'='2452642', 'data_size'='23039903992') + """ + + sql """ + alter table store_sales modify column ss_sold_time_sk set stats ('row_count'='2879987999', 'ndv'='47252', 'num_nulls'='129593012', 'min_value'='28800', 'max_value'='75599', 'data_size'='23039903992') + """ + + sql """ + alter table ship_mode modify column sm_carrier set stats ('row_count'='20', 'ndv'='20', 'num_nulls'='0', 'min_value'='AIRBORNE', 'max_value'='ZOUROS', 'data_size'='133') + """ + + sql """ + alter table customer modify column c_birth_year set stats ('row_count'='12000000', 'ndv'='69', 'num_nulls'='419584', 'min_value'='1924', 'max_value'='1992', 'data_size'='48000000') + """ + + sql """ + alter table customer modify column c_login set stats ('row_count'='12000000', 'ndv'='1', 'num_nulls'='0', 'min_value'='', 'max_value'='', 'data_size'='0') + """ + + sql """ + alter table customer modify column c_salutation set stats ('row_count'='12000000', 'ndv'='7', 'num_nulls'='0', 'min_value'='', 'max_value'='Sir', 'data_size'='37544445') + """ + + sql """ + alter table reason modify column r_reason_desc set stats ('row_count'='65', 'ndv'='64', 'num_nulls'='0', 'min_value'='Did not fit', 'max_value'='unauthoized purchase', 'data_size'='848') + """ + + sql """ + alter table date_dim modify column d_current_year set stats ('row_count'='73049', 'ndv'='2', 'num_nulls'='0', 'min_value'='N', 'max_value'='Y', 'data_size'='73049') + """ + + sql """ + alter table date_dim modify column d_dom set stats ('row_count'='73049', 'ndv'='31', 'num_nulls'='0', 'min_value'='1', 'max_value'='31', 'data_size'='292196') + """ + + sql """ + alter table date_dim modify column d_same_day_lq set stats ('row_count'='73049', 'ndv'='72231', 'num_nulls'='0', 'min_value'='2414930', 'max_value'='2487978', 'data_size'='292196') + """ + + sql """ + alter table date_dim modify column d_week_seq set stats ('row_count'='73049', 'ndv'='10448', 'num_nulls'='0', 'min_value'='1', 'max_value'='10436', 'data_size'='292196') + """ + + sql """ + alter table date_dim modify column d_weekend set stats ('row_count'='73049', 'ndv'='2', 'num_nulls'='0', 'min_value'='N', 'max_value'='Y', 'data_size'='73049') + """ + + sql """ + alter table warehouse modify column w_zip set stats ('row_count'='20', 'ndv'='18', 'num_nulls'='0', 'min_value'='19231', 'max_value'='89275', 'data_size'='100') + """ + + sql """ + alter table catalog_sales modify column cs_catalog_page_sk set stats ('row_count'='1439980416', 'ndv'='17005', 'num_nulls'='7199032', 'min_value'='1', 'max_value'='25207', 'data_size'='11519843328') + """ + + sql """ + alter table catalog_sales modify column cs_coupon_amt set stats ('row_count'='1439980416', 'ndv'='1578778', 'num_nulls'='7198116', 'min_value'='0.00', 'max_value'='28730.00', 'data_size'='5759921664') + """ + + sql """ + alter table catalog_sales modify column cs_list_price set stats ('row_count'='1439980416', 'ndv'='29396', 'num_nulls'='7201549', 'min_value'='1.00', 'max_value'='300.00', 'data_size'='5759921664') + """ + + sql """ + alter table catalog_sales modify column cs_net_profit set stats ('row_count'='1439980416', 'ndv'='2058398', 'num_nulls'='0', 'min_value'='-10000.00', 'max_value'='19962.00', 'data_size'='5759921664') + """ + + sql """ + alter table catalog_sales modify column cs_order_number set stats ('row_count'='1439980416', 'ndv'='159051824', 'num_nulls'='0', 'min_value'='1', 'max_value'='160000000', 'data_size'='11519843328') + """ + + sql """ + alter table catalog_sales modify column cs_ship_hdemo_sk set stats ('row_count'='1439980416', 'ndv'='7251', 'num_nulls'='7201542', 'min_value'='1', 'max_value'='7200', 'data_size'='11519843328') + """ + + sql """ + alter table call_center modify column cc_call_center_sk set stats ('row_count'='42', 'ndv'='42', 'num_nulls'='0', 'min_value'='1', 'max_value'='42', 'data_size'='336') + """ + + sql """ + alter table call_center modify column cc_city set stats ('row_count'='42', 'ndv'='17', 'num_nulls'='0', 'min_value'='Antioch', 'max_value'='Spring Hill', 'data_size'='386') + """ + + sql """ + alter table call_center modify column cc_closed_date_sk set stats ('row_count'='42', 'ndv'='0', 'num_nulls'='42', 'data_size'='168') + """ + + sql """ + alter table call_center modify column cc_gmt_offset set stats ('row_count'='42', 'ndv'='4', 'num_nulls'='0', 'min_value'='-8.00', 'max_value'='-5.00', 'data_size'='168') + """ + + sql """ + alter table call_center modify column cc_hours set stats ('row_count'='42', 'ndv'='3', 'num_nulls'='0', 'min_value'='8AM-12AM', 'max_value'='8AM-8AM', 'data_size'='300') + """ + + sql """ + alter table call_center modify column cc_street_number set stats ('row_count'='42', 'ndv'='21', 'num_nulls'='0', 'min_value'='38', 'max_value'='999', 'data_size'='120') + """ + + sql """ + alter table call_center modify column cc_tax_percentage set stats ('row_count'='42', 'ndv'='12', 'num_nulls'='0', 'min_value'='0.00', 'max_value'='0.12', 'data_size'='168') + """ + + sql """ + alter table inventory modify column inv_date_sk set stats ('row_count'='783000000', 'ndv'='261', 'num_nulls'='0', 'min_value'='2450815', 'max_value'='2452635', 'data_size'='6264000000') + """ + + sql """ + alter table inventory modify column inv_item_sk set stats ('row_count'='783000000', 'ndv'='295433', 'num_nulls'='0', 'min_value'='1', 'max_value'='300000', 'data_size'='6264000000') + """ + + sql """ + alter table catalog_returns modify column cr_fee set stats ('row_count'='143996756', 'ndv'='9958', 'num_nulls'='2882168', 'min_value'='0.50', 'max_value'='100.00', 'data_size'='575987024') + """ + + sql """ + alter table catalog_returns modify column cr_return_quantity set stats ('row_count'='143996756', 'ndv'='100', 'num_nulls'='2878774', 'min_value'='1', 'max_value'='100', 'data_size'='575987024') + """ + + sql """ + alter table catalog_returns modify column cr_returned_time_sk set stats ('row_count'='143996756', 'ndv'='87677', 'num_nulls'='0', 'min_value'='0', 'max_value'='86399', 'data_size'='1151974048') + """ + + sql """ + alter table household_demographics modify column hd_dep_count set stats ('row_count'='7200', 'ndv'='10', 'num_nulls'='0', 'min_value'='0', 'max_value'='9', 'data_size'='28800') + """ + + sql """ + alter table customer_address modify column ca_county set stats ('row_count'='6000000', 'ndv'='1825', 'num_nulls'='0', 'min_value'='', 'max_value'='Ziebach County', 'data_size'='81254984') + """ + + sql """ + alter table income_band modify column ib_lower_bound set stats ('row_count'='20', 'ndv'='20', 'num_nulls'='0', 'min_value'='0', 'max_value'='190001', 'data_size'='80') + """ + + sql """ + alter table item modify column i_category_id set stats ('row_count'='300000', 'ndv'='10', 'num_nulls'='766', 'min_value'='1', 'max_value'='10', 'data_size'='1200000') + """ + + sql """ + alter table item modify column i_class set stats ('row_count'='300000', 'ndv'='100', 'num_nulls'='0', 'min_value'='', 'max_value'='womens watch', 'data_size'='2331199') + """ + + sql """ + alter table item modify column i_container set stats ('row_count'='300000', 'ndv'='2', 'num_nulls'='0', 'min_value'='', 'max_value'='Unknown', 'data_size'='2094652') + """ + + sql """ + alter table item modify column i_current_price set stats ('row_count'='300000', 'ndv'='9685', 'num_nulls'='775', 'min_value'='0.09', 'max_value'='99.99', 'data_size'='1200000') + """ + + sql """ + alter table item modify column i_manager_id set stats ('row_count'='300000', 'ndv'='100', 'num_nulls'='744', 'min_value'='1', 'max_value'='100', 'data_size'='1200000') + """ + + sql """ + alter table item modify column i_size set stats ('row_count'='300000', 'ndv'='8', 'num_nulls'='0', 'min_value'='', 'max_value'='small', 'data_size'='1296134') + """ + + sql """ + alter table web_returns modify column wr_order_number set stats ('row_count'='71997522', 'ndv'='42383708', 'num_nulls'='0', 'min_value'='1', 'max_value'='60000000', 'data_size'='575980176') + """ + + sql """ + alter table web_returns modify column wr_refunded_cash set stats ('row_count'='71997522', 'ndv'='955369', 'num_nulls'='3240493', 'min_value'='0.00', 'max_value'='26992.92', 'data_size'='287990088') + """ + + sql """ + alter table web_site modify column web_country set stats ('row_count'='54', 'ndv'='2', 'num_nulls'='0', 'min_value'='', 'max_value'='United States', 'data_size'='689') + """ + + sql """ + alter table web_site modify column web_gmt_offset set stats ('row_count'='54', 'ndv'='4', 'num_nulls'='1', 'min_value'='-8.00', 'max_value'='-5.00', 'data_size'='216') + """ + + sql """ + alter table web_site modify column web_market_manager set stats ('row_count'='54', 'ndv'='46', 'num_nulls'='0', 'min_value'='', 'max_value'='Zachery Oneil', 'data_size'='691') + """ + + sql """ + alter table web_site modify column web_site_sk set stats ('row_count'='54', 'ndv'='54', 'num_nulls'='0', 'min_value'='1', 'max_value'='54', 'data_size'='432') + """ + + sql """ + alter table web_site modify column web_street_name set stats ('row_count'='54', 'ndv'='53', 'num_nulls'='0', 'min_value'='', 'max_value'='Wilson Ridge', 'data_size'='471') + """ + + sql """ + alter table web_site modify column web_tax_percentage set stats ('row_count'='54', 'ndv'='13', 'num_nulls'='1', 'min_value'='0.00', 'max_value'='0.12', 'data_size'='216') + """ + + sql """ + alter table promotion modify column p_channel_tv set stats ('row_count'='1500', 'ndv'='2', 'num_nulls'='0', 'min_value'='', 'max_value'='N', 'data_size'='1481') + """ + + sql """ + alter table promotion modify column p_response_targe set stats ('row_count'='1500', 'ndv'='1', 'num_nulls'='27', 'min_value'='1', 'max_value'='1', 'data_size'='6000') + """ + + sql """ + alter table web_sales modify column ws_bill_addr_sk set stats ('row_count'='720000376', 'ndv'='6015742', 'num_nulls'='179648', 'min_value'='1', 'max_value'='6000000', 'data_size'='5760003008') + """ + + sql """ + alter table web_sales modify column ws_ext_sales_price set stats ('row_count'='720000376', 'ndv'='1091003', 'num_nulls'='180023', 'min_value'='0.00', 'max_value'='29810.00', 'data_size'='2880001504') + """ + + sql """ + alter table web_sales modify column ws_net_profit set stats ('row_count'='720000376', 'ndv'='2014057', 'num_nulls'='0', 'min_value'='-10000.00', 'max_value'='19840.00', 'data_size'='2880001504') + """ + + sql """ + alter table web_sales modify column ws_promo_sk set stats ('row_count'='720000376', 'ndv'='1489', 'num_nulls'='180016', 'min_value'='1', 'max_value'='1500', 'data_size'='5760003008') + """ + + sql """ + alter table web_sales modify column ws_ship_customer_sk set stats ('row_count'='720000376', 'ndv'='12074547', 'num_nulls'='179966', 'min_value'='1', 'max_value'='12000000', 'data_size'='5760003008') + """ + + sql """ + alter table store modify column s_division_name set stats ('row_count'='1002', 'ndv'='2', 'num_nulls'='0', 'min_value'='', 'max_value'='Unknown', 'data_size'='6965') + """ + + sql """ + alter table store modify column s_floor_space set stats ('row_count'='1002', 'ndv'='752', 'num_nulls'='6', 'min_value'='5002549', 'max_value'='9997773', 'data_size'='4008') + """ + + sql """ + alter table store modify column s_tax_percentage set stats ('row_count'='1002', 'ndv'='12', 'num_nulls'='8', 'min_value'='0.00', 'max_value'='0.11', 'data_size'='4008') + """ + + sql """ + alter table time_dim modify column t_time_id set stats ('row_count'='86400', 'ndv'='85663', 'num_nulls'='0', 'min_value'='AAAAAAAAAAAABAAA', 'max_value'='AAAAAAAAPPPPAAAA', 'data_size'='1382400') + """ + + sql """ + alter table time_dim modify column t_time_sk set stats ('row_count'='86400', 'ndv'='87677', 'num_nulls'='0', 'min_value'='0', 'max_value'='86399', 'data_size'='691200') + """ + + sql """ + alter table store_returns modify column sr_fee set stats ('row_count'='287999764', 'ndv'='9958', 'num_nulls'='10081860', 'min_value'='0.50', 'max_value'='100.00', 'data_size'='1151999056') + """ + + sql """ + alter table store_returns modify column sr_reason_sk set stats ('row_count'='287999764', 'ndv'='65', 'num_nulls'='10087936', 'min_value'='1', 'max_value'='65', 'data_size'='2303998112') + """ + + sql """ + alter table store_returns modify column sr_store_credit set stats ('row_count'='287999764', 'ndv'='698161', 'num_nulls'='10077188', 'min_value'='0.00', 'max_value'='17792.48', 'data_size'='1151999056') + """ + + sql """ + alter table store_returns modify column sr_ticket_number set stats ('row_count'='287999764', 'ndv'='168770768', 'num_nulls'='0', 'min_value'='1', 'max_value'='240000000', 'data_size'='2303998112') + """ + + sql """ + alter table store_sales modify column ss_ext_list_price set stats ('row_count'='2879987999', 'ndv'='770971', 'num_nulls'='129593800', 'min_value'='1.00', 'max_value'='20000.00', 'data_size'='11519951996') + """ + + sql """ + alter table store_sales modify column ss_ext_sales_price set stats ('row_count'='2879987999', 'ndv'='754248', 'num_nulls'='129589177', 'min_value'='0.00', 'max_value'='19972.00', 'data_size'='11519951996') + """ + + sql """ + alter table store_sales modify column ss_net_profit set stats ('row_count'='2879987999', 'ndv'='1497362', 'num_nulls'='129572933', 'min_value'='-10000.00', 'max_value'='9986.00', 'data_size'='11519951996') + """ + + sql """ + alter table store_sales modify column ss_promo_sk set stats ('row_count'='2879987999', 'ndv'='1489', 'num_nulls'='129597096', 'min_value'='1', 'max_value'='1500', 'data_size'='23039903992') + """ + + sql """ + alter table ship_mode modify column sm_code set stats ('row_count'='20', 'ndv'='4', 'num_nulls'='0', 'min_value'='AIR', 'max_value'='SURFACE', 'data_size'='87') + """ + + sql """ + alter table ship_mode modify column sm_contract set stats ('row_count'='20', 'ndv'='20', 'num_nulls'='0', 'min_value'='2mM8l', 'max_value'='yVfotg7Tio3MVhBg6Bkn', 'data_size'='252') + """ + + sql """ + alter table customer modify column c_current_hdemo_sk set stats ('row_count'='12000000', 'ndv'='7251', 'num_nulls'='418736', 'min_value'='1', 'max_value'='7200', 'data_size'='96000000') + """ + + sql """ + alter table dbgen_version modify column dv_create_date set stats ('row_count'='1', 'ndv'='1', 'num_nulls'='0', 'min_value'='2023-07-06', 'max_value'='2023-07-06', 'data_size'='4') + """ + + sql """ + alter table dbgen_version modify column dv_create_time set stats ('row_count'='1', 'ndv'='1', 'num_nulls'='0', 'min_value'='2017-05-13 00:00:00', 'max_value'='2017-05-13 00:00:00', 'data_size'='8') + """ + + // ---- primary key / foreign key / unique key constraints ---- + sql """alter table item add constraint i_pk primary key (i_item_sk);""" + sql """alter table customer add constraint c_pk primary key (c_customer_sk);""" + sql """alter table store_sales add constraint ss_c_fk foreign key(ss_customer_sk) references customer(c_customer_sk);""" + sql """alter table web_sales add constraint ws_c_fk foreign key(ws_bill_customer_sk) references customer(c_customer_sk);""" + sql """alter table catalog_sales add constraint cs_c_fk foreign key(cs_bill_customer_sk) references customer(c_customer_sk);""" + sql """alter table customer add constraint c_uk unique (c_customer_id);""" +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query1.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query1.groovy new file mode 100644 index 00000000000000..8bf95133cf6678 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query1.groovy @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query1_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_FEE) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =2000 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'TN' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100""" + qt_ds_shape_1_constraints ''' + explain shape plan + with customer_total_return as +(select sr_customer_sk as ctr_customer_sk +,sr_store_sk as ctr_store_sk +,sum(SR_FEE) as ctr_total_return +from store_returns +,date_dim +where sr_returned_date_sk = d_date_sk +and d_year =2000 +group by sr_customer_sk +,sr_store_sk) + select c_customer_id +from customer_total_return ctr1 +,store +,customer +where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 +from customer_total_return ctr2 +where ctr1.ctr_store_sk = ctr2.ctr_store_sk) +and s_store_sk = ctr1.ctr_store_sk +and s_state = 'TN' +and ctr1.ctr_customer_sk = c_customer_sk +order by c_customer_id +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query10.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query10.groovy new file mode 100644 index 00000000000000..c59f2a27b5ff3c --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query10.groovy @@ -0,0 +1,156 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query10_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('Fairfield County','Campbell County','Washtenaw County','Escambia County','Cleburne County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 3 and 3+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 3 ANd 3+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 3 and 3+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100""" + qt_ds_shape_10_constraints ''' + explain shape plan + select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3, + cd_dep_count, + count(*) cnt4, + cd_dep_employed_count, + count(*) cnt5, + cd_dep_college_count, + count(*) cnt6 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_county in ('Fairfield County','Campbell County','Washtenaw County','Escambia County','Cleburne County') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 3 and 3+3) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 3 ANd 3+3) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2001 and + d_moy between 3 and 3+3)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query11.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query11.groovy new file mode 100644 index 00000000000000..2ead5df7a6ce5e --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query11.groovy @@ -0,0 +1,200 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query11_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_email_address + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1998 + and t_s_secyear.dyear = 1998+1 + and t_w_firstyear.dyear = 1998 + and t_w_secyear.dyear = 1998+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_email_address +limit 100""" + qt_ds_shape_11_constraints ''' + explain shape plan + with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_email_address + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1998 + and t_s_secyear.dyear = 1998+1 + and t_w_firstyear.dyear = 1998 + and t_w_secyear.dyear = 1998+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_email_address +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query12.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query12.groovy new file mode 100644 index 00000000000000..7991a9f0d94256 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query12.groovy @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query12_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Men', 'Books', 'Electronics') + and ws_sold_date_sk = d_date_sk + and d_date between cast('2001-06-15' as date) + and (cast('2001-06-15' as date) + interval 30 day) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100""" + qt_ds_shape_12_constraints ''' + explain shape plan + select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over + (partition by i_class) as revenueratio +from + web_sales + ,item + ,date_dim +where + ws_item_sk = i_item_sk + and i_category in ('Men', 'Books', 'Electronics') + and ws_sold_date_sk = d_date_sk + and d_date between cast('2001-06-15' as date) + and (cast('2001-06-15' as date) + interval 30 day) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query13.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query13.groovy new file mode 100644 index 00000000000000..45b37d70c4657b --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query13.groovy @@ -0,0 +1,142 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query13_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'M' + and cd_education_status = 'College' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'D' + and cd_education_status = 'Primary' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'W' + and cd_education_status = '2 yr Degree' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('IL', 'TN', 'TX') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('WY', 'OH', 'ID') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('MS', 'SC', 'IA') + and ss_net_profit between 50 and 250 + )) +""" + qt_ds_shape_13_constraints ''' + explain shape plan + select avg(ss_quantity) + ,avg(ss_ext_sales_price) + ,avg(ss_ext_wholesale_cost) + ,sum(ss_ext_wholesale_cost) + from store_sales + ,store + ,customer_demographics + ,household_demographics + ,customer_address + ,date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and((ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'M' + and cd_education_status = 'College' + and ss_sales_price between 100.00 and 150.00 + and hd_dep_count = 3 + )or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'D' + and cd_education_status = 'Primary' + and ss_sales_price between 50.00 and 100.00 + and hd_dep_count = 1 + ) or + (ss_hdemo_sk=hd_demo_sk + and cd_demo_sk = ss_cdemo_sk + and cd_marital_status = 'W' + and cd_education_status = '2 yr Degree' + and ss_sales_price between 150.00 and 200.00 + and hd_dep_count = 1 + )) + and((ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('IL', 'TN', 'TX') + and ss_net_profit between 100 and 200 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('WY', 'OH', 'ID') + and ss_net_profit between 150 and 300 + ) or + (ss_addr_sk = ca_address_sk + and ca_country = 'United States' + and ca_state in ('MS', 'SC', 'IA') + and ss_net_profit between 50 and 250 + )) + + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query14.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query14.groovy new file mode 100644 index 00000000000000..17fc07b610892b --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query14.groovy @@ -0,0 +1,246 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query14_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1999 AND 1999 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1999 AND 1999 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1999 AND 1999 + 2) + t where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), +avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100""" + qt_ds_shape_14_constraints ''' + explain shape plan + with cross_items as + (select i_item_sk ss_item_sk + from item, + (select iss.i_brand_id brand_id + ,iss.i_class_id class_id + ,iss.i_category_id category_id + from store_sales + ,item iss + ,date_dim d1 + where ss_item_sk = iss.i_item_sk + and ss_sold_date_sk = d1.d_date_sk + and d1.d_year between 1999 AND 1999 + 2 + intersect + select ics.i_brand_id + ,ics.i_class_id + ,ics.i_category_id + from catalog_sales + ,item ics + ,date_dim d2 + where cs_item_sk = ics.i_item_sk + and cs_sold_date_sk = d2.d_date_sk + and d2.d_year between 1999 AND 1999 + 2 + intersect + select iws.i_brand_id + ,iws.i_class_id + ,iws.i_category_id + from web_sales + ,item iws + ,date_dim d3 + where ws_item_sk = iws.i_item_sk + and ws_sold_date_sk = d3.d_date_sk + and d3.d_year between 1999 AND 1999 + 2) + t where i_brand_id = brand_id + and i_class_id = class_id + and i_category_id = category_id +), +avg_sales as + (select avg(quantity*list_price) average_sales + from (select ss_quantity quantity + ,ss_list_price list_price + from store_sales + ,date_dim + where ss_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select cs_quantity quantity + ,cs_list_price list_price + from catalog_sales + ,date_dim + where cs_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2 + union all + select ws_quantity quantity + ,ws_list_price list_price + from web_sales + ,date_dim + where ws_sold_date_sk = d_date_sk + and d_year between 1999 and 1999 + 2) x) + select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) + from( + select 'store' channel, i_brand_id,i_class_id + ,i_category_id,sum(ss_quantity*ss_list_price) sales + , count(*) number_sales + from store_sales + ,item + ,date_dim + where ss_item_sk in (select ss_item_sk from cross_items) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales) + union all + select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales + from catalog_sales + ,item + ,date_dim + where cs_item_sk in (select ss_item_sk from cross_items) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales) + union all + select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales + from web_sales + ,item + ,date_dim + where ws_item_sk in (select ss_item_sk from cross_items) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 1999+2 + and d_moy = 11 + group by i_brand_id,i_class_id,i_category_id + having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales) + ) y + group by rollup (channel, i_brand_id,i_class_id,i_category_id) + order by channel,i_brand_id,i_class_id,i_category_id + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query15.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query15.groovy new file mode 100644 index 00000000000000..3cd7c97523bee8 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query15.groovy @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query15_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2001 + group by ca_zip + order by ca_zip + limit 100""" + qt_ds_shape_15_constraints ''' + explain shape plan + select ca_zip + ,sum(cs_sales_price) + from catalog_sales + ,customer + ,customer_address + ,date_dim + where cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', + '85392', '85460', '80348', '81792') + or ca_state in ('CA','WA','GA') + or cs_sales_price > 500) + and cs_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 2001 + group by ca_zip + order by ca_zip + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query16.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query16.groovy new file mode 100644 index 00000000000000..777d98e5310f06 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query16.groovy @@ -0,0 +1,100 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query16_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between '2002-4-01' and + (cast('2002-4-01' as date) + interval 60 day) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'PA' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Williamson County','Williamson County','Williamson County','Williamson County', + 'Williamson County' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100""" + qt_ds_shape_16_constraints ''' + explain shape plan + select + count(distinct cs_order_number) as "order count" + ,sum(cs_ext_ship_cost) as "total shipping cost" + ,sum(cs_net_profit) as "total net profit" +from + catalog_sales cs1 + ,date_dim + ,customer_address + ,call_center +where + d_date between '2002-4-01' and + (cast('2002-4-01' as date) + interval 60 day) +and cs1.cs_ship_date_sk = d_date_sk +and cs1.cs_ship_addr_sk = ca_address_sk +and ca_state = 'PA' +and cs1.cs_call_center_sk = cc_call_center_sk +and cc_county in ('Williamson County','Williamson County','Williamson County','Williamson County', + 'Williamson County' +) +and exists (select * + from catalog_sales cs2 + where cs1.cs_order_number = cs2.cs_order_number + and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) +and not exists(select * + from catalog_returns cr1 + where cs1.cs_order_number = cr1.cr_order_number) +order by count(distinct cs_order_number) +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query17.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query17.groovy new file mode 100644 index 00000000000000..b68be1256cc17c --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query17.groovy @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query17_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '2001Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('2001Q1','2001Q2','2001Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('2001Q1','2001Q2','2001Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100""" + qt_ds_shape_17_constraints ''' + explain shape plan + select i_item_id + ,i_item_desc + ,s_state + ,count(ss_quantity) as store_sales_quantitycount + ,avg(ss_quantity) as store_sales_quantityave + ,stddev_samp(ss_quantity) as store_sales_quantitystdev + ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov + ,count(sr_return_quantity) as store_returns_quantitycount + ,avg(sr_return_quantity) as store_returns_quantityave + ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev + ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov + ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave + ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev + ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov + from store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where d1.d_quarter_name = '2001Q1' + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_quarter_name in ('2001Q1','2001Q2','2001Q3') + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_quarter_name in ('2001Q1','2001Q2','2001Q3') + group by i_item_id + ,i_item_desc + ,s_state + order by i_item_id + ,i_item_desc + ,s_state +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query18.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query18.groovy new file mode 100644 index 00000000000000..654fa2cd01c802 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query18.groovy @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query18_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select i_item_id, + ca_country, + ca_state, + ca_county, + avg( cast(cs_quantity as decimal(12,2))) agg1, + avg( cast(cs_list_price as decimal(12,2))) agg2, + avg( cast(cs_coupon_amt as decimal(12,2))) agg3, + avg( cast(cs_sales_price as decimal(12,2))) agg4, + avg( cast(cs_net_profit as decimal(12,2))) agg5, + avg( cast(c_birth_year as decimal(12,2))) agg6, + avg( cast(cd1.cd_dep_count as decimal(12,2))) agg7 + from catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'F' and + cd1.cd_education_status = 'Primary' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (1,3,7,11,10,4) and + d_year = 2001 and + ca_state in ('AL','MO','TN' + ,'GA','MT','IN','CA') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100""" + qt_ds_shape_18_constraints ''' + explain shape plan + select i_item_id, + ca_country, + ca_state, + ca_county, + avg( cast(cs_quantity as decimal(12,2))) agg1, + avg( cast(cs_list_price as decimal(12,2))) agg2, + avg( cast(cs_coupon_amt as decimal(12,2))) agg3, + avg( cast(cs_sales_price as decimal(12,2))) agg4, + avg( cast(cs_net_profit as decimal(12,2))) agg5, + avg( cast(c_birth_year as decimal(12,2))) agg6, + avg( cast(cd1.cd_dep_count as decimal(12,2))) agg7 + from catalog_sales, customer_demographics cd1, + customer_demographics cd2, customer, customer_address, date_dim, item + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd1.cd_demo_sk and + cs_bill_customer_sk = c_customer_sk and + cd1.cd_gender = 'F' and + cd1.cd_education_status = 'Primary' and + c_current_cdemo_sk = cd2.cd_demo_sk and + c_current_addr_sk = ca_address_sk and + c_birth_month in (1,3,7,11,10,4) and + d_year = 2001 and + ca_state in ('AL','MO','TN' + ,'GA','MT','IN','CA') + group by rollup (i_item_id, ca_country, ca_state, ca_county) + order by ca_country, + ca_state, + ca_county, + i_item_id + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query19.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query19.groovy new file mode 100644 index 00000000000000..708432825f656e --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query19.groovy @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query19_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=14 + and d_moy=11 + and d_year=2002 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 """ + qt_ds_shape_19_constraints ''' + explain shape plan + select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item,customer,customer_address,store + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=14 + and d_moy=11 + and d_year=2002 + and ss_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk + group by i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact + order by ext_price desc + ,i_brand + ,i_brand_id + ,i_manufact_id + ,i_manufact +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query2.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query2.groovy new file mode 100644 index 00000000000000..9376613587eac0 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query2.groovy @@ -0,0 +1,158 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query2_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) t), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1""" + qt_ds_shape_2_constraints ''' + explain shape plan + with wscs as + (select sold_date_sk + ,sales_price + from (select ws_sold_date_sk sold_date_sk + ,ws_ext_sales_price sales_price + from web_sales + union all + select cs_sold_date_sk sold_date_sk + ,cs_ext_sales_price sales_price + from catalog_sales) t), + wswscs as + (select d_week_seq, + sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales + from wscs + ,date_dim + where d_date_sk = sold_date_sk + group by d_week_seq) + select d_week_seq1 + ,round(sun_sales1/sun_sales2,2) + ,round(mon_sales1/mon_sales2,2) + ,round(tue_sales1/tue_sales2,2) + ,round(wed_sales1/wed_sales2,2) + ,round(thu_sales1/thu_sales2,2) + ,round(fri_sales1/fri_sales2,2) + ,round(sat_sales1/sat_sales2,2) + from + (select wswscs.d_week_seq d_week_seq1 + ,sun_sales sun_sales1 + ,mon_sales mon_sales1 + ,tue_sales tue_sales1 + ,wed_sales wed_sales1 + ,thu_sales thu_sales1 + ,fri_sales fri_sales1 + ,sat_sales sat_sales1 + from wswscs,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998) y, + (select wswscs.d_week_seq d_week_seq2 + ,sun_sales sun_sales2 + ,mon_sales mon_sales2 + ,tue_sales tue_sales2 + ,wed_sales wed_sales2 + ,thu_sales thu_sales2 + ,fri_sales fri_sales2 + ,sat_sales sat_sales2 + from wswscs + ,date_dim + where date_dim.d_week_seq = wswscs.d_week_seq and + d_year = 1998+1) z + where d_week_seq1=d_week_seq2-53 + order by d_week_seq1 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query20.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query20.groovy new file mode 100644 index 00000000000000..47ee83c1ca383c --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query20.groovy @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query20_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Books', 'Music', 'Sports') + and cs_sold_date_sk = d_date_sk + and d_date between cast('2002-06-18' as date) + and (cast('2002-06-18' as date) + interval 30 day) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100""" + qt_ds_shape_20_constraints ''' + explain shape plan + select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over + (partition by i_class) as revenueratio + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and i_category in ('Books', 'Music', 'Sports') + and cs_sold_date_sk = d_date_sk + and d_date between cast('2002-06-18' as date) + and (cast('2002-06-18' as date) + interval 30 day) + group by i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + order by i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query21.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query21.groovy new file mode 100644 index 00000000000000..c7b486f7895f78 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query21.groovy @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query21_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'SET enable_fold_constant_by_be = false' //plan shape will be different + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('1999-06-22' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('1999-06-22' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('1999-06-22' as date) - interval 30 day) + and (cast ('1999-06-22' as date) + interval 30 day) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100""" + qt_ds_shape_21_constraints ''' + explain shape plan + select * + from(select w_warehouse_name + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('1999-06-22' as date)) + then inv_quantity_on_hand + else 0 end) as inv_before + ,sum(case when (cast(d_date as date) >= cast ('1999-06-22' as date)) + then inv_quantity_on_hand + else 0 end) as inv_after + from inventory + ,warehouse + ,item + ,date_dim + where i_current_price between 0.99 and 1.49 + and i_item_sk = inv_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_date between (cast ('1999-06-22' as date) - interval 30 day) + and (cast ('1999-06-22' as date) + interval 30 day) + group by w_warehouse_name, i_item_id) x + where (case when inv_before > 0 + then inv_after / inv_before + else null + end) between 2.0/3.0 and 3.0/2.0 + order by w_warehouse_name + ,i_item_id + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query22.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query22.groovy new file mode 100644 index 00000000000000..83b88c78cae361 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query22.groovy @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query22_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1200 and 1200 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100""" + qt_ds_shape_22_constraints ''' + explain shape plan + select i_product_name + ,i_brand + ,i_class + ,i_category + ,avg(inv_quantity_on_hand) qoh + from inventory + ,date_dim + ,item + where inv_date_sk=d_date_sk + and inv_item_sk=i_item_sk + and d_month_seq between 1200 and 1200 + 11 + group by rollup(i_product_name + ,i_brand + ,i_class + ,i_category) +order by qoh, i_product_name, i_brand, i_class, i_category +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query23.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query23.groovy new file mode 100644 index 00000000000000..9bc5f2c2386fa7 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query23.groovy @@ -0,0 +1,145 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query23_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + multi_sql """ + use ${db}; + set enable_nereids_planner=true; + set enable_nereids_distribute_planner=false; + set enable_fallback_to_original_planner=false; + set exec_mem_limit=21G; + set be_number_for_test=3; + set enable_runtime_filter_prune=false; + set parallel_pipeline_task_num=8; + set forbid_unknown_col_stats=false; + set enable_stats=true; + set runtime_filter_type=8; + set broadcast_row_count_limit = 30000000; + set enable_nereids_timeout = false; + set enable_pipeline_engine = true; + set disable_nereids_rules='PRUNE_EMPTY_PARTITION'; + set push_topn_to_agg = true; + set topn_opt_limit_threshold=1024; + """ + + sql 'set join_order_time_limit=10000' + + def ds = """with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by c_customer_sk) t), +best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 2000 + and d_moy = 7 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 2000 + and d_moy = 7 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) t2 + limit 100""" + qt_ds_shape_23_constraints ''' + explain shape plan + with frequent_ss_items as + (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt + from store_sales + ,date_dim + ,item + where ss_sold_date_sk = d_date_sk + and ss_item_sk = i_item_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by substr(i_item_desc,1,30),i_item_sk,d_date + having count(*) >4), + max_store_sales as + (select max(csales) tpcds_cmax + from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales + from store_sales + ,customer + ,date_dim + where ss_customer_sk = c_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (2000,2000+1,2000+2,2000+3) + group by c_customer_sk) t), +best_ss_customer as + (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales + from store_sales + ,customer + where ss_customer_sk = c_customer_sk + group by c_customer_sk + having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select + * +from + max_store_sales)) + select sum(sales) + from (select cs_quantity*cs_list_price sales + from catalog_sales + ,date_dim + where d_year = 2000 + and d_moy = 7 + and cs_sold_date_sk = d_date_sk + and cs_item_sk in (select item_sk from frequent_ss_items) + and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) + union all + select ws_quantity*ws_list_price sales + from web_sales + ,date_dim + where d_year = 2000 + and d_moy = 7 + and ws_sold_date_sk = d_date_sk + and ws_item_sk in (select item_sk from frequent_ss_items) + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) t2 + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query24.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query24.groovy new file mode 100644 index 00000000000000..1795dfc501f91e --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query24.groovy @@ -0,0 +1,148 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query24_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_paid) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=5 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'aquamarine' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name +""" + qt_ds_shape_24_constraints ''' + explain shape plan + with ssales as +(select c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size + ,sum(ss_net_paid) netpaid +from store_sales + ,store_returns + ,store + ,item + ,customer + ,customer_address +where ss_ticket_number = sr_ticket_number + and ss_item_sk = sr_item_sk + and ss_customer_sk = c_customer_sk + and ss_item_sk = i_item_sk + and ss_store_sk = s_store_sk + and c_current_addr_sk = ca_address_sk + and c_birth_country <> upper(ca_country) + and s_zip = ca_zip +and s_market_id=5 +group by c_last_name + ,c_first_name + ,s_store_name + ,ca_state + ,s_state + ,i_color + ,i_current_price + ,i_manager_id + ,i_units + ,i_size) +select c_last_name + ,c_first_name + ,s_store_name + ,sum(netpaid) paid +from ssales +where i_color = 'aquamarine' +group by c_last_name + ,c_first_name + ,s_store_name +having sum(netpaid) > (select 0.05*avg(netpaid) + from ssales) +order by c_last_name + ,c_first_name + ,s_store_name + + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query25.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query25.groovy new file mode 100644 index 00000000000000..1f30400171a79c --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query25.groovy @@ -0,0 +1,134 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query25_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,max(ss_net_profit) as store_sales_profit + ,max(sr_net_loss) as store_returns_loss + ,max(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1999 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 1999 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 1999 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100""" + qt_ds_shape_25_constraints ''' + explain shape plan + select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,max(ss_net_profit) as store_sales_profit + ,max(sr_net_loss) as store_returns_loss + ,max(cs_net_profit) as catalog_sales_profit + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1999 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 10 + and d2.d_year = 1999 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_moy between 4 and 10 + and d3.d_year = 1999 + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query26.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query26.groovy new file mode 100644 index 00000000000000..0e8ef0b1441073 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query26.groovy @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query26_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'W' and + cd_education_status = 'Unknown' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2002 + group by i_item_id + order by i_item_id + limit 100""" + qt_ds_shape_26_constraints ''' + explain shape plan + select i_item_id, + avg(cs_quantity) agg1, + avg(cs_list_price) agg2, + avg(cs_coupon_amt) agg3, + avg(cs_sales_price) agg4 + from catalog_sales, customer_demographics, date_dim, item, promotion + where cs_sold_date_sk = d_date_sk and + cs_item_sk = i_item_sk and + cs_bill_cdemo_sk = cd_demo_sk and + cs_promo_sk = p_promo_sk and + cd_gender = 'M' and + cd_marital_status = 'W' and + cd_education_status = 'Unknown' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2002 + group by i_item_id + order by i_item_id + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query27.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query27.groovy new file mode 100644 index 00000000000000..bea384589f5350 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query27.groovy @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query27_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'M' and + cd_marital_status = 'W' and + cd_education_status = 'Secondary' and + d_year = 1999 and + s_state in ('TN','TN', 'TN', 'TN', 'TN', 'TN') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100""" + qt_ds_shape_27_constraints ''' + explain shape plan + select i_item_id, + s_state, grouping(s_state) g_state, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, store, item + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_store_sk = s_store_sk and + ss_cdemo_sk = cd_demo_sk and + cd_gender = 'M' and + cd_marital_status = 'W' and + cd_education_status = 'Secondary' and + d_year = 1999 and + s_state in ('TN','TN', 'TN', 'TN', 'TN', 'TN') + group by rollup (i_item_id, s_state) + order by i_item_id + ,s_state + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query28.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query28.groovy new file mode 100644 index 00000000000000..5983257cef35c8 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query28.groovy @@ -0,0 +1,144 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query28_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 107 and 107+10 + or ss_coupon_amt between 1319 and 1319+1000 + or ss_wholesale_cost between 60 and 60+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 23 and 23+10 + or ss_coupon_amt between 825 and 825+1000 + or ss_wholesale_cost between 43 and 43+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 74 and 74+10 + or ss_coupon_amt between 4381 and 4381+1000 + or ss_wholesale_cost between 57 and 57+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 89 and 89+10 + or ss_coupon_amt between 3117 and 3117+1000 + or ss_wholesale_cost between 68 and 68+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 58 and 58+10 + or ss_coupon_amt between 9402 and 9402+1000 + or ss_wholesale_cost between 38 and 38+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 64 and 64+10 + or ss_coupon_amt between 5792 and 5792+1000 + or ss_wholesale_cost between 73 and 73+20)) B6 +limit 100""" + qt_ds_shape_28_constraints ''' + explain shape plan + select * +from (select avg(ss_list_price) B1_LP + ,count(ss_list_price) B1_CNT + ,count(distinct ss_list_price) B1_CNTD + from store_sales + where ss_quantity between 0 and 5 + and (ss_list_price between 107 and 107+10 + or ss_coupon_amt between 1319 and 1319+1000 + or ss_wholesale_cost between 60 and 60+20)) B1, + (select avg(ss_list_price) B2_LP + ,count(ss_list_price) B2_CNT + ,count(distinct ss_list_price) B2_CNTD + from store_sales + where ss_quantity between 6 and 10 + and (ss_list_price between 23 and 23+10 + or ss_coupon_amt between 825 and 825+1000 + or ss_wholesale_cost between 43 and 43+20)) B2, + (select avg(ss_list_price) B3_LP + ,count(ss_list_price) B3_CNT + ,count(distinct ss_list_price) B3_CNTD + from store_sales + where ss_quantity between 11 and 15 + and (ss_list_price between 74 and 74+10 + or ss_coupon_amt between 4381 and 4381+1000 + or ss_wholesale_cost between 57 and 57+20)) B3, + (select avg(ss_list_price) B4_LP + ,count(ss_list_price) B4_CNT + ,count(distinct ss_list_price) B4_CNTD + from store_sales + where ss_quantity between 16 and 20 + and (ss_list_price between 89 and 89+10 + or ss_coupon_amt between 3117 and 3117+1000 + or ss_wholesale_cost between 68 and 68+20)) B4, + (select avg(ss_list_price) B5_LP + ,count(ss_list_price) B5_CNT + ,count(distinct ss_list_price) B5_CNTD + from store_sales + where ss_quantity between 21 and 25 + and (ss_list_price between 58 and 58+10 + or ss_coupon_amt between 9402 and 9402+1000 + or ss_wholesale_cost between 38 and 38+20)) B5, + (select avg(ss_list_price) B6_LP + ,count(ss_list_price) B6_CNT + ,count(distinct ss_list_price) B6_CNTD + from store_sales + where ss_quantity between 26 and 30 + and (ss_list_price between 64 and 64+10 + or ss_coupon_amt between 5792 and 5792+1000 + or ss_wholesale_cost between 73 and 73+20)) B6 +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query29.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query29.groovy new file mode 100644 index 00000000000000..aa5cc58ec0157d --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query29.groovy @@ -0,0 +1,132 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query29_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,max(ss_quantity) as store_sales_quantity + ,max(sr_return_quantity) as store_returns_quantity + ,max(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1998 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 1998 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (1998,1998+1,1998+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100""" + qt_ds_shape_29_constraints ''' + explain shape plan + select + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + ,max(ss_quantity) as store_sales_quantity + ,max(sr_return_quantity) as store_returns_quantity + ,max(cs_quantity) as catalog_sales_quantity + from + store_sales + ,store_returns + ,catalog_sales + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,item + where + d1.d_moy = 4 + and d1.d_year = 1998 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and ss_customer_sk = sr_customer_sk + and ss_item_sk = sr_item_sk + and ss_ticket_number = sr_ticket_number + and sr_returned_date_sk = d2.d_date_sk + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 1998 + and sr_customer_sk = cs_bill_customer_sk + and sr_item_sk = cs_item_sk + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (1998,1998+1,1998+2) + group by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + order by + i_item_id + ,i_item_desc + ,s_store_id + ,s_store_name + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query3.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query3.groovy new file mode 100644 index 00000000000000..01c59f348bcfd4 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query3.groovy @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query3_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_sales_price) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 816 + and dt.d_moy=11 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100""" + qt_ds_shape_3_constraints ''' + explain shape plan + select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_sales_price) sum_agg + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manufact_id = 816 + and dt.d_moy=11 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,sum_agg desc + ,brand_id + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query30.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query30.groovy new file mode 100644 index 00000000000000..c0806381f7dd2a --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query30.groovy @@ -0,0 +1,100 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query30_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =2000 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'AR' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100""" + qt_ds_shape_30_constraints ''' + explain shape plan + with customer_total_return as + (select wr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(wr_return_amt) as ctr_total_return + from web_returns + ,date_dim + ,customer_address + where wr_returned_date_sk = d_date_sk + and d_year =2000 + and wr_returning_addr_sk = ca_address_sk + group by wr_returning_customer_sk + ,ca_state) + select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'AR' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag + ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address + ,c_last_review_date_sk,ctr_total_return +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query31.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query31.groovy new file mode 100644 index 00000000000000..7a0bd117d04a0c --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query31.groovy @@ -0,0 +1,142 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query31_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 1999 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 1999 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 1999 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 1999 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 1999 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =1999 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by store_q2_q3_increase""" + qt_ds_shape_31_constraints ''' + explain shape plan + with ss as + (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales + from store_sales,date_dim,customer_address + where ss_sold_date_sk = d_date_sk + and ss_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year), + ws as + (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales + from web_sales,date_dim,customer_address + where ws_sold_date_sk = d_date_sk + and ws_bill_addr_sk=ca_address_sk + group by ca_county,d_qoy, d_year) + select + ss1.ca_county + ,ss1.d_year + ,ws2.web_sales/ws1.web_sales web_q1_q2_increase + ,ss2.store_sales/ss1.store_sales store_q1_q2_increase + ,ws3.web_sales/ws2.web_sales web_q2_q3_increase + ,ss3.store_sales/ss2.store_sales store_q2_q3_increase + from + ss ss1 + ,ss ss2 + ,ss ss3 + ,ws ws1 + ,ws ws2 + ,ws ws3 + where + ss1.d_qoy = 1 + and ss1.d_year = 1999 + and ss1.ca_county = ss2.ca_county + and ss2.d_qoy = 2 + and ss2.d_year = 1999 + and ss2.ca_county = ss3.ca_county + and ss3.d_qoy = 3 + and ss3.d_year = 1999 + and ss1.ca_county = ws1.ca_county + and ws1.d_qoy = 1 + and ws1.d_year = 1999 + and ws1.ca_county = ws2.ca_county + and ws2.d_qoy = 2 + and ws2.d_year = 1999 + and ws1.ca_county = ws3.ca_county + and ws3.d_qoy = 3 + and ws3.d_year =1999 + and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end + > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end + and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end + > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end + order by store_q2_q3_increase + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query32.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query32.groovy new file mode 100644 index 00000000000000..d5b07c5fd943d2 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query32.groovy @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query32_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + multi_sql """ + use ${db}; + set enable_nereids_planner=true; + set enable_nereids_distribute_planner=false; + set enable_fallback_to_original_planner=false; + set exec_mem_limit=21G; + set be_number_for_test=3; + set enable_runtime_filter_prune=false; + set parallel_pipeline_task_num=8; + set forbid_unknown_col_stats=false; + set enable_stats=true; + set runtime_filter_type=8; + set broadcast_row_count_limit = 30000000; + set enable_nereids_timeout = false; + set enable_pipeline_engine = true; + set disable_nereids_rules='PRUNE_EMPTY_PARTITION'; + set push_topn_to_agg = true; + set topn_opt_limit_threshold=1024; + """ + + sql 'set join_order_time_limit=10000' + + def ds = """select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 722 +and i_item_sk = cs_item_sk +and d_date between '2001-03-09' and + (cast('2001-03-09' as date) + interval 90 day) +and d_date_sk = cs_sold_date_sk +and cs_ext_discount_amt + > ( + select + 1.3 * avg(cs_ext_discount_amt) + from + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between '2001-03-09' and + (cast('2001-03-09' as date) + interval 90 day) + and d_date_sk = cs_sold_date_sk + ) +limit 100""" + qt_ds_shape_32_constraints ''' + explain shape plan + select sum(cs_ext_discount_amt) as "excess discount amount" +from + catalog_sales + ,item + ,date_dim +where +i_manufact_id = 722 +and i_item_sk = cs_item_sk +and d_date between '2001-03-09' and + (cast('2001-03-09' as date) + interval 90 day) +and d_date_sk = cs_sold_date_sk +and cs_ext_discount_amt + > ( + select + 1.3 * avg(cs_ext_discount_amt) + from + catalog_sales + ,date_dim + where + cs_item_sk = i_item_sk + and d_date between '2001-03-09' and + (cast('2001-03-09' as date) + interval 90 day) + and d_date_sk = cs_sold_date_sk + ) +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query33.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query33.groovy new file mode 100644 index 00000000000000..4991d230ce4827 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query33.groovy @@ -0,0 +1,188 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query33_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Books')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 3 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Books')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 3 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Books')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 3 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100""" + qt_ds_shape_33_constraints ''' + explain shape plan + with ss as ( + select + i_manufact_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Books')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 3 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id), + cs as ( + select + i_manufact_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Books')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 3 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id), + ws as ( + select + i_manufact_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_manufact_id in (select + i_manufact_id +from + item +where i_category in ('Books')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2001 + and d_moy = 3 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_manufact_id) + select i_manufact_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_manufact_id + order by total_sales +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query34.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query34.groovy new file mode 100644 index 00000000000000..091faddbf18324 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query34.groovy @@ -0,0 +1,100 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query34_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '1001-5000' or + household_demographics.hd_buy_potential = '0-500') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Williamson County','Williamson County','Williamson County','Williamson County', + 'Williamson County','Williamson County','Williamson County','Williamson County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number""" + qt_ds_shape_34_constraints ''' + explain shape plan + select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28) + and (household_demographics.hd_buy_potential = '1001-5000' or + household_demographics.hd_buy_potential = '0-500') + and household_demographics.hd_vehicle_count > 0 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count + else null + end) > 1.2 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Williamson County','Williamson County','Williamson County','Williamson County', + 'Williamson County','Williamson County','Williamson County','Williamson County') + group by ss_ticket_number,ss_customer_sk) dn,customer + where ss_customer_sk = c_customer_sk + and cnt between 15 and 20 + order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query35.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query35.groovy new file mode 100644 index 00000000000000..90af531bac2ad6 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query35.groovy @@ -0,0 +1,154 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query35_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + avg(cd_dep_count), + stddev_samp(cd_dep_count), + sum(cd_dep_count), + cd_dep_employed_count, + count(*) cnt2, + avg(cd_dep_employed_count), + stddev_samp(cd_dep_employed_count), + sum(cd_dep_employed_count), + cd_dep_college_count, + count(*) cnt3, + avg(cd_dep_college_count), + stddev_samp(cd_dep_college_count), + sum(cd_dep_college_count) + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100""" + qt_ds_shape_35_constraints ''' + explain shape plan + select + ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + count(*) cnt1, + avg(cd_dep_count), + stddev_samp(cd_dep_count), + sum(cd_dep_count), + cd_dep_employed_count, + count(*) cnt2, + avg(cd_dep_employed_count), + stddev_samp(cd_dep_employed_count), + sum(cd_dep_employed_count), + cd_dep_college_count, + count(*) cnt3, + avg(cd_dep_college_count), + stddev_samp(cd_dep_college_count), + sum(cd_dep_college_count) + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4) and + (exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4) or + exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 1999 and + d_qoy < 4)) + group by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + order by ca_state, + cd_gender, + cd_marital_status, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query36.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query36.groovy new file mode 100644 index 00000000000000..c617d4762ca5e9 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query36.groovy @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query36_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('TN','TN','TN','TN', + 'TN','TN','TN','TN') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100""" + qt_ds_shape_36_constraints ''' + explain shape plan + select + sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,item + ,store + where + d1.d_year = 2000 + and d1.d_date_sk = ss_sold_date_sk + and i_item_sk = ss_item_sk + and s_store_sk = ss_store_sk + and s_state in ('TN','TN','TN','TN', + 'TN','TN','TN','TN') + group by rollup(i_category,i_class) + order by + lochierarchy desc + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query37.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query37.groovy new file mode 100644 index 00000000000000..7800935f33791a --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query37.groovy @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query37_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 29 and 29 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2002-03-29' as date) and (cast('2002-03-29' as date) + interval 60 day) + and i_manufact_id in (705,742,777,944) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100""" + qt_ds_shape_37_constraints ''' + explain shape plan + select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, catalog_sales + where i_current_price between 29 and 29 + 30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2002-03-29' as date) and (cast('2002-03-29' as date) + interval 60 day) + and i_manufact_id in (705,742,777,944) + and inv_quantity_on_hand between 100 and 500 + and cs_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query38.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query38.groovy new file mode 100644 index 00000000000000..3edfcf0f1772cc --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query38.groovy @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query38_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + multi_sql """ + use ${db}; + set enable_nereids_planner=true; + set enable_nereids_distribute_planner=false; + set enable_fallback_to_original_planner=false; + set exec_mem_limit=21G; + set be_number_for_test=3; + set enable_runtime_filter_prune=false; + set parallel_pipeline_task_num=8; + set forbid_unknown_col_stats=false; + set enable_stats=true; + set runtime_filter_type=8; + set broadcast_row_count_limit = 30000000; + set enable_nereids_timeout = false; + set enable_pipeline_engine = true; + set disable_nereids_rules='PRUNE_EMPTY_PARTITION'; + set push_topn_to_agg = true; + set topn_opt_limit_threshold=1024; + """ + + sql 'set join_order_time_limit=10000' + + def ds = """select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1189 and 1189 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1189 and 1189 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1189 and 1189 + 11 +) hot_cust +limit 100""" + qt_ds_shape_38_constraints ''' + explain shape plan + select count(*) from ( + select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1189 and 1189 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1189 and 1189 + 11 + intersect + select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1189 and 1189 + 11 +) hot_cust +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query39.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query39.groovy new file mode 100644 index 00000000000000..5d5a99578e0282 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query39.groovy @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query39_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2000 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=1 + and inv2.d_moy=1+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov""" + qt_ds_shape_39_constraints ''' + explain shape plan + with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0 then null else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from inventory + ,item + ,warehouse + ,date_dim + where inv_item_sk = i_item_sk + and inv_warehouse_sk = w_warehouse_sk + and inv_date_sk = d_date_sk + and d_year =2000 + group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo + where case mean when 0 then 0 else stdev/mean end > 1) +select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov + ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov +from inv inv1,inv inv2 +where inv1.i_item_sk = inv2.i_item_sk + and inv1.w_warehouse_sk = inv2.w_warehouse_sk + and inv1.d_moy=1 + and inv2.d_moy=1+1 +order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov + ,inv2.d_moy,inv2.mean, inv2.cov + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query4.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query4.groovy new file mode 100644 index 00000000000000..b1711ca8f7d74b --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query4.groovy @@ -0,0 +1,270 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query4_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1999 + and t_s_secyear.dyear = 1999+1 + and t_c_firstyear.dyear = 1999 + and t_c_secyear.dyear = 1999+1 + and t_w_firstyear.dyear = 1999 + and t_w_secyear.dyear = 1999+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country +limit 100""" + qt_ds_shape_4_constraints ''' + explain shape plan + with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total + ,'c' sale_type + from customer + ,catalog_sales + ,date_dim + where c_customer_sk = cs_bill_customer_sk + and cs_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year +union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,c_preferred_cust_flag customer_preferred_cust_flag + ,c_birth_country customer_birth_country + ,c_login customer_login + ,c_email_address customer_email_address + ,d_year dyear + ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + group by c_customer_id + ,c_first_name + ,c_last_name + ,c_preferred_cust_flag + ,c_birth_country + ,c_login + ,c_email_address + ,d_year + ) + select + t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_c_firstyear + ,year_total t_c_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_c_secyear.customer_id + and t_s_firstyear.customer_id = t_c_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_c_firstyear.sale_type = 'c' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_c_secyear.sale_type = 'c' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.dyear = 1999 + and t_s_secyear.dyear = 1999+1 + and t_c_firstyear.dyear = 1999 + and t_c_secyear.dyear = 1999+1 + and t_w_firstyear.dyear = 1999 + and t_w_secyear.dyear = 1999+1 + and t_s_firstyear.year_total > 0 + and t_c_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end + > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + order by t_s_secyear.customer_id + ,t_s_secyear.customer_first_name + ,t_s_secyear.customer_last_name + ,t_s_secyear.customer_birth_country +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query40.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query40.groovy new file mode 100644 index 00000000000000..bd97f7482e7ee5 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query40.groovy @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query40_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2001-05-02' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('2001-05-02' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('2001-05-02' as date) - interval 30 day) + and (cast ('2001-05-02' as date) + interval 30 day) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100""" + qt_ds_shape_40_constraints ''' + explain shape plan + select + w_state + ,i_item_id + ,sum(case when (cast(d_date as date) < cast ('2001-05-02' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before + ,sum(case when (cast(d_date as date) >= cast ('2001-05-02' as date)) + then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after + from + catalog_sales left outer join catalog_returns on + (cs_order_number = cr_order_number + and cs_item_sk = cr_item_sk) + ,warehouse + ,item + ,date_dim + where + i_current_price between 0.99 and 1.49 + and i_item_sk = cs_item_sk + and cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and d_date between (cast ('2001-05-02' as date) - interval 30 day) + and (cast ('2001-05-02' as date) + interval 30 day) + group by + w_state,i_item_id + order by w_state,i_item_id +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query41.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query41.groovy new file mode 100644 index 00000000000000..e21bd7141a5aa5 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query41.groovy @@ -0,0 +1,142 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query41_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select distinct(i_product_name) + from item i1 + where i_manufact_id between 704 and 704+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'forest' or i_color = 'lime') and + (i_units = 'Pallet' or i_units = 'Pound') and + (i_size = 'economy' or i_size = 'small') + ) or + (i_category = 'Women' and + (i_color = 'navy' or i_color = 'slate') and + (i_units = 'Gross' or i_units = 'Bunch') and + (i_size = 'extra large' or i_size = 'petite') + ) or + (i_category = 'Men' and + (i_color = 'powder' or i_color = 'sky') and + (i_units = 'Dozen' or i_units = 'Lb') and + (i_size = 'N/A' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'maroon' or i_color = 'smoke') and + (i_units = 'Ounce' or i_units = 'Case') and + (i_size = 'economy' or i_size = 'small') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'dark' or i_color = 'aquamarine') and + (i_units = 'Ton' or i_units = 'Tbl') and + (i_size = 'economy' or i_size = 'small') + ) or + (i_category = 'Women' and + (i_color = 'frosted' or i_color = 'plum') and + (i_units = 'Dram' or i_units = 'Box') and + (i_size = 'extra large' or i_size = 'petite') + ) or + (i_category = 'Men' and + (i_color = 'papaya' or i_color = 'peach') and + (i_units = 'Bundle' or i_units = 'Carton') and + (i_size = 'N/A' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'firebrick' or i_color = 'sienna') and + (i_units = 'Cup' or i_units = 'Each') and + (i_size = 'economy' or i_size = 'small') + )))) > 0 + order by i_product_name + limit 100""" + qt_ds_shape_41_constraints ''' + explain shape plan + select distinct(i_product_name) + from item i1 + where i_manufact_id between 704 and 704+40 + and (select count(*) as item_cnt + from item + where (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'forest' or i_color = 'lime') and + (i_units = 'Pallet' or i_units = 'Pound') and + (i_size = 'economy' or i_size = 'small') + ) or + (i_category = 'Women' and + (i_color = 'navy' or i_color = 'slate') and + (i_units = 'Gross' or i_units = 'Bunch') and + (i_size = 'extra large' or i_size = 'petite') + ) or + (i_category = 'Men' and + (i_color = 'powder' or i_color = 'sky') and + (i_units = 'Dozen' or i_units = 'Lb') and + (i_size = 'N/A' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'maroon' or i_color = 'smoke') and + (i_units = 'Ounce' or i_units = 'Case') and + (i_size = 'economy' or i_size = 'small') + ))) or + (i_manufact = i1.i_manufact and + ((i_category = 'Women' and + (i_color = 'dark' or i_color = 'aquamarine') and + (i_units = 'Ton' or i_units = 'Tbl') and + (i_size = 'economy' or i_size = 'small') + ) or + (i_category = 'Women' and + (i_color = 'frosted' or i_color = 'plum') and + (i_units = 'Dram' or i_units = 'Box') and + (i_size = 'extra large' or i_size = 'petite') + ) or + (i_category = 'Men' and + (i_color = 'papaya' or i_color = 'peach') and + (i_units = 'Bundle' or i_units = 'Carton') and + (i_size = 'N/A' or i_size = 'large') + ) or + (i_category = 'Men' and + (i_color = 'firebrick' or i_color = 'sienna') and + (i_units = 'Cup' or i_units = 'Each') and + (i_size = 'economy' or i_size = 'small') + )))) > 0 + order by i_product_name + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query42.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query42.groovy new file mode 100644 index 00000000000000..25fefbdc55e5f4 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query42.groovy @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query42_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=1998 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 """ + qt_ds_shape_42_constraints ''' + explain shape plan + select dt.d_year + ,item.i_category_id + ,item.i_category + ,sum(ss_ext_sales_price) + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=11 + and dt.d_year=1998 + group by dt.d_year + ,item.i_category_id + ,item.i_category + order by sum(ss_ext_sales_price) desc,dt.d_year + ,item.i_category_id + ,item.i_category +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query43.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query43.groovy new file mode 100644 index 00000000000000..ac61df34d8108e --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query43.groovy @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query43_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -5 and + d_year = 2000 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100""" + qt_ds_shape_43_constraints ''' + explain shape plan + select s_store_name, s_store_id, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from date_dim, store_sales, store + where d_date_sk = ss_sold_date_sk and + s_store_sk = ss_store_sk and + s_gmt_offset = -5 and + d_year = 2000 + group by s_store_name, s_store_id + order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query44.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query44.groovy new file mode 100644 index 00000000000000..7f9137df282286 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query44.groovy @@ -0,0 +1,108 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query44_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 4 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 4 + and ss_hdemo_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 4 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 4 + and ss_hdemo_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100""" + qt_ds_shape_44_constraints ''' + explain shape plan + select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing +from(select * + from (select item_sk,rank() over (order by rank_col asc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 4 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 4 + and ss_hdemo_sk is null + group by ss_store_sk))V1)V11 + where rnk < 11) asceding, + (select * + from (select item_sk,rank() over (order by rank_col desc) rnk + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from store_sales ss1 + where ss_store_sk = 4 + group by ss_item_sk + having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col + from store_sales + where ss_store_sk = 4 + and ss_hdemo_sk is null + group by ss_store_sk))V2)V21 + where rnk < 11) descending, +item i1, +item i2 +where asceding.rnk = descending.rnk + and i1.i_item_sk=asceding.item_sk + and i2.i_item_sk=descending.item_sk +order by asceding.rnk +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query45.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query45.groovy new file mode 100644 index 00000000000000..d5186fb84773d3 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query45.groovy @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query45_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select ca_zip, ca_city, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 2000 + group by ca_zip, ca_city + order by ca_zip, ca_city + limit 100""" + qt_ds_shape_45_constraints ''' + explain shape plan + select ca_zip, ca_city, sum(ws_sales_price) + from web_sales, customer, customer_address, date_dim, item + where ws_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk + and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') + or + i_item_id in (select i_item_id + from item + where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + ) + ) + and ws_sold_date_sk = d_date_sk + and d_qoy = 1 and d_year = 2000 + group by ca_zip, ca_city + order by ca_zip, ca_city + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query46.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query46.groovy new file mode 100644 index 00000000000000..89c07bd81f6584 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query46.groovy @@ -0,0 +1,108 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query46_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 8 or + household_demographics.hd_vehicle_count= 0) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_city in ('Midway','Fairview','Fairview','Midway','Fairview') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100""" + qt_ds_shape_46_constraints ''' + explain shape plan + select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and (household_demographics.hd_dep_count = 8 or + household_demographics.hd_vehicle_count= 0) + and date_dim.d_dow in (6,0) + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_city in ('Midway','Fairview','Fairview','Midway','Fairview') + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query47.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query47.groovy new file mode 100644 index 00000000000000..025fa133e5ef94 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query47.groovy @@ -0,0 +1,140 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query47_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 2000 or + ( d_year = 2000-1 and d_moy =12) or + ( d_year = 2000+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.s_store_name, v1.s_company_name + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2000 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, nsum + limit 100""" + qt_ds_shape_47_constraints ''' + explain shape plan + with v1 as( + select i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, + s_store_name, s_company_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + s_store_name, s_company_name + order by d_year, d_moy) rn + from item, store_sales, date_dim, store + where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + ( + d_year = 2000 or + ( d_year = 2000-1 and d_moy =12) or + ( d_year = 2000+1 and d_moy =1) + ) + group by i_category, i_brand, + s_store_name, s_company_name, + d_year, d_moy), + v2 as( + select v1.s_store_name, v1.s_company_name + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1.s_store_name = v1_lag.s_store_name and + v1.s_store_name = v1_lead.s_store_name and + v1.s_company_name = v1_lag.s_company_name and + v1.s_company_name = v1_lead.s_company_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2000 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, nsum + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query48.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query48.groovy new file mode 100644 index 00000000000000..a49f284798ba37 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query48.groovy @@ -0,0 +1,172 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query48_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'S' + and + cd_education_status = 'Secondary' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'M' + and + cd_education_status = '2 yr Degree' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'D' + and + cd_education_status = 'Advanced Degree' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('ND', 'NY', 'SD') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('MD', 'GA', 'KS') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('CO', 'MN', 'NC') + and ss_net_profit between 50 and 25000 + ) + ) +""" + qt_ds_shape_48_constraints ''' + explain shape plan + select sum (ss_quantity) + from store_sales, store, customer_demographics, customer_address, date_dim + where s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk and d_year = 2001 + and + ( + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'S' + and + cd_education_status = 'Secondary' + and + ss_sales_price between 100.00 and 150.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'M' + and + cd_education_status = '2 yr Degree' + and + ss_sales_price between 50.00 and 100.00 + ) + or + ( + cd_demo_sk = ss_cdemo_sk + and + cd_marital_status = 'D' + and + cd_education_status = 'Advanced Degree' + and + ss_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('ND', 'NY', 'SD') + and ss_net_profit between 0 and 2000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('MD', 'GA', 'KS') + and ss_net_profit between 150 and 3000 + ) + or + (ss_addr_sk = ca_address_sk + and + ca_country = 'United States' + and + ca_state in ('CO', 'MN', 'NC') + and ss_net_profit between 50 and 25000 + ) + ) + + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query49.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query49.groovy new file mode 100644 index 00000000000000..c2495abca5d106 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query49.groovy @@ -0,0 +1,296 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query49_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 11 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 11 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 11 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) + t order by 1,4,5,2 + limit 100""" + qt_ds_shape_49_constraints ''' + explain shape plan + select channel, item, return_ratio, return_rank, currency_rank from + (select + 'web' as channel + ,web.item + ,web.return_ratio + ,web.return_rank + ,web.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select ws.ws_item_sk as item + ,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/ + cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + web_sales ws left outer join web_returns wr + on (ws.ws_order_number = wr.wr_order_number and + ws.ws_item_sk = wr.wr_item_sk) + ,date_dim + where + wr.wr_return_amt > 10000 + and ws.ws_net_profit > 1 + and ws.ws_net_paid > 0 + and ws.ws_quantity > 0 + and ws_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 11 + group by ws.ws_item_sk + ) in_web + ) web + where + ( + web.return_rank <= 10 + or + web.currency_rank <= 10 + ) + union + select + 'catalog' as channel + ,catalog.item + ,catalog.return_ratio + ,catalog.return_rank + ,catalog.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select + cs.cs_item_sk as item + ,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/ + cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + catalog_sales cs left outer join catalog_returns cr + on (cs.cs_order_number = cr.cr_order_number and + cs.cs_item_sk = cr.cr_item_sk) + ,date_dim + where + cr.cr_return_amount > 10000 + and cs.cs_net_profit > 1 + and cs.cs_net_paid > 0 + and cs.cs_quantity > 0 + and cs_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 11 + group by cs.cs_item_sk + ) in_cat + ) catalog + where + ( + catalog.return_rank <= 10 + or + catalog.currency_rank <=10 + ) + union + select + 'store' as channel + ,store.item + ,store.return_ratio + ,store.return_rank + ,store.currency_rank + from ( + select + item + ,return_ratio + ,currency_ratio + ,rank() over (order by return_ratio) as return_rank + ,rank() over (order by currency_ratio) as currency_rank + from + ( select sts.ss_item_sk as item + ,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio + ,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio + from + store_sales sts left outer join store_returns sr + on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk) + ,date_dim + where + sr.sr_return_amt > 10000 + and sts.ss_net_profit > 1 + and sts.ss_net_paid > 0 + and sts.ss_quantity > 0 + and ss_sold_date_sk = d_date_sk + and d_year = 1998 + and d_moy = 11 + group by sts.ss_item_sk + ) in_store + ) store + where ( + store.return_rank <= 10 + or + store.currency_rank <= 10 + ) + ) + t order by 1,4,5,2 + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query5.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query5.groovy new file mode 100644 index 00000000000000..6881ea46d55969 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query5.groovy @@ -0,0 +1,294 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query5_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('2000-08-19' as date) + and (cast('2000-08-19' as date) + interval 14 day) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('2000-08-19' as date) + and (cast('2000-08-19' as date) + interval 14 day) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('2000-08-19' as date) + and (cast('2000-08-19' as date) + interval 14 day) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , concat('store', s_store_id) id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , concat('catalog_page', cp_catalog_page_id) id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , concat('web_site', web_site_id) id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100""" + qt_ds_shape_5_constraints ''' + explain shape plan + with ssr as + (select s_store_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ss_store_sk as store_sk, + ss_sold_date_sk as date_sk, + ss_ext_sales_price as sales_price, + ss_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from store_sales + union all + select sr_store_sk as store_sk, + sr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + sr_return_amt as return_amt, + sr_net_loss as net_loss + from store_returns + ) salesreturns, + date_dim, + store + where date_sk = d_date_sk + and d_date between cast('2000-08-19' as date) + and (cast('2000-08-19' as date) + interval 14 day) + and store_sk = s_store_sk + group by s_store_id) + , + csr as + (select cp_catalog_page_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select cs_catalog_page_sk as page_sk, + cs_sold_date_sk as date_sk, + cs_ext_sales_price as sales_price, + cs_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from catalog_sales + union all + select cr_catalog_page_sk as page_sk, + cr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + cr_return_amount as return_amt, + cr_net_loss as net_loss + from catalog_returns + ) salesreturns, + date_dim, + catalog_page + where date_sk = d_date_sk + and d_date between cast('2000-08-19' as date) + and (cast('2000-08-19' as date) + interval 14 day) + and page_sk = cp_catalog_page_sk + group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(sales_price) as sales, + sum(profit) as profit, + sum(return_amt) as returns, + sum(net_loss) as profit_loss + from + ( select ws_web_site_sk as wsr_web_site_sk, + ws_sold_date_sk as date_sk, + ws_ext_sales_price as sales_price, + ws_net_profit as profit, + cast(0 as decimal(7,2)) as return_amt, + cast(0 as decimal(7,2)) as net_loss + from web_sales + union all + select ws_web_site_sk as wsr_web_site_sk, + wr_returned_date_sk as date_sk, + cast(0 as decimal(7,2)) as sales_price, + cast(0 as decimal(7,2)) as profit, + wr_return_amt as return_amt, + wr_net_loss as net_loss + from web_returns left outer join web_sales on + ( wr_item_sk = ws_item_sk + and wr_order_number = ws_order_number) + ) salesreturns, + date_dim, + web_site + where date_sk = d_date_sk + and d_date between cast('2000-08-19' as date) + and (cast('2000-08-19' as date) + interval 14 day) + and wsr_web_site_sk = web_site_sk + group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , concat('store', s_store_id) id + , sales + , returns + , (profit - profit_loss) as profit + from ssr + union all + select 'catalog channel' as channel + , concat('catalog_page', cp_catalog_page_id) id + , sales + , returns + , (profit - profit_loss) as profit + from csr + union all + select 'web channel' as channel + , concat('web_site', web_site_id) id + , sales + , returns + , (profit - profit_loss) as profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query50.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query50.groovy new file mode 100644 index 00000000000000..7c7c53b0e6dabf --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query50.groovy @@ -0,0 +1,156 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query50_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 2001 +and d2.d_moy = 8 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100""" + qt_ds_shape_50_constraints ''' + explain shape plan + select + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and + (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and + (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and + (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + store_sales + ,store_returns + ,store + ,date_dim d1 + ,date_dim d2 +where + d2.d_year = 2001 +and d2.d_moy = 8 +and ss_ticket_number = sr_ticket_number +and ss_item_sk = sr_item_sk +and ss_sold_date_sk = d1.d_date_sk +and sr_returned_date_sk = d2.d_date_sk +and ss_customer_sk = sr_customer_sk +and ss_store_sk = s_store_sk +group by + s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +order by s_store_name + ,s_company_id + ,s_street_number + ,s_street_name + ,s_street_type + ,s_suite_number + ,s_city + ,s_county + ,s_state + ,s_zip +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query51.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query51.groovy new file mode 100644 index 00000000000000..2244bdbfe43419 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query51.groovy @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query51_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1212 and 1212+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1212 and 1212+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100""" + qt_ds_shape_51_constraints ''' + explain shape plan + WITH web_v1 as ( +select + ws_item_sk item_sk, d_date, + sum(sum(ws_sales_price)) + over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from web_sales + ,date_dim +where ws_sold_date_sk=d_date_sk + and d_month_seq between 1212 and 1212+11 + and ws_item_sk is not NULL +group by ws_item_sk, d_date), +store_v1 as ( +select + ss_item_sk item_sk, d_date, + sum(sum(ss_sales_price)) + over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales +from store_sales + ,date_dim +where ss_sold_date_sk=d_date_sk + and d_month_seq between 1212 and 1212+11 + and ss_item_sk is not NULL +group by ss_item_sk, d_date) + select * +from (select item_sk + ,d_date + ,web_sales + ,store_sales + ,max(web_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative + ,max(store_sales) + over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative + from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk + ,case when web.d_date is not null then web.d_date else store.d_date end d_date + ,web.cume_sales web_sales + ,store.cume_sales store_sales + from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk + and web.d_date = store.d_date) + )x )y +where web_cumulative > store_cumulative +order by item_sk + ,d_date +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query52.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query52.groovy new file mode 100644 index 00000000000000..422d55d6632bd7 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query52.groovy @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query52_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=2000 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 """ + qt_ds_shape_52_constraints ''' + explain shape plan + select dt.d_year + ,item.i_brand_id brand_id + ,item.i_brand brand + ,sum(ss_ext_sales_price) ext_price + from date_dim dt + ,store_sales + ,item + where dt.d_date_sk = store_sales.ss_sold_date_sk + and store_sales.ss_item_sk = item.i_item_sk + and item.i_manager_id = 1 + and dt.d_moy=12 + and dt.d_year=2000 + group by dt.d_year + ,item.i_brand + ,item.i_brand_id + order by dt.d_year + ,ext_price desc + ,brand_id +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query53.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query53.groovy new file mode 100644 index 00000000000000..db0a362b1cc197 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query53.groovy @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query53_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1186,1186+1,1186+2,1186+3,1186+4,1186+5,1186+6,1186+7,1186+8,1186+9,1186+10,1186+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100""" + qt_ds_shape_53_constraints ''' + explain shape plan + select * from +(select i_manufact_id, +sum(ss_sales_price) sum_sales, +avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and +ss_sold_date_sk = d_date_sk and +ss_store_sk = s_store_sk and +d_month_seq in (1186,1186+1,1186+2,1186+3,1186+4,1186+5,1186+6,1186+7,1186+8,1186+9,1186+10,1186+11) and +((i_category in ('Books','Children','Electronics') and +i_class in ('personal','portable','reference','self-help') and +i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) +or(i_category in ('Women','Music','Men') and +i_class in ('accessories','classical','fragrances','pants') and +i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manufact_id, d_qoy ) tmp1 +where case when avg_quarterly_sales > 0 + then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales + else null end > 0.1 +order by avg_quarterly_sales, + sum_sales, + i_manufact_id +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query54.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query54.groovy new file mode 100644 index 00000000000000..cbe384649550b2 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query54.groovy @@ -0,0 +1,150 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query54_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=12' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Music' + and i_class = 'country' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 1 + and d_year = 1999 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 1999 and d_moy = 1) + and (select distinct d_month_seq+3 + from date_dim where d_year = 1999 and d_moy = 1) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100""" + qt_ds_shape_54_constraints ''' + explain shape plan + with my_customers as ( + select distinct c_customer_sk + , c_current_addr_sk + from + ( select cs_sold_date_sk sold_date_sk, + cs_bill_customer_sk customer_sk, + cs_item_sk item_sk + from catalog_sales + union all + select ws_sold_date_sk sold_date_sk, + ws_bill_customer_sk customer_sk, + ws_item_sk item_sk + from web_sales + ) cs_or_ws_sales, + item, + date_dim, + customer + where sold_date_sk = d_date_sk + and item_sk = i_item_sk + and i_category = 'Music' + and i_class = 'country' + and c_customer_sk = cs_or_ws_sales.customer_sk + and d_moy = 1 + and d_year = 1999 + ) + , my_revenue as ( + select c_customer_sk, + sum(ss_ext_sales_price) as revenue + from my_customers, + store_sales, + customer_address, + store, + date_dim + where c_current_addr_sk = ca_address_sk + and ca_county = s_county + and ca_state = s_state + and ss_sold_date_sk = d_date_sk + and c_customer_sk = ss_customer_sk + and d_month_seq between (select distinct d_month_seq+1 + from date_dim where d_year = 1999 and d_moy = 1) + and (select distinct d_month_seq+3 + from date_dim where d_year = 1999 and d_moy = 1) + group by c_customer_sk + ) + , segments as + (select cast((revenue/50) as int) as segment + from my_revenue + ) + select segment, count(*) as num_customers, segment*50 as segment_base + from segments + group by segment + order by segment, num_customers + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query55.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query55.groovy new file mode 100644 index 00000000000000..4efdc1c4aae456 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query55.groovy @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query55_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=52 + and d_moy=11 + and d_year=2000 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 """ + qt_ds_shape_55_constraints ''' + explain shape plan + select i_brand_id brand_id, i_brand brand, + sum(ss_ext_sales_price) ext_price + from date_dim, store_sales, item + where d_date_sk = ss_sold_date_sk + and ss_item_sk = i_item_sk + and i_manager_id=52 + and d_moy=11 + and d_year=2000 + group by i_brand, i_brand_id + order by ext_price desc, i_brand_id +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query56.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query56.groovy new file mode 100644 index 00000000000000..18579b075dd26e --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query56.groovy @@ -0,0 +1,176 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query56_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('powder','orchid','pink')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 3 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('powder','orchid','pink')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 3 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('powder','orchid','pink')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 3 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100""" + qt_ds_shape_56_constraints ''' + explain shape plan + with ss as ( + select i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where i_item_id in (select + i_item_id +from item +where i_color in ('powder','orchid','pink')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 3 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + cs as ( + select i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('powder','orchid','pink')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 3 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id), + ws as ( + select i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from item +where i_color in ('powder','orchid','pink')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 3 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -6 + group by i_item_id) + select i_item_id ,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by total_sales, + i_item_id + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query57.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query57.groovy new file mode 100644 index 00000000000000..57b4070b4d189e --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query57.groovy @@ -0,0 +1,134 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query57_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2001 or + ( d_year = 2001-1 and d_moy =12) or + ( d_year = 2001+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.i_category, v1.i_brand, v1.cc_name + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2001 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, avg_monthly_sales + limit 100""" + qt_ds_shape_57_constraints ''' + explain shape plan + with v1 as( + select i_category, i_brand, + cc_name, + d_year, d_moy, + sum(cs_sales_price) sum_sales, + avg(sum(cs_sales_price)) over + (partition by i_category, i_brand, + cc_name, d_year) + avg_monthly_sales, + rank() over + (partition by i_category, i_brand, + cc_name + order by d_year, d_moy) rn + from item, catalog_sales, date_dim, call_center + where cs_item_sk = i_item_sk and + cs_sold_date_sk = d_date_sk and + cc_call_center_sk= cs_call_center_sk and + ( + d_year = 2001 or + ( d_year = 2001-1 and d_moy =12) or + ( d_year = 2001+1 and d_moy =1) + ) + group by i_category, i_brand, + cc_name , d_year, d_moy), + v2 as( + select v1.i_category, v1.i_brand, v1.cc_name + ,v1.d_year + ,v1.avg_monthly_sales + ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum + from v1, v1 v1_lag, v1 v1_lead + where v1.i_category = v1_lag.i_category and + v1.i_category = v1_lead.i_category and + v1.i_brand = v1_lag.i_brand and + v1.i_brand = v1_lead.i_brand and + v1. cc_name = v1_lag. cc_name and + v1. cc_name = v1_lead. cc_name and + v1.rn = v1_lag.rn + 1 and + v1.rn = v1_lead.rn - 1) + select * + from v2 + where d_year = 2001 and + avg_monthly_sales > 0 and + case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 + order by sum_sales - avg_monthly_sales, avg_monthly_sales + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query58.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query58.groovy new file mode 100644 index 00000000000000..a9e885f8aa2324 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query58.groovy @@ -0,0 +1,168 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query58_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = '2001-06-16')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = '2001-06-16')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = '2001-06-16')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100""" + qt_ds_shape_58_constraints ''' + explain shape plan + with ss_items as + (select i_item_id item_id + ,sum(ss_ext_sales_price) ss_item_rev + from store_sales + ,item + ,date_dim + where ss_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = '2001-06-16')) + and ss_sold_date_sk = d_date_sk + group by i_item_id), + cs_items as + (select i_item_id item_id + ,sum(cs_ext_sales_price) cs_item_rev + from catalog_sales + ,item + ,date_dim + where cs_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq = (select d_week_seq + from date_dim + where d_date = '2001-06-16')) + and cs_sold_date_sk = d_date_sk + group by i_item_id), + ws_items as + (select i_item_id item_id + ,sum(ws_ext_sales_price) ws_item_rev + from web_sales + ,item + ,date_dim + where ws_item_sk = i_item_sk + and d_date in (select d_date + from date_dim + where d_week_seq =(select d_week_seq + from date_dim + where d_date = '2001-06-16')) + and ws_sold_date_sk = d_date_sk + group by i_item_id) + select ss_items.item_id + ,ss_item_rev + ,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev + ,cs_item_rev + ,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev + ,ws_item_rev + ,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev + ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average + from ss_items,cs_items,ws_items + where ss_items.item_id=cs_items.item_id + and ss_items.item_id=ws_items.item_id + and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev + and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev + and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev + order by item_id + ,ss_item_rev + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query59.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query59.groovy new file mode 100644 index 00000000000000..809551b5319f26 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query59.groovy @@ -0,0 +1,126 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query59_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + wss.ss_store_sk = s_store_sk and + d_month_seq between 1195 and 1195 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + wss.ss_store_sk = s_store_sk and + d_month_seq between 1195+ 12 and 1195 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100""" + qt_ds_shape_59_constraints ''' + explain shape plan + with wss as + (select d_week_seq, + ss_store_sk, + sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales, + sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales, + sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales, + sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales, + sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales, + sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales, + sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + group by d_week_seq,ss_store_sk + ) + select s_store_name1,s_store_id1,d_week_seq1 + ,sun_sales1/sun_sales2,mon_sales1/mon_sales2 + ,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2 + ,fri_sales1/fri_sales2,sat_sales1/sat_sales2 + from + (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1 + ,s_store_id s_store_id1,sun_sales sun_sales1 + ,mon_sales mon_sales1,tue_sales tue_sales1 + ,wed_sales wed_sales1,thu_sales thu_sales1 + ,fri_sales fri_sales1,sat_sales sat_sales1 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + wss.ss_store_sk = s_store_sk and + d_month_seq between 1195 and 1195 + 11) y, + (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 + ,s_store_id s_store_id2,sun_sales sun_sales2 + ,mon_sales mon_sales2,tue_sales tue_sales2 + ,wed_sales wed_sales2,thu_sales thu_sales2 + ,fri_sales fri_sales2,sat_sales sat_sales2 + from wss,store,date_dim d + where d.d_week_seq = wss.d_week_seq and + wss.ss_store_sk = s_store_sk and + d_month_seq between 1195+ 12 and 1195 + 23) x + where s_store_id1=s_store_id2 + and d_week_seq1=d_week_seq2-52 + order by s_store_name1,s_store_id1,d_week_seq1 +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query6.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query6.groovy new file mode 100644 index 00000000000000..f6120df7c5c023 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query6.groovy @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query6_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 2002 + and d_moy = 3 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100""" + qt_ds_shape_6_constraints ''' + explain shape plan + select a.ca_state state, count(*) cnt + from customer_address a + ,customer c + ,store_sales s + ,date_dim d + ,item i + where a.ca_address_sk = c.c_current_addr_sk + and c.c_customer_sk = s.ss_customer_sk + and s.ss_sold_date_sk = d.d_date_sk + and s.ss_item_sk = i.i_item_sk + and d.d_month_seq = + (select distinct (d_month_seq) + from date_dim + where d_year = 2002 + and d_moy = 3 ) + and i.i_current_price > 1.2 * + (select avg(j.i_current_price) + from item j + where j.i_category = i.i_category) + group by a.ca_state + having count(*) >= 10 + order by cnt, a.ca_state + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query60.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query60.groovy new file mode 100644 index 00000000000000..0771436aabfc15 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query60.groovy @@ -0,0 +1,194 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query60_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Jewelry')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 10 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Jewelry')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 10 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Jewelry')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 10 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100""" + qt_ds_shape_60_constraints ''' + explain shape plan + with ss as ( + select + i_item_id,sum(ss_ext_sales_price) total_sales + from + store_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Jewelry')) + and ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 10 + and ss_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + cs as ( + select + i_item_id,sum(cs_ext_sales_price) total_sales + from + catalog_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Jewelry')) + and cs_item_sk = i_item_sk + and cs_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 10 + and cs_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id), + ws as ( + select + i_item_id,sum(ws_ext_sales_price) total_sales + from + web_sales, + date_dim, + customer_address, + item + where + i_item_id in (select + i_item_id +from + item +where i_category in ('Jewelry')) + and ws_item_sk = i_item_sk + and ws_sold_date_sk = d_date_sk + and d_year = 2000 + and d_moy = 10 + and ws_bill_addr_sk = ca_address_sk + and ca_gmt_offset = -5 + group by i_item_id) + select + i_item_id +,sum(total_sales) total_sales + from (select * from ss + union all + select * from cs + union all + select * from ws) tmp1 + group by i_item_id + order by i_item_id + ,total_sales + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query61.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query61.groovy new file mode 100644 index 00000000000000..1538c7e0672424 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query61.groovy @@ -0,0 +1,126 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query61_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Home' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -7 + and d_year = 2000 + and d_moy = 12) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Home' + and s_gmt_offset = -7 + and d_year = 2000 + and d_moy = 12) all_sales +order by promotions, total +limit 100""" + qt_ds_shape_61_constraints ''' + explain shape plan + select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100 +from + (select sum(ss_ext_sales_price) promotions + from store_sales + ,store + ,promotion + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_promo_sk = p_promo_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Home' + and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') + and s_gmt_offset = -7 + and d_year = 2000 + and d_moy = 12) promotional_sales, + (select sum(ss_ext_sales_price) total + from store_sales + ,store + ,date_dim + ,customer + ,customer_address + ,item + where ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and ss_customer_sk= c_customer_sk + and ca_address_sk = c_current_addr_sk + and ss_item_sk = i_item_sk + and ca_gmt_offset = -7 + and i_category = 'Home' + and s_gmt_offset = -7 + and d_year = 2000 + and d_moy = 12) all_sales +order by promotions, total +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query62.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query62.groovy new file mode 100644 index 00000000000000..63f646408858d5 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query62.groovy @@ -0,0 +1,108 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query62_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1223 and 1223 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100""" + qt_ds_shape_62_constraints ''' + explain shape plan + select + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and + (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and + (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and + (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + web_sales + ,warehouse + ,ship_mode + ,web_site + ,date_dim +where + d_month_seq between 1223 and 1223 + 11 +and ws_ship_date_sk = d_date_sk +and ws_warehouse_sk = w_warehouse_sk +and ws_ship_mode_sk = sm_ship_mode_sk +and ws_web_site_sk = web_site_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,web_name +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query63.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query63.groovy new file mode 100644 index 00000000000000..8c6c7bc9b81024 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query63.groovy @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query63_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1222,1222+1,1222+2,1222+3,1222+4,1222+5,1222+6,1222+7,1222+8,1222+9,1222+10,1222+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100""" + qt_ds_shape_63_constraints ''' + explain shape plan + select * +from (select i_manager_id + ,sum(ss_sales_price) sum_sales + ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales + from item + ,store_sales + ,date_dim + ,store + where ss_item_sk = i_item_sk + and ss_sold_date_sk = d_date_sk + and ss_store_sk = s_store_sk + and d_month_seq in (1222,1222+1,1222+2,1222+3,1222+4,1222+5,1222+6,1222+7,1222+8,1222+9,1222+10,1222+11) + and (( i_category in ('Books','Children','Electronics') + and i_class in ('personal','portable','reference','self-help') + and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7', + 'exportiunivamalg #9','scholaramalgamalg #9')) + or( i_category in ('Women','Music','Men') + and i_class in ('accessories','classical','fragrances','pants') + and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1', + 'importoamalg #1'))) +group by i_manager_id, d_moy) tmp1 +where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1 +order by i_manager_id + ,avg_monthly_sales + ,sum_sales +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query64.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query64.groovy new file mode 100644 index 00000000000000..9adbfeed0d140a --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query64.groovy @@ -0,0 +1,281 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query64_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + sql "set memo_max_group_expression_size = 1000000" + sql 'set join_order_time_limit=10000' + + def ds = """with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('orange','lace','lawn','misty','blush','pink') and + i_current_price between 48 and 48 + 10 and + i_current_price between 48 + 1 and 48 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 1999 and + cs2.syear = 1999 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1""" + +qt_ds_shape_64_constraints ''' + explain shape plan + with cs_ui as + (select cs_item_sk + ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund + from catalog_sales + ,catalog_returns + where cs_item_sk = cr_item_sk + and cs_order_number = cr_order_number + group by cs_item_sk + having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)), +cross_sales as + (select i_product_name product_name + ,i_item_sk item_sk + ,s_store_name store_name + ,s_zip store_zip + ,ad1.ca_street_number b_street_number + ,ad1.ca_street_name b_street_name + ,ad1.ca_city b_city + ,ad1.ca_zip b_zip + ,ad2.ca_street_number c_street_number + ,ad2.ca_street_name c_street_name + ,ad2.ca_city c_city + ,ad2.ca_zip c_zip + ,d1.d_year as syear + ,d2.d_year as fsyear + ,d3.d_year s2year + ,count(*) cnt + ,sum(ss_wholesale_cost) s1 + ,sum(ss_list_price) s2 + ,sum(ss_coupon_amt) s3 + FROM store_sales + ,store_returns + ,cs_ui + ,date_dim d1 + ,date_dim d2 + ,date_dim d3 + ,store + ,customer + ,customer_demographics cd1 + ,customer_demographics cd2 + ,promotion + ,household_demographics hd1 + ,household_demographics hd2 + ,customer_address ad1 + ,customer_address ad2 + ,income_band ib1 + ,income_band ib2 + ,item + WHERE ss_store_sk = s_store_sk AND + ss_sold_date_sk = d1.d_date_sk AND + ss_customer_sk = c_customer_sk AND + ss_cdemo_sk= cd1.cd_demo_sk AND + ss_hdemo_sk = hd1.hd_demo_sk AND + ss_addr_sk = ad1.ca_address_sk and + ss_item_sk = i_item_sk and + ss_item_sk = sr_item_sk and + ss_ticket_number = sr_ticket_number and + ss_item_sk = cs_ui.cs_item_sk and + c_current_cdemo_sk = cd2.cd_demo_sk AND + c_current_hdemo_sk = hd2.hd_demo_sk AND + c_current_addr_sk = ad2.ca_address_sk and + c_first_sales_date_sk = d2.d_date_sk and + c_first_shipto_date_sk = d3.d_date_sk and + ss_promo_sk = p_promo_sk and + hd1.hd_income_band_sk = ib1.ib_income_band_sk and + hd2.hd_income_band_sk = ib2.ib_income_band_sk and + cd1.cd_marital_status <> cd2.cd_marital_status and + i_color in ('orange','lace','lawn','misty','blush','pink') and + i_current_price between 48 and 48 + 10 and + i_current_price between 48 + 1 and 48 + 15 +group by i_product_name + ,i_item_sk + ,s_store_name + ,s_zip + ,ad1.ca_street_number + ,ad1.ca_street_name + ,ad1.ca_city + ,ad1.ca_zip + ,ad2.ca_street_number + ,ad2.ca_street_name + ,ad2.ca_city + ,ad2.ca_zip + ,d1.d_year + ,d2.d_year + ,d3.d_year +) +select cs1.product_name + ,cs1.store_name + ,cs1.store_zip + ,cs1.b_street_number + ,cs1.b_street_name + ,cs1.b_city + ,cs1.b_zip + ,cs1.c_street_number + ,cs1.c_street_name + ,cs1.c_city + ,cs1.c_zip + ,cs1.syear + ,cs1.cnt + ,cs1.s1 as s11 + ,cs1.s2 as s21 + ,cs1.s3 as s31 + ,cs2.s1 as s12 + ,cs2.s2 as s22 + ,cs2.s3 as s32 + ,cs2.syear + ,cs2.cnt +from cross_sales cs1,cross_sales cs2 +where cs1.item_sk=cs2.item_sk and + cs1.syear = 1999 and + cs2.syear = 1999 + 1 and + cs2.cnt <= cs1.cnt and + cs1.store_name = cs2.store_name and + cs1.store_zip = cs2.store_zip +order by cs1.product_name + ,cs1.store_name + ,cs2.cnt + ,cs1.s1 + ,cs2.s1 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query65.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query65.groovy new file mode 100644 index 00000000000000..6012dbbf85f7f4 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query65.groovy @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query65_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1176 and 1176+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1176 and 1176+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100""" + qt_ds_shape_65_constraints ''' + explain shape plan + select + s_store_name, + i_item_desc, + sc.revenue, + i_current_price, + i_wholesale_cost, + i_brand + from store, item, + (select ss_store_sk, avg(revenue) as ave + from + (select ss_store_sk, ss_item_sk, + sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1176 and 1176+11 + group by ss_store_sk, ss_item_sk) sa + group by ss_store_sk) sb, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue + from store_sales, date_dim + where ss_sold_date_sk = d_date_sk and d_month_seq between 1176 and 1176+11 + group by ss_store_sk, ss_item_sk) sc + where sb.ss_store_sk = sc.ss_store_sk and + sc.revenue <= 0.1 * sb.ave and + s_store_sk = sc.ss_store_sk and + i_item_sk = sc.ss_item_sk + order by s_store_name, i_item_desc +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query66.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query66.groovy new file mode 100644 index 00000000000000..90d6e722a0dcc6 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query66.groovy @@ -0,0 +1,478 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query66_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,concat(concat('ORIENTAL ', ','), ' BOXBUNDLES') as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_ext_sales_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_ext_sales_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_ext_sales_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_ext_sales_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_ext_sales_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_ext_sales_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_ext_sales_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_ext_sales_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_ext_sales_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_ext_sales_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_ext_sales_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_ext_sales_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 2001 + and t_time between 42970 and 42970+28800 + and sm_carrier in ('ORIENTAL','BOXBUNDLES') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,concat(concat('ORIENTAL ', ','), ' BOXBUNDLES') as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_ext_list_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_ext_list_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_ext_list_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_ext_list_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_ext_list_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_ext_list_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_ext_list_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_ext_list_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_ext_list_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_ext_list_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_ext_list_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_ext_list_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_paid * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_paid * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_paid * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_paid * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_paid * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_paid * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_paid * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_paid * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_paid * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_paid * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_paid * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_paid * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 2001 + and t_time between 42970 AND 42970+28800 + and sm_carrier in ('ORIENTAL','BOXBUNDLES') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100""" + qt_ds_shape_66_constraints ''' + explain shape plan + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + ,sum(jan_sales) as jan_sales + ,sum(feb_sales) as feb_sales + ,sum(mar_sales) as mar_sales + ,sum(apr_sales) as apr_sales + ,sum(may_sales) as may_sales + ,sum(jun_sales) as jun_sales + ,sum(jul_sales) as jul_sales + ,sum(aug_sales) as aug_sales + ,sum(sep_sales) as sep_sales + ,sum(oct_sales) as oct_sales + ,sum(nov_sales) as nov_sales + ,sum(dec_sales) as dec_sales + ,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot + ,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot + ,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot + ,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot + ,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot + ,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot + ,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot + ,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot + ,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot + ,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot + ,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot + ,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot + ,sum(jan_net) as jan_net + ,sum(feb_net) as feb_net + ,sum(mar_net) as mar_net + ,sum(apr_net) as apr_net + ,sum(may_net) as may_net + ,sum(jun_net) as jun_net + ,sum(jul_net) as jul_net + ,sum(aug_net) as aug_net + ,sum(sep_net) as sep_net + ,sum(oct_net) as oct_net + ,sum(nov_net) as nov_net + ,sum(dec_net) as dec_net + from ( + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,concat(concat('ORIENTAL ', ','), ' BOXBUNDLES') as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then ws_ext_sales_price* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then ws_ext_sales_price* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then ws_ext_sales_price* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then ws_ext_sales_price* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then ws_ext_sales_price* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then ws_ext_sales_price* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then ws_ext_sales_price* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then ws_ext_sales_price* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then ws_ext_sales_price* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then ws_ext_sales_price* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then ws_ext_sales_price* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then ws_ext_sales_price* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then ws_net_paid_inc_ship * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = 2001 + and t_time between 42970 and 42970+28800 + and sm_carrier in ('ORIENTAL','BOXBUNDLES') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + union all + select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,concat(concat('ORIENTAL ', ','), ' BOXBUNDLES') as ship_carriers + ,d_year as year + ,sum(case when d_moy = 1 + then cs_ext_list_price* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then cs_ext_list_price* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then cs_ext_list_price* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then cs_ext_list_price* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then cs_ext_list_price* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then cs_ext_list_price* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then cs_ext_list_price* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then cs_ext_list_price* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then cs_ext_list_price* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then cs_ext_list_price* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then cs_ext_list_price* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then cs_ext_list_price* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then cs_net_paid * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then cs_net_paid * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then cs_net_paid * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then cs_net_paid * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then cs_net_paid * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then cs_net_paid * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then cs_net_paid * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then cs_net_paid * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then cs_net_paid * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then cs_net_paid * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then cs_net_paid * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then cs_net_paid * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = 2001 + and t_time between 42970 AND 42970+28800 + and sm_carrier in ('ORIENTAL','BOXBUNDLES') + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,d_year + ) x + group by + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,year + order by w_warehouse_name + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query67.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query67.groovy new file mode 100644 index 00000000000000..f5075dfc8c2c81 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query67.groovy @@ -0,0 +1,126 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query67_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1217 and 1217+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100""" + qt_ds_shape_67_constraints ''' + explain shape plan + select * +from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rank() over (partition by i_category order by sumsales desc) rk + from (select i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales + from store_sales + ,date_dim + ,store + ,item + where ss_sold_date_sk=d_date_sk + and ss_item_sk=i_item_sk + and ss_store_sk = s_store_sk + and d_month_seq between 1217 and 1217+11 + group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 +where rk <= 100 +order by i_category + ,i_class + ,i_brand + ,i_product_name + ,d_year + ,d_qoy + ,d_moy + ,s_store_id + ,sumsales + ,rk +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query68.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query68.groovy new file mode 100644 index 00000000000000..d52c0f067e1da2 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query68.groovy @@ -0,0 +1,122 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query68_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 3 or + household_demographics.hd_vehicle_count= 4) + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_city in ('Fairview','Midway') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100""" + qt_ds_shape_68_constraints ''' + explain shape plan + select c_last_name + ,c_first_name + ,ca_city + ,bought_city + ,ss_ticket_number + ,extended_price + ,extended_tax + ,list_price + from (select ss_ticket_number + ,ss_customer_sk + ,ca_city bought_city + ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_list_price) list_price + ,sum(ss_ext_tax) extended_tax + from store_sales + ,date_dim + ,store + ,household_demographics + ,customer_address + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and store_sales.ss_addr_sk = customer_address.ca_address_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_dep_count = 3 or + household_demographics.hd_vehicle_count= 4) + and date_dim.d_year in (1998,1998+1,1998+2) + and store.s_city in ('Fairview','Midway') + group by ss_ticket_number + ,ss_customer_sk + ,ss_addr_sk,ca_city) dn + ,customer + ,customer_address current_addr + where ss_customer_sk = c_customer_sk + and customer.c_current_addr_sk = current_addr.ca_address_sk + and current_addr.ca_city <> bought_city + order by c_last_name + ,ss_ticket_number + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query69.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query69.groovy new file mode 100644 index 00000000000000..1943449afac8d4 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query69.groovy @@ -0,0 +1,132 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query69_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('IL','TX','ME') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 1 and 1+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 1 and 1+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 1 and 1+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100""" + qt_ds_shape_69_constraints ''' + explain shape plan + select + cd_gender, + cd_marital_status, + cd_education_status, + count(*) cnt1, + cd_purchase_estimate, + count(*) cnt2, + cd_credit_rating, + count(*) cnt3 + from + customer c,customer_address ca,customer_demographics + where + c.c_current_addr_sk = ca.ca_address_sk and + ca_state in ('IL','TX','ME') and + cd_demo_sk = c.c_current_cdemo_sk and + exists (select * + from store_sales,date_dim + where c.c_customer_sk = ss_customer_sk and + ss_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 1 and 1+2) and + (not exists (select * + from web_sales,date_dim + where c.c_customer_sk = ws_bill_customer_sk and + ws_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 1 and 1+2) and + not exists (select * + from catalog_sales,date_dim + where c.c_customer_sk = cs_ship_customer_sk and + cs_sold_date_sk = d_date_sk and + d_year = 2002 and + d_moy between 1 and 1+2)) + group by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + order by cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query7.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query7.groovy new file mode 100644 index 00000000000000..30e1ee3e6b525a --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query7.groovy @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query7_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'W' and + cd_education_status = 'College' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2001 + group by i_item_id + order by i_item_id + limit 100""" + qt_ds_shape_7_constraints ''' + explain shape plan + select i_item_id, + avg(ss_quantity) agg1, + avg(ss_list_price) agg2, + avg(ss_coupon_amt) agg3, + avg(ss_sales_price) agg4 + from store_sales, customer_demographics, date_dim, item, promotion + where ss_sold_date_sk = d_date_sk and + ss_item_sk = i_item_sk and + ss_cdemo_sk = cd_demo_sk and + ss_promo_sk = p_promo_sk and + cd_gender = 'F' and + cd_marital_status = 'W' and + cd_education_status = 'College' and + (p_channel_email = 'N' or p_channel_event = 'N') and + d_year = 2001 + group by i_item_id + order by i_item_id + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query70.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query70.groovy new file mode 100644 index 00000000000000..a3b1408d471c0c --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query70.groovy @@ -0,0 +1,114 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query70_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1220 and 1220+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1220 and 1220+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100""" + qt_ds_shape_70_constraints ''' + explain shape plan + select + sum(ss_net_profit) as total_sum + ,s_state + ,s_county + ,grouping(s_state)+grouping(s_county) as lochierarchy + ,rank() over ( + partition by grouping(s_state)+grouping(s_county), + case when grouping(s_county) = 0 then s_state end + order by sum(ss_net_profit) desc) as rank_within_parent + from + store_sales + ,date_dim d1 + ,store + where + d1.d_month_seq between 1220 and 1220+11 + and d1.d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + and s_state in + ( select s_state + from (select s_state as s_state, + rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking + from store_sales, store, date_dim + where d_month_seq between 1220 and 1220+11 + and d_date_sk = ss_sold_date_sk + and s_store_sk = ss_store_sk + group by s_state + ) tmp1 + where ranking <= 5 + ) + group by rollup(s_state,s_county) + order by + lochierarchy desc + ,case when lochierarchy = 0 then s_state end + ,rank_within_parent + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query71.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query71.groovy new file mode 100644 index 00000000000000..66e98c580ad403 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query71.groovy @@ -0,0 +1,118 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query71_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=12 + and d_year=2002 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=12 + and d_year=2002 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=12 + and d_year=2002 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + """ + qt_ds_shape_71_constraints ''' + explain shape plan + select i_brand_id brand_id, i_brand brand,t_hour,t_minute, + sum(ext_price) ext_price + from item, (select ws_ext_sales_price as ext_price, + ws_sold_date_sk as sold_date_sk, + ws_item_sk as sold_item_sk, + ws_sold_time_sk as time_sk + from web_sales,date_dim + where d_date_sk = ws_sold_date_sk + and d_moy=12 + and d_year=2002 + union all + select cs_ext_sales_price as ext_price, + cs_sold_date_sk as sold_date_sk, + cs_item_sk as sold_item_sk, + cs_sold_time_sk as time_sk + from catalog_sales,date_dim + where d_date_sk = cs_sold_date_sk + and d_moy=12 + and d_year=2002 + union all + select ss_ext_sales_price as ext_price, + ss_sold_date_sk as sold_date_sk, + ss_item_sk as sold_item_sk, + ss_sold_time_sk as time_sk + from store_sales,date_dim + where d_date_sk = ss_sold_date_sk + and d_moy=12 + and d_year=2002 + ) tmp,time_dim + where + sold_item_sk = i_item_sk + and i_manager_id=1 + and time_sk = t_time_sk + and (t_meal_time = 'breakfast' or t_meal_time = 'dinner') + group by i_brand, i_brand_id,t_hour,t_minute + order by ext_price desc, i_brand_id + + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query72.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query72.groovy new file mode 100644 index 00000000000000..2ea0a2d9f07410 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query72.groovy @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query72_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and (d3.d_date > (d1.d_date + INTERVAL '5' DAY)) + and hd_buy_potential = '1001-5000' + and d1.d_year = 1998 + and cd_marital_status = 'S' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100""" + qt_ds_shape_72_constraints ''' + explain shape plan + select i_item_desc + ,w_warehouse_name + ,d1.d_week_seq + ,sum(case when p_promo_sk is null then 1 else 0 end) no_promo + ,sum(case when p_promo_sk is not null then 1 else 0 end) promo + ,count(*) total_cnt +from catalog_sales +join inventory on (cs_item_sk = inv_item_sk) +join warehouse on (w_warehouse_sk=inv_warehouse_sk) +join item on (i_item_sk = cs_item_sk) +join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) +join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) +join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) +join date_dim d2 on (inv_date_sk = d2.d_date_sk) +join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) +left outer join promotion on (cs_promo_sk=p_promo_sk) +left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) +where d1.d_week_seq = d2.d_week_seq + and inv_quantity_on_hand < cs_quantity + and (d3.d_date > (d1.d_date + INTERVAL '5' DAY)) + and hd_buy_potential = '1001-5000' + and d1.d_year = 1998 + and cd_marital_status = 'S' +group by i_item_desc,w_warehouse_name,d1.d_week_seq +order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query73.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query73.groovy new file mode 100644 index 00000000000000..b67a5622ff4892 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query73.groovy @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query73_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '1001-5000' or + household_demographics.hd_buy_potential = '5001-10000') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Williamson County','Williamson County','Williamson County','Williamson County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc""" + qt_ds_shape_73_constraints ''' + explain shape plan + select c_last_name + ,c_first_name + ,c_salutation + ,c_preferred_cust_flag + ,ss_ticket_number + ,cnt from + (select ss_ticket_number + ,ss_customer_sk + ,count(*) cnt + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and date_dim.d_dom between 1 and 2 + and (household_demographics.hd_buy_potential = '1001-5000' or + household_demographics.hd_buy_potential = '5001-10000') + and household_demographics.hd_vehicle_count > 0 + and case when household_demographics.hd_vehicle_count > 0 then + household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Williamson County','Williamson County','Williamson County','Williamson County') + group by ss_ticket_number,ss_customer_sk) dj,customer + where ss_customer_sk = c_customer_sk + and cnt between 1 and 5 + order by cnt desc, c_last_name asc + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query74.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query74.groovy new file mode 100644 index 00000000000000..f82ef921a19034 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query74.groovy @@ -0,0 +1,160 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query74_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,max(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1999,1999+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,max(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (1999,1999+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 1999 + and t_s_secyear.year = 1999+1 + and t_w_firstyear.year = 1999 + and t_w_secyear.year = 1999+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 1,3,2 +limit 100""" + qt_ds_shape_74_constraints ''' + explain shape plan + with year_total as ( + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,max(ss_net_paid) year_total + ,'s' sale_type + from customer + ,store_sales + ,date_dim + where c_customer_sk = ss_customer_sk + and ss_sold_date_sk = d_date_sk + and d_year in (1999,1999+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + union all + select c_customer_id customer_id + ,c_first_name customer_first_name + ,c_last_name customer_last_name + ,d_year as year + ,max(ws_net_paid) year_total + ,'w' sale_type + from customer + ,web_sales + ,date_dim + where c_customer_sk = ws_bill_customer_sk + and ws_sold_date_sk = d_date_sk + and d_year in (1999,1999+1) + group by c_customer_id + ,c_first_name + ,c_last_name + ,d_year + ) + select + t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name + from year_total t_s_firstyear + ,year_total t_s_secyear + ,year_total t_w_firstyear + ,year_total t_w_secyear + where t_s_secyear.customer_id = t_s_firstyear.customer_id + and t_s_firstyear.customer_id = t_w_secyear.customer_id + and t_s_firstyear.customer_id = t_w_firstyear.customer_id + and t_s_firstyear.sale_type = 's' + and t_w_firstyear.sale_type = 'w' + and t_s_secyear.sale_type = 's' + and t_w_secyear.sale_type = 'w' + and t_s_firstyear.year = 1999 + and t_s_secyear.year = 1999+1 + and t_w_firstyear.year = 1999 + and t_w_secyear.year = 1999+1 + and t_s_firstyear.year_total > 0 + and t_w_firstyear.year_total > 0 + and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end + > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end + order by 1,3,2 +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query75.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query75.groovy new file mode 100644 index 00000000000000..6ad340276aa8e5 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query75.groovy @@ -0,0 +1,178 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query75_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Sports' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Sports' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Sports') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=2002 + AND prev_yr.d_year=2002-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100""" + qt_ds_shape_75_constraints ''' + explain shape plan + WITH all_sales AS ( + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,SUM(sales_cnt) AS sales_cnt + ,SUM(sales_amt) AS sales_amt + FROM (SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt + ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt + FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk + JOIN date_dim ON d_date_sk=cs_sold_date_sk + LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number + AND cs_item_sk=cr_item_sk) + WHERE i_category='Sports' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt + ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt + FROM store_sales JOIN item ON i_item_sk=ss_item_sk + JOIN date_dim ON d_date_sk=ss_sold_date_sk + LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number + AND ss_item_sk=sr_item_sk) + WHERE i_category='Sports' + UNION + SELECT d_year + ,i_brand_id + ,i_class_id + ,i_category_id + ,i_manufact_id + ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt + ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt + FROM web_sales JOIN item ON i_item_sk=ws_item_sk + JOIN date_dim ON d_date_sk=ws_sold_date_sk + LEFT JOIN web_returns ON (ws_order_number=wr_order_number + AND ws_item_sk=wr_item_sk) + WHERE i_category='Sports') sales_detail + GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) + SELECT prev_yr.d_year AS prev_year + ,curr_yr.d_year AS year + ,curr_yr.i_brand_id + ,curr_yr.i_class_id + ,curr_yr.i_category_id + ,curr_yr.i_manufact_id + ,prev_yr.sales_cnt AS prev_yr_cnt + ,curr_yr.sales_cnt AS curr_yr_cnt + ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff + ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff + FROM all_sales curr_yr, all_sales prev_yr + WHERE curr_yr.i_brand_id=prev_yr.i_brand_id + AND curr_yr.i_class_id=prev_yr.i_class_id + AND curr_yr.i_category_id=prev_yr.i_category_id + AND curr_yr.i_manufact_id=prev_yr.i_manufact_id + AND curr_yr.d_year=2002 + AND prev_yr.d_year=2002-1 + AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9 + ORDER BY sales_cnt_diff,sales_amt_diff + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query76.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query76.groovy new file mode 100644 index 00000000000000..8479cac63f191b --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query76.groovy @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query76_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_customer_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_customer_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_promo_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_promo_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_bill_customer_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_bill_customer_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100""" + qt_ds_shape_76_constraints ''' + explain shape plan + select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( + SELECT 'store' as channel, 'ss_customer_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price + FROM store_sales, item, date_dim + WHERE ss_customer_sk IS NULL + AND ss_sold_date_sk=d_date_sk + AND ss_item_sk=i_item_sk + UNION ALL + SELECT 'web' as channel, 'ws_promo_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price + FROM web_sales, item, date_dim + WHERE ws_promo_sk IS NULL + AND ws_sold_date_sk=d_date_sk + AND ws_item_sk=i_item_sk + UNION ALL + SELECT 'catalog' as channel, 'cs_bill_customer_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price + FROM catalog_sales, item, date_dim + WHERE cs_bill_customer_sk IS NULL + AND cs_sold_date_sk=d_date_sk + AND cs_item_sk=i_item_sk) foo +GROUP BY channel, col_name, d_year, d_qoy, i_category +ORDER BY channel, col_name, d_year, d_qoy, i_category +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query77.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query77.groovy new file mode 100644 index 00000000000000..98d9c7e4a1d175 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query77.groovy @@ -0,0 +1,254 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query77_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('2000-08-10' as date) + and (cast('2000-08-10' as date) + interval 30 day) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('2000-08-10' as date) + and (cast('2000-08-10' as date) + interval 30 day) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('2000-08-10' as date) + and (cast('2000-08-10' as date) + interval 30 day) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('2000-08-10' as date) + and (cast('2000-08-10' as date) + interval 30 day) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('2000-08-10' as date) + and (cast('2000-08-10' as date) + interval 30 day) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('2000-08-10' as date) + and (cast('2000-08-10' as date) + interval 30 day) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100""" + qt_ds_shape_77_constraints ''' + explain shape plan + with ss as + (select s_store_sk, + sum(ss_ext_sales_price) as sales, + sum(ss_net_profit) as profit + from store_sales, + date_dim, + store + where ss_sold_date_sk = d_date_sk + and d_date between cast('2000-08-10' as date) + and (cast('2000-08-10' as date) + interval 30 day) + and ss_store_sk = s_store_sk + group by s_store_sk) + , + sr as + (select s_store_sk, + sum(sr_return_amt) as returns, + sum(sr_net_loss) as profit_loss + from store_returns, + date_dim, + store + where sr_returned_date_sk = d_date_sk + and d_date between cast('2000-08-10' as date) + and (cast('2000-08-10' as date) + interval 30 day) + and sr_store_sk = s_store_sk + group by s_store_sk), + cs as + (select cs_call_center_sk, + sum(cs_ext_sales_price) as sales, + sum(cs_net_profit) as profit + from catalog_sales, + date_dim + where cs_sold_date_sk = d_date_sk + and d_date between cast('2000-08-10' as date) + and (cast('2000-08-10' as date) + interval 30 day) + group by cs_call_center_sk + ), + cr as + (select cr_call_center_sk, + sum(cr_return_amount) as returns, + sum(cr_net_loss) as profit_loss + from catalog_returns, + date_dim + where cr_returned_date_sk = d_date_sk + and d_date between cast('2000-08-10' as date) + and (cast('2000-08-10' as date) + interval 30 day) + group by cr_call_center_sk + ), + ws as + ( select wp_web_page_sk, + sum(ws_ext_sales_price) as sales, + sum(ws_net_profit) as profit + from web_sales, + date_dim, + web_page + where ws_sold_date_sk = d_date_sk + and d_date between cast('2000-08-10' as date) + and (cast('2000-08-10' as date) + interval 30 day) + and ws_web_page_sk = wp_web_page_sk + group by wp_web_page_sk), + wr as + (select wp_web_page_sk, + sum(wr_return_amt) as returns, + sum(wr_net_loss) as profit_loss + from web_returns, + date_dim, + web_page + where wr_returned_date_sk = d_date_sk + and d_date between cast('2000-08-10' as date) + and (cast('2000-08-10' as date) + interval 30 day) + and wr_web_page_sk = wp_web_page_sk + group by wp_web_page_sk) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , ss.s_store_sk as id + , sales + , coalesce(returns, 0) as returns + , (profit - coalesce(profit_loss,0)) as profit + from ss left join sr + on ss.s_store_sk = sr.s_store_sk + union all + select 'catalog channel' as channel + , cs_call_center_sk as id + , sales + , returns + , (profit - profit_loss) as profit + from cs + , cr + union all + select 'web channel' as channel + , ws.wp_web_page_sk as id + , sales + , coalesce(returns, 0) returns + , (profit - coalesce(profit_loss,0)) as profit + from ws left join wr + on ws.wp_web_page_sk = wr.wp_web_page_sk + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query78.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query78.groovy new file mode 100644 index 00000000000000..dfd301e2ad44a9 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query78.groovy @@ -0,0 +1,154 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query78_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null and d_year=1998 + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null and d_year=1998 + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null and d_year=1998 + group by d_year, ss_item_sk, ss_customer_sk + ) +select +ss_customer_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=1998 +order by + ss_customer_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100""" + qt_ds_shape_78_constraints ''' + explain shape plan + with ws as + (select d_year AS ws_sold_year, ws_item_sk, + ws_bill_customer_sk ws_customer_sk, + sum(ws_quantity) ws_qty, + sum(ws_wholesale_cost) ws_wc, + sum(ws_sales_price) ws_sp + from web_sales + left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk + join date_dim on ws_sold_date_sk = d_date_sk + where wr_order_number is null and d_year=1998 + group by d_year, ws_item_sk, ws_bill_customer_sk + ), +cs as + (select d_year AS cs_sold_year, cs_item_sk, + cs_bill_customer_sk cs_customer_sk, + sum(cs_quantity) cs_qty, + sum(cs_wholesale_cost) cs_wc, + sum(cs_sales_price) cs_sp + from catalog_sales + left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk + join date_dim on cs_sold_date_sk = d_date_sk + where cr_order_number is null and d_year=1998 + group by d_year, cs_item_sk, cs_bill_customer_sk + ), +ss as + (select d_year AS ss_sold_year, ss_item_sk, + ss_customer_sk, + sum(ss_quantity) ss_qty, + sum(ss_wholesale_cost) ss_wc, + sum(ss_sales_price) ss_sp + from store_sales + left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk + join date_dim on ss_sold_date_sk = d_date_sk + where sr_ticket_number is null and d_year=1998 + group by d_year, ss_item_sk, ss_customer_sk + ) +select +ss_customer_sk, +round(ss_qty/(coalesce(ws_qty,0)+coalesce(cs_qty,0)),2) ratio, +ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, +coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty, +coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost, +coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price +from ss +left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk) +left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) +where (coalesce(ws_qty,0)>0 or coalesce(cs_qty, 0)>0) and ss_sold_year=1998 +order by + ss_customer_sk, + ss_qty desc, ss_wc desc, ss_sp desc, + other_chan_qty, + other_chan_wholesale_cost, + other_chan_sales_price, + ratio +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query79.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query79.groovy new file mode 100644 index 00000000000000..6fb70914bf8566 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query79.groovy @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query79_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 7 or household_demographics.hd_vehicle_count > -1) + and date_dim.d_dow = 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100""" + qt_ds_shape_79_constraints ''' + explain shape plan + select + c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + from + (select ss_ticket_number + ,ss_customer_sk + ,store.s_city + ,sum(ss_coupon_amt) amt + ,sum(ss_net_profit) profit + from store_sales,date_dim,store,household_demographics + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_store_sk = store.s_store_sk + and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk + and (household_demographics.hd_dep_count = 7 or household_demographics.hd_vehicle_count > -1) + and date_dim.d_dow = 1 + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_number_employees between 200 and 295 + group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer + where ss_customer_sk = c_customer_sk + order by c_last_name,c_first_name,substr(s_city,1,30), profit +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query8.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query8.groovy new file mode 100644 index 00000000000000..5f647c3c1ab5ec --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query8.groovy @@ -0,0 +1,255 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query8_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + sql "set experimental_enable_virtual_slot_for_cse=true" + + sql 'set join_order_time_limit=10000' + + def ds = """select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '47602','16704','35863','28577','83910','36201', + '58412','48162','28055','41419','80332', + '38607','77817','24891','16226','18410', + '21231','59345','13918','51089','20317', + '17167','54585','67881','78366','47770', + '18360','51717','73108','14440','21800', + '89338','45859','65501','34948','25973', + '73219','25333','17291','10374','18829', + '60736','82620','41351','52094','19326', + '25214','54207','40936','21814','79077', + '25178','75742','77454','30621','89193', + '27369','41232','48567','83041','71948', + '37119','68341','14073','16891','62878', + '49130','19833','24286','27700','40979', + '50412','81504','94835','84844','71954', + '39503','57649','18434','24987','12350', + '86379','27413','44529','98569','16515', + '27287','24255','21094','16005','56436', + '91110','68293','56455','54558','10298', + '83647','32754','27052','51766','19444', + '13869','45645','94791','57631','20712', + '37788','41807','46507','21727','71836', + '81070','50632','88086','63991','20244', + '31655','51782','29818','63792','68605', + '94898','36430','57025','20601','82080', + '33869','22728','35834','29086','92645', + '98584','98072','11652','78093','57553', + '43830','71144','53565','18700','90209', + '71256','38353','54364','28571','96560', + '57839','56355','50679','45266','84680', + '34306','34972','48530','30106','15371', + '92380','84247','92292','68852','13338', + '34594','82602','70073','98069','85066', + '47289','11686','98862','26217','47529', + '63294','51793','35926','24227','14196', + '24594','32489','99060','49472','43432', + '49211','14312','88137','47369','56877', + '20534','81755','15794','12318','21060', + '73134','41255','63073','81003','73873', + '66057','51184','51195','45676','92696', + '70450','90669','98338','25264','38919', + '59226','58581','60298','17895','19489', + '52301','80846','95464','68770','51634', + '19988','18367','18421','11618','67975', + '25494','41352','95430','15734','62585', + '97173','33773','10425','75675','53535', + '17879','41967','12197','67998','79658', + '59130','72592','14851','43933','68101', + '50636','25717','71286','24660','58058', + '72991','95042','15543','33122','69280', + '11912','59386','27642','65177','17672', + '33467','64592','36335','54010','18767', + '63193','42361','49254','33113','33159', + '36479','59080','11855','81963','31016', + '49140','29392','41836','32958','53163', + '13844','73146','23952','65148','93498', + '14530','46131','58454','13376','13378', + '83986','12320','17193','59852','46081', + '98533','52389','13086','68843','31013', + '13261','60560','13443','45533','83583', + '11489','58218','19753','22911','25115', + '86709','27156','32669','13123','51933', + '39214','41331','66943','14155','69998', + '49101','70070','35076','14242','73021', + '59494','15782','29752','37914','74686', + '83086','34473','15751','81084','49230', + '91894','60624','17819','28810','63180', + '56224','39459','55233','75752','43639', + '55349','86057','62361','50788','31830', + '58062','18218','85761','60083','45484', + '21204','90229','70041','41162','35390', + '16364','39500','68908','26689','52868', + '81335','40146','11340','61527','61794', + '71997','30415','59004','29450','58117', + '69952','33562','83833','27385','61860', + '96435','48333','23065','32961','84919', + '61997','99132','22815','56600','68730', + '48017','95694','32919','88217','27116', + '28239','58032','18884','16791','21343', + '97462','18569','75660','15475') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 1998 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100""" + qt_ds_shape_8_constraints ''' + explain shape plan + select s_store_name + ,sum(ss_net_profit) + from store_sales + ,date_dim + ,store, + (select ca_zip + from ( + SELECT substr(ca_zip,1,5) ca_zip + FROM customer_address + WHERE substr(ca_zip,1,5) IN ( + '47602','16704','35863','28577','83910','36201', + '58412','48162','28055','41419','80332', + '38607','77817','24891','16226','18410', + '21231','59345','13918','51089','20317', + '17167','54585','67881','78366','47770', + '18360','51717','73108','14440','21800', + '89338','45859','65501','34948','25973', + '73219','25333','17291','10374','18829', + '60736','82620','41351','52094','19326', + '25214','54207','40936','21814','79077', + '25178','75742','77454','30621','89193', + '27369','41232','48567','83041','71948', + '37119','68341','14073','16891','62878', + '49130','19833','24286','27700','40979', + '50412','81504','94835','84844','71954', + '39503','57649','18434','24987','12350', + '86379','27413','44529','98569','16515', + '27287','24255','21094','16005','56436', + '91110','68293','56455','54558','10298', + '83647','32754','27052','51766','19444', + '13869','45645','94791','57631','20712', + '37788','41807','46507','21727','71836', + '81070','50632','88086','63991','20244', + '31655','51782','29818','63792','68605', + '94898','36430','57025','20601','82080', + '33869','22728','35834','29086','92645', + '98584','98072','11652','78093','57553', + '43830','71144','53565','18700','90209', + '71256','38353','54364','28571','96560', + '57839','56355','50679','45266','84680', + '34306','34972','48530','30106','15371', + '92380','84247','92292','68852','13338', + '34594','82602','70073','98069','85066', + '47289','11686','98862','26217','47529', + '63294','51793','35926','24227','14196', + '24594','32489','99060','49472','43432', + '49211','14312','88137','47369','56877', + '20534','81755','15794','12318','21060', + '73134','41255','63073','81003','73873', + '66057','51184','51195','45676','92696', + '70450','90669','98338','25264','38919', + '59226','58581','60298','17895','19489', + '52301','80846','95464','68770','51634', + '19988','18367','18421','11618','67975', + '25494','41352','95430','15734','62585', + '97173','33773','10425','75675','53535', + '17879','41967','12197','67998','79658', + '59130','72592','14851','43933','68101', + '50636','25717','71286','24660','58058', + '72991','95042','15543','33122','69280', + '11912','59386','27642','65177','17672', + '33467','64592','36335','54010','18767', + '63193','42361','49254','33113','33159', + '36479','59080','11855','81963','31016', + '49140','29392','41836','32958','53163', + '13844','73146','23952','65148','93498', + '14530','46131','58454','13376','13378', + '83986','12320','17193','59852','46081', + '98533','52389','13086','68843','31013', + '13261','60560','13443','45533','83583', + '11489','58218','19753','22911','25115', + '86709','27156','32669','13123','51933', + '39214','41331','66943','14155','69998', + '49101','70070','35076','14242','73021', + '59494','15782','29752','37914','74686', + '83086','34473','15751','81084','49230', + '91894','60624','17819','28810','63180', + '56224','39459','55233','75752','43639', + '55349','86057','62361','50788','31830', + '58062','18218','85761','60083','45484', + '21204','90229','70041','41162','35390', + '16364','39500','68908','26689','52868', + '81335','40146','11340','61527','61794', + '71997','30415','59004','29450','58117', + '69952','33562','83833','27385','61860', + '96435','48333','23065','32961','84919', + '61997','99132','22815','56600','68730', + '48017','95694','32919','88217','27116', + '28239','58032','18884','16791','21343', + '97462','18569','75660','15475') + intersect + select ca_zip + from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt + FROM customer_address, customer + WHERE ca_address_sk = c_current_addr_sk and + c_preferred_cust_flag='Y' + group by ca_zip + having count(*) > 10)A1)A2) V1 + where ss_store_sk = s_store_sk + and ss_sold_date_sk = d_date_sk + and d_qoy = 2 and d_year = 1998 + and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) + group by s_store_name + order by s_store_name + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query80.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query80.groovy new file mode 100644 index 00000000000000..657ca0733decb9 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query80.groovy @@ -0,0 +1,230 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query80_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('2002-08-14' as date) + and (cast('2002-08-14' as date) + interval 30 day) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('2002-08-14' as date) + and (cast('2002-08-14' as date) + interval 30 day) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('2002-08-14' as date) + and (cast('2002-08-14' as date) + interval 30 day) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , concat('store', store_id) as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , concat('catalog_page', catalog_page_id) as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , concat('web_site', web_site_id) as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100""" + qt_ds_shape_80_constraints ''' + explain shape plan + with ssr as + (select s_store_id as store_id, + sum(ss_ext_sales_price) as sales, + sum(coalesce(sr_return_amt, 0)) as returns, + sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit + from store_sales left outer join store_returns on + (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number), + date_dim, + store, + item, + promotion + where ss_sold_date_sk = d_date_sk + and d_date between cast('2002-08-14' as date) + and (cast('2002-08-14' as date) + interval 30 day) + and ss_store_sk = s_store_sk + and ss_item_sk = i_item_sk + and i_current_price > 50 + and ss_promo_sk = p_promo_sk + and p_channel_tv = 'N' + group by s_store_id) + , + csr as + (select cp_catalog_page_id as catalog_page_id, + sum(cs_ext_sales_price) as sales, + sum(coalesce(cr_return_amount, 0)) as returns, + sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit + from catalog_sales left outer join catalog_returns on + (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number), + date_dim, + catalog_page, + item, + promotion + where cs_sold_date_sk = d_date_sk + and d_date between cast('2002-08-14' as date) + and (cast('2002-08-14' as date) + interval 30 day) + and cs_catalog_page_sk = cp_catalog_page_sk + and cs_item_sk = i_item_sk + and i_current_price > 50 + and cs_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by cp_catalog_page_id) + , + wsr as + (select web_site_id, + sum(ws_ext_sales_price) as sales, + sum(coalesce(wr_return_amt, 0)) as returns, + sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit + from web_sales left outer join web_returns on + (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number), + date_dim, + web_site, + item, + promotion + where ws_sold_date_sk = d_date_sk + and d_date between cast('2002-08-14' as date) + and (cast('2002-08-14' as date) + interval 30 day) + and ws_web_site_sk = web_site_sk + and ws_item_sk = i_item_sk + and i_current_price > 50 + and ws_promo_sk = p_promo_sk + and p_channel_tv = 'N' +group by web_site_id) + select channel + , id + , sum(sales) as sales + , sum(returns) as returns + , sum(profit) as profit + from + (select 'store channel' as channel + , concat('store', store_id) as id + , sales + , returns + , profit + from ssr + union all + select 'catalog channel' as channel + , concat('catalog_page', catalog_page_id) as id + , sales + , returns + , profit + from csr + union all + select 'web channel' as channel + , concat('web_site', web_site_id) as id + , sales + , returns + , profit + from wsr + ) x + group by rollup (channel, id) + order by channel + ,id + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query81.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query81.groovy new file mode 100644 index 00000000000000..b7e8558a286e22 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query81.groovy @@ -0,0 +1,100 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query81_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =2001 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'TN' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100""" + qt_ds_shape_81_constraints ''' + explain shape plan + with customer_total_return as + (select cr_returning_customer_sk as ctr_customer_sk + ,ca_state as ctr_state, + sum(cr_return_amt_inc_tax) as ctr_total_return + from catalog_returns + ,date_dim + ,customer_address + where cr_returned_date_sk = d_date_sk + and d_year =2001 + and cr_returning_addr_sk = ca_address_sk + group by cr_returning_customer_sk + ,ca_state ) + select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + from customer_total_return ctr1 + ,customer_address + ,customer + where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 + from customer_total_return ctr2 + where ctr1.ctr_state = ctr2.ctr_state) + and ca_address_sk = c_current_addr_sk + and ca_state = 'TN' + and ctr1.ctr_customer_sk = c_customer_sk + order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name + ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset + ,ca_location_type,ctr_total_return + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query82.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query82.groovy new file mode 100644 index 00000000000000..db1abf7dff8983 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query82.groovy @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query82_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 58 and 58+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2001-01-13' as date) and (cast('2001-01-13' as date) + interval 60 day) + and i_manufact_id in (259,559,580,485) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100""" + qt_ds_shape_82_constraints ''' + explain shape plan + select i_item_id + ,i_item_desc + ,i_current_price + from item, inventory, date_dim, store_sales + where i_current_price between 58 and 58+30 + and inv_item_sk = i_item_sk + and d_date_sk=inv_date_sk + and d_date between cast('2001-01-13' as date) and (cast('2001-01-13' as date) + interval 60 day) + and i_manufact_id in (259,559,580,485) + and inv_quantity_on_hand between 100 and 500 + and ss_item_sk = i_item_sk + group by i_item_id,i_item_desc,i_current_price + order by i_item_id + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query83.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query83.groovy new file mode 100644 index 00000000000000..7f6e8c3f32ebe8 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query83.groovy @@ -0,0 +1,172 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query83_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in ('2001-07-13','2001-09-10','2001-11-16'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in ('2001-07-13','2001-09-10','2001-11-16'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in ('2001-07-13','2001-09-10','2001-11-16'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100""" + qt_ds_shape_83_constraints ''' + explain shape plan + with sr_items as + (select i_item_id item_id, + sum(sr_return_quantity) sr_item_qty + from store_returns, + item, + date_dim + where sr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in ('2001-07-13','2001-09-10','2001-11-16'))) + and sr_returned_date_sk = d_date_sk + group by i_item_id), + cr_items as + (select i_item_id item_id, + sum(cr_return_quantity) cr_item_qty + from catalog_returns, + item, + date_dim + where cr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in ('2001-07-13','2001-09-10','2001-11-16'))) + and cr_returned_date_sk = d_date_sk + group by i_item_id), + wr_items as + (select i_item_id item_id, + sum(wr_return_quantity) wr_item_qty + from web_returns, + item, + date_dim + where wr_item_sk = i_item_sk + and d_date in + (select d_date + from date_dim + where d_week_seq in + (select d_week_seq + from date_dim + where d_date in ('2001-07-13','2001-09-10','2001-11-16'))) + and wr_returned_date_sk = d_date_sk + group by i_item_id) + select sr_items.item_id + ,sr_item_qty + ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,cr_item_qty + ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,wr_item_qty + ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average + from sr_items + ,cr_items + ,wr_items + where sr_items.item_id=cr_items.item_id + and sr_items.item_id=wr_items.item_id + order by sr_items.item_id + ,sr_item_qty + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query84.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query84.groovy new file mode 100644 index 00000000000000..1cc97791ea8149 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query84.groovy @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query84_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select c_customer_id as customer_id + , concat(concat(coalesce(c_last_name,''), ','), coalesce(c_first_name,'')) as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Woodland' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 60306 + and ib_upper_bound <= 60306 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100""" + qt_ds_shape_84_constraints ''' + explain shape plan + select c_customer_id as customer_id + , concat(concat(coalesce(c_last_name,''), ','), coalesce(c_first_name,'')) as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = 'Woodland' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= 60306 + and ib_upper_bound <= 60306 + 50000 + and ib_income_band_sk = hd_income_band_sk + and cd_demo_sk = c_current_cdemo_sk + and hd_demo_sk = c_current_hdemo_sk + and sr_cdemo_sk = cd_demo_sk + order by c_customer_id + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query85.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query85.groovy new file mode 100644 index 00000000000000..450330a437622e --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query85.groovy @@ -0,0 +1,205 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query85_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + sql 'set join_order_time_limit=10000' + + def ds = """select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 1998 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'D' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Primary' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'S' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'College' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'U' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Advanced Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('NC', 'TX', 'IA') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('WI', 'WV', 'GA') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('OK', 'VA', 'KY') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100""" + qt_ds_shape_85_constraints ''' + explain shape plan + select substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) + from web_sales, web_returns, web_page, customer_demographics cd1, + customer_demographics cd2, customer_address, date_dim, reason + where ws_web_page_sk = wp_web_page_sk + and ws_item_sk = wr_item_sk + and ws_order_number = wr_order_number + and ws_sold_date_sk = d_date_sk and d_year = 1998 + and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd2.cd_demo_sk = wr_returning_cdemo_sk + and ca_address_sk = wr_refunded_addr_sk + and r_reason_sk = wr_reason_sk + and + ( + ( + cd1.cd_marital_status = 'D' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Primary' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 100.00 and 150.00 + ) + or + ( + cd1.cd_marital_status = 'S' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'College' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 50.00 and 100.00 + ) + or + ( + cd1.cd_marital_status = 'U' + and + cd1.cd_marital_status = cd2.cd_marital_status + and + cd1.cd_education_status = 'Advanced Degree' + and + cd1.cd_education_status = cd2.cd_education_status + and + ws_sales_price between 150.00 and 200.00 + ) + ) + and + ( + ( + ca_country = 'United States' + and + ca_state in ('NC', 'TX', 'IA') + and ws_net_profit between 100 and 200 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('WI', 'WV', 'GA') + and ws_net_profit between 150 and 300 + ) + or + ( + ca_country = 'United States' + and + ca_state in ('OK', 'VA', 'KY') + and ws_net_profit between 50 and 250 + ) + ) +group by r_reason_desc +order by substr(r_reason_desc,1,20) + ,avg(ws_quantity) + ,avg(wr_refunded_cash) + ,avg(wr_fee) +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query86.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query86.groovy new file mode 100644 index 00000000000000..3b8863ebaabe18 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query86.groovy @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query86_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1186 and 1186+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100""" + qt_ds_shape_86_constraints ''' + explain shape plan + select + sum(ws_net_paid) as total_sum + ,i_category + ,i_class + ,grouping(i_category)+grouping(i_class) as lochierarchy + ,rank() over ( + partition by grouping(i_category)+grouping(i_class), + case when grouping(i_class) = 0 then i_category end + order by sum(ws_net_paid) desc) as rank_within_parent + from + web_sales + ,date_dim d1 + ,item + where + d1.d_month_seq between 1186 and 1186+11 + and d1.d_date_sk = ws_sold_date_sk + and i_item_sk = ws_item_sk + group by rollup(i_category,i_class) + order by + lochierarchy desc, + case when lochierarchy = 0 then i_category end, + rank_within_parent + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query87.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query87.groovy new file mode 100644 index 00000000000000..748c30f890a819 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query87.groovy @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query87_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1202 and 1202+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1202 and 1202+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1202 and 1202+11) +) cool_cust +""" + qt_ds_shape_87_constraints ''' + explain shape plan + select count(*) +from ((select distinct c_last_name, c_first_name, d_date + from store_sales, date_dim, customer + where store_sales.ss_sold_date_sk = date_dim.d_date_sk + and store_sales.ss_customer_sk = customer.c_customer_sk + and d_month_seq between 1202 and 1202+11) + except + (select distinct c_last_name, c_first_name, d_date + from catalog_sales, date_dim, customer + where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1202 and 1202+11) + except + (select distinct c_last_name, c_first_name, d_date + from web_sales, date_dim, customer + where web_sales.ws_sold_date_sk = date_dim.d_date_sk + and web_sales.ws_bill_customer_sk = customer.c_customer_sk + and d_month_seq between 1202 and 1202+11) +) cool_cust + + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query88.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query88.groovy new file mode 100644 index 00000000000000..5c54b098c6eae0 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query88.groovy @@ -0,0 +1,226 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query88_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s8 +""" + qt_ds_shape_88_constraints ''' + explain shape plan + select * +from + (select count(*) h8_30_to_9 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s1, + (select count(*) h9_to_9_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s2, + (select count(*) h9_30_to_10 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 9 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s3, + (select count(*) h10_to_10_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s4, + (select count(*) h10_30_to_11 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 10 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s5, + (select count(*) h11_to_11_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s6, + (select count(*) h11_30_to_12 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 11 + and time_dim.t_minute >= 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s7, + (select count(*) h12_to_12_30 + from store_sales, household_demographics , time_dim, store + where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 12 + and time_dim.t_minute < 30 + and ((household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or + (household_demographics.hd_dep_count = -1 and household_demographics.hd_vehicle_count<=-1+2) or + (household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2)) + and store.s_store_name = 'ese') s8 + + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query89.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query89.groovy new file mode 100644 index 00000000000000..6f94c21f455170 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query89.groovy @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query89_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (2001) and + ((i_category in ('Books','Children','Electronics') and + i_class in ('history','school-uniforms','audio') + ) + or (i_category in ('Men','Sports','Shoes') and + i_class in ('pants','tennis','womens') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100""" + qt_ds_shape_89_constraints ''' + explain shape plan + select * +from( +select i_category, i_class, i_brand, + s_store_name, s_company_name, + d_moy, + sum(ss_sales_price) sum_sales, + avg(sum(ss_sales_price)) over + (partition by i_category, i_brand, s_store_name, s_company_name) + avg_monthly_sales +from item, store_sales, date_dim, store +where ss_item_sk = i_item_sk and + ss_sold_date_sk = d_date_sk and + ss_store_sk = s_store_sk and + d_year in (2001) and + ((i_category in ('Books','Children','Electronics') and + i_class in ('history','school-uniforms','audio') + ) + or (i_category in ('Men','Sports','Shoes') and + i_class in ('pants','tennis','womens') + )) +group by i_category, i_class, i_brand, + s_store_name, s_company_name, d_moy) tmp1 +where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 +order by sum_sales - avg_monthly_sales, s_store_name +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query9.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query9.groovy new file mode 100644 index 00000000000000..055d76301446c6 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query9.groovy @@ -0,0 +1,141 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query9_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + sql "set enable_parallel_result_sink=false;" + + sql 'set join_order_time_limit=10000' + + def ds = """select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 1071 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 39161 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 29434 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 6568 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 21216 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 +""" + qt_ds_shape_9_constraints ''' + explain shape plan + select case when (select count(*) + from store_sales + where ss_quantity between 1 and 20) > 1071 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 1 and 20) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 1 and 20) end bucket1 , + case when (select count(*) + from store_sales + where ss_quantity between 21 and 40) > 39161 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 21 and 40) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 21 and 40) end bucket2, + case when (select count(*) + from store_sales + where ss_quantity between 41 and 60) > 29434 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 41 and 60) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 41 and 60) end bucket3, + case when (select count(*) + from store_sales + where ss_quantity between 61 and 80) > 6568 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 61 and 80) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 61 and 80) end bucket4, + case when (select count(*) + from store_sales + where ss_quantity between 81 and 100) > 21216 + then (select avg(ss_ext_tax) + from store_sales + where ss_quantity between 81 and 100) + else (select avg(ss_net_paid_inc_tax) + from store_sales + where ss_quantity between 81 and 100) end bucket5 +from reason +where r_reason_sk = 1 + + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query90.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query90.groovy new file mode 100644 index 00000000000000..d95f966036dcfb --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query90.groovy @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query90_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 12 and 12+1 + and household_demographics.hd_dep_count = 6 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 14 and 14+1 + and household_demographics.hd_dep_count = 6 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100""" + qt_ds_shape_90_constraints ''' + explain shape plan + select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio + from ( select count(*) amc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 12 and 12+1 + and household_demographics.hd_dep_count = 6 + and web_page.wp_char_count between 5000 and 5200) at, + ( select count(*) pmc + from web_sales, household_demographics , time_dim, web_page + where ws_sold_time_sk = time_dim.t_time_sk + and ws_ship_hdemo_sk = household_demographics.hd_demo_sk + and ws_web_page_sk = web_page.wp_web_page_sk + and time_dim.t_hour between 14 and 14+1 + and household_demographics.hd_dep_count = 6 + and web_page.wp_char_count between 5000 and 5200) pt + order by am_pm_ratio + limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query91.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query91.groovy new file mode 100644 index 00000000000000..42504c87670017 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query91.groovy @@ -0,0 +1,100 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query91_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 2000 +and d_moy = 12 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like 'Unknown%' +and ca_gmt_offset = -7 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc""" + qt_ds_shape_91_constraints ''' + explain shape plan + select + cc_call_center_id Call_Center, + cc_name Call_Center_Name, + cc_manager Manager, + sum(cr_net_loss) Returns_Loss +from + call_center, + catalog_returns, + date_dim, + customer, + customer_address, + customer_demographics, + household_demographics +where + cr_call_center_sk = cc_call_center_sk +and cr_returned_date_sk = d_date_sk +and cr_returning_customer_sk= c_customer_sk +and cd_demo_sk = c_current_cdemo_sk +and hd_demo_sk = c_current_hdemo_sk +and ca_address_sk = c_current_addr_sk +and d_year = 2000 +and d_moy = 12 +and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown') + or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree')) +and hd_buy_potential like 'Unknown%' +and ca_gmt_offset = -7 +group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status +order by sum(cr_net_loss) desc + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query92.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query92.groovy new file mode 100644 index 00000000000000..33038d2f2b3e5d --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query92.groovy @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query92_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 714 +and i_item_sk = ws_item_sk +and d_date between '2000-02-01' and + (cast('2000-02-01' as date) + interval 90 day) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between '2000-02-01' and + (cast('2000-02-01' as date) + interval 90 day) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100""" + qt_ds_shape_92_constraints ''' + explain shape plan + select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + web_sales + ,item + ,date_dim +where +i_manufact_id = 714 +and i_item_sk = ws_item_sk +and d_date between '2000-02-01' and + (cast('2000-02-01' as date) + interval 90 day) +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3 * avg(ws_ext_discount_amt) + FROM + web_sales + ,date_dim + WHERE + ws_item_sk = i_item_sk + and d_date between '2000-02-01' and + (cast('2000-02-01' as date) + interval 90 day) + and d_date_sk = ws_sold_date_sk + ) +order by sum(ws_ext_discount_amt) +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query93.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query93.groovy new file mode 100644 index 00000000000000..bd5ebf4397c8ba --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query93.groovy @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query93_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'reason 58') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100""" + qt_ds_shape_93_constraints ''' + explain shape plan + select ss_customer_sk + ,sum(act_sales) sumsales + from (select ss_item_sk + ,ss_ticket_number + ,ss_customer_sk + ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price + else (ss_quantity*ss_sales_price) end act_sales + from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk + and sr_ticket_number = ss_ticket_number) + ,reason + where sr_reason_sk = r_reason_sk + and r_reason_desc = 'reason 58') t + group by ss_customer_sk + order by sumsales, ss_customer_sk +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query94.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query94.groovy new file mode 100644 index 00000000000000..965ef1d6ad8890 --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query94.groovy @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query94_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between '2002-5-01' and + (cast('2002-5-01' as date) + interval 60 day) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'OK' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100""" + qt_ds_shape_94_constraints ''' + explain shape plan + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between '2002-5-01' and + (cast('2002-5-01' as date) + interval 60 day) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'OK' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and exists (select * + from web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) +and not exists(select * + from web_returns wr1 + where ws1.ws_order_number = wr1.wr_order_number) +order by count(distinct ws_order_number) +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query95.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query95.groovy new file mode 100644 index 00000000000000..42465546cddc9d --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query95.groovy @@ -0,0 +1,102 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query95_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between '2001-4-01' and + (cast('2001-4-01' as date) + interval 60 day) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'VA' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100""" + qt_ds_shape_95_constraints ''' + explain shape plan + with ws_wh as +(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2 + from web_sales ws1,web_sales ws2 + where ws1.ws_order_number = ws2.ws_order_number + and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) + select + count(distinct ws_order_number) as "order count" + ,sum(ws_ext_ship_cost) as "total shipping cost" + ,sum(ws_net_profit) as "total net profit" +from + web_sales ws1 + ,date_dim + ,customer_address + ,web_site +where + d_date between '2001-4-01' and + (cast('2001-4-01' as date) + interval 60 day) +and ws1.ws_ship_date_sk = d_date_sk +and ws1.ws_ship_addr_sk = ca_address_sk +and ca_state = 'VA' +and ws1.ws_web_site_sk = web_site_sk +and web_company_name = 'pri' +and ws1.ws_order_number in (select ws_order_number + from ws_wh) +and ws1.ws_order_number in (select wr_order_number + from web_returns,ws_wh + where wr_order_number = ws_wh.ws_order_number) +order by count(distinct ws_order_number) +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query96.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query96.groovy new file mode 100644 index 00000000000000..26e984fd7c2ebe --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query96.groovy @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query96_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 0 + and store.s_store_name = 'ese' +order by count(*) +limit 100""" + qt_ds_shape_96_constraints ''' + explain shape plan + select count(*) +from store_sales + ,household_demographics + ,time_dim, store +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk + and ss_store_sk = s_store_sk + and time_dim.t_hour = 8 + and time_dim.t_minute >= 30 + and household_demographics.hd_dep_count = 0 + and store.s_store_name = 'ese' +order by count(*) +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query97.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query97.groovy new file mode 100644 index 00000000000000..f07d1484046aff --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query97.groovy @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query97_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + multi_sql """ + use ${db}; + set enable_nereids_planner=true; + set enable_nereids_distribute_planner=false; + set enable_fallback_to_original_planner=false; + set exec_mem_limit=21G; + set be_number_for_test=3; + set enable_runtime_filter_prune=false; + set parallel_pipeline_task_num=8; + set forbid_unknown_col_stats=false; + set enable_stats=true; + set runtime_filter_type=8; + set broadcast_row_count_limit = 30000000; + set enable_nereids_timeout = false; + set enable_pipeline_engine = true; + set disable_nereids_rules='PRUNE_EMPTY_PARTITION'; + set push_topn_to_agg = true; + set topn_opt_limit_threshold=1024; + """ + + sql 'set join_order_time_limit=10000' + + def ds = """with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1199 and 1199 + 11 and ss_sold_date_sk IS NOT NULL +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1199 and 1199 + 11 and cs_sold_date_sk IS NOT NULL +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100""" + qt_ds_shape_97_constraints ''' + explain shape plan + with ssci as ( +select ss_customer_sk customer_sk + ,ss_item_sk item_sk +from store_sales,date_dim +where ss_sold_date_sk = d_date_sk + and d_month_seq between 1199 and 1199 + 11 and ss_sold_date_sk IS NOT NULL +group by ss_customer_sk + ,ss_item_sk), +csci as( + select cs_bill_customer_sk customer_sk + ,cs_item_sk item_sk +from catalog_sales,date_dim +where cs_sold_date_sk = d_date_sk + and d_month_seq between 1199 and 1199 + 11 and cs_sold_date_sk IS NOT NULL +group by cs_bill_customer_sk + ,cs_item_sk) + select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only + ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only + ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog +from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk + and ssci.item_sk = csci.item_sk) +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query98.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query98.groovy new file mode 100644 index 00000000000000..80b1605a48bd8e --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query98.groovy @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query98_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Men', 'Sports', 'Jewelry') + and ss_sold_date_sk = d_date_sk + and d_date between cast('1999-02-05' as date) + and (cast('1999-02-05' as date) + interval 30 day) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio""" + qt_ds_shape_98_constraints ''' + explain shape plan + select i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price + ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over + (partition by i_class) as revenueratio +from + store_sales + ,item + ,date_dim +where + ss_item_sk = i_item_sk + and i_category in ('Men', 'Sports', 'Jewelry') + and ss_sold_date_sk = d_date_sk + and d_date between cast('1999-02-05' as date) + and (cast('1999-02-05' as date) + interval 30 day) +group by + i_item_id + ,i_item_desc + ,i_category + ,i_class + ,i_current_price +order by + i_category + ,i_class + ,i_item_id + ,i_item_desc + ,revenueratio + ''' +} diff --git a/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query99.groovy b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query99.groovy new file mode 100644 index 00000000000000..dc6c00ad2d497a --- /dev/null +++ b/regression-test/suites/shape_check/tpcds_sf1000_constraints/shape/query99.groovy @@ -0,0 +1,108 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("query99_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'set be_number_for_test=3' + sql 'set parallel_pipeline_task_num=8; ' + sql 'set forbid_unknown_col_stats=true' + sql 'set enable_nereids_timeout = false' + sql 'set enable_runtime_filter_prune=false' + sql 'set runtime_filter_type=8' + sql 'set dump_nereids_memo=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + sql 'set join_order_time_limit=10000' + + def ds = """select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1194 and 1194 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100""" + qt_ds_shape_99_constraints ''' + explain shape plan + select + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" +from + catalog_sales + ,warehouse + ,ship_mode + ,call_center + ,date_dim +where + d_month_seq between 1194 and 1194 + 11 +and cs_ship_date_sk = d_date_sk +and cs_warehouse_sk = w_warehouse_sk +and cs_ship_mode_sk = sm_ship_mode_sk +and cs_call_center_sk = cc_call_center_sk +group by + substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +order by substr(w_warehouse_name,1,20) + ,sm_type + ,cc_name +limit 100 + ''' +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/load.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/load.groovy new file mode 100644 index 00000000000000..f6f6a12799c22f --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/load.groovy @@ -0,0 +1,502 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("load") { + String database = context.config.getDbNameByFile(context.file) + sql "drop database if exists ${database}" + sql "create database ${database}" + sql "use ${database}" + sql """ + drop table if exists lineitem; + """ + sql """ + CREATE TABLE lineitem ( + l_shipdate DATEV2 NOT NULL, + l_orderkey bigint NOT NULL, + l_linenumber int not null, + l_partkey int NOT NULL, + l_suppkey int not null, + l_quantity decimal(15, 2) NOT NULL, + l_extendedprice decimal(15, 2) NOT NULL, + l_discount decimal(15, 2) NOT NULL, + l_tax decimal(15, 2) NOT NULL, + l_returnflag VARCHAR(1) NOT NULL, + l_linestatus VARCHAR(1) NOT NULL, + l_commitdate DATEV2 NOT NULL, + l_receiptdate DATEV2 NOT NULL, + l_shipinstruct VARCHAR(25) NOT NULL, + l_shipmode VARCHAR(10) NOT NULL, + l_comment VARCHAR(44) NOT NULL + )ENGINE=OLAP + DUPLICATE KEY(`l_shipdate`, `l_orderkey`) + COMMENT "OLAP" + DISTRIBUTED BY HASH(`l_orderkey`) BUCKETS 96 + PROPERTIES ( + "replication_num" = "1", + "colocate_with" = "lineitem_orders" + ); + """ + + sql """ + drop table if exists orders; + """ + + sql ''' + CREATE TABLE orders ( + o_orderkey bigint NOT NULL, + o_orderdate DATEV2 NOT NULL, + o_custkey int NOT NULL, + o_orderstatus VARCHAR(1) NOT NULL, + o_totalprice decimal(15, 2) NOT NULL, + o_orderpriority VARCHAR(15) NOT NULL, + o_clerk VARCHAR(15) NOT NULL, + o_shippriority int NOT NULL, + o_comment VARCHAR(79) NOT NULL + )ENGINE=OLAP + DUPLICATE KEY(`o_orderkey`, `o_orderdate`) + COMMENT "OLAP" + DISTRIBUTED BY HASH(`o_orderkey`) BUCKETS 96 + PROPERTIES ( + "replication_num" = "1", + "colocate_with" = "lineitem_orders" + ); ''' + + sql ''' + drop table if exists partsupp; + ''' + + sql ''' + CREATE TABLE partsupp ( + ps_partkey int NOT NULL, + ps_suppkey int NOT NULL, + ps_availqty int NOT NULL, + ps_supplycost decimal(15, 2) NOT NULL, + ps_comment VARCHAR(199) NOT NULL + )ENGINE=OLAP + DUPLICATE KEY(`ps_partkey`) + COMMENT "OLAP" + DISTRIBUTED BY HASH(`ps_partkey`) BUCKETS 24 + PROPERTIES ( + "replication_num" = "1", + "colocate_with" = "part_partsupp" + ); + ''' + + sql ''' + drop table if exists part; + ''' + + sql ''' + CREATE TABLE part ( + p_partkey int NOT NULL, + p_name VARCHAR(55) NOT NULL, + p_mfgr VARCHAR(25) NOT NULL, + p_brand VARCHAR(10) NOT NULL, + p_type VARCHAR(25) NOT NULL, + p_size int NOT NULL, + p_container VARCHAR(10) NOT NULL, + p_retailprice decimal(15, 2) NOT NULL, + p_comment VARCHAR(23) NOT NULL + )ENGINE=OLAP + DUPLICATE KEY(`p_partkey`) + COMMENT "OLAP" + DISTRIBUTED BY HASH(`p_partkey`) BUCKETS 24 + PROPERTIES ( + "replication_num" = "1", + "colocate_with" = "part_partsupp" + ); + ''' + + sql ''' + drop table if exists customer; + ''' + + sql ''' + CREATE TABLE customer ( + c_custkey int NOT NULL, + c_name VARCHAR(25) NOT NULL, + c_address VARCHAR(40) NOT NULL, + c_nationkey int NOT NULL, + c_phone VARCHAR(15) NOT NULL, + c_acctbal decimal(15, 2) NOT NULL, + c_mktsegment VARCHAR(10) NOT NULL, + c_comment VARCHAR(117) NOT NULL + )ENGINE=OLAP + DUPLICATE KEY(`c_custkey`) + COMMENT "OLAP" + DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 24 + PROPERTIES ( + "replication_num" = "1" + ); + ''' + + sql ''' + drop table if exists supplier + ''' + + sql ''' + CREATE TABLE supplier ( + s_suppkey int NOT NULL, + s_name VARCHAR(25) NOT NULL, + s_address VARCHAR(40) NOT NULL, + s_nationkey int NOT NULL, + s_phone VARCHAR(15) NOT NULL, + s_acctbal decimal(15, 2) NOT NULL, + s_comment VARCHAR(101) NOT NULL + )ENGINE=OLAP + DUPLICATE KEY(`s_suppkey`) + COMMENT "OLAP" + DISTRIBUTED BY HASH(`s_suppkey`) BUCKETS 12 + PROPERTIES ( + "replication_num" = "1" + ); + ''' + + sql ''' + drop table if exists nation; + ''' + + sql ''' + CREATE TABLE `nation` ( + `n_nationkey` int(11) NOT NULL, + `n_name` varchar(25) NOT NULL, + `n_regionkey` int(11) NOT NULL, + `n_comment` varchar(152) NULL + ) ENGINE=OLAP + DUPLICATE KEY(`N_NATIONKEY`) + COMMENT "OLAP" + DISTRIBUTED BY HASH(`N_NATIONKEY`) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ); + ''' + + sql ''' + drop table if exists region; + ''' + + sql ''' + CREATE TABLE region ( + r_regionkey int NOT NULL, + r_name VARCHAR(25) NOT NULL, + r_comment VARCHAR(152) + )ENGINE=OLAP + DUPLICATE KEY(`r_regionkey`) + COMMENT "OLAP" + DISTRIBUTED BY HASH(`r_regionkey`) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ); + ''' + + sql ''' + drop view if exists revenue0; + ''' + + sql ''' + create view revenue0 (supplier_no, total_revenue) as + select + l_suppkey, + sum(l_extendedprice * (1 - l_discount)) + from + lineitem + where + l_shipdate >= date '1996-01-01' + and l_shipdate < date '1996-01-01' + interval '3' month + group by + l_suppkey; + ''' + + +sql ''' +alter table lineitem modify column l_shipdate set stats ('ndv'='2539', 'num_nulls'='0', 'min_value'='1992-01-02', 'max_value'='1998-12-01', 'row_count'='5999989709'); +''' + +sql ''' +alter table lineitem modify column l_orderkey set stats ('ndv'='1491920000', 'num_nulls'='0', 'min_value'='1', 'max_value'='6000000000', 'row_count'='5999989709'); +''' + +sql ''' +alter table lineitem modify column l_linenumber set stats ('ndv'='7', 'num_nulls'='0', 'min_value'='1', 'max_value'='7', 'row_count'='5999989709'); +''' + +sql ''' +alter table lineitem modify column l_partkey set stats ('ndv'='200778064', 'num_nulls'='0', 'min_value'='1', 'max_value'='200000000', 'row_count'='5999989709'); +''' + +sql ''' +alter table lineitem modify column l_suppkey set stats ('ndv'='10031328', 'num_nulls'='0', 'min_value'='1', 'max_value'='10000000', 'row_count'='5999989709'); +''' + +sql ''' +alter table lineitem modify column l_quantity set stats ('ndv'='50', 'num_nulls'='0', 'min_value'='1.00', 'max_value'='50.00', 'row_count'='5999989709'); +''' + +sql ''' +alter table lineitem modify column l_extendedprice set stats ('ndv'='3793003', 'num_nulls'='0', 'min_value'='900.00', 'max_value'='104950.00', 'row_count'='5999989709'); +''' + +sql ''' +alter table lineitem modify column l_discount set stats ('ndv'='11', 'num_nulls'='0', 'min_value'='0.00', 'max_value'='0.10', 'row_count'='5999989709'); +''' + +sql ''' +alter table lineitem modify column l_tax set stats ('ndv'='9', 'num_nulls'='0', 'min_value'='0.00', 'max_value'='0.08', 'row_count'='5999989709'); +''' + +sql ''' +alter table lineitem modify column l_returnflag set stats ('ndv'='3', 'num_nulls'='0', 'min_value'='A', 'max_value'='R', 'row_count'='5999989709'); +''' + +sql ''' +alter table lineitem modify column l_linestatus set stats ('ndv'='2', 'num_nulls'='0', 'min_value'='F', 'max_value'='O', 'row_count'='5999989709'); +''' + +sql ''' +alter table lineitem modify column l_commitdate set stats ('ndv'='2473', 'num_nulls'='0', 'min_value'='1992-01-31', 'max_value'='1998-10-31', 'row_count'='5999989709'); +''' + +sql ''' +alter table lineitem modify column l_receiptdate set stats ('ndv'='2568', 'num_nulls'='0', 'min_value'='1992-01-03', 'max_value'='1998-12-31', 'row_count'='5999989709'); +''' + +sql ''' +alter table lineitem modify column l_shipinstruct set stats ('ndv'='4', 'num_nulls'='0', 'min_value'='COLLECT COD', 'max_value'='TAKE BACK RETURN', 'row_count'='5999989709'); +''' + +sql ''' +alter table lineitem modify column l_shipmode set stats ('ndv'='7', 'num_nulls'='0', 'min_value'='AIR', 'max_value'='TRUCK', 'row_count'='5999989709'); +''' + +sql ''' +alter table lineitem modify column l_comment set stats ('ndv'='155259104', 'num_nulls'='0', 'min_value'=' Tiresias ', 'max_value'='zzle? unusual', 'row_count'='5999989709'); +''' + + +sql ''' +alter table orders modify column o_orderkey set stats ('ndv'='1491920000', 'num_nulls'='0', 'min_value'='1', 'max_value'='6000000000', 'row_count'='1500000000'); +''' + +sql ''' +alter table orders modify column o_orderdate set stats ('ndv'='2417', 'num_nulls'='0', 'min_value'='1992-01-01', 'max_value'='1998-08-02', 'row_count'='1500000000'); +''' + +sql ''' +alter table orders modify column o_custkey set stats ('ndv'='101410744', 'num_nulls'='0', 'min_value'='1', 'max_value'='149999999', 'row_count'='1500000000'); +''' + +sql ''' +alter table orders modify column o_orderstatus set stats ('ndv'='3', 'num_nulls'='0', 'min_value'='F', 'max_value'='P', 'row_count'='1500000000'); +''' + +sql ''' +alter table orders modify column o_totalprice set stats ('ndv'='41700404', 'num_nulls'='0', 'min_value'='810.87', 'max_value'='602901.81', 'row_count'='1500000000'); +''' + +sql ''' +alter table orders modify column o_orderpriority set stats ('ndv'='5', 'num_nulls'='0', 'min_value'='1-URGENT', 'max_value'='5-LOW', 'row_count'='1500000000'); +''' + +sql ''' +alter table orders modify column o_clerk set stats ('ndv'='1013689', 'num_nulls'='0', 'min_value'='Clerk#000000001', 'max_value'='Clerk#001000000', 'row_count'='1500000000'); +''' + +sql ''' +alter table orders modify column o_shippriority set stats ('ndv'='1', 'num_nulls'='0', 'min_value'='0', 'max_value'='0', 'row_count'='1500000000'); +''' + +sql ''' +alter table orders modify column o_comment set stats ('ndv'='272632352', 'num_nulls'='0', 'min_value'=' Tiresias about the', 'max_value'='zzle? unusual requests w', 'row_count'='1500000000'); +''' + + +sql ''' +alter table partsupp modify column ps_partkey set stats ('ndv'='200778064', 'num_nulls'='0', 'min_value'='1', 'max_value'='200000000', 'row_count'='800000000'); +''' + +sql ''' +alter table partsupp modify column ps_suppkey set stats ('ndv'='10031328', 'num_nulls'='0', 'min_value'='1', 'max_value'='10000000', 'row_count'='800000000'); +''' + +sql ''' +alter table partsupp modify column ps_availqty set stats ('ndv'='10008', 'num_nulls'='0', 'min_value'='1', 'max_value'='9999', 'row_count'='800000000'); +''' + +sql ''' +alter table partsupp modify column ps_supplycost set stats ('ndv'='100279', 'num_nulls'='0', 'min_value'='1.00', 'max_value'='1000.00', 'row_count'='800000000'); +''' + +sql ''' +alter table partsupp modify column ps_comment set stats ('ndv'='303150816', 'num_nulls'='0', 'min_value'=' Tiresias about the accounts detect quickly final foxes. instructions about the blithely unusual theodolites use blithely f', 'max_value'='zzle? unusual requests wake slyly. slyly regular requests are e', 'row_count'='800000000'); +''' + + + +sql ''' +alter table part modify column p_partkey set stats ('ndv'='200778064', 'num_nulls'='0', 'min_value'='1', 'max_value'='200000000', 'row_count'='200000000'); +''' + +sql ''' +alter table part modify column p_name set stats ('ndv'='196191408', 'num_nulls'='0', 'min_value'='almond antique aquamarine azure blush', 'max_value'='yellow white wheat violet red', 'row_count'='200000000'); +''' + +sql ''' +alter table part modify column p_mfgr set stats ('ndv'='5', 'num_nulls'='0', 'min_value'='Manufacturer#1', 'max_value'='Manufacturer#5', 'row_count'='200000000'); +''' + +sql ''' +alter table part modify column p_brand set stats ('ndv'='25', 'num_nulls'='0', 'min_value'='Brand#11', 'max_value'='Brand#55', 'row_count'='200000000'); +''' + +sql ''' +alter table part modify column p_type set stats ('ndv'='150', 'num_nulls'='0', 'min_value'='ECONOMY ANODIZED BRASS', 'max_value'='STANDARD POLISHED TIN', 'row_count'='200000000'); +''' + +sql ''' +alter table part modify column p_size set stats ('ndv'='50', 'num_nulls'='0', 'min_value'='1', 'max_value'='50', 'row_count'='200000000'); +''' + +sql ''' +alter table part modify column p_container set stats ('ndv'='40', 'num_nulls'='0', 'min_value'='JUMBO BAG', 'max_value'='WRAP PKG', 'row_count'='200000000'); +''' + +sql ''' +alter table part modify column p_retailprice set stats ('ndv'='120904', 'num_nulls'='0', 'min_value'='900.00', 'max_value'='2099.00', 'row_count'='200000000'); +''' + +sql ''' +alter table part modify column p_comment set stats ('ndv'='14213541', 'num_nulls'='0', 'min_value'=' Tire', 'max_value'='zzle? speci', 'row_count'='200000000'); +''' + + + +sql ''' +alter table supplier modify column s_suppkey set stats ('ndv'='10031328', 'num_nulls'='0', 'min_value'='1', 'max_value'='10000000', 'row_count'='10000000'); +''' + +sql ''' +alter table supplier modify column s_name set stats ('ndv'='9992858', 'num_nulls'='0', 'min_value'='Supplier#000000001', 'max_value'='Supplier#010000000', 'row_count'='10000000'); +''' + +sql ''' +alter table supplier modify column s_address set stats ('ndv'='10000390', 'num_nulls'='0', 'min_value'=' 04SJW3NWgeWBx2YualVtK62DXnr', 'max_value'='zzzzr MaemffsKy', 'row_count'='10000000'); +''' + +sql ''' +alter table supplier modify column s_nationkey set stats ('ndv'='25', 'num_nulls'='0', 'min_value'='0', 'max_value'='24', 'row_count'='10000000'); +''' + +sql ''' +alter table supplier modify column s_phone set stats ('ndv'='9975965', 'num_nulls'='0', 'min_value'='10-100-101-9215', 'max_value'='34-999-999-3239', 'row_count'='10000000'); +''' + +sql ''' +alter table supplier modify column s_acctbal set stats ('ndv'='1109296', 'num_nulls'='0', 'min_value'='-999.99', 'max_value'='9999.99', 'row_count'='10000000'); +''' + +sql ''' +alter table supplier modify column s_comment set stats ('ndv'='9854117', 'num_nulls'='0', 'min_value'=' Customer accounts are blithely furiousRecommends', 'max_value'='zzle? special packages haggle carefully regular inst', 'row_count'='10000000'); +''' + + + +sql ''' +alter table customer modify column c_custkey set stats ('ndv'='151682592', 'num_nulls'='0', 'min_value'='1', 'max_value'='150000000', 'row_count'='150000000'); +''' + +sql ''' +alter table customer modify column c_name set stats ('ndv'='149989056', 'num_nulls'='0', 'min_value'='Customer#000000001', 'max_value'='Customer#150000000', 'row_count'='150000000'); +''' + +sql ''' +alter table customer modify column c_address set stats ('ndv'='149316720', 'num_nulls'='0', 'min_value'=' 2WGW,hiM7jHg2', 'max_value'='zzzzyW,aeC8HnFV', 'row_count'='150000000'); +''' + +sql ''' +alter table customer modify column c_nationkey set stats ('ndv'='25', 'num_nulls'='0', 'min_value'='0', 'max_value'='24', 'row_count'='150000000'); +''' + +sql ''' +alter table customer modify column c_phone set stats ('ndv'='150226160', 'num_nulls'='0', 'min_value'='10-100-100-3024', 'max_value'='34-999-999-9215', 'row_count'='150000000'); +''' + +sql ''' +alter table customer modify column c_acctbal set stats ('ndv'='1109296', 'num_nulls'='0', 'min_value'='-999.99', 'max_value'='9999.99', 'row_count'='150000000'); +''' + +sql ''' +alter table customer modify column c_mktsegment set stats ('ndv'='5', 'num_nulls'='0', 'min_value'='AUTOMOBILE', 'max_value'='MACHINERY', 'row_count'='150000000'); +''' + +sql ''' +alter table customer modify column c_comment set stats ('ndv'='120255488', 'num_nulls'='0', 'min_value'=' Tiresias about the accounts haggle quiet, busy foxe', 'max_value'='zzle? special accounts about the iro', 'row_count'='150000000'); +''' + + + +sql ''' +alter table region modify column r_regionkey set stats ('ndv'='5', 'num_nulls'='0', 'min_value'='0', 'max_value'='4', 'row_count'='5'); +''' + +sql ''' +alter table region modify column r_name set stats ('ndv'='5', 'num_nulls'='0', 'min_value'='AFRICA', 'max_value'='MIDDLE EAST', 'row_count'='5'); +''' + +sql ''' +alter table region modify column r_comment set stats ('ndv'='5', 'num_nulls'='0', 'min_value'='ges. thinly even pinto beans ca', 'max_value'='uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl', 'row_count'='5'); +''' + + + +sql ''' +alter table nation modify column n_nationkey set stats ('ndv'='25', 'num_nulls'='0', 'min_value'='0', 'max_value'='24', 'row_count'='25'); +''' + +sql ''' +alter table nation modify column n_name set stats ('ndv'='25', 'num_nulls'='0', 'min_value'='ALGERIA', 'max_value'='VIETNAM', 'row_count'='25'); +''' + +sql ''' +alter table nation modify column n_regionkey set stats ('ndv'='5', 'num_nulls'='0', 'min_value'='0', 'max_value'='4', 'row_count'='25'); +''' + +sql ''' +alter table nation modify column n_comment set stats ('ndv'='25', 'num_nulls'='0', 'min_value'=' haggle. carefully final deposits detect slyly agai', 'max_value'='y final packages. slow foxes cajole quickly. quickly silent platelets breach ironic accounts. unusual pinto be', 'row_count'='25'); +''' + + // ---- primary key / foreign key / unique key constraints ---- + sql """alter table region add constraint r_pk primary key (r_regionkey);""" + sql """alter table nation add constraint n_pk primary key (n_nationkey);""" + sql """alter table supplier add constraint s_pk primary key (s_suppkey);""" + sql """alter table customer add constraint c_pk primary key (c_custkey);""" + sql """alter table part add constraint p_pk primary key (p_partkey);""" + sql """alter table partsupp add constraint ps_pk primary key (ps_partkey, ps_suppkey);""" + sql """alter table orders add constraint o_pk primary key (o_orderkey);""" + sql """alter table lineitem add constraint l_pk primary key (l_orderkey, l_linenumber);""" + sql """alter table nation add constraint n_r_fk foreign key (n_regionkey) references region(r_regionkey);""" + sql """alter table supplier add constraint s_n_fk foreign key (s_nationkey) references nation(n_nationkey);""" + sql """alter table customer add constraint c_n_fk foreign key (c_nationkey) references nation(n_nationkey);""" + sql """alter table partsupp add constraint ps_p_fk foreign key (ps_partkey) references part(p_partkey);""" + sql """alter table partsupp add constraint ps_s_fk foreign key (ps_suppkey) references supplier(s_suppkey);""" + sql """alter table orders add constraint o_c_fk foreign key (o_custkey) references customer(c_custkey);""" + sql """alter table lineitem add constraint l_o_fk foreign key (l_orderkey) references orders(o_orderkey);""" + sql """alter table lineitem add constraint l_p_fk foreign key (l_partkey) references part(p_partkey);""" + sql """alter table lineitem add constraint l_s_fk foreign key (l_suppkey) references supplier(s_suppkey);""" + sql """alter table lineitem add constraint l_ps_fk foreign key (l_partkey, l_suppkey) references partsupp(ps_partkey, ps_suppkey);""" + sql """alter table region add constraint r_uk unique (r_name);""" + sql """alter table nation add constraint n_uk unique (n_name);""" +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q1.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q1.groovy new file mode 100644 index 00000000000000..50fc3c2509f812 --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q1.groovy @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q1_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set parallel_pipeline_task_num=8' + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" + sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + + qt_select """ + explain shape plan + select + l_returnflag, + l_linestatus, + sum(l_quantity) as sum_qty, + sum(l_extendedprice) as sum_base_price, + sum(l_extendedprice * (1 - l_discount)) as sum_disc_price, + sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge, + avg(l_quantity) as avg_qty, + avg(l_extendedprice) as avg_price, + avg(l_discount) as avg_disc, + count(*) as count_order + from + lineitem + where + l_shipdate <= date '1998-12-01' - interval '90' day + group by + l_returnflag, + l_linestatus + order by + l_returnflag, + l_linestatus; + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q10.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q10.groovy new file mode 100644 index 00000000000000..9c0a7272fc8024 --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q10.groovy @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q10_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set parallel_pipeline_task_num=8' + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + qt_select """ + explain shape plan + select + c_custkey, + c_name, + sum(l_extendedprice * (1 - l_discount)) as revenue, + c_acctbal, + n_name, + c_address, + c_phone, + c_comment + from + customer, + orders, + lineitem, + nation + where + c_custkey = o_custkey + and l_orderkey = o_orderkey + and o_orderdate >= date '1993-10-01' + and o_orderdate < date '1993-10-01' + interval '3' month + and l_returnflag = 'R' + and c_nationkey = n_nationkey + group by + c_custkey, + c_name, + c_acctbal, + c_phone, + n_name, + c_address, + c_comment + order by + revenue desc + limit 20; + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q11.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q11.groovy new file mode 100644 index 00000000000000..75048e20819000 --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q11.groovy @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q11_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + sql 'set parallel_pipeline_task_num=8' + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + + + + qt_select """ + explain shape plan + select + ps_partkey, + sum(ps_supplycost * ps_availqty) as value + from + partsupp, + supplier, + nation + where + ps_suppkey = s_suppkey + and s_nationkey = n_nationkey + and n_name = 'GERMANY' + group by + ps_partkey having + sum(ps_supplycost * ps_availqty) > ( + select + sum(ps_supplycost * ps_availqty) * 0.000002 + from + partsupp, + supplier, + nation + where + ps_suppkey = s_suppkey + and s_nationkey = n_nationkey + and n_name = 'GERMANY' + ) + order by + value desc; + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q12.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q12.groovy new file mode 100644 index 00000000000000..c5e8a9ce4f71ae --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q12.groovy @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q12_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + sql 'set parallel_pipeline_task_num=8' + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + qt_select """ + explain shape plan + select + l_shipmode, + sum(case + when o_orderpriority = '1-URGENT' + or o_orderpriority = '2-HIGH' + then 1 + else 0 + end) as high_line_count, + sum(case + when o_orderpriority <> '1-URGENT' + and o_orderpriority <> '2-HIGH' + then 1 + else 0 + end) as low_line_count + from + orders, + lineitem + where + o_orderkey = l_orderkey + and l_shipmode in ('MAIL', 'SHIP') + and l_commitdate < l_receiptdate + and l_shipdate < l_commitdate + and l_receiptdate >= date '1994-01-01' + and l_receiptdate < date '1994-01-01' + interval '1' year + group by + l_shipmode + order by + l_shipmode; + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q13.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q13.groovy new file mode 100644 index 00000000000000..ba33300c3c6156 --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q13.groovy @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q13_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set parallel_pipeline_task_num=8' + + + + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + qt_select """ + explain shape plan + select + c_count, + count(*) as custdist + from + ( + select + c_custkey, + count(o_orderkey) as c_count + from + customer left outer join orders on + c_custkey = o_custkey + and o_comment not like '%special%requests%' + group by + c_custkey + ) as c_orders + group by + c_count + order by + custdist desc, + c_count desc; + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q14.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q14.groovy new file mode 100644 index 00000000000000..785cd0b751114a --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q14.groovy @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q14_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set parallel_pipeline_task_num=8' + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + qt_select """ + explain shape plan + select + 100.00 * sum(case + when p_type like 'PROMO%' + then l_extendedprice * (1 - l_discount) + else 0 + end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue + from + lineitem, + part + where + l_partkey = p_partkey + and l_shipdate >= date '1995-09-01' + and l_shipdate < date '1995-09-01' + interval '1' month; + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q15.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q15.groovy new file mode 100644 index 00000000000000..d5e83162eafafd --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q15.groovy @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q15_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set parallel_pipeline_task_num=8' + + + + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + + qt_select """ + explain shape plan + select + s_suppkey, + s_name, + s_address, + s_phone, + total_revenue + from + supplier, + revenue0 + where + s_suppkey = supplier_no + and total_revenue = ( + select + max(total_revenue) + from + revenue0 + ) + order by + s_suppkey; + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q16.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q16.groovy new file mode 100644 index 00000000000000..99a4aa32af4cd4 --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q16.groovy @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q16_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set parallel_pipeline_task_num=8' + + + + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + + qt_select """ + explain shape plan + select + p_brand, + p_type, + p_size, + count(distinct ps_suppkey) as supplier_cnt + from + partsupp, + part + where + p_partkey = ps_partkey + and p_brand <> 'Brand#45' + and p_type not like 'MEDIUM POLISHED%' + and p_size in (49, 14, 23, 45, 19, 3, 36, 9) + and ps_suppkey not in ( + select + s_suppkey + from + supplier + where + s_comment like '%Customer%Complaints%' + ) + group by + p_brand, + p_type, + p_size + order by + supplier_cnt desc, + p_brand, + p_type, + p_size; + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q17.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q17.groovy new file mode 100644 index 00000000000000..d08c1bce1bd63e --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q17.groovy @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q17_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set parallel_pipeline_task_num=8' + + + + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + + qt_select """ + explain shape plan + select + sum(l_extendedprice) / 7.0 as avg_yearly + from + lineitem, + part + where + p_partkey = l_partkey + and p_brand = 'Brand#23' + and p_container = 'MED BOX' + and l_quantity < ( + select + 0.2 * avg(l_quantity) + from + lineitem + where + l_partkey = p_partkey + ); + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q18.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q18.groovy new file mode 100644 index 00000000000000..00e4590bf83012 --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q18.groovy @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q18_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set parallel_pipeline_task_num=8' + + + + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + + qt_select """ + explain shape plan + select + c_name, + c_custkey, + o_orderkey, + o_orderdate, + o_totalprice, + sum(l_quantity) + from + customer, + orders, + lineitem + where + o_orderkey in ( + select + l_orderkey + from + lineitem + group by + l_orderkey having + sum(l_quantity) > 300 + ) + and c_custkey = o_custkey + and o_orderkey = l_orderkey + group by + c_name, + c_custkey, + o_orderkey, + o_orderdate, + o_totalprice + order by + o_totalprice desc, + o_orderdate + limit 100; + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q19.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q19.groovy new file mode 100644 index 00000000000000..4ccd0609525247 --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q19.groovy @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q19_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set parallel_pipeline_task_num=8' + + + + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + + qt_select """ + explain shape plan + select + sum(l_extendedprice* (1 - l_discount)) as revenue + from + lineitem, + part + where + ( + p_partkey = l_partkey + and p_brand = 'Brand#12' + and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') + and l_quantity >= 1 and l_quantity <= 1 + 10 + and p_size between 1 and 5 + and l_shipmode in ('AIR', 'AIR REG') + and l_shipinstruct = 'DELIVER IN PERSON' + ) + or + ( + p_partkey = l_partkey + and p_brand = 'Brand#23' + and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') + and l_quantity >= 10 and l_quantity <= 10 + 10 + and p_size between 1 and 10 + and l_shipmode in ('AIR', 'AIR REG') + and l_shipinstruct = 'DELIVER IN PERSON' + ) + or + ( + p_partkey = l_partkey + and p_brand = 'Brand#34' + and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') + and l_quantity >= 20 and l_quantity <= 20 + 10 + and p_size between 1 and 15 + and l_shipmode in ('AIR', 'AIR REG') + and l_shipinstruct = 'DELIVER IN PERSON' + ); + + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q2.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q2.groovy new file mode 100644 index 00000000000000..00b5f0fca7d7fc --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q2.groovy @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q2_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set parallel_pipeline_task_num=8' + + + + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + + qt_select """ + explain shape plan + select + s_acctbal, + s_name, + n_name, + p_partkey, + p_mfgr, + s_address, + s_phone, + s_comment + from + part, + supplier, + partsupp, + nation, + region + where + p_partkey = ps_partkey + and s_suppkey = ps_suppkey + and p_size = 15 + and p_type like '%BRASS' + and s_nationkey = n_nationkey + and n_regionkey = r_regionkey + and r_name = 'EUROPE' + and ps_supplycost = ( + select + min(ps_supplycost) + from + partsupp, + supplier, + nation, + region + where + p_partkey = ps_partkey + and s_suppkey = ps_suppkey + and s_nationkey = n_nationkey + and n_regionkey = r_regionkey + and r_name = 'EUROPE' + ) + order by + s_acctbal desc, + n_name, + s_name, + p_partkey + limit 100; + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q20-rewrite.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q20-rewrite.groovy new file mode 100644 index 00000000000000..e535459836b858 --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q20-rewrite.groovy @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q20-rewrite_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + sql 'set parallel_pipeline_task_num=8' + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + + + + + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + + qt_select """ + explain shape plan +select +s_name, s_address +from +supplier left semi join +( + select * from + ( + select l_partkey,l_suppkey, 0.5 * sum(l_quantity) as l_q + from lineitem + where l_shipdate >= date '1994-01-01' + and l_shipdate < date '1994-01-01' + interval '1' year + group by l_partkey,l_suppkey + ) t2 join + ( + select ps_partkey, ps_suppkey, ps_availqty + from partsupp left semi join part + on ps_partkey = p_partkey and p_name like 'forest%' + ) t1 + on t2.l_partkey = t1.ps_partkey and t2.l_suppkey = t1.ps_suppkey + and t1.ps_availqty > t2.l_q +) t3 +on s_suppkey = t3.ps_suppkey +join nation +where s_nationkey = n_nationkey + and n_name = 'CANADA' +order by s_name +; + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q20.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q20.groovy new file mode 100644 index 00000000000000..e9d8f581f7376a --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q20.groovy @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q20_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set parallel_pipeline_task_num=8' + + + + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + + qt_select """ + explain shape plan + select + s_name, + s_address + from + supplier, + nation + where + s_suppkey in ( + select + ps_suppkey + from + partsupp + where + ps_partkey in ( + select + p_partkey + from + part + where + p_name like 'forest%' + ) + and ps_availqty > ( + select + 0.5 * sum(l_quantity) + from + lineitem + where + l_partkey = ps_partkey + and l_suppkey = ps_suppkey + and l_shipdate >= date '1994-01-01' + and l_shipdate < date '1994-01-01' + interval '1' year + ) + ) + and s_nationkey = n_nationkey + and n_name = 'CANADA' + order by + s_name; + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q21.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q21.groovy new file mode 100644 index 00000000000000..b8f05a81325eea --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q21.groovy @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q21_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set parallel_pipeline_task_num=8' + + + + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + + qt_select """ + explain shape plan + select + s_name, + count(*) as numwait + from + supplier, + lineitem l1, + orders, + nation + where + s_suppkey = l1.l_suppkey + and o_orderkey = l1.l_orderkey + and o_orderstatus = 'F' + and l1.l_receiptdate > l1.l_commitdate + and exists ( + select + * + from + lineitem l2 + where + l2.l_orderkey = l1.l_orderkey + and l2.l_suppkey <> l1.l_suppkey + ) + and not exists ( + select + * + from + lineitem l3 + where + l3.l_orderkey = l1.l_orderkey + and l3.l_suppkey <> l1.l_suppkey + and l3.l_receiptdate > l3.l_commitdate + ) + and s_nationkey = n_nationkey + and n_name = 'SAUDI ARABIA' + group by + s_name + order by + numwait desc, + s_name + limit 100; + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q22.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q22.groovy new file mode 100644 index 00000000000000..6a75a40d221423 --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q22.groovy @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q22_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set parallel_pipeline_task_num=8' + + + + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + + qt_select """ + explain shape plan + select + cntrycode, + count(*) as numcust, + sum(c_acctbal) as totacctbal + from + ( + select + substring(c_phone, 1, 2) as cntrycode, + c_acctbal + from + customer + where + substring(c_phone, 1, 2) in + ('13', '31', '23', '29', '30', '18', '17') + and c_acctbal > ( + select + avg(c_acctbal) + from + customer + where + c_acctbal > 0.00 + and substring(c_phone, 1, 2) in + ('13', '31', '23', '29', '30', '18', '17') + ) + and not exists ( + select + * + from + orders + where + o_custkey = c_custkey + ) + ) as custsale + group by + cntrycode + order by + cntrycode; + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q3.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q3.groovy new file mode 100644 index 00000000000000..ecadcc434af649 --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q3.groovy @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q3_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + // db = "tpch" + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set parallel_pipeline_task_num=8' + + + + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + + qt_select """ + explain shape plan + select + l_orderkey, + sum(l_extendedprice * (1 - l_discount)) as revenue, + o_orderdate, + o_shippriority + from + customer, + orders, + lineitem + where + c_mktsegment = 'BUILDING' + and c_custkey = o_custkey + and l_orderkey = o_orderkey + and o_orderdate < date '1995-03-15' + and l_shipdate > date '1995-03-15' + group by + l_orderkey, + o_orderdate, + o_shippriority + order by + revenue desc, + o_orderdate + limit 10; + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q4.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q4.groovy new file mode 100644 index 00000000000000..297b997931a7bf --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q4.groovy @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q4_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql 'set parallel_pipeline_task_num=8' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + + + + + qt_select """ + explain shape plan + select + o_orderpriority, + count(*) as order_count + from + orders + where + o_orderdate >= date '1993-07-01' + and o_orderdate < date '1993-07-01' + interval '3' month + and exists ( + select + * + from + lineitem + where + l_orderkey = o_orderkey + and l_commitdate < l_receiptdate + ) + group by + o_orderpriority + order by + o_orderpriority; + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q5.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q5.groovy new file mode 100644 index 00000000000000..534a6e2dde37c0 --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q5.groovy @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q5_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set parallel_pipeline_task_num=8' + + + + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + + qt_select """ + explain shape plan + select + n_name, + sum(l_extendedprice * (1 - l_discount)) as revenue + from + customer, + orders, + lineitem, + supplier, + nation, + region + where + c_custkey = o_custkey + and l_orderkey = o_orderkey + and l_suppkey = s_suppkey + and c_nationkey = s_nationkey + and s_nationkey = n_nationkey + and n_regionkey = r_regionkey + and r_name = 'ASIA' + and o_orderdate >= date '1994-01-01' + and o_orderdate < date '1994-01-01' + interval '1' year + group by + n_name + order by + revenue desc; + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q6.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q6.groovy new file mode 100644 index 00000000000000..4668f425708642 --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q6.groovy @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q6_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set parallel_pipeline_task_num=8' + + + + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + + qt_select """ + explain shape plan + select + sum(l_extendedprice * l_discount) as revenue + from + lineitem + where + l_shipdate >= date '1994-01-01' + and l_shipdate < date '1994-01-01' + interval '1' year + and l_discount between .06 - 0.01 and .06 + 0.01 + and l_quantity < 24; + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q7.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q7.groovy new file mode 100644 index 00000000000000..5d5868fc9e2d5f --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q7.groovy @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q7_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set parallel_pipeline_task_num=8' + + + + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + + qt_select """ + explain shape plan + select + supp_nation, + cust_nation, + l_year, + sum(volume) as revenue + from + ( + select + n1.n_name as supp_nation, + n2.n_name as cust_nation, + extract(year from l_shipdate) as l_year, + l_extendedprice * (1 - l_discount) as volume + from + supplier, + lineitem, + orders, + customer, + nation n1, + nation n2 + where + s_suppkey = l_suppkey + and o_orderkey = l_orderkey + and c_custkey = o_custkey + and s_nationkey = n1.n_nationkey + and c_nationkey = n2.n_nationkey + and ( + (n1.n_name = 'FRANCE' and n2.n_name = 'GERMANY') + or (n1.n_name = 'GERMANY' and n2.n_name = 'FRANCE') + ) + and l_shipdate between date '1995-01-01' and date '1996-12-31' + ) as shipping + group by + supp_nation, + cust_nation, + l_year + order by + supp_nation, + cust_nation, + l_year; + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q8.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q8.groovy new file mode 100644 index 00000000000000..7a875f6578b2f7 --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q8.groovy @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q8_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set parallel_pipeline_task_num=8' + + + + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + + qt_select """ + explain shape plan + select + o_year, + sum(case + when nation = 'BRAZIL' then volume + else 0 + end) / sum(volume) as mkt_share + from + ( + select + extract(year from o_orderdate) as o_year, + l_extendedprice * (1 - l_discount) as volume, + n2.n_name as nation + from + part, + supplier, + lineitem, + orders, + customer, + nation n1, + nation n2, + region + where + p_partkey = l_partkey + and s_suppkey = l_suppkey + and l_orderkey = o_orderkey + and o_custkey = c_custkey + and c_nationkey = n1.n_nationkey + and n1.n_regionkey = r_regionkey + and r_name = 'AMERICA' + and s_nationkey = n2.n_nationkey + and o_orderdate between date '1995-01-01' and date '1996-12-31' + and p_type = 'ECONOMY ANODIZED STEEL' + ) as all_nations + group by + o_year + order by + o_year; + """ +} diff --git a/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q9.groovy b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q9.groovy new file mode 100644 index 00000000000000..1a76f9f5167e49 --- /dev/null +++ b/regression-test/suites/shape_check/tpch_sf1000_constraints/shape/q9.groovy @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +suite("q9_constraints") { + String db = context.config.getDbNameByFile(new File(context.file.parent)) + if (isCloudMode()) { + return + } + sql "use ${db}" + sql 'set enable_nereids_planner=true' + sql 'set enable_nereids_distribute_planner=false' + sql 'set enable_fallback_to_original_planner=false' + sql "set runtime_filter_mode='GLOBAL'" + + sql 'set exec_mem_limit=21G' + sql 'SET enable_pipeline_engine = true' + sql 'set parallel_pipeline_task_num=8' + + + + sql 'set be_number_for_test=3' + sql "set runtime_filter_type=8" +sql 'set enable_runtime_filter_prune=false' + sql "set disable_nereids_rules=PRUNE_EMPTY_PARTITION" + + + qt_select """ + explain shape plan + select + nation, + o_year, + sum(amount) as sum_profit + from + ( + select + n_name as nation, + extract(year from o_orderdate) as o_year, + l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount + from + part, + supplier, + lineitem, + partsupp, + orders, + nation + where + s_suppkey = l_suppkey + and ps_suppkey = l_suppkey + and ps_partkey = l_partkey + and p_partkey = l_partkey + and o_orderkey = l_orderkey + and s_nationkey = n_nationkey + and p_name like '%green%' + ) as profit + group by + nation, + o_year + order by + nation, + o_year desc; + """ +}