Skip to content

Commit ade8910

Browse files
committed
Fixed window function examples
1 parent 1585432 commit ade8910

File tree

1 file changed

+11
-9
lines changed
  • lib/dl_formula_ref/dl_formula_ref/functions

1 file changed

+11
-9
lines changed

lib/dl_formula_ref/dl_formula_ref/functions/window.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import List
22

33
from dl_formula.core.datatype import DataType
4+
from dl_formula.inspect.function import supports_ordering
45
from dl_formula_ref.categories.window import CATEGORY_WINDOW
56
from dl_formula_ref.examples.config import (
67
ExampleConfig,
@@ -52,6 +53,7 @@
5253

5354

5455
def _make_standard_window_examples(func: str) -> List[DataExample]:
56+
order_by_str = "ORDER BY [City], [Category]" if supports_ordering(name=func.lower(), is_window=True) else ""
5557
func = func.upper()
5658
examples = [
5759
DataExample(
@@ -67,9 +69,9 @@ def _make_standard_window_examples(func: str) -> List[DataExample]:
6769
("City", "[City]"),
6870
("Category", "[Category]"),
6971
("Order Sum", "[Order Sum]"),
70-
(f"{func} 1", f"{func}([Order Sum] TOTAL)"),
71-
(f"{func} 2", f"{func}([Order Sum] WITHIN [City])"),
72-
(f"{func} 3", f"{func}([Order Sum] WITHIN [Category])"),
72+
(f"{func} 1", f"{func}([Order Sum] TOTAL{order_by_str})"),
73+
(f"{func} 2", f"{func}([Order Sum] WITHIN [City]{order_by_str})"),
74+
(f"{func} 3", f"{func}([Order Sum] WITHIN [Category]{order_by_str})"),
7375
],
7476
],
7577
override_formula_fields=[
@@ -623,18 +625,18 @@ def _make_mfunc_examples(func: str) -> List[DataExample]:
623625
("City", "[City]"),
624626
("Category", "[Category]"),
625627
("Order Sum", "[Order Sum]"),
626-
(f"{func} 1", f"{func}([Order Sum], 1 TOTAL)"),
627-
(f"{func} 2", f"{func}([Order Sum], 1 WITHIN [City])"),
628-
(f"{func} 3", f"{func}([Order Sum], 1 WITHIN [Category])"),
628+
(f"{func} 1", f"{func}([Order Sum], 1 TOTAL ORDER BY [City], [Category])"),
629+
(f"{func} 2", f"{func}([Order Sum], 1 WITHIN [City] ORDER BY [Category])"),
630+
(f"{func} 3", f"{func}([Order Sum], 1 WITHIN [Category] ORDER BY [City])"),
629631
],
630632
],
631633
override_formula_fields=[
632634
("City", "[City]"),
633635
("Category", "[Category]"),
634636
("Order Sum", "SUM([Orders])"),
635-
(f"{func} 1", f"{func}(SUM([Orders]), 1 TOTAL ORDER BY [City])"),
636-
(f"{func} 2", f"{func}(SUM([Orders]), 1 WITHIN [City] ORDER BY [City])"),
637-
(f"{func} 3", f"{func}(SUM([Orders]), 1 AMONG [City] ORDER BY [City])"),
637+
(f"{func} 1", f"{func}(SUM([Orders]), 1 TOTAL)"),
638+
(f"{func} 2", f"{func}(SUM([Orders]), 1 WITHIN [City])"),
639+
(f"{func} 3", f"{func}(SUM([Orders]), 1 AMONG [City])"),
638640
],
639641
),
640642
),

0 commit comments

Comments
 (0)