cubes:
  - name: orders
    sql: "SELECT * FROM orders"
    dimensions:
      - name: id
        type: number
        sql: id
        primary_key: true
      - name: status
        type: string
        sql: status
      - name: amount
        type: number
        sql: amount
      - name: created_at
        type: time
        sql: created_at
        granularities:
          - name: half_year
            interval: "6 months"
            origin: "2024-01-01"
          - name: half_year_by_1st_april
            interval: "6 months"
            origin: "2024-04-01"
          - name: fiscal_year
            interval: "1 year"
            offset: "1 month"

      - name: fiscal_year_alias
        type: time
        sql: "{created_at.fiscal_year}"

      - name: created_at_minus_one_day
        type: time
        sql: "{CUBE}.created_at - interval '1 day'"
    measures:
      - name: count
        type: count
      - name: total_amount
        type: sum
        sql: amount
