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

    joins:
      - name: order
        sql: "{CUBE}.`orderId` = {order.id}"
        relationship: many_to_one

      - name: site
        sql: "{CUBE}.`siteId` = {site.id}"
        relationship: many_to_one

    dimensions:
      - name: id
        sql: id
        type: number
        primary_key: true

      - name: bundled_by
        sql: bundled_by
        type: string

      - name: bundled_item_title
        sql: bundled_item_title
        type: string

      - name: bundled_items
        sql: bundled_items
        type: string

      - name: externalorderid
        sql: "{CUBE}.`externalOrderId`"
        type: string

      - name: externalorderitemid
        sql: "{CUBE}.`externalOrderItemId`"
        type: string

      - name: externalproductid
        sql: "{CUBE}.`externalProductId`"
        type: string

      - name: externalvariationid
        sql: "{CUBE}.`externalVariationId`"
        type: string

      - name: global_unique_id
        sql: global_unique_id
        type: string

      - name: image
        sql: image
        type: string

      - name: meta_data
        sql: meta_data
        type: string

      - name: name
        sql: name
        type: string

      - name: parent_name
        sql: parent_name
        type: string

      - name: sku
        sql: sku
        type: string

      - name: tax_class
        sql: tax_class
        type: string

      - name: taxes
        sql: taxes
        type: string

      - name: createdat
        sql: "{CUBE}.`createdAt`"
        type: time

      - name: updatedat
        sql: "{CUBE}.`updatedAt`"
        type: time

    measures:
      - name: count
        type: count

      - name: price
        sql: price
        type: sum

      - name: quantity
        sql: quantity
        type: sum

      - name: subtotal
        sql: subtotal
        type: sum

      - name: total
        sql: total
        type: sum

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

