【发布时间】:2022-06-14 21:42:48
【问题描述】:
我有一个 Snowflake VIEW 定义如下:
create order_amount_by_order_type_view as (
with temp_table as (
select * FROM orders inner join order_lines on orders.order_no=order_lines.order_no)
select order_type, sum(amount)
from temp_table
group by orders.order_type
)
请注意,我选择了 CTE 中的所有字段,即使主查询中不需要它们。
问题:Snowflake 是否足够聪明,能够识别出主要使用 order_type 和 amount 并相应地优化 CTE?
或者我应该手动限制 CTE 中的必填字段吗?
create order_amount_by_order_type_view as (
with temp_table as (
select orders.order_type, order_lines.amount FROM orders inner join order_lines on orders.order_no=order_lines.order_no)
select order_type, sum(amount)
from temp_table
group by orders.order_type
)
【问题讨论】:
标签: snowflake-cloud-data-platform