Mar*_* C. 13 flatten snowflake-cloud-data-platform lateral-join
LATERAL FLATTEN(...)Snowflake 中和 的使用有什么区别TABLE(FLATTEN(...))?FLATTEN我检查了,LATERAL和的文档,TABLE无法明确以下查询之间的功能差异。
select
id as account_id,
account_regions.value::string as region
from
salesforce.accounts,
lateral flatten(split(salesforce.accounts.regions, ', ')) account_regions
Run Code Online (Sandbox Code Playgroud)
select
id as account_id,
account_regions.value::string as region
from
salesforce.accounts,
table(flatten(split(salesforce.accounts.regions, ', '))) account_regions
Run Code Online (Sandbox Code Playgroud)
我想说的是,在所提供的查询中没有区别 - 因为横向联接是通过在来自行的值内操作的结果动态创建表来隐含的。
对关键字的真正需求flatten来自于这样的查询:
select *
from departments as d
, lateral (
select *
from employees as e
where e.department_id = d.department_id
) as iv2
order by employee_id;
-- https://docs.snowflake.com/en/sql-reference/constructs/join-lateral.html
Run Code Online (Sandbox Code Playgroud)
如果没有lateral此连接的关键字,您将得到一个Error: invalid identifier 'D.DEPARTMENT_ID'.
| 归档时间: |
|
| 查看次数: |
8761 次 |
| 最近记录: |