tekumara / fakesnow

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

`Catalog Error: Scalar Function with name date does not exist!` in version 0.9.8 #83

Closed Stegallo closed 2 months ago

Stegallo commented 2 months ago

when using function date() in a sql script results in Catalog Error: Scalar Function with name date does not exist! in version 0.9.8.

it used to work successfully in version 0.9.6.

here's code used to replicate the issue. Works in 0.9.6. Fails in 0.9.8

import fakesnow
import snowflake.connector

conn = snowflake.connector.connect()

conn.cursor().execute('CREATE DATABASE TEST')
conn.cursor().execute('USE DATABASE TEST')
conn.cursor().execute('CREATE SCHEMA TEST')
conn.cursor().execute('USE SCHEMA TEST')
print(conn.cursor().execute("with SOURCE_TABLE AS (SELECT '2024-01-01' AS start_date) SELECT 'Hello fake world!', date(a.start_date) from SOURCE_TABLE AS a").fetchone())
tekumara commented 2 months ago

Thanks for raising this, looks like this was introduced when moving from sqlglot 21.2 to 23.3 👀

tekumara commented 2 months ago

Raised here https://github.com/tobymao/sqlglot/issues/3338