diff --git a/sqlglot/expressions.py b/sqlglot/expressions.py index e0344eb1a2..067582419e 100644 --- a/sqlglot/expressions.py +++ b/sqlglot/expressions.py @@ -3620,6 +3620,10 @@ class Not(Unary): class Paren(Unary): arg_types = {"this": True, "with": False} + @property + def output_name(self) -> str: + return self.this.name + class Neg(Unary): pass diff --git a/tests/fixtures/optimizer/tpc-ds/tpc-ds.sql b/tests/fixtures/optimizer/tpc-ds/tpc-ds.sql index a6ee325c2c..a67d5ec55c 100644 --- a/tests/fixtures/optimizer/tpc-ds/tpc-ds.sql +++ b/tests/fixtures/optimizer/tpc-ds/tpc-ds.sql @@ -931,7 +931,7 @@ ORDER BY cnt LIMIT 100; WITH "_u_0" AS ( SELECT DISTINCT - "date_dim"."d_month_seq" AS "_col_0" + "date_dim"."d_month_seq" AS "d_month_seq" FROM "date_dim" AS "date_dim" WHERE "date_dim"."d_moy" = 7 AND "date_dim"."d_year" = 1998 @@ -949,7 +949,7 @@ SELECT FROM "customer_address" AS "customer_address" CROSS JOIN "_u_0" AS "_u_0" JOIN "date_dim" AS "date_dim" - ON "date_dim"."d_month_seq" = "_u_0"."_col_0" + ON "date_dim"."d_month_seq" = "_u_0"."d_month_seq" JOIN "store_sales" AS "store_sales" ON "store_sales"."ss_sold_date_sk" = "date_dim"."d_date_sk" JOIN "customer" AS "customer" @@ -4890,7 +4890,7 @@ WHERE i_manufact_id BETWEEN 765 AND 765 + 40 ORDER BY i_product_name LIMIT 100; SELECT DISTINCT - "i1"."i_product_name" AS "_col_0" + "i1"."i_product_name" AS "i_product_name" FROM "item" AS "i1" WHERE "i1"."i_manufact_id" <= 805