Snowflake datetime type and function support
Initial draft of some polish work for Snowflake datetime related items.
- Support for
DATE_PART
DATE_PART is a function roughly equivalent to EXTRACT that's present in many databases (including Redshift, Databricks, Snowflake, and SQL Server). I added DATE_PART as 2-argument function expression.
- In Snowflake, using
EXTRACTas a synonym forDATE_PART
In my SQL codebase I found instances of the EXTRACT function being used as a synonym for DATE_PART using the 2-argument syntax instead of the FROM syntax. This isn't clearly documented, but it is an officially supported use of EXTRACT.
I quickly threw together a first pass modifying the global _parse_extract, though I suspect this isn't the right approach. In order to best encapsulate Snowflake's nonstandard behavior, I probably want to write a custom _parse_extract for Snowflake and include it as part of the Snowflake parser's FUNCTION_PARSERS block. Looking for guidance.
- Added snowflake timestamp types
Added support for Snowflake's relatively unique TIMESTAMP WITH LOCAL TIME ZONE.
Snowflake has no plain TIMESTAMP type. When Snowflake parses a TIMESTAMP expression it checks the current session parameters to determine how it should be interpreted, with TIMESTAMP_NTZ as the default. I have reflected this default in sqlglot behavior, but I'd like to go a step further and throw a parser warning when sqlglot encounters a naked TIMESTAMP in snowflake sql.
why not just have the default timestamp turn into snowflake default?
@teej any plans to finish this?
I'll wrap it up tonight/tomorrow
Closing this, will open a new PR.