Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed window function examples #113

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions lib/dl_formula_ref/dl_formula_ref/functions/window.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import List

from dl_formula.core.datatype import DataType
from dl_formula.inspect.function import supports_ordering
from dl_formula_ref.categories.window import CATEGORY_WINDOW
from dl_formula_ref.examples.config import (
ExampleConfig,
Expand Down Expand Up @@ -52,6 +53,7 @@


def _make_standard_window_examples(func: str) -> List[DataExample]:
order_by_str = " ORDER BY [City], [Category]" if supports_ordering(name=func.lower(), is_window=True) else ""
func = func.upper()
examples = [
DataExample(
Expand All @@ -67,9 +69,9 @@ def _make_standard_window_examples(func: str) -> List[DataExample]:
("City", "[City]"),
("Category", "[Category]"),
("Order Sum", "[Order Sum]"),
(f"{func} 1", f"{func}([Order Sum] TOTAL)"),
(f"{func} 2", f"{func}([Order Sum] WITHIN [City])"),
(f"{func} 3", f"{func}([Order Sum] WITHIN [Category])"),
(f"{func} 1", f"{func}([Order Sum] TOTAL{order_by_str})"),
(f"{func} 2", f"{func}([Order Sum] WITHIN [City]{order_by_str})"),
(f"{func} 3", f"{func}([Order Sum] WITHIN [Category]{order_by_str})"),
],
],
override_formula_fields=[
Expand Down Expand Up @@ -623,17 +625,17 @@ def _make_mfunc_examples(func: str) -> List[DataExample]:
("City", "[City]"),
("Category", "[Category]"),
("Order Sum", "[Order Sum]"),
(f"{func} 1", f"{func}([Order Sum], 1 TOTAL)"),
(f"{func} 2", f"{func}([Order Sum], 1 WITHIN [City])"),
(f"{func} 3", f"{func}([Order Sum], 1 WITHIN [Category])"),
(f"{func} 1", f"{func}([Order Sum], 1 TOTAL ORDER BY [City], [Category])"),
(f"{func} 2", f"{func}([Order Sum], 1 WITHIN [City] ORDER BY [Category])"),
(f"{func} 3", f"{func}([Order Sum], 1 WITHIN [Category] ORDER BY [City])"),
],
],
override_formula_fields=[
("City", "[City]"),
("Category", "[Category]"),
("Order Sum", "SUM([Orders])"),
(f"{func} 1", f"{func}(SUM([Orders]), 1 TOTAL ORDER BY [City])"),
(f"{func} 2", f"{func}(SUM([Orders]), 1 WITHIN [City] ORDER BY [City])"),
(f"{func} 1", f"{func}(SUM([Orders]), 1 TOTAL ORDER BY [City], [Category])"),
(f"{func} 2", f"{func}(SUM([Orders]), 1 WITHIN [City] ORDER BY [Category])"),
(f"{func} 3", f"{func}(SUM([Orders]), 1 AMONG [City] ORDER BY [City])"),
],
),
Expand Down
Loading