cubes:
    - name: visitor_checkins
      sql: "SELECT * FROM visitor_checkins"
      dimensions:
          - name: id
            type: number
            sql: id
          - name: visitor_id
            type: number
            sql: visitor_id
          - name: minDate
            type: time
            sql: "MIN(created_at)"
          - name: minDate1
            type: time
            sql: "MIN(created_at) + INTERVAL '1 day'"
      measures:
          - name: count
            type: count
            sql: "COUNT(*)"

    - name: visitors
      sql: "SELECT * FROM visitors"
      dimensions:
          - name: id
            type: number
            sql: id
          - name: visitor_id
            type: number
            sql: "{CUBE}.visitor_id"
          - name: wrong_double_cube_ref
            type: number
            sql: "{CUBE}.visitor_id + {visitor_checkins}.visitor_id"
          - name: wrong_foreign_cube_ref
            type: number
            sql: "{visitor_checkins}.visitor_id"
          - name: visitor_id_proxy
            type: number
            sql: "{visitors.visitor_id}"
          - name: visitor_id_twice
            type: number
            sql: "{visitor_id} * 2"
          - name: source
            type: string
            sql: source
          - name: source_concat_id
            type: string
            sql: "CONCAT({CUBE.source}, ' ', {visitors.visitor_id})"
          - name: created_at
            type: time
            sql: created_at
          - name: minVisitorCheckinDate
            type: time
            sql: "{visitor_checkins.minDate}"
            sub_query: true
          - name: minVisitorCheckinDate1
            type: time
            sql: "{visitor_checkins.minDate1}"
            sub_query: true
          - name: location
            type: geo
            latitude: latitude
            longitude: longitude
          - name: is_active
            type: boolean
            sql: is_active
          - name: questionMark
            type: string
            sql: "replace('some string question string ? ?? ???', 'string', 'with some ? ?? ???')"
      measures:
          - name: count
            type: count
            sql: "COUNT(*)"
          - name: total_revenue
            type: sum
            sql: revenue
          - name: total_revenue_proxy
            type: number
            sql: "{total_revenue}"
          - name: revenue
            type: sum
            sql: "{CUBE}.revenue"
          - name: total_revenue_per_count
            type: number
            sql: "{visitors.count} / {total_revenue}"
          - name: source_label
            type: string
            sql: "MAX({CUBE}.source)"
      segments:
          - name: google
            sql: "{CUBE.source} = 'google'"

views:
    - name: visitors_visitors_checkins
      cubes:
          - join_path: visitors
            includes:
                - id
                - source_concat_id
          - join_path: visitors.visitor_checkins
            includes:
                - visitor_id
                - count
