cubes:
  - name: customer
    sql_table: inventory_v2.customer
    data_source: default

    joins:
      - name: site
        sql: "{CUBE}.site_id = {site.id}"
        relationship: many_to_one

    dimensions:
      - name: id
        sql: id
        type: number
        primary_key: true
      - name: customer_state
        sql: "JSON_EXTRACT({customer.shipping}, '$.state')"
        type: string

      - name: avatar
        sql: avatar
        type: string

      - name: billing
        sql: billing
        type: string

      - name: email
        sql: email
        type: string

      - name: first_name
        sql: first_name
        type: string

      - name: fullname
        sql: fullname
        type: string

      - name: last_name
        sql: last_name
        type: string

      - name: origin_id
        sql: origin_id
        type: string

      - name: phone
        sql: phone
        type: string

      - name: raw
        sql: raw
        type: string

      - name: shipping
        sql: shipping
        type: string

      - name: username
        sql: username
        type: string

      - name: created_at
        sql: created_at
        type: time

      - name: site_created_at
        sql: site_created_at
        type: time

      - name: site_updated_at
        sql: site_updated_at
        type: time

      - name: updated_at
        sql: updated_at
        type: time

    measures:
      - name: count
        type: count

    pre_aggregations:
      # Pre-aggregation definitions go here.
      # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started

