hello-stephen commented on code in PR #71211:
URL: https://github.com/apache/doris/pull/71211#discussion_r4750618932
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/ExpressionAnalyzer.java:
##########
@@ -1513,68 +1515,72 @@ private boolean shouldBindSlotBy(int namePartSize, Slot
boundSlot) {
return namePartSize <= boundSlot.getQualifier().size() + 1;
}
- private List<Slot> bindSingleSlotByName(String name, Scope scope) {
- int namePartSize = 1;
+ /**
+ * Binds {@code name} to the slots of {@code scope} that {@code accepts}
takes, renamed to the SQL's spelling.
+ * Names are told apart as {@link ColumnNames} does, so {@code Σ} binds a
slot {@code σ} but not a slot
+ * {@code ς}; a name that is the same as no accepted slot binds the slots
equal to it ignoring case, as every name
+ * did before. A name that bound one slot still binds it, and one that was
ambiguous between slots such as
+ * {@code Σ} and {@code ς} binds the slot it names.
+ */
+ private static List<Slot> bindSlotsNamed(String name, Scope scope, boolean
all, Predicate<Slot> accepts) {
+ List<Slot> equalIgnoringCase = scope.findSlotIgnoreCase(name, all);
+ List<Slot> sameName = acceptSlots(name, equalIgnoringCase,
+ slot -> ColumnNames.same(slot.getName(), name) &&
accepts.test(slot));
+ return sameName.isEmpty() ? acceptSlots(name, equalIgnoringCase,
accepts) : sameName;
Review Comment:
[P1] Align preliminary partition binding with the new name resolution
Please update `StatementContext.preloadFilteredScanPartitionViews()`
alongside this change: it still resolves a name against **partition columns
only** using `equalsIgnoreCase(...).findFirst()`.
For a Hive table `t(id INT, ς INT)` partitioned by `σ INT`, with a row
`(id=1, ς=100, σ=1)` and a matching internal-table row, run as root:
```sql
SELECT e.`ς` FROM hive.db.t e
JOIN internal.db.i i ON e.id = i.id
WHERE e.`ς` = 100;
```
The relevant plan is:
```text
Project(e.ς)
Filter(e.ς = 100)
InnerJoin(e.id = i.id)
HiveScan(id, ς, partition σ)
InternalScan(id)
```
Before full analysis, partition preloading misbinds `e.ς` to `σ`, prunes
using `σ = 100`, and discards the matching `σ=1` partition.
`PruneFileScanPartition` then reuses that filtered view/handle; an empty
selection reaches `PluginDrivenScanNode.finishPrunedToZeroScan()`. This helper
now correctly binds `ς`, so the query succeeds with missing rows where the old
analyzer rejected the reference as ambiguous.
Resolve preliminary references against the full schema with the same naming
rule, then push a predicate only when its resolved column is a partition
column. Please add a mixed internal/external regression covering this case.
--
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]