From 5c26f56ad6f1814b543c81d9e8263ebfd11a5634 Mon Sep 17 00:00:00 2001 From: tobymao Date: Tue, 2 May 2023 15:39:15 -0700 Subject: [PATCH] Fix: windowspec generator --- sqlglot/__init__.py | 3 +++ sqlglot/generator.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sqlglot/__init__.py b/sqlglot/__init__.py index f31d72c968..15c4f933cd 100644 --- a/sqlglot/__init__.py +++ b/sqlglot/__init__.py @@ -21,10 +21,12 @@ Expression as Expression, alias_ as alias, and_ as and_, + cast as cast, column as column, condition as condition, except_ as except_, from_ as from_, + func as func, intersect as intersect, maybe_parse as maybe_parse, not_ as not_, @@ -33,6 +35,7 @@ subquery as subquery, table_ as table, to_column as to_column, + to_identifier as to_identifier, to_table as to_table, union as union, ) diff --git a/sqlglot/generator.py b/sqlglot/generator.py index 37ddfd140f..bd12d54ac9 100644 --- a/sqlglot/generator.py +++ b/sqlglot/generator.py @@ -1550,7 +1550,7 @@ def window_sql(self, expression: exp.Window) -> str: partition_sql = partition + " " if partition and order else partition spec = expression.args.get("spec") - spec_sql = " " + self.window_spec_sql(spec) if spec else "" + spec_sql = " " + self.windowspec_sql(spec) if spec else "" alias = self.sql(expression, "alias") over = self.sql(expression, "over") or "OVER" @@ -1572,7 +1572,7 @@ def partition_by_sql(self, expression: exp.Window | exp.MatchRecognize) -> str: partition = self.expressions(expression, key="partition_by", flat=True) return f"PARTITION BY {partition}" if partition else "" - def window_spec_sql(self, expression: exp.WindowSpec) -> str: + def windowspec_sql(self, expression: exp.WindowSpec) -> str: kind = self.sql(expression, "kind") start = csv(self.sql(expression, "start"), self.sql(expression, "start_side"), sep=" ") end = (