Skip to content

Commit

Permalink
No need to use Coalesce in InnerJoin
Browse files Browse the repository at this point in the history
  • Loading branch information
Beyyes committed Dec 20, 2024
1 parent 92c1fdd commit 1e872ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,7 @@ public RelationPlan plan(QuerySpecification node)

// The new scope is the composite of the fields from the FROM and SELECT clause (local nested scopes). Fields from the bottom of
// the scope stack need to be placed first to match the expected layout for nested scopes.
List<Symbol> newFields = new ArrayList<>();
newFields.addAll(builder.getTranslations().getFieldSymbols());
List<Symbol> newFields = new ArrayList<>(builder.getTranslations().getFieldSymbols());

outputs.stream()
.map(builder::translate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1179,9 +1179,14 @@ If casts are redundant (due to column type and common type being equal),
for (Identifier column : joinColumns) {
Symbol output = symbolAllocator.newSymbol(column.getValue(), analysis.getType(column));
outputs.add(output);
assignments.put(output, new Coalesce(
leftJoinColumns.get(column).toSymbolReference(),
rightJoinColumns.get(column).toSymbolReference()));
if (join.getType() == JoinType.INNER) {
assignments.put(output, leftJoinColumns.get(column).toSymbolReference());
}
else {
assignments.put(output, new Coalesce(
leftJoinColumns.get(column).toSymbolReference(),
rightJoinColumns.get(column).toSymbolReference()));
}
}

for (int field : joinAnalysis.getOtherLeftFields()) {
Expand Down

0 comments on commit 1e872ea

Please sign in to comment.