Skip to content

.all() for window aggregations not supported in YAML #115

@boringdata

Description

@boringdata

Window aggregations using .all() (for percent-of-total) must be defined in Python, not YAML.

YAML example that fails:

flights:
  table: flights_tbl
  measures:
    total_distance: _.distance.sum()
    distance_share:
      expr: (_.distance.sum() / _.all(_.distance.sum())) * 100
      # ❌ Error: _ (ibis Deferred) doesn't have .all() method

Reproduce:

# See bsl-profiles branch: examples/percent_of_total.py

# WORKAROUND - Add programmatically:
from boring_semantic_layer import from_yaml

models = from_yaml("flights.yml", profile="example_db")
flights = models["flights"]

flights = flights.with_measures(
    distance_share=lambda t: (t.distance.sum() / t.all(t.distance.sum())) * 100
)

flights.group_by("carrier").aggregate("distance_share").execute()

Files: https://github.com/boringdata/boring-semantic-layer/blob/bsl-profiles/examples/percent_of_total.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions