Canner / wren-engine

🤖 The semantic engine for LLMs, bringing semantic context to AI agents. 🔥
https://getwren.ai/oss
Apache License 2.0
114 stars 25 forks source link

Allow save query as view without column alias #680

Closed goldmedal closed 1 month ago

goldmedal commented 1 month ago

Description

We have introduced the view in https://github.com/Canner/wren-engine/pull/645 but there are some column limitations for it. Currently, we query the complex expression with the alias name in the view. The followed SQL isn't valid:

select order_id, sum(price) from wrenai.public.order_items group by order_id

It should be

select order_id, sum(price) as sum_price from wrenai.public.order_items group by order_id

There're some todo case that should be enabled: https://github.com/Canner/wren-engine/blob/daf5a60fd4695e85fb152c589c83cd4c5a328f40/wren-modeling-rs/sqllogictest/src/test_context.rs#L261-L262

goldmedal commented 1 month ago

I found even we add an alias for it, the complex expressions are also broken. I disable the test at https://github.com/Canner/wren-engine/blob/f6c1cbf0d5c7abad7488b18165d2135dc1ca9af4/wren-modeling-rs/sqllogictest/src/test_context.rs#L262