[Wranglers] Snowflake now support querying from Semantic Views

Ali, Saqib docbook.xml at gmail.com
Tue Jun 3 18:58:13 UTC 2025


here is the Snowflake official documentation on Semantic Views:
https://snowflake.com/en/engineering-blog/native-semantic-views-ai-bi/



On Tue, Jun 3, 2025 at 9:50 AM Ali, Saqib <docbook.xml at gmail.com> wrote:

> One thing I noticed is that while Snowflake lets you define PRIMARY KEY on
> the TABLE in a Semantic View, it does not enforce the Primary Key
> constraint. This could potentially lead to incorrect metric calculations in
> the Semantic View. Hopefully Snowflake fixes this soon......
>
>
>
> On Tue, Jun 3, 2025 at 6:02 AM Ali, Saqib <docbook.xml at gmail.com> wrote:
>
>> Snowflake now supports querying from Semantic Views.
>>
>>
>> -- Let's create a Semantic View
>> CREATE OR REPLACE SEMANTIC VIEW tpch_analysis_semantic_view
>>
>> TABLES (
>>     customer AS SNOWFLAKE_SAMPLE_DATA.TPCH_SF1.CUSTOMER PRIMARY KEY
>> (c_custkey)
>>     , orders AS SNOWFLAKE_SAMPLE_DATA.TPCH_SF1.ORDERS
>>   )
>>
>>   RELATIONSHIPS (
>>     orders (o_custkey) REFERENCES customer
>>   )
>>
>>   DIMENSIONS (
>>     customer.customer_name AS c_name
>>     , customer.customer_market_segment AS c_mktsegment
>>   )
>>
>>   METRICS (
>>     customer.customer_count AS COUNT(c_custkey)
>>     , orders.order_count AS COUNT(o_orderkey)
>>     , orders.order_average_value AS AVG(orders.o_totalprice)
>>     , orders.order_total_value AS SUM(orders.o_totalprice)
>>     , orders.first_order_date as min(orders.o_orderdate)
>>     , orders.latest_order_date as max(orders.o_orderdate)
>>
>>   )
>> ;
>>
>> -- Now query the semantic view
>>
>> SELECT * FROM SEMANTIC_VIEW(
>>   tpch_analysis_semantic_view
>>   DIMENSIONS customer.customer_market_segment
>>   METRICS orders.order_count
>>     , orders.order_average_value
>>     , orders.order_total_value
>>     , orders.first_order_date
>>     , orders.latest_order_date
>>
>>
>>   );
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://analyticsengineering.net/pipermail/wranglers/attachments/20250603/b496fce9/attachment.htm>


More information about the Wranglers mailing list