Skip to content

Commit

Permalink
Fix incorrect schema attribute names for snowflake
Browse files Browse the repository at this point in the history
  • Loading branch information
rlh1994 committed Jan 9, 2024
1 parent 643c779 commit 8f59822
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ select
object_construct('type', ecommerce_action_type, 'name', ecommerce_action_name) as unstruct_event_com_snowplowanalytics_snowplow_ecommerce_snowplow_ecommerce_action_1,
-- we do this complicated nonsense because Snowflake's `parse_json` function returns a null object if any of the fields inside the JSON are null...
TO_VARIANT(ARRAY_CONSTRUCT(OBJECT_CONSTRUCT_KEEP_NULL('id', page_view_id))) as contexts_com_snowplowanalytics_snowplow_web_page_1,
TO_VARIANT(ARRAY_CONSTRUCT(OBJECT_CONSTRUCT_KEEP_NULL('id',ecommerce_user_id,'email',ecommerce_user_email,'isGuest',ecommerce_user_is_guest))) as contexts_com_snowplowanalytics_snowplow_ecommerce_user_1,
TO_VARIANT(ARRAY_CONSTRUCT(OBJECT_CONSTRUCT_KEEP_NULL('id',ecommerce_user_id,'email',ecommerce_user_email,'is_guest',ecommerce_user_is_guest))) as contexts_com_snowplowanalytics_snowplow_ecommerce_user_1,
TO_VARIANT(ARRAY_CONSTRUCT(OBJECT_CONSTRUCT_KEEP_NULL('type',ecommerce_page_type,'language',ecommerce_page_language,'locale',ecommerce_page_locale))) as contexts_com_snowplowanalytics_snowplow_ecommerce_page_1,
TO_VARIANT(ARRAY_CONSTRUCT(OBJECT_CONSTRUCT_KEEP_NULL('cartId',ecommerce_cart_id,'currency',ecommerce_cart_currency,'totalValue',ecommerce_cart_total_value))) as contexts_com_snowplowanalytics_snowplow_ecommerce_cart_1,
TO_VARIANT(ARRAY_CONSTRUCT(OBJECT_CONSTRUCT_KEEP_NULL('cart_id',ecommerce_cart_id,'currency',ecommerce_cart_currency,'total_value',ecommerce_cart_total_value))) as contexts_com_snowplowanalytics_snowplow_ecommerce_cart_1,
contexts_com_snowplowanalytics_snowplow_ecommerce_product_1,
TO_VARIANT(ARRAY_CONSTRUCT(OBJECT_CONSTRUCT_KEEP_NULL('step',checkout_step_number,'accountType',checkout_account_type,'billingFullAddress',checkout_billing_full_address,'billingPostcode',checkout_billing_postcode,'couponCode',checkout_coupon_code,'deliveryMethod',checkout_delivery_method,'deliveryProvider',checkout_delivery_provider,'marketingOptIn',checkout_marketing_opt_in,'paymentMethod',checkout_payment_method,'proofOfPayment',checkout_proof_of_payment,'shippingFullAddress',checkout_shipping_full_address,'shippingPostcode',checkout_shipping_postcode))) as contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1,
TO_VARIANT(ARRAY_CONSTRUCT(OBJECT_CONSTRUCT_KEEP_NULL('transactionId',ecommerce_transaction_id,'currency',ecommerce_currency,'paymentMethod',ecommerce_payment_method,'revenue',ecommerce_revenue,'totalQuantity',ecommerce_total_quantity,'creditOrder',ecommerce_credit_order,'discountAmount',ecommerce_discount_amount,'discountCode',ecommerce_discount_code,'shipping',ecommerce_shipping,'tax',ecommerce_tax))) as contexts_com_snowplowanalytics_snowplow_ecommerce_transaction_1,
TO_VARIANT(ARRAY_CONSTRUCT(OBJECT_CONSTRUCT_KEEP_NULL('step',checkout_step_number,'account_type',checkout_account_type,'billing_full_address',checkout_billing_full_address,'billing_postcode',checkout_billing_postcode,'coupon_code',checkout_coupon_code,'delivery_method',checkout_delivery_method,'delivery_provider',checkout_delivery_provider,'marketing_opt_in',checkout_marketing_opt_in,'payment_method',checkout_payment_method,'proof_of_payment',checkout_proof_of_payment,'shipping_full_address',checkout_shipping_full_address,'shipping_postcode',checkout_shipping_postcode))) as contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1,
TO_VARIANT(ARRAY_CONSTRUCT(OBJECT_CONSTRUCT_KEEP_NULL('transaction_id',ecommerce_transaction_id,'currency',ecommerce_currency,'payment_method',ecommerce_payment_method,'revenue',ecommerce_revenue,'total_quantity',ecommerce_total_quantity,'credit_order',ecommerce_credit_order,'discount_amount',ecommerce_discount_amount,'discount_code',ecommerce_discount_code,'shipping',ecommerce_shipping,'tax',ecommerce_tax))) as contexts_com_snowplowanalytics_snowplow_ecommerce_transaction_1,
TO_VARIANT(ARRAY_CONSTRUCT(OBJECT_CONSTRUCT_KEEP_NULL('eventIndex',event_index,'firstEventId',first_event_id,'firstEventTimestamp',first_event_timestamp,'previousSessionId',previous_session_id,'sessionId',session_id,'sessionIndex',session_index,'storageMechanism',storage_mechanism,'userId',mobile_user_id))) as contexts_com_snowplowanalytics_snowplow_client_session_1,
TO_VARIANT(ARRAY_CONSTRUCT(OBJECT_CONSTRUCT_KEEP_NULL('id',screen_view_id,'name',screen_view_name))) as contexts_com_snowplowanalytics_mobile_screen_1

Expand Down
4 changes: 2 additions & 2 deletions macros/field_extractions/get_cart_context_fields.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
, cast(NULL as {{ type_string() }}) as cart_currency
, cast(NULL as decimal(9,2)) as cart_total_value
{% else %}
, contexts_com_snowplowanalytics_snowplow_ecommerce_cart_1[0]:cartId::varchar as cart_id
, contexts_com_snowplowanalytics_snowplow_ecommerce_cart_1[0]:cart_id::varchar as cart_id
, contexts_com_snowplowanalytics_snowplow_ecommerce_cart_1[0]:currency::varchar as cart_currency
, contexts_com_snowplowanalytics_snowplow_ecommerce_cart_1[0]:totalValue::decimal(9,2) as cart_total_value
, contexts_com_snowplowanalytics_snowplow_ecommerce_cart_1[0]:total_value::decimal(9,2) as cart_total_value
{% endif %}
{% endmacro %}
22 changes: 11 additions & 11 deletions macros/field_extractions/get_checkout_context_fields.sql
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,16 @@
, cast(NULL as {{ type_string() }}) as checkout_shipping_postcode
{% else %}
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:step::int as checkout_step_number
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:accountType::varchar as checkout_account_type
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:billingFullAddress::varchar as checkout_billing_full_address
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:billingPostcode::varchar as checkout_billing_postcode
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:couponCode::varchar as checkout_coupon_code
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:deliveryMethod::varchar as checkout_delivery_method
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:deliveryProvider::varchar as checkout_delivery_provider
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:marketingOptIn::boolean as checkout_marketing_opt_in
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:paymentMethod::varchar as checkout_payment_method
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:proofOfPayment::varchar as checkout_proof_of_payment
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:shippingFullAddress::varchar as checkout_shipping_full_address
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:shippingPostcode::varchar as checkout_shipping_postcode
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:account_type::varchar as checkout_account_type
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:billing_full_address::varchar as checkout_billing_full_address
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:billing_postcode::varchar as checkout_billing_postcode
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:coupon_code::varchar as checkout_coupon_code
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:delivery_method::varchar as checkout_delivery_method
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:delivery_provider::varchar as checkout_delivery_provider
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:marketing_opt_in::boolean as checkout_marketing_opt_in
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:payment_method::varchar as checkout_payment_method
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:proof_of_payment::varchar as checkout_proof_of_payment
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:shipping_full_address::varchar as checkout_shipping_full_address
, contexts_com_snowplowanalytics_snowplow_ecommerce_checkout_step_1[0]:shipping_postcode::varchar as checkout_shipping_postcode
{% endif %}
{% endmacro %}
12 changes: 6 additions & 6 deletions macros/field_extractions/get_transaction_context_fields.sql
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@
, cast(NULL as decimal(9,2)) as transaction_shipping
, cast(NULL as decimal(9,2)) as transaction_tax
{% else %}
, contexts_com_snowplowanalytics_snowplow_ecommerce_transaction_1[0]:transactionId::varchar as transaction_id
, contexts_com_snowplowanalytics_snowplow_ecommerce_transaction_1[0]:transaction_id::varchar as transaction_id
, contexts_com_snowplowanalytics_snowplow_ecommerce_transaction_1[0]:currency::varchar as transaction_currency
, contexts_com_snowplowanalytics_snowplow_ecommerce_transaction_1[0]:paymentMethod::varchar as transaction_payment_method
, contexts_com_snowplowanalytics_snowplow_ecommerce_transaction_1[0]:payment_method::varchar as transaction_payment_method
, contexts_com_snowplowanalytics_snowplow_ecommerce_transaction_1[0]:revenue::decimal(9,2) as transaction_revenue
, contexts_com_snowplowanalytics_snowplow_ecommerce_transaction_1[0]:totalQuantity::int as transaction_total_quantity
, contexts_com_snowplowanalytics_snowplow_ecommerce_transaction_1[0]:creditOrder::boolean as transaction_credit_order
, contexts_com_snowplowanalytics_snowplow_ecommerce_transaction_1[0]:discountAmount::decimal(9,2) as transaction_discount_amount
, contexts_com_snowplowanalytics_snowplow_ecommerce_transaction_1[0]:discountCode::varchar as transaction_discount_code
, contexts_com_snowplowanalytics_snowplow_ecommerce_transaction_1[0]:total_quantity::int as transaction_total_quantity
, contexts_com_snowplowanalytics_snowplow_ecommerce_transaction_1[0]:credit_order::boolean as transaction_credit_order
, contexts_com_snowplowanalytics_snowplow_ecommerce_transaction_1[0]:discount_amount::decimal(9,2) as transaction_discount_amount
, contexts_com_snowplowanalytics_snowplow_ecommerce_transaction_1[0]:discount_code::varchar as transaction_discount_code
, contexts_com_snowplowanalytics_snowplow_ecommerce_transaction_1[0]:shipping::decimal(9,2) as transaction_shipping
, contexts_com_snowplowanalytics_snowplow_ecommerce_transaction_1[0]:tax::decimal(9,2) as transaction_tax
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion macros/field_extractions/get_user_context_fields.sql
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@
{% else %}
, contexts_com_snowplowanalytics_snowplow_ecommerce_user_1[0]:id::varchar as ecommerce_user_id
, contexts_com_snowplowanalytics_snowplow_ecommerce_user_1[0]:email::varchar as ecommerce_user_email
, contexts_com_snowplowanalytics_snowplow_ecommerce_user_1[0]:isGuest::boolean as ecommerce_user_is_guest
, contexts_com_snowplowanalytics_snowplow_ecommerce_user_1[0]:is_guest::boolean as ecommerce_user_is_guest
{% endif %}
{% endmacro %}

0 comments on commit 8f59822

Please sign in to comment.