首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >BigQuery集成中使用Stitch的简单连接错误

BigQuery集成中使用Stitch的简单连接错误
EN

Stack Overflow用户
提问于 2020-04-01 19:55:08
回答 1查看 96关注 0票数 0

使用Stitch数据集成在BigQuery中编写了下面的代码,以从Shopify中提取表。非常简单,但我不熟悉嵌套,我怀疑这可能是抛掉了我的查询。

任何帮助都将不胜感激。查询和错误如下:

查询

代码语言:javascript
复制
SELECT distinct
order_number
,so.created_at
,buyer_accepts_marketing
,currency
,value. sku
,value. vendor
,value. variant_title
,value. gift_card
,value. product_id
,customer. id
,shipping_address. province
,shipping_address. country
,shipping_address. city
,shipping_address. longitude
,shipping_address. country_code
,shipping_address. latitude
,sum(total_price_usd) as price_usd
,sum(total_price) as total_price
,sum(total_discounts) as total_discounts
FROM `shopifytest-272721.testconn.orders` as so
CROSS JOIN UNNEST(line_items)

left join

(SELECT distinct
created_at
,id
,product_type
,title
,value.sku
,value.fulfillment_service
,value.inventory_quantity
FROM `shopifytest-272721.testconn.products` 
CROSS JOIN UNNEST(variants)) as sp 

on so.product_id = sp.id 
and so.created_at = sp.created_at

group by 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16

错误名称product_id在36:7中找不到

EN

回答 1

Stack Overflow用户

发布于 2020-04-04 02:17:00

在第一个选择中,您有value.product_id,但您正在加入so.product_id = sp.id,在这个级别上不知道字段product_id,但是如果您设置别名,它可以工作:

代码语言:javascript
复制
value.product_id as product_id

另一个有噪声的字段是第一个查询中的so.created_at。让我为您的查询提供以下结构建议:

代码语言:javascript
复制
SELECT distinct
order_number
,created_at
,buyer_accepts_marketing
,currency
,value. sku
,value. vendor
,value. variant_title
,value. gift_card
,value. product_id as product_id
,customer. id
,shipping_address. province
,shipping_address. country
,shipping_address. city
,shipping_address. longitude
,shipping_address. country_code
,shipping_address. latitude
,sum(total_price_usd) as price_usd
,sum(total_price) as total_price
,sum(total_discounts) as total_discounts
FROM `shopifytest-272721.testconn.orders` as so --if line_items is contained into so:
CROSS JOIN UNNEST(so.line_items) as items

left join

(SELECT distinct
created_at
,id
,product_type
,title
,value.sku
,value.fulfillment_service
,value.inventory_quantity
FROM `shopifytest-272721.testconn.products` as p
CROSS JOIN UNNEST(p.variants)) as sp 

on items.product_id = sp.id 
and items.created_at = sp.created_at

group by 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16

此外,由于您不熟悉嵌套,我建议您检查UNNEST压扁阵列连接类型

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60979257

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档