Canner / wren-engine

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

fix(core): disable CommonSubexprEliminate to avoid generate invalid plan for unparsing #917

Closed goldmedal closed 3 days ago

goldmedal commented 4 days ago

Description

CommonSubexprEliminate is used to clean up the duplicate expressions. However, it could generate a plan like

     Projection: c.properties_first AS contact_first_name, c.properties_last AS contact_last_name, c.properties_e AS properties_e_a
      Projection: c.createdAt, c.properties_e, c.properties_first, c.properties_last
        Filter: __common_expr_1 >= CAST(CAST(Utf8("2024-11-01 00:00:00") AS Timestamp(Nanosecond, None)) AS Timestamp(Nanosecond, Some("+00:00"))) AND __common_expr_1 < CAST(CAST(Utf8("2024-11-15 00:00:00") AS Timestamp(Nanosecond, None)) AS Timestamp(Nanosecond, Some("+00:00")))
          Projection: CAST(c.createdAt AS Timestamp(Nanosecond, Some("+00:00"))) AS __common_expr_1, c.createdAt, c.properties_e, c.properties_first, c.properties_last

This plan has continued projection plans that cause an anonymous subquery. There are some issues with the continued projection plans for the unparsing.

This PR disables it to avoid generating this kind of plan.