Skip to content

Commit

Permalink
sql: use aliases variable when building SELECT
Browse files Browse the repository at this point in the history
  • Loading branch information
erikgrinaker committed Jul 17, 2024
1 parent 97f54aa commit 4678fc8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/sql/planner/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,19 @@ impl<'a, C: Catalog> Planner<'a, C> {

// Build the SELECT column expressions and aliases.
let mut expressions = Vec::with_capacity(select.len());
let mut labels = Vec::with_capacity(select.len());
let mut aliases = Vec::with_capacity(select.len());
for (expr, alias) in select {
expressions.push(Self::build_expression(expr, &scope)?);
labels.push(Label::from(alias));
aliases.push(Label::from(alias));
}

// Add hidden columns for HAVING and ORDER BY columns not in SELECT.
let hidden = self.build_select_hidden(&scope, &mut child_scope, &having, &order_by);
labels.extend(std::iter::repeat(Label::None).take(hidden.len()));
aliases.extend(std::iter::repeat(Label::None).take(hidden.len()));
expressions.extend(hidden);

scope = child_scope;
node = Node::Projection { source: Box::new(node), expressions, aliases: labels };
node = Node::Projection { source: Box::new(node), expressions, aliases };
};

// Build HAVING clause.
Expand Down

0 comments on commit 4678fc8

Please sign in to comment.