sqlglot 30.27.0__tar.gz → 30.29.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sqlglot-30.27.0 → sqlglot-30.29.0}/CHANGELOG.md +27 -0
- {sqlglot-30.27.0/sqlglot.egg-info → sqlglot-30.29.0}/PKG-INFO +3 -3
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/_version.py +3 -3
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/bigquery.py +1 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/expressions/builders.py +8 -1
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/expressions/core.py +4 -1
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/expressions/properties.py +5 -1
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/expressions/query.py +1 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/expressions/temporal.py +8 -1
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generator.py +11 -3
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/bigquery.py +42 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/duckdb.py +13 -8
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/oracle.py +6 -2
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/snowflake.py +5 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/sqlite.py +6 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/jsonpath.py +4 -1
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/eliminate_joins.py +5 -1
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/merge_subqueries.py +31 -2
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/unnest_subqueries.py +101 -16
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parser.py +2 -1
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/oracle.py +11 -2
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/snowflake.py +5 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/sqlite.py +33 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0/sqlglot.egg-info}/PKG-INFO +3 -3
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot.egg-info/requires.txt +2 -2
- sqlglot-30.29.0/sqlglot.egg-info/scm_version.json +8 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglotc/setup.py +5 -1
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_bigquery.py +22 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_dialect.py +35 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_oracle.py +6 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_postgres.py +6 -3
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_redshift.py +30 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_snowflake.py +77 -2
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_sqlite.py +52 -10
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/eliminate_joins.sql +36 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/optimizer.sql +18 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/simplify.sql +2 -2
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_expressions.py +79 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_jsonpath.py +7 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_optimizer.py +7 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_parser.py +22 -1
- sqlglot-30.27.0/sqlglot.egg-info/scm_version.json +0 -8
- {sqlglot-30.27.0 → sqlglot-30.29.0}/.gitignore +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/.gitmodules +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/.gitpod.yml +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/.pre-commit-config.yaml +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/AGENTS.md +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/CLAUDE.md +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/CONTRIBUTING.md +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/LICENSE +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/MANIFEST.in +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/Makefile +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/README.md +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/pyproject.toml +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/setup.cfg +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/setup.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/__init__.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/__main__.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/_typing.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/anonymize.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/__init__.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/athena.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/clickhouse.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/databricks.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/dax.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/dialect.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/doris.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/dremio.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/drill.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/druid.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/duckdb.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/dune.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/exasol.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/fabric.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/hive.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/materialize.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/mysql.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/oracle.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/postgres.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/presto.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/prql.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/redshift.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/risingwave.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/singlestore.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/snowflake.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/solr.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/spark.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/spark2.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/sqlite.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/starrocks.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/tableau.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/teradata.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/trino.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/dialects/tsql.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/diff.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/errors.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/executor/__init__.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/executor/context.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/executor/env.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/executor/python.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/executor/table.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/expressions/__init__.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/expressions/aggregate.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/expressions/array.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/expressions/constraints.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/expressions/datatypes.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/expressions/ddl.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/expressions/dml.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/expressions/functions.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/expressions/json.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/expressions/math.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/expressions/string.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/__init__.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/athena.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/clickhouse.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/databricks.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/dax.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/doris.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/dremio.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/drill.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/druid.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/dune.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/exasol.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/fabric.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/hive.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/materialize.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/mysql.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/postgres.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/presto.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/prql.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/python.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/redshift.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/risingwave.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/singlestore.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/solr.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/spark.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/spark2.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/starrocks.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/tableau.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/teradata.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/trino.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/generators/tsql.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/helper.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/lineage.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/__init__.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/annotate_types.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/canonicalize.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/canonicalize_internal_names.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/eliminate_ctes.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/eliminate_subqueries.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/helpers.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/isolate_table_selects.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/journal.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/normalize.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/normalize_identifiers.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/optimize_joins.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/optimizer.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/pushdown_predicates.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/pushdown_projections.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/qualify.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/qualify_columns.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/qualify_tables.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/resolver.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/scope.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/optimizer/simplify.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/__init__.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/athena.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/base.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/bigquery.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/clickhouse.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/databricks.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/dax.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/doris.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/dremio.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/drill.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/druid.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/duckdb.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/dune.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/exasol.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/fabric.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/hive.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/materialize.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/mysql.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/postgres.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/presto.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/prql.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/redshift.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/risingwave.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/singlestore.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/solr.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/spark.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/spark2.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/starrocks.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/tableau.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/teradata.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/trino.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/parsers/tsql.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/planner.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/py.typed +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/schema.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/serde.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/time.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/tokenizer_core.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/tokens.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/transforms.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/trie.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/typing/__init__.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/typing/bigquery.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/typing/clickhouse.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/typing/databricks.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/typing/duckdb.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/typing/hive.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/typing/mysql.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/typing/postgres.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/typing/presto.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/typing/redshift.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/typing/snowflake.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/typing/spark.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/typing/spark2.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot/typing/tsql.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot.egg-info/SOURCES.txt +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot.egg-info/dependency_links.txt +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot.egg-info/scm_file_list.json +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot.egg-info/top_level.txt +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglot.png +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglotc/MANIFEST.in +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/sqlglotc/pyproject.toml +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/__init__.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/__init__.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_athena.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_clickhouse.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_databricks.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_dax.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_doris.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_dremio.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_drill.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_druid.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_duckdb.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_dune.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_exasol.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_fabric.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_hive.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_materialize.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_mysql.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_pipe_syntax.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_presto.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_prql.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_risingwave.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_singlestore.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_solr.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_spark.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_starrocks.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_tableau.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_teradata.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_trino.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/dialects/test_tsql.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/identity.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/jsonpath/LICENSE +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/jsonpath/cts.json +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/annotate_functions.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/annotate_types.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/canonicalize.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/canonicalize_internal_names.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/eliminate_ctes.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/eliminate_subqueries.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/isolate_table_selects.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/merge_subqueries.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/normalize.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/normalize_identifiers.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/optimize_joins.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/pushdown_cte_alias_columns.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/pushdown_predicates.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/pushdown_projections.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/qualify_columns.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/qualify_columns__invalid.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/qualify_columns__with_invisible.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/qualify_columns_ddl.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/qualify_tables.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/quote_identifiers.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/call_center.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/catalog_page.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/catalog_returns.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/catalog_sales.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/customer.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/customer_address.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/customer_demographics.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/date_dim.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/household_demographics.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/income_band.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/inventory.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/item.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/promotion.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/reason.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/ship_mode.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/store.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/store_returns.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/store_sales.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/time_dim.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/tpc-ds.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/warehouse.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/web_page.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/web_returns.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/web_sales.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-ds/web_site.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-h/customer.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-h/lineitem.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-h/nation.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-h/orders.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-h/part.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-h/partsupp.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-h/region.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-h/supplier.csv.gz +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/tpc-h/tpc-h.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/optimizer/unnest_subqueries.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/partial.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/fixtures/pretty.sql +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/gen_fixtures.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/helpers.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/leakcheck.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/sqlglot/__init__.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_anonymize.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_build.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_dialect_entry_points.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_dialect_imports.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_diff.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_docs.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_errors.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_executor.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_generator.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_helper.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_integration_loader.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_lineage.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_schema.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_serde.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_sqlglotc.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_time.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_tokens.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_transforms.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_transpile.py +0 -0
- {sqlglot-30.27.0 → sqlglot-30.29.0}/tests/test_typing.py +0 -0
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
## [v30.27.0] - 2026-10-30
|
|
5
|
+
### :boom: BREAKING CHANGES
|
|
6
|
+
- due to [`5b7af1e`](https://github.com/tobymao/sqlglot/commit/5b7af1e765052d256aacb7d42624aee1a076fac4) - parse ~ as a partial regex match from DuckDB 2.0 [a mix of models in Hermes Agent] *(PR [#8840](https://github.com/tobymao/sqlglot/pull/8840) by [@ryanduguid](https://github.com/ryanduguid))*:
|
|
7
|
+
|
|
8
|
+
parse ~ as a partial regex match from DuckDB 2.0 [a mix of models in Hermes Agent] (#8840)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### :sparkles: New Features
|
|
12
|
+
- [`9878263`](https://github.com/tobymao/sqlglot/commit/98782638dd6dbdedebad0e6ff6edc6e69598b81e) - add REF data type for named references *(PR [#8847](https://github.com/tobymao/sqlglot/pull/8847) by [@georgesittas](https://github.com/georgesittas))*
|
|
13
|
+
|
|
14
|
+
### :bug: Bug Fixes
|
|
15
|
+
- [`04f4a44`](https://github.com/tobymao/sqlglot/commit/04f4a4405b80dde33a05da0f4271a6ea2ac38938) - **parser**: allow IN as identifier *(PR [#8837](https://github.com/tobymao/sqlglot/pull/8837) by [@treysp](https://github.com/treysp))*
|
|
16
|
+
- [`f31f109`](https://github.com/tobymao/sqlglot/commit/f31f109daef0ca99347d36295534a0d59956059c) - **duckdb**: prevent SORT BY tokenization *(commit by [@treysp](https://github.com/treysp))*
|
|
17
|
+
- [`5b7af1e`](https://github.com/tobymao/sqlglot/commit/5b7af1e765052d256aacb7d42624aee1a076fac4) - **duckdb**: parse ~ as a partial regex match from DuckDB 2.0 [a mix of models in Hermes Agent] *(PR [#8840](https://github.com/tobymao/sqlglot/pull/8840) by [@ryanduguid](https://github.com/ryanduguid))*
|
|
18
|
+
- [`20f01c7`](https://github.com/tobymao/sqlglot/commit/20f01c7fbc0d7b80d1ef6ead063e6510026de36d) - **optimizer**: Fix merging subqueries with group by all and window functions ([#8834](https://github.com/tobymao/sqlglot/pull/8834)) [CODEX] *(commit by [@fivetran-amrutabhimsenayachit](https://github.com/fivetran-amrutabhimsenayachit))*
|
|
19
|
+
- [`52763cd`](https://github.com/tobymao/sqlglot/commit/52763cdd96d5d6d4e7d8f06213c586ebfec8c711) - **sqlite**: preserve modifiers on parenthesized queries [CODEX] *(PR [#8843](https://github.com/tobymao/sqlglot/pull/8843) by [@georgesittas](https://github.com/georgesittas))*
|
|
20
|
+
- :arrow_lower_right: *fixes issue [#8841](https://github.com/tobymao/sqlglot/issues/8841) opened by [@dvzadara](https://github.com/dvzadara)*
|
|
21
|
+
- [`da00199`](https://github.com/tobymao/sqlglot/commit/da00199fa2a33505bbb4b6c708d1ec10a0549850) - **optimizer**: skip decorrelation for subqueries evaluated after outer GROUP BY *(PR [#8836](https://github.com/tobymao/sqlglot/pull/8836) by [@treysp](https://github.com/treysp))*
|
|
22
|
+
|
|
23
|
+
### :zap: Performance Improvements
|
|
24
|
+
- [`2ef935d`](https://github.com/tobymao/sqlglot/commit/2ef935d6ce02dd46e579b2edda7fce6298c8ad11) - **diff**: index the leaf matching set when scoring node pairs [CLAUDE] *(PR [#8838](https://github.com/tobymao/sqlglot/pull/8838) by [@LD-RW](https://github.com/LD-RW))*
|
|
25
|
+
|
|
26
|
+
### :recycle: Refactors
|
|
27
|
+
- [`6f90b49`](https://github.com/tobymao/sqlglot/commit/6f90b498078d65515bf57cf71c94332daf282009) - **diff**: keep the edit script in a stable order *(PR [#8844](https://github.com/tobymao/sqlglot/pull/8844) by [@LD-RW](https://github.com/LD-RW))*
|
|
28
|
+
|
|
29
|
+
|
|
4
30
|
## [v30.26.0] - 2026-10-29
|
|
5
31
|
### :boom: BREAKING CHANGES
|
|
6
32
|
- due to [`e54ad9a`](https://github.com/tobymao/sqlglot/commit/e54ad9aaedeb5e9b2be615ebd5f1ff40cfb854a2) - resolve set operation types during annotation [CODEX] *(PR [#8720](https://github.com/tobymao/sqlglot/pull/8720) by [@georgesittas](https://github.com/georgesittas))*:
|
|
@@ -16560,3 +16586,4 @@ pip install "sqlglot[c]" # compiled — faster, but no subclassing
|
|
|
16560
16586
|
[v30.24.0]: https://github.com/tobymao/sqlglot/compare/v30.23.0...v30.24.0
|
|
16561
16587
|
[v30.25.0]: https://github.com/tobymao/sqlglot/compare/v30.24.0...v30.25.0
|
|
16562
16588
|
[v30.26.0]: https://github.com/tobymao/sqlglot/compare/v30.25.0...v30.26.0
|
|
16589
|
+
[v30.27.0]: https://github.com/tobymao/sqlglot/compare/v30.26.0...v30.27.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sqlglot
|
|
3
|
-
Version: 30.
|
|
3
|
+
Version: 30.29.0
|
|
4
4
|
Summary: An easily customizable SQL parser and transpiler
|
|
5
5
|
Author-email: Toby Mao <toby.mao@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -34,10 +34,10 @@ Requires-Dist: types-pytz; extra == "dev"
|
|
|
34
34
|
Requires-Dist: typing_extensions; extra == "dev"
|
|
35
35
|
Requires-Dist: pyperf; extra == "dev"
|
|
36
36
|
Provides-Extra: c
|
|
37
|
-
Requires-Dist: sqlglotc==30.
|
|
37
|
+
Requires-Dist: sqlglotc==30.29.0; python_version >= "3.10" and extra == "c"
|
|
38
38
|
Provides-Extra: rs
|
|
39
39
|
Requires-Dist: sqlglotrs==0.13.0; extra == "rs"
|
|
40
|
-
Requires-Dist: sqlglotc==30.
|
|
40
|
+
Requires-Dist: sqlglotc==30.29.0; python_version >= "3.10" and extra == "rs"
|
|
41
41
|
Dynamic: license-file
|
|
42
42
|
Dynamic: provides-extra
|
|
43
43
|
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '30.
|
|
22
|
-
__version_tuple__ = version_tuple = (30,
|
|
21
|
+
__version__ = version = '30.29.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (30, 29, 0)
|
|
23
23
|
|
|
24
|
-
__commit_id__ = commit_id = '
|
|
24
|
+
__commit_id__ = commit_id = 'g2fe25297a'
|
|
@@ -824,7 +824,7 @@ def normalize_table_name(table: str | Table, dialect: DialectType = None, copy:
|
|
|
824
824
|
def replace_tables(
|
|
825
825
|
expression: E, mapping: dict[str, str], dialect: DialectType = None, copy: bool = True
|
|
826
826
|
) -> E:
|
|
827
|
-
"""Replace all tables in expression according to the mapping.
|
|
827
|
+
"""Replace all FROM sources (tables, views, table functions...) in expression according to the mapping.
|
|
828
828
|
|
|
829
829
|
Args:
|
|
830
830
|
expression: expression node to be transformed and replaced.
|
|
@@ -845,6 +845,10 @@ def replace_tables(
|
|
|
845
845
|
|
|
846
846
|
def _replace_tables(node: Expr) -> Expr:
|
|
847
847
|
if isinstance(node, Table) and node.meta_get("replace") is not False:
|
|
848
|
+
call = node.this
|
|
849
|
+
if isinstance(call, Func) and not isinstance(call, Anonymous):
|
|
850
|
+
return node
|
|
851
|
+
|
|
848
852
|
original = normalize_table_name(node, dialect=dialect)
|
|
849
853
|
new_name = mapping.get(original)
|
|
850
854
|
|
|
@@ -854,6 +858,9 @@ def replace_tables(
|
|
|
854
858
|
**{k: v for k, v in node.args.items() if k not in TABLE_PARTS},
|
|
855
859
|
dialect=dialect,
|
|
856
860
|
)
|
|
861
|
+
if isinstance(call, Anonymous):
|
|
862
|
+
call.set("this", table.this)
|
|
863
|
+
table.set("this", call)
|
|
857
864
|
table.add_comments([original])
|
|
858
865
|
return table
|
|
859
866
|
return node
|
|
@@ -933,7 +933,10 @@ class Expression(Expr):
|
|
|
933
933
|
|
|
934
934
|
@property
|
|
935
935
|
def is_int(self) -> bool:
|
|
936
|
-
|
|
936
|
+
try:
|
|
937
|
+
return self.is_number and isinstance(self.to_py(), int)
|
|
938
|
+
except ValueError:
|
|
939
|
+
return False
|
|
937
940
|
|
|
938
941
|
@property
|
|
939
942
|
def is_star(self) -> bool:
|
|
@@ -222,6 +222,10 @@ class OutputModelProperty(Property):
|
|
|
222
222
|
arg_types = {"this": True}
|
|
223
223
|
|
|
224
224
|
|
|
225
|
+
class InteractiveProperty(Property):
|
|
226
|
+
arg_types = {}
|
|
227
|
+
|
|
228
|
+
|
|
225
229
|
class IsolatedLoadingProperty(Property):
|
|
226
230
|
arg_types = {"no": False, "concurrent": False, "target": False}
|
|
227
231
|
|
|
@@ -520,7 +524,7 @@ class UsingProperty(Property):
|
|
|
520
524
|
|
|
521
525
|
|
|
522
526
|
class TemporaryProperty(Property):
|
|
523
|
-
arg_types = {"this": False}
|
|
527
|
+
arg_types = {"this": False, "scoped": False}
|
|
524
528
|
|
|
525
529
|
|
|
526
530
|
class VirtualProperty(Property):
|
|
@@ -454,7 +454,13 @@ class ParseTime(Expression, Func):
|
|
|
454
454
|
|
|
455
455
|
|
|
456
456
|
class StrToDate(Expression, Func):
|
|
457
|
-
arg_types = {
|
|
457
|
+
arg_types = {
|
|
458
|
+
"this": True,
|
|
459
|
+
"format": False,
|
|
460
|
+
"safe": False,
|
|
461
|
+
"default_year": False,
|
|
462
|
+
"nlsparam": False,
|
|
463
|
+
}
|
|
458
464
|
|
|
459
465
|
|
|
460
466
|
class StrToTime(Expression, Func):
|
|
@@ -465,6 +471,7 @@ class StrToTime(Expression, Func):
|
|
|
465
471
|
"safe": False,
|
|
466
472
|
"target_type": False,
|
|
467
473
|
"default_year": False,
|
|
474
|
+
"nlsparam": False,
|
|
468
475
|
}
|
|
469
476
|
|
|
470
477
|
|
|
@@ -765,6 +765,7 @@ class Generator:
|
|
|
765
765
|
exp.IcebergProperty: exp.Properties.Location.POST_CREATE,
|
|
766
766
|
exp.IncludeProperty: exp.Properties.Location.POST_SCHEMA,
|
|
767
767
|
exp.InputModelProperty: exp.Properties.Location.POST_SCHEMA,
|
|
768
|
+
exp.InteractiveProperty: exp.Properties.Location.UNSUPPORTED,
|
|
768
769
|
exp.IsolatedLoadingProperty: exp.Properties.Location.POST_NAME,
|
|
769
770
|
exp.JournalProperty: exp.Properties.Location.POST_NAME,
|
|
770
771
|
exp.LanguageProperty: exp.Properties.Location.POST_SCHEMA,
|
|
@@ -2862,7 +2863,8 @@ class Generator:
|
|
|
2862
2863
|
else values
|
|
2863
2864
|
)
|
|
2864
2865
|
values = self.query_modifiers(expression, values)
|
|
2865
|
-
|
|
2866
|
+
pivots = self.expressions(expression, key="pivots", sep="", flat=True)
|
|
2867
|
+
return f"{values} AS {alias}{pivots}" if alias else f"{values}{pivots}"
|
|
2866
2868
|
|
|
2867
2869
|
# Converts `VALUES...` expression into a series of select unions.
|
|
2868
2870
|
alias_node = expression.args.get("alias")
|
|
@@ -2885,11 +2887,17 @@ class Generator:
|
|
|
2885
2887
|
# the deep nesting of the resulting exp.Unions. If this is a problem, either increase
|
|
2886
2888
|
# `sys.setrecursionlimit` to avoid RecursionErrors, or don't set `pretty`.
|
|
2887
2889
|
query = reduce(lambda x, y: exp.union(x, y, distinct=False, copy=False), selects)
|
|
2888
|
-
|
|
2890
|
+
for key in ("order", "limit", "offset"):
|
|
2891
|
+
if value := expression.args.get(key):
|
|
2892
|
+
query.set(key, value.pop())
|
|
2893
|
+
subquery = query.subquery(alias_node and alias_node.this, copy=False)
|
|
2894
|
+
subquery.set("pivots", expression.args.pop("pivots", None))
|
|
2895
|
+
return self.subquery_sql(subquery)
|
|
2889
2896
|
|
|
2890
2897
|
alias = f" AS {self.sql(alias_node, 'this')}" if alias_node else ""
|
|
2891
2898
|
unions = " UNION ALL ".join(self.sql(select) for select in selects)
|
|
2892
|
-
|
|
2899
|
+
pivots = self.expressions(expression, key="pivots", sep="", flat=True)
|
|
2900
|
+
return f"({self.query_modifiers(expression, unions)}){alias}{pivots}"
|
|
2893
2901
|
|
|
2894
2902
|
def var_sql(self, expression: exp.Var) -> str:
|
|
2895
2903
|
return self.sql(expression, "this")
|
|
@@ -30,9 +30,13 @@ from sqlglot.dialects.dialect import (
|
|
|
30
30
|
groupconcat_sql,
|
|
31
31
|
sha2_digest_sql,
|
|
32
32
|
)
|
|
33
|
+
from sqlglot.errors import ErrorLevel
|
|
33
34
|
from sqlglot.generator import unsupported_args
|
|
34
35
|
from sqlglot.helper import seq_get
|
|
35
36
|
|
|
37
|
+
if t.TYPE_CHECKING:
|
|
38
|
+
from sqlglot.dialects.dialect import DialectType
|
|
39
|
+
|
|
36
40
|
logger = logging.getLogger("sqlglot")
|
|
37
41
|
|
|
38
42
|
JSON_EXTRACT_TYPE = t.Union[exp.JSONExtract, exp.JSONExtractScalar, exp.JSONExtractArray]
|
|
@@ -683,6 +687,44 @@ class BigQueryGenerator(generator.Generator):
|
|
|
683
687
|
"within",
|
|
684
688
|
}
|
|
685
689
|
|
|
690
|
+
def __init__(
|
|
691
|
+
self,
|
|
692
|
+
pretty: bool | int | None = None,
|
|
693
|
+
identify: str | bool = False,
|
|
694
|
+
normalize: bool = False,
|
|
695
|
+
pad: int = 2,
|
|
696
|
+
indent: int = 2,
|
|
697
|
+
normalize_functions: str | bool | None = None,
|
|
698
|
+
unsupported_level: ErrorLevel = ErrorLevel.WARN,
|
|
699
|
+
max_unsupported: int = 3,
|
|
700
|
+
leading_comma: bool = False,
|
|
701
|
+
max_text_width: int = 80,
|
|
702
|
+
comments: bool = True,
|
|
703
|
+
dialect: DialectType = None,
|
|
704
|
+
) -> None:
|
|
705
|
+
super().__init__(
|
|
706
|
+
pretty=pretty,
|
|
707
|
+
identify=identify,
|
|
708
|
+
normalize=normalize,
|
|
709
|
+
pad=pad,
|
|
710
|
+
indent=indent,
|
|
711
|
+
normalize_functions=normalize_functions,
|
|
712
|
+
unsupported_level=unsupported_level,
|
|
713
|
+
max_unsupported=max_unsupported,
|
|
714
|
+
leading_comma=leading_comma,
|
|
715
|
+
max_text_width=max_text_width,
|
|
716
|
+
comments=comments,
|
|
717
|
+
dialect=dialect,
|
|
718
|
+
)
|
|
719
|
+
|
|
720
|
+
self._escaped_identifier_end = r"\`"
|
|
721
|
+
|
|
722
|
+
# Escape existing backslashes before introducing new escape sequences.
|
|
723
|
+
self._identifier_escaped_sequences = {
|
|
724
|
+
**self._identifier_escaped_sequences,
|
|
725
|
+
**self.dialect.ESCAPED_SEQUENCES,
|
|
726
|
+
}
|
|
727
|
+
|
|
686
728
|
def frombase_sql(self, expression: exp.FromBase) -> str:
|
|
687
729
|
# Hex is the only base BigQuery can cast from, and the sign goes before the prefix, e.g. -0xff
|
|
688
730
|
if expression.expression.name != "16":
|
|
@@ -111,7 +111,7 @@ def _apply_base64_alphabet_replacements(
|
|
|
111
111
|
reverse: bool = False,
|
|
112
112
|
) -> exp.Expr:
|
|
113
113
|
"""
|
|
114
|
-
|
|
114
|
+
Translate base64 alphabet characters without cascading replacements.
|
|
115
115
|
|
|
116
116
|
Base64 alphabet can be 1-3 chars: 1st = index 62 ('+'), 2nd = index 63 ('/'), 3rd = padding ('=').
|
|
117
117
|
zip truncates to the shorter string, so 1-char alphabet only replaces '+', 2-char replaces '+/', etc.
|
|
@@ -123,14 +123,19 @@ def _apply_base64_alphabet_replacements(
|
|
|
123
123
|
If True, replace custom with default (decode)
|
|
124
124
|
"""
|
|
125
125
|
if isinstance(alphabet, exp.Literal) and alphabet.is_string:
|
|
126
|
+
source, target = "", ""
|
|
126
127
|
for default_char, new_char in zip("+/=", alphabet.this):
|
|
127
128
|
if new_char != default_char:
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
source += default_char
|
|
130
|
+
target += new_char
|
|
131
|
+
if source:
|
|
132
|
+
if reverse:
|
|
133
|
+
source, target = target, source
|
|
134
|
+
result = exp.Translate(
|
|
135
|
+
this=result,
|
|
136
|
+
from_=exp.Literal.string(source),
|
|
137
|
+
to=exp.Literal.string(target),
|
|
138
|
+
)
|
|
134
139
|
return result
|
|
135
140
|
|
|
136
141
|
|
|
@@ -139,7 +144,7 @@ def _base64_decode_sql(self: DuckDBGenerator, expression: exp.Expr, to_string: b
|
|
|
139
144
|
Transpile Snowflake BASE64_DECODE_STRING/BINARY to DuckDB.
|
|
140
145
|
|
|
141
146
|
DuckDB uses FROM_BASE64() which returns BLOB. For string output, wrap with DECODE().
|
|
142
|
-
Custom alphabets require
|
|
147
|
+
Custom alphabets require TRANSLATE() to convert to standard base64.
|
|
143
148
|
"""
|
|
144
149
|
input_expr = expression.this
|
|
145
150
|
alphabet = expression.args.get("alphabet")
|
|
@@ -89,8 +89,12 @@ class OracleGenerator(generator.Generator):
|
|
|
89
89
|
exp.StrPosition: lambda self, e: strposition_sql(
|
|
90
90
|
self, e, func_name="INSTR", supports_position=True, supports_occurrence=True
|
|
91
91
|
),
|
|
92
|
-
exp.StrToTime: lambda self, e: self.func(
|
|
93
|
-
|
|
92
|
+
exp.StrToTime: lambda self, e: self.func(
|
|
93
|
+
"TO_TIMESTAMP", e.this, self.format_time(e), e.args.get("nlsparam")
|
|
94
|
+
),
|
|
95
|
+
exp.StrToDate: lambda self, e: self.func(
|
|
96
|
+
"TO_DATE", e.this, self.format_time(e), e.args.get("nlsparam")
|
|
97
|
+
),
|
|
94
98
|
exp.Subquery: lambda self, e: self.subquery_sql(e, sep=" "),
|
|
95
99
|
exp.Substring: rename_func("SUBSTR"),
|
|
96
100
|
exp.Table: lambda self, e: self.table_sql(e, sep=" "),
|
|
@@ -499,6 +499,7 @@ class SnowflakeGenerator(generator.Generator):
|
|
|
499
499
|
exp.GetExtract: rename_func("GET"),
|
|
500
500
|
exp.GroupConcat: lambda self, e: groupconcat_sql(self, e, sep=""),
|
|
501
501
|
exp.If: if_sql(name="IFF", false_value="NULL"),
|
|
502
|
+
exp.InteractiveProperty: lambda *_: "INTERACTIVE",
|
|
502
503
|
exp.JSONArray: lambda self, e: self.func(
|
|
503
504
|
"TO_VARIANT", self.func("ARRAY_CONSTRUCT", *e.expressions)
|
|
504
505
|
),
|
|
@@ -577,6 +578,9 @@ class SnowflakeGenerator(generator.Generator):
|
|
|
577
578
|
exp.StrtokToArray: rename_func("STRTOK_TO_ARRAY"),
|
|
578
579
|
exp.Stuff: rename_func("INSERT"),
|
|
579
580
|
exp.StPoint: rename_func("ST_MAKEPOINT"),
|
|
581
|
+
exp.TemporaryProperty: lambda _, e: (
|
|
582
|
+
"SCOPED TEMPORARY" if e.args.get("scoped") else "TEMPORARY"
|
|
583
|
+
),
|
|
580
584
|
exp.TimeAdd: date_delta_sql("TIMEADD"),
|
|
581
585
|
exp.TimeSlice: lambda self, e: self.func(
|
|
582
586
|
"TIME_SLICE",
|
|
@@ -648,6 +652,7 @@ class SnowflakeGenerator(generator.Generator):
|
|
|
648
652
|
PROPERTIES_LOCATION = {
|
|
649
653
|
**generator.Generator.PROPERTIES_LOCATION,
|
|
650
654
|
exp.CredentialsProperty: exp.Properties.Location.POST_WITH,
|
|
655
|
+
exp.InteractiveProperty: exp.Properties.Location.POST_CREATE,
|
|
651
656
|
exp.LocationProperty: exp.Properties.Location.POST_WITH,
|
|
652
657
|
exp.PartitionedByProperty: exp.Properties.Location.POST_SCHEMA,
|
|
653
658
|
exp.RowAccessProperty: exp.Properties.Location.POST_SCHEMA,
|
|
@@ -128,6 +128,12 @@ class SQLiteGenerator(generator.Generator):
|
|
|
128
128
|
exp.DType.VARBINARY: "BLOB",
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
def nullsafeeq_sql(self, expression: exp.NullSafeEQ) -> str:
|
|
132
|
+
return self.binary(expression, "IS")
|
|
133
|
+
|
|
134
|
+
def nullsafeneq_sql(self, expression: exp.NullSafeNEQ) -> str:
|
|
135
|
+
return self.binary(expression, "IS NOT")
|
|
136
|
+
|
|
131
137
|
TOKEN_MAPPING = {
|
|
132
138
|
TokenType.AUTO_INCREMENT: "AUTOINCREMENT",
|
|
133
139
|
}
|
|
@@ -113,7 +113,10 @@ def parse(path: str, dialect: DialectType = None) -> exp.JSONPath:
|
|
|
113
113
|
number += token.text
|
|
114
114
|
|
|
115
115
|
if number:
|
|
116
|
-
|
|
116
|
+
try:
|
|
117
|
+
return int(number)
|
|
118
|
+
except ValueError:
|
|
119
|
+
raise ParseError(_error(f"Invalid integer index: {number}"))
|
|
117
120
|
|
|
118
121
|
return False
|
|
119
122
|
|
|
@@ -84,7 +84,11 @@ def _is_joined_on_all_unique_outputs(scope: Scope, join: exp.Join) -> bool:
|
|
|
84
84
|
return False
|
|
85
85
|
|
|
86
86
|
_, join_keys, _ = join_condition(join)
|
|
87
|
-
|
|
87
|
+
|
|
88
|
+
# we check for columns because transformations can map distinct values to the same join key
|
|
89
|
+
remaining_unique_outputs = unique_outputs - {
|
|
90
|
+
c.name for c in join_keys if isinstance(c, exp.Column)
|
|
91
|
+
}
|
|
88
92
|
return not remaining_unique_outputs
|
|
89
93
|
|
|
90
94
|
|
|
@@ -6,7 +6,7 @@ from collections import Counter, defaultdict
|
|
|
6
6
|
|
|
7
7
|
from sqlglot import expressions as exp
|
|
8
8
|
from sqlglot.helper import find_new_name, seq_get
|
|
9
|
-
from sqlglot.optimizer.helpers import is_implicit_group_by_all
|
|
9
|
+
from sqlglot.optimizer.helpers import is_implicit_group_by_all, projection_has_aggregate
|
|
10
10
|
from sqlglot.optimizer.scope import Scope, find_all_in_scope, traverse_scope
|
|
11
11
|
|
|
12
12
|
if t.TYPE_CHECKING:
|
|
@@ -231,6 +231,28 @@ def _mergeable(
|
|
|
231
231
|
outer_args = outer.args
|
|
232
232
|
inner_name = from_or_join.alias_or_name
|
|
233
233
|
|
|
234
|
+
def _constant_projection_empties_group_by_all(column_free_aliases: set[str]) -> bool:
|
|
235
|
+
"""
|
|
236
|
+
GROUP BY ALL infers its keys from the SELECT list, but engines (e.g. DuckDB) drop any
|
|
237
|
+
column-free SELECT item from that inferred set, unlike a column reference to the same
|
|
238
|
+
constant. Only unsafe if inlining would empty out every remaining key; a constant key
|
|
239
|
+
beside a real column key is harmless.
|
|
240
|
+
"""
|
|
241
|
+
if not column_free_aliases or not is_implicit_group_by_all(t.cast(exp.Select, outer)):
|
|
242
|
+
return False
|
|
243
|
+
|
|
244
|
+
windows = outer_args.get("windows")
|
|
245
|
+
for s in t.cast(exp.Select, outer).selects:
|
|
246
|
+
if projection_has_aggregate(s, windows):
|
|
247
|
+
continue
|
|
248
|
+
if any(
|
|
249
|
+
column.table != inner_name or column.name not in column_free_aliases
|
|
250
|
+
for column in find_all_in_scope(s, exp.Column)
|
|
251
|
+
):
|
|
252
|
+
return False
|
|
253
|
+
|
|
254
|
+
return True
|
|
255
|
+
|
|
234
256
|
def _window_projection_blocks_merge(window_aliases: set[str]) -> bool:
|
|
235
257
|
"""A window function's result depends on the full row set it sees, so merging the
|
|
236
258
|
subquery into the outer query is unsafe when:
|
|
@@ -378,6 +400,7 @@ def _mergeable(
|
|
|
378
400
|
# Window tree walks, and precomputes what the checks below need per-projection.
|
|
379
401
|
window_aliases: set[str] = set()
|
|
380
402
|
number_literal_aliases: set[str] = set()
|
|
403
|
+
column_free_aliases: set[str] = set()
|
|
381
404
|
projections: dict[str, exp.Expr] = {}
|
|
382
405
|
|
|
383
406
|
for s in inner_select.selects:
|
|
@@ -385,14 +408,20 @@ def _mergeable(
|
|
|
385
408
|
projections[name] = s
|
|
386
409
|
if s.unalias().is_number:
|
|
387
410
|
number_literal_aliases.add(name)
|
|
411
|
+
has_column = False
|
|
388
412
|
for node in s.walk():
|
|
389
413
|
if isinstance(node, (exp.AggFunc, exp.Select, *exp.SET_RETURNING_FUNCTIONS)):
|
|
390
414
|
return False
|
|
391
415
|
if isinstance(node, exp.Window):
|
|
392
416
|
window_aliases.add(name)
|
|
417
|
+
if isinstance(node, exp.Column):
|
|
418
|
+
has_column = True
|
|
419
|
+
if not has_column:
|
|
420
|
+
column_free_aliases.add(name)
|
|
393
421
|
|
|
394
422
|
return (
|
|
395
|
-
not
|
|
423
|
+
not _constant_projection_empties_group_by_all(column_free_aliases)
|
|
424
|
+
and not _outer_select_joins_on_inner_select_join(projections)
|
|
396
425
|
and not _window_projection_blocks_merge(window_aliases)
|
|
397
426
|
and not _literal_group_unmergeable(number_literal_aliases)
|
|
398
427
|
and not _literal_in_order_by(number_literal_aliases)
|
|
@@ -31,6 +31,28 @@ def unnest_subqueries(expression: E) -> E:
|
|
|
31
31
|
parent = select.parent_select
|
|
32
32
|
if not parent:
|
|
33
33
|
continue
|
|
34
|
+
|
|
35
|
+
# Don't hoist a subquery out of a correlated, ungrouped aggregate if it's evaluated after the
|
|
36
|
+
# aggregation: the aggregate returns a row even for keys with no input rows, and the hoisted
|
|
37
|
+
# MAX(...) would turn the row's value into NULL
|
|
38
|
+
if (
|
|
39
|
+
scope.parent
|
|
40
|
+
and scope.parent.expression is parent
|
|
41
|
+
and scope.parent.is_correlated_subquery
|
|
42
|
+
and not _has_plain_explicit_group(parent)
|
|
43
|
+
and (
|
|
44
|
+
_has_aggregate_projection(parent)
|
|
45
|
+
or _has_order_aggregate(parent)
|
|
46
|
+
or parent.args.get("having")
|
|
47
|
+
or (
|
|
48
|
+
(qualify := parent.args.get("qualify"))
|
|
49
|
+
and projection_has_aggregate(qualify, parent.args.get("windows"))
|
|
50
|
+
)
|
|
51
|
+
)
|
|
52
|
+
and _is_post_aggregation(select, parent)
|
|
53
|
+
):
|
|
54
|
+
continue
|
|
55
|
+
|
|
34
56
|
if scope.external_columns:
|
|
35
57
|
# a correlated set operation branch can't be hoisted out on its own
|
|
36
58
|
if scope.scope_type != ScopeType.SET_OPERATION:
|
|
@@ -82,6 +104,14 @@ def unnest(select, parent_select, next_alias_name):
|
|
|
82
104
|
)
|
|
83
105
|
).from_(select.subquery(inner_alias))
|
|
84
106
|
|
|
107
|
+
if (
|
|
108
|
+
isinstance(predicate, (exp.In, exp.Any))
|
|
109
|
+
and not select.args.get("group")
|
|
110
|
+
and not find_in_scope(select.selects[0], exp.AggFunc)
|
|
111
|
+
and find_in_scope(select.selects[0], exp.Anonymous)
|
|
112
|
+
):
|
|
113
|
+
return
|
|
114
|
+
|
|
85
115
|
alias = next_alias_name()
|
|
86
116
|
|
|
87
117
|
# This subquery returns a scalar and can just be converted to a cross join
|
|
@@ -188,7 +218,9 @@ def decorrelate(select, parent_select, external_columns, next_alias_name):
|
|
|
188
218
|
return
|
|
189
219
|
|
|
190
220
|
if isinstance(parent_predicate, (exp.In, exp.Any, exp.All)) and (
|
|
191
|
-
select.args.get("group")
|
|
221
|
+
select.args.get("group")
|
|
222
|
+
or select.args.get("having")
|
|
223
|
+
or find_in_scope(select, exp.AggFunc, exp.Anonymous)
|
|
192
224
|
):
|
|
193
225
|
return
|
|
194
226
|
|
|
@@ -219,6 +251,8 @@ def decorrelate(select, parent_select, external_columns, next_alias_name):
|
|
|
219
251
|
if isinstance(on_clause_ancestor, exp.Join) and on_clause_join_index is None:
|
|
220
252
|
return
|
|
221
253
|
|
|
254
|
+
zero_fill = False
|
|
255
|
+
|
|
222
256
|
if isinstance(parent_predicate, exp.Exists):
|
|
223
257
|
if select.args.get("having") or select.args.get("qualify"):
|
|
224
258
|
return
|
|
@@ -235,6 +269,34 @@ def decorrelate(select, parent_select, external_columns, next_alias_name):
|
|
|
235
269
|
return
|
|
236
270
|
elif not _is_plain_group(group):
|
|
237
271
|
return
|
|
272
|
+
if any(find_in_scope(projection, exp.Anonymous) for projection in select.selects):
|
|
273
|
+
return
|
|
274
|
+
elif not isinstance(parent_predicate, (exp.All, exp.Any, exp.In)):
|
|
275
|
+
value = select.selects[0]
|
|
276
|
+
group = select.args.get("group")
|
|
277
|
+
if group and not _has_plain_explicit_group(select):
|
|
278
|
+
return
|
|
279
|
+
|
|
280
|
+
if not group and (
|
|
281
|
+
select.args.get("having") or select.args.get("qualify") or _has_order_aggregate(select)
|
|
282
|
+
):
|
|
283
|
+
return
|
|
284
|
+
|
|
285
|
+
if find_in_scope(value, exp.Window):
|
|
286
|
+
return
|
|
287
|
+
|
|
288
|
+
if find_in_scope(value, exp.AggFunc, exp.Anonymous):
|
|
289
|
+
projection = value.unalias().unnest()
|
|
290
|
+
if (
|
|
291
|
+
not value.alias
|
|
292
|
+
or len(select.selects) != 1
|
|
293
|
+
or not _is_supported_scalar_aggregate(projection)
|
|
294
|
+
or select.args.get("qualify")
|
|
295
|
+
):
|
|
296
|
+
return
|
|
297
|
+
|
|
298
|
+
# Key-grouped COUNT returns scalar NULL when no group matches.
|
|
299
|
+
zero_fill = not group and isinstance(projection, exp.Count)
|
|
238
300
|
|
|
239
301
|
# Joined columns may not be grouped, so keep post-group subqueries correlated.
|
|
240
302
|
parent_group = parent_select.args.get("group")
|
|
@@ -391,7 +453,9 @@ def decorrelate(select, parent_select, external_columns, next_alias_name):
|
|
|
391
453
|
parent_predicate = _replace(parent_predicate.parent, predicate)
|
|
392
454
|
else:
|
|
393
455
|
predicate = op_type(this=other, expression=exp.column("_x"))
|
|
394
|
-
parent_predicate = _replace(
|
|
456
|
+
parent_predicate = _replace(
|
|
457
|
+
parent_predicate.parent, f"ARRAY_ANY({alias}, _x -> {predicate})"
|
|
458
|
+
)
|
|
395
459
|
elif isinstance(parent_predicate, exp.In):
|
|
396
460
|
if value.this in group_by:
|
|
397
461
|
parent_predicate = _replace(parent_predicate, f"{other} = {alias}")
|
|
@@ -401,18 +465,8 @@ def decorrelate(select, parent_select, external_columns, next_alias_name):
|
|
|
401
465
|
f"ARRAY_ANY({alias}, _x -> _x = {parent_predicate.this})",
|
|
402
466
|
)
|
|
403
467
|
else:
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
if find_in_scope(value, exp.Count):
|
|
407
|
-
|
|
408
|
-
def remove_aggs(node):
|
|
409
|
-
if isinstance(node, exp.Count):
|
|
410
|
-
return exp.Literal.number(0)
|
|
411
|
-
elif isinstance(node, exp.AggFunc):
|
|
412
|
-
return exp.null()
|
|
413
|
-
return node
|
|
414
|
-
|
|
415
|
-
alias = exp.Coalesce(this=alias, expressions=[value.this.transform(remove_aggs)])
|
|
468
|
+
if zero_fill:
|
|
469
|
+
alias = exp.Coalesce(this=alias, expressions=[exp.Literal.number(0)])
|
|
416
470
|
|
|
417
471
|
if is_subquery_projection and select.parent.alias:
|
|
418
472
|
alias = exp.alias_(alias, select.parent.alias)
|
|
@@ -445,8 +499,11 @@ def decorrelate(select, parent_select, external_columns, next_alias_name):
|
|
|
445
499
|
parent_predicate, exp.paren(exp.and_(parent_predicate.copy(), right, copy=False))
|
|
446
500
|
)
|
|
447
501
|
|
|
502
|
+
group = select.args.get("group")
|
|
448
503
|
parent_select.join(
|
|
449
|
-
select.group_by(
|
|
504
|
+
select.group_by(
|
|
505
|
+
*(key for key in group_by if not group or key not in group.expressions), copy=False
|
|
506
|
+
),
|
|
450
507
|
# A grouped key is constant per group, so any predicate on it can be checked in the join
|
|
451
508
|
on=[predicate for key, _, predicate in keys if key in group_by],
|
|
452
509
|
join_type="LEFT",
|
|
@@ -482,6 +539,11 @@ def _is_plain_group(group: exp.Group) -> bool:
|
|
|
482
539
|
)
|
|
483
540
|
|
|
484
541
|
|
|
542
|
+
def _has_plain_explicit_group(select: exp.Select) -> bool:
|
|
543
|
+
group = select.args.get("group")
|
|
544
|
+
return isinstance(group, exp.Group) and not group.args.get("all") and _is_plain_group(group)
|
|
545
|
+
|
|
546
|
+
|
|
485
547
|
def _is_post_aggregation(expression: exp.Expr, select: exp.Select) -> bool:
|
|
486
548
|
# The nearest ordinary aggregate consumes input rows, even inside a window.
|
|
487
549
|
# A window aggregate consumes post-group rows.
|
|
@@ -506,12 +568,35 @@ def _is_post_aggregation(expression: exp.Expr, select: exp.Select) -> bool:
|
|
|
506
568
|
return node is not None and node.arg_key not in ("with_", "from_", "laterals", "joins", "where")
|
|
507
569
|
|
|
508
570
|
|
|
571
|
+
def _is_supported_scalar_aggregate(expression: exp.Expr) -> bool:
|
|
572
|
+
expression = expression.unnest()
|
|
573
|
+
if isinstance(expression, (exp.Count, exp.Sum, exp.Avg, exp.Min, exp.Max)):
|
|
574
|
+
return True
|
|
575
|
+
if isinstance(expression, exp.Literal):
|
|
576
|
+
return expression.is_number
|
|
577
|
+
if isinstance(expression, exp.Neg):
|
|
578
|
+
operands = [expression.this]
|
|
579
|
+
elif isinstance(expression, (exp.Add, exp.Sub, exp.Mul, exp.Div, exp.IntDiv, exp.Mod, exp.Pow)):
|
|
580
|
+
operands = [expression.this, expression.expression]
|
|
581
|
+
else:
|
|
582
|
+
return False
|
|
583
|
+
# COUNT inside arithmetic would need a non-NULL default for missing keys
|
|
584
|
+
return all(
|
|
585
|
+
not isinstance(operand.unnest(), exp.Count) and _is_supported_scalar_aggregate(operand)
|
|
586
|
+
for operand in operands
|
|
587
|
+
)
|
|
588
|
+
|
|
589
|
+
|
|
509
590
|
def _has_aggregate_projection(select: exp.Select) -> bool:
|
|
510
591
|
windows = select.args.get("windows")
|
|
511
|
-
|
|
512
592
|
return any(projection_has_aggregate(projection, windows) for projection in select.selects)
|
|
513
593
|
|
|
514
594
|
|
|
595
|
+
def _has_order_aggregate(select: exp.Select) -> bool:
|
|
596
|
+
order = select.args.get("order")
|
|
597
|
+
return order is not None and projection_has_aggregate(order, select.args.get("windows"))
|
|
598
|
+
|
|
599
|
+
|
|
515
600
|
def _other_operand(expression: object) -> exp.Expr | None:
|
|
516
601
|
if isinstance(expression, exp.In):
|
|
517
602
|
return expression.this
|