polyglot-sql-chio 0.12.2__tar.gz → 0.13.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.
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/Cargo.lock +7 -6
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/Cargo.toml +1 -1
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/PKG-INFO +2 -5
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/Cargo.toml +4 -3
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/README.md +4 -4
- polyglot_sql_chio-0.13.0/crates/polyglot-sql/examples/validate_batch.rs +22 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/lineage.rs +71 -16
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/optimizer/annotate_types.rs +79 -5
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/resolver.rs +99 -24
- polyglot_sql_chio-0.13.0/crates/polyglot-sql/src/validation/coercion.rs +293 -0
- polyglot_sql_chio-0.13.0/crates/polyglot-sql/src/validation/expressions.rs +598 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/validation/semantics.rs +390 -3
- polyglot_sql_chio-0.13.0/crates/polyglot-sql/src/validation/signatures.rs +335 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/validation/tests.rs +744 -1
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/validation.rs +330 -55
- polyglot_sql_chio-0.13.0/crates/polyglot-sql/tests/fixtures/snowflake_semantic_truth.json +1918 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/query_analysis.rs +116 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-function-catalogs/README.md +1 -1
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-function-catalogs/src/lib.rs +19 -1
- polyglot_sql_chio-0.13.0/crates/polyglot-sql-function-catalogs/src/types.rs +139 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/Cargo.toml +1 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/validate.rs +1 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/pyproject.toml +1 -4
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/README.md +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/benches/allocation_hotspots.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/benches/ast_traversal.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/benches/in_list.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/benches/lineage.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/benches/parsing.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/benches/performance_hotspots.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/benches/rust_parsing.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/benches/transpile.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/examples/basic_usage.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/examples/bench_json.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/ast_children.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/ast_json.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/ast_mutation.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/ast_transforms.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/binding.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/builder/mod.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/builder/plan.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/athena.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/bigquery.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/clickhouse.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/cockroachdb.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/databricks.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/datafusion.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/doris.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/dremio.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/drill.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/druid.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/duckdb.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/dune.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/exasol.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/fabric.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/generic.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/hive.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/materialize.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/mod.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/mysql.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/normalization/aggregates.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/normalization/collections.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/normalization/json.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/normalization/mod.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/normalization/operators.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/normalization/postgres_interval.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/normalization/scalar.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/normalization/statements.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/normalization/temporal.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/normalization/types.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/oracle.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/postgres.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/presto.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/redshift.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/risingwave.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/singlestore.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/snowflake.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/solr.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/spark.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/sqlite.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/starrocks.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/tableau.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/teradata.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/tidb.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/trino.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/dialects/tsql.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/diff.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/error.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/expressions.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/format_tokens.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/function_catalog.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/function_registry.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/generator.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/guard.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/helper.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/lib.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/openlineage.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/optimizer/canonicalize.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/optimizer/eliminate_ctes.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/optimizer/eliminate_joins.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/optimizer/isolate_table_selects.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/optimizer/mod.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/optimizer/normalize.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/optimizer/normalize_identifiers.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/optimizer/optimize_joins.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/optimizer/optimizer.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/optimizer/pushdown_predicates.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/optimizer/pushdown_projections.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/optimizer/qualify_columns.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/optimizer/qualify_tables.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/optimizer/set_operation_types.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/optimizer/simplify.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/optimizer/subquery.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/parser.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/planner.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/query_analysis/column_uses.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/query_analysis.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/schema.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/scope.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/set_operation.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/time.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/tokens.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/transforms.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/traversal.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/src/trie.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/analyze_failures.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/clickhouse_regression.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/common/known_failures.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/common/mod.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/common/test_data.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/common/test_runner.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/create_view_security_comment_regression.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/custom_clickhouse_coverage.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/custom_clickhouse_parser.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/custom_dialect.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/custom_dialect_tests.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/custom_fixtures/datafusion/ddl.json +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/custom_fixtures/datafusion/dml.json +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/custom_fixtures/datafusion/functions.json +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/custom_fixtures/datafusion/identity.json +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/custom_fixtures/datafusion/operators.json +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/custom_fixtures/datafusion/select.json +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/custom_fixtures/datafusion/transpilation.json +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/custom_fixtures/datafusion/types.json +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/data_type_api.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/deep_nesting_regression.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/dialect_matrix.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/error_handling.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/fabric_regression.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/fabric_tpch_regression.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/identity_roundtrip.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/oracle_data_types_regression.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/postgres_explain_options.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/postgres_regexp_clickhouse.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/postgres_sqlite_regression.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/qualify_tables.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/query_analysis_regression.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/snowflake_regression_test.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/sqlglot_compat.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/sqlglot_dialect_identity.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/sqlglot_identity.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/sqlglot_identity_detailed.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/sqlglot_parser.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/sqlglot_pretty.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/sqlglot_transpilation.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/sqlglot_transpile.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/tpch_transpile_stack.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/transform_regression.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql/tests/tsql_regression.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-ast-derive/Cargo.toml +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-ast-derive/src/lib.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-function-catalogs/Cargo.toml +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-function-catalogs/src/clickhouse.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-function-catalogs/src/duckdb.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-function-catalogs/tools/clickhouse/extract_functions.py +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-function-catalogs/tools/duckdb/extract_functions.py +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/README.md +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/docs/api.md +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/docs/index.md +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/mkdocs.yml +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/annotate_types.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/builders.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/dialects.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/diff.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/errors.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/expr.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/expr_types.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/format.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/generate.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/helpers.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/lib.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/lineage.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/openlineage.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/optimize.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/parse.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/query_analysis.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/tokenize.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/transforms.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/transpile.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/src/types.rs +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/tests/conftest.py +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/tests/test_builders.py +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/tests/test_compat.py +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/tests/test_dialects.py +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/tests/test_diff.py +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/tests/test_expression.py +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/tests/test_format.py +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/tests/test_generate.py +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/tests/test_lineage.py +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/tests/test_optimize.py +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/tests/test_parse.py +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/tests/test_query_analysis.py +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/tests/test_transforms.py +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/tests/test_transpile.py +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/tests/test_validate.py +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/crates/polyglot-sql-python/uv.lock +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/python/polyglot_sql/__init__.py +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/python/polyglot_sql/__init__.pyi +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/python/polyglot_sql/analysis_types.py +0 -0
- {polyglot_sql_chio-0.12.2 → polyglot_sql_chio-0.13.0}/python/polyglot_sql/py.typed +0 -0
|
@@ -605,13 +605,14 @@ dependencies = [
|
|
|
605
605
|
|
|
606
606
|
[[package]]
|
|
607
607
|
name = "polyglot-sql"
|
|
608
|
-
version = "0.
|
|
608
|
+
version = "0.13.0"
|
|
609
609
|
dependencies = [
|
|
610
610
|
"criterion",
|
|
611
611
|
"once_cell",
|
|
612
612
|
"polyglot-sql-ast-derive",
|
|
613
613
|
"polyglot-sql-function-catalogs",
|
|
614
614
|
"pretty_assertions",
|
|
615
|
+
"regex",
|
|
615
616
|
"serde",
|
|
616
617
|
"serde_json",
|
|
617
618
|
"stacker",
|
|
@@ -623,7 +624,7 @@ dependencies = [
|
|
|
623
624
|
|
|
624
625
|
[[package]]
|
|
625
626
|
name = "polyglot-sql-ast-derive"
|
|
626
|
-
version = "0.
|
|
627
|
+
version = "0.13.0"
|
|
627
628
|
dependencies = [
|
|
628
629
|
"proc-macro2",
|
|
629
630
|
"quote",
|
|
@@ -632,7 +633,7 @@ dependencies = [
|
|
|
632
633
|
|
|
633
634
|
[[package]]
|
|
634
635
|
name = "polyglot-sql-ffi"
|
|
635
|
-
version = "0.
|
|
636
|
+
version = "0.13.0"
|
|
636
637
|
dependencies = [
|
|
637
638
|
"cbindgen",
|
|
638
639
|
"polyglot-sql",
|
|
@@ -642,11 +643,11 @@ dependencies = [
|
|
|
642
643
|
|
|
643
644
|
[[package]]
|
|
644
645
|
name = "polyglot-sql-function-catalogs"
|
|
645
|
-
version = "0.
|
|
646
|
+
version = "0.13.0"
|
|
646
647
|
|
|
647
648
|
[[package]]
|
|
648
649
|
name = "polyglot-sql-python"
|
|
649
|
-
version = "0.
|
|
650
|
+
version = "0.13.0"
|
|
650
651
|
dependencies = [
|
|
651
652
|
"polyglot-sql",
|
|
652
653
|
"pyo3",
|
|
@@ -657,7 +658,7 @@ dependencies = [
|
|
|
657
658
|
|
|
658
659
|
[[package]]
|
|
659
660
|
name = "polyglot-sql-wasm"
|
|
660
|
-
version = "0.
|
|
661
|
+
version = "0.13.0"
|
|
661
662
|
dependencies = [
|
|
662
663
|
"console_error_panic_hook",
|
|
663
664
|
"js-sys",
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: polyglot-sql-chio
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.0
|
|
4
4
|
Classifier: Development Status :: 4 - Beta
|
|
5
5
|
Classifier: Intended Audience :: Developers
|
|
6
6
|
Classifier: License :: OSI Approved :: MIT License
|
|
7
7
|
Classifier: Programming Language :: Rust
|
|
8
8
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
13
10
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
11
|
Classifier: Programming Language :: Python :: 3.13
|
|
15
12
|
Classifier: Topic :: Database
|
|
@@ -18,7 +15,7 @@ Summary: Rust-powered SQL transpiler for more than 30 SQL dialects. Parse, gener
|
|
|
18
15
|
Keywords: sql,transpiler,parser,dialect,database
|
|
19
16
|
Home-Page: https://github.com/tobilg/polyglot
|
|
20
17
|
License: MIT
|
|
21
|
-
Requires-Python: >=3.
|
|
18
|
+
Requires-Python: >=3.12
|
|
22
19
|
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
23
20
|
Project-URL: Documentation, https://polyglot.gh.tobilg.com
|
|
24
21
|
Project-URL: Homepage, https://github.com/chio-labs/polyglot
|
|
@@ -28,7 +28,7 @@ generate = []
|
|
|
28
28
|
transpile = ["generate"]
|
|
29
29
|
builder = ["generate"]
|
|
30
30
|
ast-tools = []
|
|
31
|
-
semantic = ["ast-tools"]
|
|
31
|
+
semantic = ["ast-tools", "function-catalog-duckdb", "dep:regex"]
|
|
32
32
|
openlineage = ["semantic"]
|
|
33
33
|
diff = ["generate"]
|
|
34
34
|
planner = []
|
|
@@ -100,14 +100,15 @@ function-catalog-all-dialects = [
|
|
|
100
100
|
]
|
|
101
101
|
|
|
102
102
|
[dependencies]
|
|
103
|
-
|
|
103
|
+
regex = { version = "1", optional = true }
|
|
104
|
+
polyglot-sql-ast-derive = { path = "../polyglot-sql-ast-derive", version = "0.13.0" }
|
|
104
105
|
serde = { workspace = true }
|
|
105
106
|
serde_json = { workspace = true }
|
|
106
107
|
thiserror = { workspace = true }
|
|
107
108
|
unicode-segmentation = { workspace = true }
|
|
108
109
|
stacker = { version = "0.1", optional = true }
|
|
109
110
|
ts-rs = { version = "12.0", features = ["serde-compat"], optional = true }
|
|
110
|
-
polyglot-sql-function-catalogs = { path = "../polyglot-sql-function-catalogs", version = "0.
|
|
111
|
+
polyglot-sql-function-catalogs = { path = "../polyglot-sql-function-catalogs", version = "0.13.0", optional = true, default-features = false }
|
|
111
112
|
|
|
112
113
|
[dev-dependencies]
|
|
113
114
|
pretty_assertions = "1.4"
|
|
@@ -25,12 +25,12 @@ By default, `polyglot-sql` enables the full public API. Parser-only consumers ca
|
|
|
25
25
|
disable default features and opt into only the dialect parsers they need:
|
|
26
26
|
|
|
27
27
|
```toml
|
|
28
|
-
polyglot-sql = { version = "0.
|
|
28
|
+
polyglot-sql = { version = "0.13.0", default-features = false }
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
```toml
|
|
32
32
|
polyglot-sql = {
|
|
33
|
-
version = "0.
|
|
33
|
+
version = "0.13.0",
|
|
34
34
|
default-features = false,
|
|
35
35
|
features = ["dialect-clickhouse"],
|
|
36
36
|
}
|
|
@@ -44,14 +44,14 @@ Examples:
|
|
|
44
44
|
```toml
|
|
45
45
|
# Parse and generate SQL for one dialect.
|
|
46
46
|
polyglot-sql = {
|
|
47
|
-
version = "0.
|
|
47
|
+
version = "0.13.0",
|
|
48
48
|
default-features = false,
|
|
49
49
|
features = ["generate", "dialect-clickhouse"],
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
# Cross-dialect transpilation.
|
|
53
53
|
polyglot-sql = {
|
|
54
|
-
version = "0.
|
|
54
|
+
version = "0.13.0",
|
|
55
55
|
default-features = false,
|
|
56
56
|
features = ["transpile", "dialect-clickhouse", "dialect-postgresql"],
|
|
57
57
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//! Validate newline-delimited schema-aware requests from standard input.
|
|
2
|
+
use polyglot_sql::validation::{validate_with_schema, SchemaValidationOptions, ValidationSchema};
|
|
3
|
+
use polyglot_sql::DialectType;
|
|
4
|
+
use serde::Deserialize;
|
|
5
|
+
use std::io::{self, BufRead};
|
|
6
|
+
|
|
7
|
+
#[derive(Deserialize)]
|
|
8
|
+
struct Request {
|
|
9
|
+
sql: String,
|
|
10
|
+
dialect: String,
|
|
11
|
+
schema: ValidationSchema,
|
|
12
|
+
options: SchemaValidationOptions,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
fn main() {
|
|
16
|
+
for line in io::stdin().lock().lines() {
|
|
17
|
+
let request: Request = serde_json::from_str(&line.unwrap()).unwrap();
|
|
18
|
+
let dialect: DialectType = request.dialect.parse().unwrap();
|
|
19
|
+
let result = validate_with_schema(&request.sql, dialect, &request.schema, &request.options);
|
|
20
|
+
println!("{}", serde_json::to_string(&result).unwrap());
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -714,13 +714,7 @@ fn expand_star_from_sources(
|
|
|
714
714
|
let qual_normalized = normalize_cte_name(qual);
|
|
715
715
|
for src in sources {
|
|
716
716
|
if src.normalized == qual_normalized || src.alias.to_lowercase() == qual_normalized {
|
|
717
|
-
|
|
718
|
-
if let Some(cols) = resolved_ctes.get(&src.normalized) {
|
|
719
|
-
expanded.extend(cols.iter().map(|c| (src.alias.clone(), c.clone())));
|
|
720
|
-
return Some(expanded);
|
|
721
|
-
}
|
|
722
|
-
// Fall back to schema
|
|
723
|
-
if let Some(cols) = lookup_schema_columns(schema, &src.fq_name) {
|
|
717
|
+
if let Some(cols) = source_output_columns(src, resolved_ctes, schema) {
|
|
724
718
|
expanded.extend(cols.into_iter().map(|c| (src.alias.clone(), c)));
|
|
725
719
|
return Some(expanded);
|
|
726
720
|
}
|
|
@@ -735,15 +729,9 @@ fn expand_star_from_sources(
|
|
|
735
729
|
// This matches sqlglot's behavior (raises SqlglotError when schema is missing).
|
|
736
730
|
let mut any_expanded = false;
|
|
737
731
|
for src in sources {
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
} else if let Some(cols) = lookup_schema_columns(schema, &src.fq_name) {
|
|
742
|
-
expanded.extend(cols.into_iter().map(|c| (src.alias.clone(), c)));
|
|
743
|
-
any_expanded = true;
|
|
744
|
-
} else {
|
|
745
|
-
return None;
|
|
746
|
-
}
|
|
732
|
+
let cols = source_output_columns(src, resolved_ctes, schema)?;
|
|
733
|
+
expanded.extend(cols.into_iter().map(|c| (src.alias.clone(), c)));
|
|
734
|
+
any_expanded = true;
|
|
747
735
|
}
|
|
748
736
|
if any_expanded {
|
|
749
737
|
Some(expanded)
|
|
@@ -753,6 +741,57 @@ fn expand_star_from_sources(
|
|
|
753
741
|
}
|
|
754
742
|
}
|
|
755
743
|
|
|
744
|
+
/// Output columns of a FROM/JOIN source, preferring resolved CTEs over the schema.
|
|
745
|
+
fn source_output_columns(
|
|
746
|
+
src: &SourceInfo,
|
|
747
|
+
resolved_ctes: &HashMap<String, Vec<String>>,
|
|
748
|
+
schema: Option<&dyn Schema>,
|
|
749
|
+
) -> Option<Vec<String>> {
|
|
750
|
+
match &src.relation {
|
|
751
|
+
SourceRelation::Plain => resolved_ctes
|
|
752
|
+
.get(&src.normalized)
|
|
753
|
+
.cloned()
|
|
754
|
+
.or_else(|| lookup_schema_columns(schema, &src.fq_name)),
|
|
755
|
+
SourceRelation::Pivot(pivot) if !pivot.unpivot => {
|
|
756
|
+
let input = pivot_input_columns(&pivot.this, resolved_ctes, schema)?;
|
|
757
|
+
let output = pivot_output_columns(pivot, &input, None);
|
|
758
|
+
(!output.is_empty()).then(|| output.into_iter().map(|(post, _)| post).collect())
|
|
759
|
+
}
|
|
760
|
+
SourceRelation::Unpivot(unpivot) => {
|
|
761
|
+
let input = pivot_input_columns(&unpivot.this, resolved_ctes, schema)?;
|
|
762
|
+
let output = crate::resolver::unpivot_output_columns(unpivot, input, None);
|
|
763
|
+
(!output.is_empty()).then_some(output)
|
|
764
|
+
}
|
|
765
|
+
SourceRelation::Pivot(_) => None,
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
fn pivot_input_columns(
|
|
770
|
+
input: &Expression,
|
|
771
|
+
resolved_ctes: &HashMap<String, Vec<String>>,
|
|
772
|
+
schema: Option<&dyn Schema>,
|
|
773
|
+
) -> Option<Vec<String>> {
|
|
774
|
+
match input {
|
|
775
|
+
Expression::Table(table) => {
|
|
776
|
+
let cte_columns = (table.schema.is_none() && table.catalog.is_none())
|
|
777
|
+
.then(|| resolved_ctes.get(&normalize_cte_name(&table.name)).cloned())
|
|
778
|
+
.flatten();
|
|
779
|
+
cte_columns.or_else(|| {
|
|
780
|
+
let fq_name = [&table.catalog, &table.schema]
|
|
781
|
+
.into_iter()
|
|
782
|
+
.flatten()
|
|
783
|
+
.map(|part| part.name.as_str())
|
|
784
|
+
.chain(std::iter::once(table.name.name.as_str()))
|
|
785
|
+
.collect::<Vec<_>>()
|
|
786
|
+
.join(".");
|
|
787
|
+
lookup_schema_columns(schema, &fq_name)
|
|
788
|
+
})
|
|
789
|
+
}
|
|
790
|
+
Expression::Paren(paren) => pivot_input_columns(&paren.this, resolved_ctes, schema),
|
|
791
|
+
_ => None,
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
|
|
756
795
|
/// Look up column names for a table from the schema.
|
|
757
796
|
fn lookup_schema_columns(schema: Option<&dyn Schema>, fq_name: &str) -> Option<Vec<String>> {
|
|
758
797
|
let schema = schema?;
|
|
@@ -802,6 +841,16 @@ struct SourceInfo {
|
|
|
802
841
|
normalized: String,
|
|
803
842
|
/// Fully-qualified table name for schema lookup (e.g., "db.schema.table").
|
|
804
843
|
fq_name: String,
|
|
844
|
+
/// Relation shape that determines how this source's output columns are derived.
|
|
845
|
+
relation: SourceRelation,
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
/// PIVOT and UNPIVOT change their input's columns, so their output cannot be
|
|
849
|
+
/// read from the CTE or table that happens to share the source name.
|
|
850
|
+
enum SourceRelation {
|
|
851
|
+
Plain,
|
|
852
|
+
Pivot(Box<crate::expressions::Pivot>),
|
|
853
|
+
Unpivot(Box<crate::expressions::Unpivot>),
|
|
805
854
|
}
|
|
806
855
|
|
|
807
856
|
/// Extract source info (alias, normalized CTE name, fully-qualified name) from a
|
|
@@ -816,6 +865,7 @@ fn get_select_sources(select: &Select) -> Vec<SourceInfo> {
|
|
|
816
865
|
quoted: alias.quoted,
|
|
817
866
|
normalized: normalize_cte_name(alias),
|
|
818
867
|
fq_name: alias.name.clone(),
|
|
868
|
+
relation: SourceRelation::Plain,
|
|
819
869
|
}
|
|
820
870
|
}
|
|
821
871
|
|
|
@@ -825,6 +875,7 @@ fn get_select_sources(select: &Select) -> Vec<SourceInfo> {
|
|
|
825
875
|
quoted: false,
|
|
826
876
|
normalized: alias.to_lowercase(),
|
|
827
877
|
fq_name: alias.to_string(),
|
|
878
|
+
relation: SourceRelation::Plain,
|
|
828
879
|
}
|
|
829
880
|
}
|
|
830
881
|
|
|
@@ -850,6 +901,7 @@ fn get_select_sources(select: &Select) -> Vec<SourceInfo> {
|
|
|
850
901
|
quoted: t.name.quoted,
|
|
851
902
|
normalized,
|
|
852
903
|
fq_name,
|
|
904
|
+
relation: SourceRelation::Plain,
|
|
853
905
|
})
|
|
854
906
|
}
|
|
855
907
|
Expression::Subquery(s) => {
|
|
@@ -862,6 +914,7 @@ fn get_select_sources(select: &Select) -> Vec<SourceInfo> {
|
|
|
862
914
|
quoted: alias_identifier.quoted,
|
|
863
915
|
normalized,
|
|
864
916
|
fq_name,
|
|
917
|
+
relation: SourceRelation::Plain,
|
|
865
918
|
})
|
|
866
919
|
}
|
|
867
920
|
Expression::Unnest(u) => u.alias.as_ref().map(virtual_source_info),
|
|
@@ -887,6 +940,7 @@ fn get_select_sources(select: &Select) -> Vec<SourceInfo> {
|
|
|
887
940
|
quoted: false,
|
|
888
941
|
normalized: alias.to_lowercase(),
|
|
889
942
|
fq_name: alias,
|
|
943
|
+
relation: SourceRelation::Pivot(pivot.clone()),
|
|
890
944
|
})
|
|
891
945
|
}
|
|
892
946
|
Expression::Unpivot(unpivot) => {
|
|
@@ -899,6 +953,7 @@ fn get_select_sources(select: &Select) -> Vec<SourceInfo> {
|
|
|
899
953
|
quoted: false,
|
|
900
954
|
normalized: alias.to_lowercase(),
|
|
901
955
|
fq_name: alias,
|
|
956
|
+
relation: SourceRelation::Unpivot(unpivot.clone()),
|
|
902
957
|
})
|
|
903
958
|
}
|
|
904
959
|
Expression::Paren(p) => extract_source(&p.this),
|
|
@@ -467,10 +467,7 @@ impl<'a> TypeAnnotator<'a> {
|
|
|
467
467
|
Expression::Count(_) => Some(DataType::BigInt { length: None }),
|
|
468
468
|
Expression::Sum(agg) => self.annotate_sum(&agg.this),
|
|
469
469
|
Expression::SumIf(f) => self.annotate_sum(&f.this),
|
|
470
|
-
Expression::Avg(
|
|
471
|
-
precision: None,
|
|
472
|
-
scale: None,
|
|
473
|
-
}),
|
|
470
|
+
Expression::Avg(agg) => self.annotate_avg(&agg.this),
|
|
474
471
|
Expression::Min(agg) => self.annotate(&agg.this),
|
|
475
472
|
Expression::Max(agg) => self.annotate(&agg.this),
|
|
476
473
|
Expression::Median(agg) => {
|
|
@@ -1032,6 +1029,12 @@ impl<'a> TypeAnnotator<'a> {
|
|
|
1032
1029
|
// WindowFunction
|
|
1033
1030
|
Expression::WindowFunction(w) => {
|
|
1034
1031
|
self.annotate_in_place(&mut w.this);
|
|
1032
|
+
for expression in &mut w.over.partition_by {
|
|
1033
|
+
self.annotate_in_place(expression);
|
|
1034
|
+
}
|
|
1035
|
+
for ordered in &mut w.over.order_by {
|
|
1036
|
+
self.annotate_in_place(&mut ordered.this);
|
|
1037
|
+
}
|
|
1035
1038
|
}
|
|
1036
1039
|
|
|
1037
1040
|
// Subquery
|
|
@@ -1418,11 +1421,20 @@ impl<'a> TypeAnnotator<'a> {
|
|
|
1418
1421
|
}
|
|
1419
1422
|
let func_name = func.name.to_uppercase();
|
|
1420
1423
|
|
|
1424
|
+
if self._dialect == Some(DialectType::PostgreSQL) && !func.quoted {
|
|
1425
|
+
match func_name.as_str() {
|
|
1426
|
+
"SUM" => return func.args.first().and_then(|arg| self.annotate_sum(arg)),
|
|
1427
|
+
"AVG" => return func.args.first().and_then(|arg| self.annotate_avg(arg)),
|
|
1428
|
+
_ => {}
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1421
1432
|
if self._dialect == Some(DialectType::DuckDB) && !func.quoted {
|
|
1422
1433
|
match func_name.as_str() {
|
|
1423
1434
|
// Builder-created Function nodes use the same inference as the
|
|
1424
1435
|
// dedicated nodes produced when parsing these built-ins.
|
|
1425
1436
|
"SUM" => return func.args.first().and_then(|arg| self.annotate_sum(arg)),
|
|
1437
|
+
"AVG" => return func.args.first().and_then(|arg| self.annotate_avg(arg)),
|
|
1426
1438
|
"COALESCE" | "IFNULL" => return self.coerce_arg_types(&func.args),
|
|
1427
1439
|
"DATE_TRUNC" => return self.annotate_duckdb_date_trunc(func),
|
|
1428
1440
|
"REGEXP_EXTRACT_ALL" => return self.annotate_duckdb_regexp_extract_all(func),
|
|
@@ -1469,6 +1481,36 @@ impl<'a> TypeAnnotator<'a> {
|
|
|
1469
1481
|
}
|
|
1470
1482
|
}
|
|
1471
1483
|
_ => {
|
|
1484
|
+
if let Some(signature) = self._dialect.and_then(|dialect| {
|
|
1485
|
+
polyglot_sql_function_catalogs::types::type_signature(
|
|
1486
|
+
crate::validation::signatures::dialect_key(dialect),
|
|
1487
|
+
&func_name.to_lowercase(),
|
|
1488
|
+
)
|
|
1489
|
+
}) {
|
|
1490
|
+
use polyglot_sql_function_catalogs::types::ReturnType;
|
|
1491
|
+
return match signature.returns {
|
|
1492
|
+
ReturnType::Average => {
|
|
1493
|
+
func.args.first().and_then(|arg| self.annotate_avg(arg))
|
|
1494
|
+
}
|
|
1495
|
+
ReturnType::Argument(index) => {
|
|
1496
|
+
func.args.get(index).and_then(|arg| self.annotate(arg))
|
|
1497
|
+
}
|
|
1498
|
+
ReturnType::Integer => Some(DataType::BigInt { length: None }),
|
|
1499
|
+
ReturnType::Numeric => Some(DataType::Double {
|
|
1500
|
+
precision: None,
|
|
1501
|
+
scale: None,
|
|
1502
|
+
}),
|
|
1503
|
+
ReturnType::String => Some(DataType::VarChar {
|
|
1504
|
+
length: None,
|
|
1505
|
+
parenthesized_length: false,
|
|
1506
|
+
}),
|
|
1507
|
+
ReturnType::Boolean => Some(DataType::Boolean),
|
|
1508
|
+
ReturnType::Timestamp => Some(DataType::Timestamp {
|
|
1509
|
+
precision: None,
|
|
1510
|
+
timezone: false,
|
|
1511
|
+
}),
|
|
1512
|
+
};
|
|
1513
|
+
}
|
|
1472
1514
|
self.used_unknown_function_fallback = true;
|
|
1473
1515
|
func.args.first().and_then(|arg| self.annotate(arg))
|
|
1474
1516
|
}
|
|
@@ -1477,7 +1519,7 @@ impl<'a> TypeAnnotator<'a> {
|
|
|
1477
1519
|
|
|
1478
1520
|
/// Relation outputs cannot rely on the scalar annotator's legacy fallback
|
|
1479
1521
|
/// that assigns an unknown function the type of its first argument.
|
|
1480
|
-
pub(
|
|
1522
|
+
pub(crate) fn function_result_is_known(func: &Function, dialect: DialectType) -> bool {
|
|
1481
1523
|
let mut annotator = Self::new(None, Some(dialect));
|
|
1482
1524
|
// Probe dispatch without traversing or cloning a query argument. The
|
|
1483
1525
|
// original annotation already supplied the type for recognized rules.
|
|
@@ -1713,8 +1755,40 @@ impl<'a> TypeAnnotator<'a> {
|
|
|
1713
1755
|
}
|
|
1714
1756
|
|
|
1715
1757
|
/// Annotate SUM function - promotes to at least BigInt
|
|
1758
|
+
fn annotate_avg(&mut self, arg: &Expression) -> Option<DataType> {
|
|
1759
|
+
if matches!(
|
|
1760
|
+
self._dialect,
|
|
1761
|
+
Some(DialectType::PostgreSQL | DialectType::DuckDB)
|
|
1762
|
+
) {
|
|
1763
|
+
if let Some(ty @ DataType::Interval { .. }) = self.annotate(arg) {
|
|
1764
|
+
return Some(ty);
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
if self._dialect == Some(DialectType::DuckDB) {
|
|
1768
|
+
match self.annotate(arg) {
|
|
1769
|
+
Some(DataType::Date) => {
|
|
1770
|
+
return Some(DataType::Timestamp {
|
|
1771
|
+
precision: None,
|
|
1772
|
+
timezone: false,
|
|
1773
|
+
})
|
|
1774
|
+
}
|
|
1775
|
+
Some(ty @ (DataType::Timestamp { .. } | DataType::Time { .. })) => return Some(ty),
|
|
1776
|
+
_ => {}
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
Some(DataType::Double {
|
|
1780
|
+
precision: None,
|
|
1781
|
+
scale: None,
|
|
1782
|
+
})
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1716
1785
|
fn annotate_sum(&mut self, arg: &Expression) -> Option<DataType> {
|
|
1717
1786
|
let arg_type = self.annotate(arg);
|
|
1787
|
+
if self._dialect == Some(DialectType::PostgreSQL)
|
|
1788
|
+
&& matches!(arg_type, Some(DataType::Interval { .. }))
|
|
1789
|
+
{
|
|
1790
|
+
return arg_type;
|
|
1791
|
+
}
|
|
1718
1792
|
if self._dialect == Some(DialectType::DuckDB) {
|
|
1719
1793
|
// These are DuckDB's bound aggregate result types, not the generic
|
|
1720
1794
|
// integer-to-BIGINT promotion. UHUGEINT binds to the DOUBLE overload.
|
|
@@ -315,7 +315,72 @@ impl<'a> Resolver<'a> {
|
|
|
315
315
|
select
|
|
316
316
|
.expressions
|
|
317
317
|
.iter()
|
|
318
|
-
.
|
|
318
|
+
.flat_map(|expr| {
|
|
319
|
+
let Expression::Star(star) = expr else {
|
|
320
|
+
return self
|
|
321
|
+
.get_expression_alias(expr)
|
|
322
|
+
.into_iter()
|
|
323
|
+
.collect::<Vec<_>>();
|
|
324
|
+
};
|
|
325
|
+
let mut columns = Vec::new();
|
|
326
|
+
for source in select
|
|
327
|
+
.from
|
|
328
|
+
.iter()
|
|
329
|
+
.flat_map(|from| &from.expressions)
|
|
330
|
+
.chain(select.joins.iter().map(|join| &join.this))
|
|
331
|
+
{
|
|
332
|
+
if let Some(qualifier) = &star.table {
|
|
333
|
+
let name = match source {
|
|
334
|
+
Expression::Table(table) => {
|
|
335
|
+
Some(table.alias.as_ref().unwrap_or(&table.name))
|
|
336
|
+
}
|
|
337
|
+
Expression::Subquery(query) => query.alias.as_ref(),
|
|
338
|
+
Expression::Alias(alias) => Some(&alias.alias),
|
|
339
|
+
_ => None,
|
|
340
|
+
};
|
|
341
|
+
if !name.is_some_and(|name| {
|
|
342
|
+
crate::set_operation::identifier_key(name, self.dialect)
|
|
343
|
+
== crate::set_operation::identifier_key(qualifier, self.dialect)
|
|
344
|
+
}) {
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
let input = self
|
|
349
|
+
.get_source_columns_for_expression(source)
|
|
350
|
+
.unwrap_or_default();
|
|
351
|
+
if input.is_empty() {
|
|
352
|
+
columns.push("*".to_owned());
|
|
353
|
+
} else {
|
|
354
|
+
columns.extend(input);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
if columns.is_empty() {
|
|
358
|
+
columns.push("*".to_owned());
|
|
359
|
+
}
|
|
360
|
+
let column_key = |column: &str| {
|
|
361
|
+
crate::set_operation::identifier_key(
|
|
362
|
+
&crate::binding::schema_identifier(column),
|
|
363
|
+
self.dialect,
|
|
364
|
+
)
|
|
365
|
+
};
|
|
366
|
+
columns.retain(|column| {
|
|
367
|
+
!star.except.iter().flatten().any(|name| {
|
|
368
|
+
crate::set_operation::identifier_key(name, self.dialect)
|
|
369
|
+
== column_key(column)
|
|
370
|
+
})
|
|
371
|
+
});
|
|
372
|
+
for column in &mut columns {
|
|
373
|
+
if let Some((_, replacement)) =
|
|
374
|
+
star.rename.iter().flatten().find(|(name, _)| {
|
|
375
|
+
crate::set_operation::identifier_key(name, self.dialect)
|
|
376
|
+
== column_key(column)
|
|
377
|
+
})
|
|
378
|
+
{
|
|
379
|
+
*column = replacement.name.clone();
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
columns
|
|
383
|
+
})
|
|
319
384
|
.collect()
|
|
320
385
|
}
|
|
321
386
|
|
|
@@ -387,29 +452,7 @@ impl<'a> Resolver<'a> {
|
|
|
387
452
|
|
|
388
453
|
fn get_unpivot_output_columns(&self, unpivot: &crate::expressions::Unpivot) -> Vec<String> {
|
|
389
454
|
let pre_columns = self.get_source_output_columns(&unpivot.this);
|
|
390
|
-
|
|
391
|
-
return Vec::new();
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
let input_columns: HashSet<String> = unpivot
|
|
395
|
-
.columns
|
|
396
|
-
.iter()
|
|
397
|
-
.flat_map(expression_column_names)
|
|
398
|
-
.map(|column| normalize_column_name(&column, self.dialect))
|
|
399
|
-
.collect();
|
|
400
|
-
let mut columns: Vec<String> = pre_columns
|
|
401
|
-
.into_iter()
|
|
402
|
-
.filter(|column| !input_columns.contains(&normalize_column_name(column, self.dialect)))
|
|
403
|
-
.collect();
|
|
404
|
-
columns.push(unpivot.name_column.name.clone());
|
|
405
|
-
columns.push(unpivot.value_column.name.clone());
|
|
406
|
-
columns.extend(
|
|
407
|
-
unpivot
|
|
408
|
-
.extra_value_columns
|
|
409
|
-
.iter()
|
|
410
|
-
.map(|column| column.name.clone()),
|
|
411
|
-
);
|
|
412
|
-
apply_alias_columns(columns, &unpivot.alias_columns)
|
|
455
|
+
unpivot_output_columns(unpivot, pre_columns, self.dialect)
|
|
413
456
|
}
|
|
414
457
|
|
|
415
458
|
fn get_source_output_columns(&self, source: &Expression) -> Vec<String> {
|
|
@@ -657,6 +700,38 @@ fn normalize_column_name(name: &str, dialect: Option<DialectType>) -> String {
|
|
|
657
700
|
normalize_name(name, dialect, false, true)
|
|
658
701
|
}
|
|
659
702
|
|
|
703
|
+
/// UNPIVOT output: unconsumed input columns, then name and value columns.
|
|
704
|
+
/// Returns no columns when the input columns are unknown.
|
|
705
|
+
pub(crate) fn unpivot_output_columns(
|
|
706
|
+
unpivot: &crate::expressions::Unpivot,
|
|
707
|
+
pre_columns: Vec<String>,
|
|
708
|
+
dialect: Option<DialectType>,
|
|
709
|
+
) -> Vec<String> {
|
|
710
|
+
if pre_columns.is_empty() || pre_columns.iter().any(|column| column == "*") {
|
|
711
|
+
return Vec::new();
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
let input_columns: HashSet<String> = unpivot
|
|
715
|
+
.columns
|
|
716
|
+
.iter()
|
|
717
|
+
.flat_map(expression_column_names)
|
|
718
|
+
.map(|column| normalize_column_name(&column, dialect))
|
|
719
|
+
.collect();
|
|
720
|
+
let mut columns: Vec<String> = pre_columns
|
|
721
|
+
.into_iter()
|
|
722
|
+
.filter(|column| !input_columns.contains(&normalize_column_name(column, dialect)))
|
|
723
|
+
.collect();
|
|
724
|
+
columns.push(unpivot.name_column.name.clone());
|
|
725
|
+
columns.push(unpivot.value_column.name.clone());
|
|
726
|
+
columns.extend(
|
|
727
|
+
unpivot
|
|
728
|
+
.extra_value_columns
|
|
729
|
+
.iter()
|
|
730
|
+
.map(|column| column.name.clone()),
|
|
731
|
+
);
|
|
732
|
+
apply_alias_columns(columns, &unpivot.alias_columns)
|
|
733
|
+
}
|
|
734
|
+
|
|
660
735
|
fn apply_alias_columns(mut columns: Vec<String>, alias_columns: &[Identifier]) -> Vec<String> {
|
|
661
736
|
for (idx, alias) in alias_columns.iter().enumerate() {
|
|
662
737
|
if let Some(column) = columns.get_mut(idx) {
|