You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DATEPART Function fails if you use text('YEAR') instead of 'YEAR' #177
When I attempt to use a datepart function with text('YEAR'), the compile code for the databricks dialect throws and error (see sample code below as it is trying to treat the text part as a quoted identifier common to databricks `.
Environment Information
OS = Windows 2022 Server
Python Version = 3.10.2
Python Package Versions
I'll review this in detail tomorrow but just wanted to throw out: I love that you're reading .databrickscfg in your repro scripts. We have an open feature request to build this support directly into the connector #148. It's good to see another usage of .databrickscfg in the wild.
This one isn't a bug. text('YEAR') inserts raw SQL — the word YEAR without quotes — which Databricks reads as a column name. date_part needs a string literal for the unit, so use a bound string instead:
Activity
narquette commentedon Jul 11, 2023
I'm sure that it will fail for other datepart calls as well such as text('MONTH'), text('DAY')
susodapop commentedon Jul 11, 2023
I'll review this in detail tomorrow but just wanted to throw out: I love that you're reading
.databrickscfgin your repro scripts. We have an open feature request to build this support directly into the connector #148. It's good to see another usage of.databrickscfgin the wild.narquette commentedon Jul 13, 2023
Did you get a chance to review it?
susodapop commentedon Jul 13, 2023
Negative. Focused instead on pushing the next release out this week.
cathleeny commentedon Dec 3, 2026
This one isn't a bug.
text('YEAR')inserts raw SQL — the wordYEARwithout quotes — which Databricks reads as a column name.date_partneeds a string literal for the unit, so use a bound string instead:Reference: https://docs.databricks.com/aws/en/sql/language-manual/functions/date_part