summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMichael Smedberg <msmedberg@zendesk.com>2019-09-08 21:47:27 -0700
committerPaul McGuire <ptmcg@users.noreply.github.com>2019-09-08 23:47:27 -0500
commite02ba7389eeca1743838665f3ec43c849afb7ce7 (patch)
treefb366c1664ba51b8c65706b26889a448337b8e6e /examples
parent87016995f05a0b4927eef22f767a349d85e6afd2 (diff)
downloadpyparsing-git-e02ba7389eeca1743838665f3ec43c849afb7ce7.tar.gz
BigQuery SQL parser: handle WINDOW clause in WITH section (#122)
Diffstat (limited to 'examples')
-rw-r--r--examples/bigquery_view_parser.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/bigquery_view_parser.py b/examples/bigquery_view_parser.py
index 6172481..86e01e5 100644
--- a/examples/bigquery_view_parser.py
+++ b/examples/bigquery_view_parser.py
@@ -566,6 +566,8 @@ class BigQueryViewParser:
)
)
+ window_select_clause = WINDOW + identifier + AS + LPAR + window_specification + RPAR
+
select_core = (
SELECT
+ Optional(DISTINCT | ALL)
@@ -581,6 +583,9 @@ class BigQueryViewParser:
ORDER + BY
+ Group(delimitedList(ordering_term))("order_by_terms")
)
+ + Optional(
+ delimitedList(window_select_clause)
+ )
)
grouped_select_core = select_core | (LPAR + select_core + RPAR)
@@ -1492,6 +1497,20 @@ class BigQueryViewParser:
[
(None, None, 'x'),
]
+ ],
+ [
+ """
+ WITH x AS (
+ SELECT a
+ FROM b
+ WINDOW w as (PARTITION BY a)
+ )
+ SELECT y FROM z
+ """,
+ [
+ (None, None, 'b'),
+ (None, None, 'z')
+ ]
]
]