tekumara / fakesnow

Fake Snowflake Connector for Python. Run, mock and test Snowflake DB locally.
Apache License 2.0
83 stars 7 forks source link

fix: GET_PATH precedence for JSONExtractScalar #78

Closed seruman closed 2 months ago

seruman commented 3 months ago

I've encountered another precedence issue with json extract scalar this time;

select JSON('{"K1": "a", "K2": "b"}') as col, CASE WHEN COL ->> '$.K1' = 'a' AND COL ->> '$.K2' = 'b' THEN 'yes' END as r;
-- Error: Conversion Error: Failed to cast value to numerical: {"K1":"a","K2":"b"}

select JSON('{"K1": "a", "K2": "b"}') as col, CASE WHEN (COL ->> '$.K1') = 'a' AND (COL ->> '$.K2') = 'b' THEN 'yes' END as r;
-- ┌─────────────────────┬─────────┐
-- │         col         │    r    │
-- │        json         │ varchar │
-- ├─────────────────────┼─────────┤
-- │ {"K1":"a","K2":"b"} │ yes     │
-- └─────────────────────┴─────────┘
tekumara commented 2 months ago

Thank you for the fix!

seruman commented 2 months ago

Thank you for the fix!

thanks for this awesome project 🎉