github-actions[bot] commented on code in PR #68499:
URL: https://github.com/apache/doris/pull/68499#discussion_r4679895623
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/Plan.java:
##########
@@ -194,6 +201,49 @@ default String treeString(boolean printStates) {
String treeString(boolean printStates, Object specialPlan);
+ /**
+ * SPM-specific full-query digest (design doc 6.1 / 6.14): the
parameterized full
+ * SQL of this plan with literal values normalized to "?"
(value-independent),
+ * including table names. Used for the SPM Level 2 exact digest matching
and shown in
+ * SHOW BASELINE PLANS as bind_sql_digest.
+ *
+ * This is a dedicated entry point for SPM, decoupled from toDigest()
+ * (Doris's query fingerprint used by audit / blocking rules); toDigest()
is
+ * intentionally left unmodified and toSpmDigest() may evolve
independently.
+ *
+ * The entry toggles {@link #SPM_DIGEST_MODE} around the toDigest() walk:
every node
+ * that renders an SPM-specific identity (a hint list, the WITH recursion
flag, the
+ * positional alias list, an unnest mode flag, the VALUES shape) adds it
INSIDE its own
+ * toDigest() while the mode is on. Without the mode a node whose
toDigest() renders
+ * its child through child().toDigest() - or asks an intermediate default
node to do so -
+ * silently DROPPED every nested SPM identity, so two variants of a
statement that
+ * differ only in a hint inside a SUBQUERY block shared one digest and the
second
+ * GLOBAL CREATE was confirmed as a duplicate of the first
+ * (see SPMPlanner#assembleBaseline).
+ */
+ default String toSpmDigest() {
Review Comment:
[P1] Include wrapper children in the SPM digest
`LogicalAssertNumRows` inherits the empty `TreeNode.toDigest()`, so this
forwarding entry drops its entire input. With `t(k)={1}` and `u(k)={2}`,
capture `SELECT a.k-b.k AS d FROM ASSERT_ROWS (SELECT k FROM t) a CROSS JOIN
ASSERT_ROWS (SELECT k FROM u) b`:
```text
Project(a.k-b.k AS d)
CrossJoin
Alias a -> AssertRows -> Scan(t)
Alias b -> AssertRows -> Scan(u)
```
Now execute the same SQL with only t/u exchanged inside the assertions. Both
assertions hold, but the outer digest and AST shapes remain equal.
`sameScanIdentity` deliberately omits table names, trusting the digest, and the
schema fingerprint still sees the same set {t,u}. Both replay paths therefore
keep the captured pairing and return -1 instead of the caller's +1;
output/cap/order checks do not catch it. `LogicalPreAggOnHint` has the same
omission for the supported trailing `/*+PREAGGOPEN*/` form. Make parseable
wrappers include their children in the SPM digest, or validate qualified
relation identity per occurrence. This differs from the earlier assertion
serialization/boundary findings.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/spm/placeholder/SPMPlaceholderBuilder.java:
##########
@@ -0,0 +1,1468 @@
+// 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.
+
+package org.apache.doris.nereids.spm.placeholder;
+
+import org.apache.doris.catalog.FunctionSignature;
+import org.apache.doris.nereids.analyzer.UnboundFunction;
+import org.apache.doris.nereids.spm.SPMPlanTreeSupport;
+import org.apache.doris.nereids.trees.expressions.And;
+import org.apache.doris.nereids.trees.expressions.CaseWhen;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.InPredicate;
+import org.apache.doris.nereids.trees.expressions.InSubquery;
+import org.apache.doris.nereids.trees.expressions.Like;
+import org.apache.doris.nereids.trees.expressions.Not;
+import org.apache.doris.nereids.trees.expressions.Or;
+import org.apache.doris.nereids.trees.expressions.SubqueryExpr;
+import org.apache.doris.nereids.trees.expressions.WhenClause;
+import org.apache.doris.nereids.trees.expressions.WindowExpression;
+import org.apache.doris.nereids.trees.expressions.functions.BoundFunction;
+import org.apache.doris.nereids.trees.expressions.functions.Function;
+import
org.apache.doris.nereids.trees.expressions.functions.scalar.CreateNamedStruct;
+import
org.apache.doris.nereids.trees.expressions.functions.scalar.CreateStruct;
+import org.apache.doris.nereids.trees.expressions.functions.scalar.ElementAt;
+import org.apache.doris.nereids.trees.expressions.functions.scalar.Lambda;
+import org.apache.doris.nereids.trees.expressions.literal.ArrayLiteral;
+import org.apache.doris.nereids.trees.expressions.literal.Literal;
+import org.apache.doris.nereids.trees.expressions.literal.MapLiteral;
+import org.apache.doris.nereids.trees.expressions.literal.NullLiteral;
+import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
+import org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
+import org.apache.doris.nereids.types.ArrayType;
+import org.apache.doris.nereids.types.BooleanType;
+import org.apache.doris.nereids.types.DataType;
+import org.apache.doris.nereids.types.MapType;
+import org.apache.doris.nereids.types.StringType;
+import org.apache.doris.nereids.types.coercion.AnyDataType;
+import org.apache.doris.nereids.types.coercion.FollowToAnyDataType;
+import org.apache.doris.nereids.types.coercion.FollowToArgumentType;
+
+import com.google.common.collect.ImmutableList;
+
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Predicate;
+
+/**
+ * Parameterizes supported literal positions with scalar or IN-list markers.
One builder retains marker records and
+ * allocates ids across bind and plan trees. Reuse requires the same value,
parent signature, child position, query
+ * block, projection item, expression-root ordinal and occurrence path. GROUP
BY mirrors can deliberately reuse a
+ * transformed expression to preserve analyzer equality.
+ *
+ * Syntax-bearing literals such as LIKE escape arguments are kept concrete.
Some NULL payloads are retyped for
+ * capture analysis so their markers survive Boolean consumers; replay still
substitutes the matched query
+ * expression.
+ */
+public class SPMPlaceholderBuilder extends ExpressionVisitor<Expression,
Expression>
+ implements SPMPlanTreeSupport.ExprTransform {
+
+ /**
+ * The ARRAY scalar functions that declare retArgType(0): each one's
result IS its
+ * first argument's array type, so an all-NULL input makes the whole
result an all-NULL array.
+ *
+ * They are exactly the wrappers a projected all-NULL container can sit
UNDER while the
+ * enclosing call is still consumed as a Boolean operand, e.g.
+ * k > 0 OR element_at(array_reverse_sort(array(NULL)), 1): the wrapper
hands
+ * array(NULL)'s NullType element type to element_at, so the marker has to
be
+ * repaired at the WRAPPER's argument position. Matching only array_sort /
+ * array_distinct left every other member of the family unrecognized.
+ *
+ * Matched by NAME because the capture runs on the PARSE tree, where the
call is still an
+ * unbound Function and no signature is resolved yet; a BOUND node is
classified from
+ * its retArgType(0) signature instead (see followsFirstArgument), so a
function added
+ * to the family is recognized without touching this list. array_concat is
NOT here:
+ * it derives its element type from EVERY part and is handled separately
+ * (isArrayConcatCall).
+ */
+ private static final Set<String> TYPE_PRESERVING_ARRAY_CALLS = Set.of(
+ "array_apply", "array_compact", "array_difference",
"array_distinct",
+ "array_except", "array_except_all", "array_filter", "array_first",
+ "array_intersect", "array_last", "array_popback", "array_popfront",
+ "array_pushback", "array_pushfront", "array_remove",
"array_reverse_sort",
+ "array_shuffle", "array_slice", "array_sort", "array_sortby",
"array_union",
+ "reverse", "trim_array");
+
+ /**
+ * MAP functions that preserve the key and value types of their first
argument.
+ * DeduplicateMap follows both type groups, while MapFilter declares
retArgType(0).
+ */
+ private static final Set<String> TYPE_PRESERVING_MAP_CALLS =
Set.of("deduplicate_map", "map_filter");
+ private static final int NO_MAP_KEY_DEPENDENCY = -1;
+
+ /** Auto-increment placeholder id counter (starts at 1). */
+ private long nextId = 1;
+
+ private final Map<PlaceholderKey, Expression> placeholderIndex = new
HashMap<>();
+ private final Map<Expression, String> parentSignatures = new
IdentityHashMap<>();
+
+ /**
+ * Optional GROUP BY mirror lookup, installed by
SPMPlanTreeSupport.TreeTransformer for
+ * one clause window (see setGroupByMirrorLookup): maps an expression's
+ * pre-parameterization text to the ALREADY-transformed GROUP BY
expression that must
+ * be reused - also for NESTED subexpressions (e.g. the substr(...) inside
+ * "HAVING substr(...) = 'x'"), because the analyzer resolves such a clause
+ * expression-wise and demands literal expression equality with the GROUP
BY under
+ * ONLY_FULL_GROUP_BY. Null outside the window.
+ */
+ private java.util.function.Function<String, Expression>
groupByMirrorLookup;
+
+ /**
+ * DFS stack of child positions: the top is the index of the expression
currently
+ * being visited inside its direct parent (empty = parent-less root). Two
literals
+ * under the same parent (e.g. the operands of "1 + 1") are different
positions and
+ * must never reuse one placeholder id.
+ */
+ private final Deque<Integer> childIndexStack = new ArrayDeque<>();
+
+ /**
+ * Query-block identity: incremented when entering a nested query block
(the plan of
+ * a subquery expression). Two literals in DIFFERENT blocks never share a
placeholder
+ * id even when value / parent / position coincide: in
+ * SELECT * FROM t WHERE a=1 AND EXISTS (SELECT 1 FROM u WHERE a=1) the
two a=1
+ * literals used to reuse one id, and a user query with outer a=2 / inner
a=3 was
+ * rejected (one id must resolve to ONE value), so the baseline could
never hit.
+ * The counter restarts per tree (see startNewTree): bind and plan trees
traverse the
+ * same structure in the same order, so corresponding blocks keep
corresponding
+ * numbers and the cross-tree id alignment is preserved.
+ */
+ private long nextBlockId = 1;
+ private long currentBlockId = 0;
+
+ /**
+ * Enclosing query-block ids (see enterQueryBlock): a nested block's id is
+ * restored on exit, so SIBLING derived tables / CTE bodies get distinct
ids while the
+ * enclosing block numbering resumes - the same discipline the
subquery-expression
+ * blocks already followed.
+ */
+ private final Deque<Long> blockIdStack = new ArrayDeque<>();
+
+ /**
+ * Projection ITEM positions of the SELECT-list slots currently being
visited (see
+ * enterProjectionItem(int)): SELECT 1 AS x, 1 AS y must give its two
+ * literals different placeholder ids although value, parent structure and
child
+ * position coincide (see PlaceholderKey).
+ */
+ private final Deque<Integer> projectItemStack = new ArrayDeque<>();
+
+ /**
+ * Ordinal of the expression ROOT currently being transformed, counted per
query block in
+ * walk order (see beginExpressionRoot): two equal literals in DIFFERENT
roots of one
+ * block (the ON clauses of two joins, two conjuncts of one filter,...)
used to share one
+ * placeholder id although they are independent slots - a query that
varies them
+ * separately (1/1 -> 2/3) was then rejected by recordPlaceholderValue and
the saved
+ * baseline could never be used. The counting restarts
+ * per tree run AND per block, so the bind and plan trees of one baseline
traverse the
+ * same structure in the same order and corresponding roots keep
corresponding ordinals.
+ */
+ private long nextRootOrdinal = 0;
+ private long currentRootOrdinal = -1;
+
+ /**
+ * Depth of an all-NULL CONDITIONAL (CASE / IF / COALESCE) currently
visited in a Boolean
+ * context (see markerPayload): such a node has NullType and the analyzer
replaces the whole
+ * operand with a typed constant, so its branch NULLs are parameterized
BOOLEAN.
+ */
+ private int booleanConditionalDepth;
+
+ /**
+ * Depth of an all-NULL container producer whose ELEMENTS / VALUES are the
markers that carry
+ * the container's element type (see markerPayload): an all-NULL element
list is what makes
+ * the constructor NullType, so its NULL elements are parameterized
BOOLEAN while the
+ * constructor itself sits in a container position of a NullType-producing
chain.
+ */
+ private int containerElementDepth;
+
+ /** Number of array items or map values before reaching the key selected
by MAP_KEYS. */
+ private int mapKeyDepth = NO_MAP_KEY_DEPENDENCY;
+
+ /**
+ * Whether a GROUP BY ordinal references a parameterized SELECT item.
Analysis can inline
+ * that expression and the physical grouping can lose its binding to the
original item.
+ * Keep the parameterized tree so replay binds the ordinal against the
caller's values.
+ */
+ private boolean parameterizedGroupByOrdinalTarget;
+
+ /** The enclosing block's root-ordinal counter, restored by
exitQueryBlock. */
+ private final Deque<Long> rootOrdinalStack = new ArrayDeque<>();
+
+ /** The enclosing root's ordinal, restored by exitQueryBlock (see
enterQueryBlock). */
+ private final Deque<Long> currentRootOrdinalStack = new ArrayDeque<>();
+
+ /** Installs / clears the GROUP BY mirror lookup window (null = disabled).
*/
+ @Override
+ public void setGroupByMirrorLookup(java.util.function.Function<String,
Expression> lookup) {
+ this.groupByMirrorLookup = lookup;
+ }
+
+ /** Reports whether capture must keep the parameterized tree for a GROUP
BY ordinal. */
+ public boolean hasParameterizedGroupByOrdinalTarget() {
+ return parameterizedGroupByOrdinalTarget;
+ }
+
+ /** Marks a GROUP BY ordinal whose SELECT item carries placeholders. */
+ @Override
+ public void noteParameterizedGroupByOrdinalTarget() {
+ this.parameterizedGroupByOrdinalTarget = true;
+ }
+
+ /** Starts one expression ROOT of the current block (see nextRootOrdinal).
*/
+ private void beginExpressionRoot() {
+ currentRootOrdinal = nextRootOrdinal++;
+ }
+
+ /** Restarts the per-tree query-block numbering (a tree's root block is
0). */
+ public void startNewTree() {
+ nextBlockId = 1;
+ currentBlockId = 0;
+ blockIdStack.clear();
+ projectItemStack.clear();
+ // one tree = one root-ordinal run: corresponding roots of the bind
tree and the
+ // (separately parsed) plan tree keep corresponding ordinals
+ nextRootOrdinal = 0;
+ currentRootOrdinal = -1;
+ rootOrdinalStack.clear();
+ currentRootOrdinalStack.clear();
+ }
+
+ /**
+ * The whole-tree parameterization transform: the builder IS an
+ * SPMPlanTreeSupport.ExprTransform, so the plan walk can hand it the query
+ * BLOCK and projection ITEM scopes of the expressions it visits (see
+ * SPMPlanTreeSupport.ExprTransform.enterQueryBlock). Passing a bare lambda
+ * instead would lose those scopes and merge independent literals into one
placeholder
+ * id.
+ */
+ @Override
+ public Expression apply(Expression expr) {
+ beginExpressionRoot();
+ return expr.accept(this, null);
+ }
+
+ /**
+ * Transform of a SUBQUERY expression's own plan tree: every expression
the walk hands
+ * over is a block ROOT (the child-position sentinel -1), and the
query-block /
+ * projection-item scope hooks are forwarded to the enclosing builder so
nested
+ * derived tables keep their own block ids.
+ */
+ private final class SubqueryBlockTransform implements
SPMPlanTreeSupport.ExprTransform {
+ @Override
+ public Expression apply(Expression expr) {
+ beginExpressionRoot();
+ childIndexStack.push(-1);
+ try {
+ return expr.accept(SPMPlaceholderBuilder.this, null);
+ } finally {
+ childIndexStack.pop();
+ }
+ }
+
+ @Override
+ public void setGroupByMirrorLookup(java.util.function.Function<String,
Expression> lookup) {
+ SPMPlaceholderBuilder.this.setGroupByMirrorLookup(lookup);
+ }
+
+ @Override
+ public void noteParameterizedGroupByOrdinalTarget() {
+ SPMPlaceholderBuilder.this.noteParameterizedGroupByOrdinalTarget();
+ }
+
+ @Override
+ public void enterQueryBlock() {
+ SPMPlaceholderBuilder.this.enterQueryBlock();
+ }
+
+ @Override
+ public void exitQueryBlock() {
+ SPMPlaceholderBuilder.this.exitQueryBlock();
+ }
+
+ @Override
+ public void enterProjectionItem(int index) {
+ SPMPlaceholderBuilder.this.enterProjectionItem(index);
+ }
+
+ @Override
+ public void exitProjectionItem() {
+ SPMPlaceholderBuilder.this.exitProjectionItem();
+ }
+ }
+
+ /**
+ * Enters a nested query block (see
+ *
org.apache.doris.nereids.spm.SPMPlanTreeSupport.ExprTransform.enterQueryBlock):
+ * the block gets its own monotonic id, the enclosing one is restored by
+ * exitQueryBlock.
+ */
+ @Override
+ public void enterQueryBlock() {
+ blockIdStack.push(currentBlockId);
+ currentBlockId = nextBlockId++;
+ // the root-ordinal counting is per BLOCK as well: a nested block's
roots must not
+ // shift the enclosing block's ordinals (and vice versa), and the
enclosing counters
+ // resume on exit
+ rootOrdinalStack.push(nextRootOrdinal);
+ nextRootOrdinal = 0;
+ currentRootOrdinalStack.push(currentRootOrdinal);
+ currentRootOrdinal = -1;
+ }
+
+ /** Leaves the current nested query block and restores the enclosing block
id. */
+ @Override
+ public void exitQueryBlock() {
+ if (!blockIdStack.isEmpty()) {
+ currentBlockId = blockIdStack.pop();
+ }
+ if (!rootOrdinalStack.isEmpty()) {
+ nextRootOrdinal = rootOrdinalStack.pop();
+ }
+ if (!currentRootOrdinalStack.isEmpty()) {
+ currentRootOrdinal = currentRootOrdinalStack.pop();
+ }
+ }
+
+ /**
+ * Enters one projection item of a projection-like list: every literal of
its subtree
+ * carries this position, so two equally shaped literals in different
items (or in a
+ * projection and in a filter) never share one placeholder id.
+ */
+ @Override
+ public void enterProjectionItem(int index) {
+ projectItemStack.push(index);
+ }
+
+ /** Leaves the current projection item. */
+ @Override
+ public void exitProjectionItem() {
+ if (!projectItemStack.isEmpty()) {
+ projectItemStack.pop();
+ }
+ }
+
+ /** Position of the projection item currently being visited; -1 outside a
SELECT list. */
+ private int currentProjectItem() {
+ Integer top = projectItemStack.peek();
+ return top == null ? -1 : top;
+ }
+
+ /** Position of the expression currently being visited inside its direct
parent; -1 at a root. */
+ private int currentChildIndex() {
+ Integer top = childIndexStack.peek();
+ return top == null ? -1 : top;
+ }
+
+ /**
+ * The occurrence path of the literal currently being visited: the child
positions from the
+ * transformed EXPRESSION ROOT down to the literal, rendered as "0/1/..."
(empty for a
+ * root literal). Two equal literals can sit under structurally EQUAL
parents at
+ * different places of one root ("a = 1 AND a = 1": the parents are the
two And
+ * children), and only the path tells those independent slots apart - see
+ * PlaceholderKey.occurrencePath.
+ */
+ private String currentOccurrencePath() {
+ if (childIndexStack.isEmpty()) {
+ return "";
+ }
+ Object[] positions = childIndexStack.toArray();
+ StringBuilder sb = new StringBuilder();
+ for (int i = positions.length - 1; i >= 0; i--) {
+ int position = (Integer) positions[i];
+ if (position == -1) {
+ // A subquery's expression root starts a new path, independent
of its caller.
+ sb.setLength(0);
+ continue;
+ }
+ if (sb.length() > 0) {
+ sb.append('/');
+ }
+ sb.append(position);
+ }
+ return sb.toString();
+ }
+
+ // literal -> scalar placeholder.
+
+ /**
+ * Whether the expression's TYPE is NullType.
+ *
+ * The type is derived structurally because this builder walks the UNBOUND
plan, where
+ * getDataType throws. A node produces NullType when EVERY value it can
yield is
+ * NULL - a NULL literal, a CASE whose every result does, an IF whose two
value arguments do,
+ * a COALESCE / IFNULL / NVL / NULLIF / GREATEST / LEAST all of whose
arguments do. Collected as
+ * a Boolean operand (directly, or through a projected slot) such an
expression is REPLACED by
+ * the analyzer with a typed constant NULL, which deletes the placeholders
inside it.
+ *
+ * The test is RECURSIVE on purpose: a conditional nested in the RESULT of
+ * another conditional (k > 0 OR (CASE WHEN k = 0 THEN ifnull(NULL, NULL)
ELSE NULL END))
+ * yields NullType although its result is not a NULL LITERAL, so a
literal-only test left its
+ * inner markers NullType and the consumer erased them - a TRUE variant
then replayed as NULL.
+ * The same recursion covers the custom-signature producers:
GreatestLeast.customSignature
+ * returns the arguments' common type, i.e. NullType for greatest(NULL,
NULL), LEAST shares the path).
+ *
+ * Parameter expr: the expression to classify
+ * Returns: whether every value the expression can yield is NULL
+ */
+ private static boolean producesNullType(Expression expr) {
+ if (expr == null) {
+ return false;
+ }
+ if (expr.isNullLiteral()) {
+ return true;
+ }
+ List<Expression> children = expr.children();
+ if (hasConditionalResultInputs(expr)) {
+ return allConditionalResultsMatch(expr,
SPMPlaceholderBuilder::producesNullType);
+ }
+ if (expr instanceof WindowExpression) {
+ return producesNullType(((WindowExpression) expr).getFunction());
+ }
+ if (isFirstArgumentTypedResult(expr)) {
+ return !children.isEmpty() && producesNullType(children.get(0));
+ }
+ if (isElementAtCall(expr)) {
+ // element_at(array(NULL), 1) takes its type from the ARRAY's
element type and
+ // element_at(map('x', NULL), 'x') from the MAP's VALUE type
(CreateMap derives
+ // MAP<STRING, NULL_TYPE>), so an all-NULL container makes the
WHOLE call NullType: a
+ // Boolean consumer replaced the two markers of
+ // k > 0 OR element_at(array(NULL), 1) with a typed constant and
the
+ // element_at(array(TRUE), 1) variant had nothing to substitute,
and
+ // the MAP spelling lost the value marker the same way.
+ return !children.isEmpty() && isAllNullContainer(children.get(0));
+ }
+ if (isArrayReducerCall(expr)) {
+ // The SAME producer classification, for the array REDUCERS:
+ // ARRAY_MIN / ARRAY_MAX return FollowToAnyDataType(0), i.e. the
INPUT array's
+ // element type, so an all-NULL input makes the whole call
NullType - binding then
+ // replaced k > 0 OR array_min(array(NULL)) with k > ph OR NULL
and the
+ // array_min(array(TRUE)) caller got NULL instead of TRUE. Keeping
the family in
+ // ONE classifier is what lets the marker be retyped before the
Boolean consumer
+ // drops it - the same defect the bare element_at trigger had, so
it is carried here
+ // instead of in a per-function inline.
+ return !children.isEmpty() && isAllNullArray(children.get(0));
+ }
+ return false;
+ }
+
+ /** These aggregates and window functions derive the result type from
their first argument. */
+ private static boolean isFirstArgumentTypedResult(Expression expression) {
+ if (!(expression instanceof Function)) {
+ return false;
+ }
+ String name = ((Function) expression).getName();
+ return "min".equalsIgnoreCase(name) || "max".equalsIgnoreCase(name)
Review Comment:
[P1] Preserve MAX_BY/MIN_BY result markers before Boolean binding
On `t(k)={-1}`, capture `SELECT k,k>0 OR max_by(NULL,k) AS c FROM t GROUP BY
k`, then execute its `max_by(TRUE,k)` variant. The reduced capture is:
```text
Aggregate(group=k, [k, Or(k>ph0, MaxBy(ph1<NULL>, k))])
Scan(t)
```
This result-type classifier omits `max_by`/`min_by`. Their `retArgType(0)`
signatures preserve the NULL marker's `NullType`, so
`ExpressionAnalyzer.visitOr` replaces the entire bound aggregate with Boolean
NULL and deletes `ph1`. The surviving threshold marker lets the frozen planning
probe succeed, and the retained bind tree still matches TRUE, but frozen replay
has no value marker to replace and returns NULL instead of TRUE. Preserve these
first-argument result dependencies or retain raw replay when they disappear.
This direct scalar-aggregate path is distinct from the previously reported
container/lookup cases.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]