summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Greenhall <agreenhall@lyft.com>2015-09-12 01:10:09 -0700
committerVictor Uriarte <victor.m.uriarte@intel.com>2016-06-06 06:31:35 -0700
commitcccb3d866906bc6d701bad1793102e31c038b28e (patch)
treed2668fdfab722c84b7226cfa1fcc5eb9e73ce6d5
parent0e5a25f39fcff8cac8c54f0209be39dc86914570 (diff)
downloadsqlparse-cccb3d866906bc6d701bad1793102e31c038b28e.tar.gz
Test: Window functions
-rw-r--r--tests/test_format.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_format.py b/tests/test_format.py
index 18cc117..7bec955 100644
--- a/tests/test_format.py
+++ b/tests/test_format.py
@@ -219,6 +219,22 @@ class TestFormatReindentAligned(TestCaseBase):
' 2',
]))
+ def test_window_functions(self):
+ sql = """
+ select a,
+ SUM(a) OVER (PARTITION BY b ORDER BY c ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as sum_a,
+ ROW_NUMBER() OVER (PARTITION BY b, c ORDER BY d DESC) as row_num
+ from table
+ """
+ self.ndiffAssertEqual(
+ self.formatter(sql),
+ '\n'.join([
+ 'select a,',
+ ' SUM(a) OVER (PARTITION BY b ORDER BY c ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as sum_a,',
+ ' ROW_NUMBER() OVER (PARTITION BY b, c ORDER BY d DESC) as row_num',
+ ' from table',
+ ]))
+
class TestFormatReindent(TestCaseBase):