sqlglot
sqlglot copied to clipboard
Python SQL Parser and Transpiler
Work in progress. Submitting as a PR for feedback. Comments/questions will be inline.
Initial draft of some polish work for Snowflake datetime related items. 1. Support for `DATE_PART` `DATE_PART` is a function roughly equivalent to `EXTRACT` that's present in many databases (including [Redshift](https://docs.aws.amazon.com/redshift/latest/dg/r_DATE_PART_function.html),...
ClickHouse has a somewhat unique way of spelling these: ``` 9bf006fcf914 :) select quantile(0.5)(a) from (select 1 a union all select 2); SELECT quantile(0.5)(a) FROM ( SELECT 1 AS a...
Spark 3 supports two CREATE TABLE formats: https://spark.apache.org/docs/latest/sql-ref-syntax-ddl-create-table-hiveformat.html https://spark.apache.org/docs/latest/sql-ref-syntax-ddl-create-table-datasource.html Some of the spark dialect assumes the former, some assumes the latter, and you can easily end up with an invalid...
Similar to https://github.com/tobymao/sqlglot/pull/3357 - Postgres doesn't support `COMMENT` post-schema properties. Reference: https://www.postgresql.org/docs/current/sql-createtable.html
Followup from slack message https://tobiko-data.slack.com/archives/C0448SFS3PF/p1715277495692029?thread_ts=1715277495.692029&cid=C0448SFS3PF **Fully reproducible code snippet** ```` from sqlglot import parse_one from sqlglot.optimizer import optimize query = """ select pt.c2, t2.person_id AS person_id, ( SELECT MAX(t3.full_name) AS...
Fixes https://github.com/tobymao/sqlglot/issues/3460 - Default hex function of all dialects, including `SQLGlot` dialect, to uppercase. - Set HEX_LOWERCASE to True in the dialect if it produces lowercase output. - Simplify LOWER...
## Problem: HEX function encodes a bytes or string into a hexadecimal encoding, but the result of the function is vary between dialects, due to the case of the result....
**Before you file an issue** - Make sure you specify the "read" dialect eg. `parse_one(sql, read="spark")`: bigquery dialect - Make sure you specify the "write" dialect eg. `ast.sql(dialect="duckdb")`: Not applicable...
Introduce support for `ALTER TABLE ... SET ...` across first class dialects. Design notes: ---------------- - Create an `exp.AlterSet` node belonging in `ALTER_PARSERS` that will hold the arguments across all...