From d1f00706bff58b863b0a1c5bf4adf39d36049d4c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 11 Nov 2022 09:54:35 +0100 Subject: Merging upstream version 10.0.1. Signed-off-by: Daniel Baumann --- sqlglot/planner.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'sqlglot/planner.py') diff --git a/sqlglot/planner.py b/sqlglot/planner.py index ea995d8..cd1de5e 100644 --- a/sqlglot/planner.py +++ b/sqlglot/planner.py @@ -72,7 +72,9 @@ class Step: if from_: from_ = from_.expressions if len(from_) > 1: - raise UnsupportedError("Multi-from statements are unsupported. Run it through the optimizer") + raise UnsupportedError( + "Multi-from statements are unsupported. Run it through the optimizer" + ) step = Scan.from_expression(from_[0], ctes) else: @@ -102,7 +104,7 @@ class Step: continue if operand not in operands: operands[operand] = f"_a_{next(sequence)}" - operand.replace(exp.column(operands[operand], step.name, quoted=True)) + operand.replace(exp.column(operands[operand], quoted=True)) else: projections.append(e) @@ -117,9 +119,11 @@ class Step: aggregate = Aggregate() aggregate.source = step.name aggregate.name = step.name - aggregate.operands = tuple(alias(operand, alias_) for operand, alias_ in operands.items()) + aggregate.operands = tuple( + alias(operand, alias_) for operand, alias_ in operands.items() + ) aggregate.aggregations = aggregations - aggregate.group = [exp.column(e.alias_or_name, step.name, quoted=True) for e in group.expressions] + aggregate.group = group.expressions aggregate.add_dependency(step) step = aggregate @@ -136,9 +140,6 @@ class Step: sort.key = order.expressions sort.add_dependency(step) step = sort - for k in sort.key + projections: - for column in k.find_all(exp.Column): - column.set("table", exp.to_identifier(step.name, quoted=True)) step.projections = projections @@ -203,7 +204,9 @@ class Scan(Step): alias_ = expression.alias if not alias_: - raise UnsupportedError("Tables/Subqueries must be aliased. Run it through the optimizer") + raise UnsupportedError( + "Tables/Subqueries must be aliased. Run it through the optimizer" + ) if isinstance(expression, exp.Subquery): table = expression.this -- cgit v1.2.3