polyglot-sql 0.5.15__tar.gz → 0.6.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-0.5.15 → polyglot_sql-0.6.0}/Cargo.lock +22 -5
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/Cargo.toml +14 -2
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/PKG-INFO +21 -6
- {polyglot_sql-0.5.15/crates/polyglot-sql-python → polyglot_sql-0.6.0}/README.md +19 -4
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/Cargo.toml +15 -1
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/README.md +14 -7
- polyglot_sql-0.6.0/crates/polyglot-sql/benches/allocation_hotspots.rs +122 -0
- polyglot_sql-0.6.0/crates/polyglot-sql/benches/ast_traversal.rs +43 -0
- polyglot_sql-0.6.0/crates/polyglot-sql/benches/performance_hotspots.rs +218 -0
- polyglot_sql-0.6.0/crates/polyglot-sql/src/ast_children.rs +105 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/fabric.rs +16 -0
- polyglot_sql-0.6.0/crates/polyglot-sql/src/dialects/mod.rs +9093 -0
- polyglot_sql-0.6.0/crates/polyglot-sql/src/dialects/normalization/aggregates.rs +1138 -0
- polyglot_sql-0.6.0/crates/polyglot-sql/src/dialects/normalization/collections.rs +2354 -0
- polyglot_sql-0.6.0/crates/polyglot-sql/src/dialects/normalization/json.rs +1195 -0
- polyglot_sql-0.6.0/crates/polyglot-sql/src/dialects/normalization/mod.rs +3739 -0
- polyglot_sql-0.6.0/crates/polyglot-sql/src/dialects/normalization/operators.rs +1753 -0
- polyglot_sql-0.6.0/crates/polyglot-sql/src/dialects/normalization/scalar.rs +16362 -0
- polyglot_sql-0.6.0/crates/polyglot-sql/src/dialects/normalization/statements.rs +1235 -0
- polyglot_sql-0.6.0/crates/polyglot-sql/src/dialects/normalization/temporal.rs +3700 -0
- polyglot_sql-0.6.0/crates/polyglot-sql/src/dialects/normalization/types.rs +991 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/postgres.rs +16 -15
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/tsql.rs +1179 -69
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/expressions.rs +869 -793
- polyglot_sql-0.6.0/crates/polyglot-sql/src/format_tokens.rs +87 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/generator.rs +795 -42
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/guard.rs +211 -22
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/lib.rs +178 -4
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/optimizer/optimizer.rs +4 -3
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/parser.rs +1104 -775
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/planner.rs +37 -10
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/tokens.rs +736 -138
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/transforms.rs +433 -19
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/traversal.rs +92 -693
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/validation/tests.rs +41 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/validation.rs +30 -12
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/custom_fixtures/datafusion/transpilation.json +5 -5
- polyglot_sql-0.6.0/crates/polyglot-sql/tests/dialect_matrix.rs +3211 -0
- polyglot_sql-0.6.0/crates/polyglot-sql/tests/fabric_regression.rs +2216 -0
- polyglot_sql-0.6.0/crates/polyglot-sql/tests/postgres_regexp_clickhouse.rs +70 -0
- polyglot_sql-0.6.0/crates/polyglot-sql/tests/query_analysis_regression.rs +201 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/transform_regression.rs +33 -1
- polyglot_sql-0.6.0/crates/polyglot-sql/tests/tsql_regression.rs +2393 -0
- polyglot_sql-0.6.0/crates/polyglot-sql-ast-derive/Cargo.toml +15 -0
- polyglot_sql-0.6.0/crates/polyglot-sql-ast-derive/src/lib.rs +333 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0/crates/polyglot-sql-python}/README.md +19 -4
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/src/expr_types.rs +3 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/src/helpers.rs +9 -78
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/src/parse.rs +5 -6
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/src/transforms.rs +1 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/src/transpile.rs +3 -2
- polyglot_sql-0.6.0/crates/polyglot-sql-python/src/validate.rs +23 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/tests/test_compat.py +39 -0
- polyglot_sql-0.6.0/crates/polyglot-sql-python/tests/test_dialects.py +57 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/tests/test_parse.py +23 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/tests/test_transpile.py +16 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/tests/test_validate.py +17 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/pyproject.toml +3 -1
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/python/polyglot_sql/__init__.py +1 -1
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/python/polyglot_sql/__init__.pyi +10 -2
- polyglot_sql-0.5.15/crates/polyglot-sql/src/dialects/mod.rs +0 -40462
- polyglot_sql-0.5.15/crates/polyglot-sql/tests/dialect_matrix.rs +0 -1467
- polyglot_sql-0.5.15/crates/polyglot-sql/tests/fabric_regression.rs +0 -857
- polyglot_sql-0.5.15/crates/polyglot-sql/tests/issue201_regression_test.rs +0 -38
- polyglot_sql-0.5.15/crates/polyglot-sql/tests/issue210_regression_test.rs +0 -80
- polyglot_sql-0.5.15/crates/polyglot-sql/tests/issue226_regression_test.rs +0 -48
- polyglot_sql-0.5.15/crates/polyglot-sql/tests/issue227_strict_unsupported.rs +0 -334
- polyglot_sql-0.5.15/crates/polyglot-sql/tests/issue265_distinct_order_nulls.rs +0 -92
- polyglot_sql-0.5.15/crates/polyglot-sql/tests/issue266_boolean_test_tsql.rs +0 -106
- polyglot_sql-0.5.15/crates/polyglot-sql/tests/issue267_boolean_predicates_tsql_fabric.rs +0 -96
- polyglot_sql-0.5.15/crates/polyglot-sql/tests/issue269_positional_order_by_tsql_fabric.rs +0 -94
- polyglot_sql-0.5.15/crates/polyglot-sql/tests/query_analysis_regression.rs +0 -79
- polyglot_sql-0.5.15/crates/polyglot-sql/tests/tsql_regression.rs +0 -1001
- polyglot_sql-0.5.15/crates/polyglot-sql-python/src/validate.rs +0 -63
- polyglot_sql-0.5.15/crates/polyglot-sql-python/tests/test_dialects.py +0 -22
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/benches/in_list.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/benches/parsing.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/benches/rust_parsing.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/benches/transpile.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/examples/basic_usage.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/examples/bench_json.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/ast_json.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/ast_transforms.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/builder.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/athena.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/bigquery.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/clickhouse.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/cockroachdb.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/databricks.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/datafusion.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/doris.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/dremio.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/drill.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/druid.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/duckdb.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/dune.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/exasol.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/generic.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/hive.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/materialize.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/mysql.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/oracle.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/presto.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/redshift.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/risingwave.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/singlestore.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/snowflake.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/solr.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/spark.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/sqlite.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/starrocks.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/tableau.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/teradata.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/tidb.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/dialects/trino.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/diff.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/error.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/function_catalog.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/function_registry.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/helper.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/lineage.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/openlineage.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/optimizer/annotate_types.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/optimizer/canonicalize.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/optimizer/eliminate_ctes.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/optimizer/eliminate_joins.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/optimizer/isolate_table_selects.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/optimizer/mod.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/optimizer/normalize.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/optimizer/normalize_identifiers.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/optimizer/optimize_joins.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/optimizer/pushdown_predicates.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/optimizer/pushdown_projections.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/optimizer/qualify_columns.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/optimizer/qualify_tables.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/optimizer/simplify.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/optimizer/subquery.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/query_analysis.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/resolver.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/schema.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/scope.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/time.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/src/trie.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/analyze_failures.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/clickhouse_regression.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/common/known_failures.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/common/mod.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/common/test_data.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/common/test_runner.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/create_view_security_comment_regression.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/custom_clickhouse_coverage.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/custom_clickhouse_parser.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/custom_dialect.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/custom_dialect_tests.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/custom_fixtures/datafusion/ddl.json +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/custom_fixtures/datafusion/dml.json +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/custom_fixtures/datafusion/functions.json +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/custom_fixtures/datafusion/identity.json +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/custom_fixtures/datafusion/operators.json +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/custom_fixtures/datafusion/select.json +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/custom_fixtures/datafusion/types.json +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/data_type_api.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/deep_nesting_regression.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/error_handling.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/fabric_tpch_regression.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/identity_roundtrip.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/postgres_sqlite_regression.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/query_analysis.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/snowflake_regression_test.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/sqlglot_compat.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/sqlglot_dialect_identity.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/sqlglot_identity.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/sqlglot_identity_detailed.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/sqlglot_parser.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/sqlglot_pretty.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/sqlglot_transpilation.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/sqlglot_transpile.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql/tests/tpch_transpile_stack.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-function-catalogs/Cargo.toml +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-function-catalogs/README.md +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-function-catalogs/src/clickhouse.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-function-catalogs/src/duckdb.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-function-catalogs/src/lib.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-function-catalogs/tools/clickhouse/extract_functions.py +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-function-catalogs/tools/duckdb/extract_functions.py +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/Cargo.toml +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/docs/api.md +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/docs/index.md +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/mkdocs.yml +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/src/annotate_types.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/src/dialects.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/src/diff.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/src/errors.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/src/expr.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/src/format.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/src/generate.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/src/lib.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/src/lineage.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/src/openlineage.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/src/optimize.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/src/query_analysis.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/src/tokenize.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/src/types.rs +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/tests/conftest.py +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/tests/test_diff.py +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/tests/test_expression.py +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/tests/test_format.py +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/tests/test_generate.py +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/tests/test_lineage.py +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/tests/test_optimize.py +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/tests/test_query_analysis.py +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/tests/test_transforms.py +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/crates/polyglot-sql-python/uv.lock +0 -0
- {polyglot_sql-0.5.15 → polyglot_sql-0.6.0}/python/polyglot_sql/py.typed +0 -0
|
@@ -605,23 +605,34 @@ dependencies = [
|
|
|
605
605
|
|
|
606
606
|
[[package]]
|
|
607
607
|
name = "polyglot-sql"
|
|
608
|
-
version = "0.
|
|
608
|
+
version = "0.6.0"
|
|
609
609
|
dependencies = [
|
|
610
610
|
"criterion",
|
|
611
611
|
"once_cell",
|
|
612
|
+
"polyglot-sql-ast-derive",
|
|
612
613
|
"polyglot-sql-function-catalogs",
|
|
613
614
|
"pretty_assertions",
|
|
614
615
|
"serde",
|
|
615
616
|
"serde_json",
|
|
616
617
|
"stacker",
|
|
618
|
+
"stats_alloc",
|
|
617
619
|
"thiserror 1.0.69",
|
|
618
620
|
"ts-rs",
|
|
619
621
|
"unicode-segmentation",
|
|
620
622
|
]
|
|
621
623
|
|
|
624
|
+
[[package]]
|
|
625
|
+
name = "polyglot-sql-ast-derive"
|
|
626
|
+
version = "0.6.0"
|
|
627
|
+
dependencies = [
|
|
628
|
+
"proc-macro2",
|
|
629
|
+
"quote",
|
|
630
|
+
"syn",
|
|
631
|
+
]
|
|
632
|
+
|
|
622
633
|
[[package]]
|
|
623
634
|
name = "polyglot-sql-ffi"
|
|
624
|
-
version = "0.
|
|
635
|
+
version = "0.6.0"
|
|
625
636
|
dependencies = [
|
|
626
637
|
"cbindgen",
|
|
627
638
|
"polyglot-sql",
|
|
@@ -631,11 +642,11 @@ dependencies = [
|
|
|
631
642
|
|
|
632
643
|
[[package]]
|
|
633
644
|
name = "polyglot-sql-function-catalogs"
|
|
634
|
-
version = "0.
|
|
645
|
+
version = "0.6.0"
|
|
635
646
|
|
|
636
647
|
[[package]]
|
|
637
648
|
name = "polyglot-sql-python"
|
|
638
|
-
version = "0.
|
|
649
|
+
version = "0.6.0"
|
|
639
650
|
dependencies = [
|
|
640
651
|
"polyglot-sql",
|
|
641
652
|
"pyo3",
|
|
@@ -646,7 +657,7 @@ dependencies = [
|
|
|
646
657
|
|
|
647
658
|
[[package]]
|
|
648
659
|
name = "polyglot-sql-wasm"
|
|
649
|
-
version = "0.
|
|
660
|
+
version = "0.6.0"
|
|
650
661
|
dependencies = [
|
|
651
662
|
"console_error_panic_hook",
|
|
652
663
|
"js-sys",
|
|
@@ -957,6 +968,12 @@ dependencies = [
|
|
|
957
968
|
"windows-sys",
|
|
958
969
|
]
|
|
959
970
|
|
|
971
|
+
[[package]]
|
|
972
|
+
name = "stats_alloc"
|
|
973
|
+
version = "0.1.10"
|
|
974
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
975
|
+
checksum = "5c0e04424e733e69714ca1bbb9204c1a57f09f5493439520f9f68c132ad25eec"
|
|
976
|
+
|
|
960
977
|
[[package]]
|
|
961
978
|
name = "strsim"
|
|
962
979
|
version = "0.11.1"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[workspace]
|
|
2
2
|
resolver = "2"
|
|
3
|
-
members = ["crates/polyglot-sql", "crates/polyglot-sql-function-catalogs", "crates/polyglot-sql-python"]
|
|
3
|
+
members = ["crates/polyglot-sql", "crates/polyglot-sql-ast-derive", "crates/polyglot-sql-function-catalogs", "crates/polyglot-sql-python"]
|
|
4
4
|
exclude = [
|
|
5
5
|
"examples/rust",
|
|
6
6
|
]
|
|
7
7
|
|
|
8
8
|
[workspace.package]
|
|
9
|
-
version = "0.
|
|
9
|
+
version = "0.6.0"
|
|
10
10
|
edition = "2021"
|
|
11
11
|
license = "MIT"
|
|
12
12
|
authors = ["polyglot contributors"]
|
|
@@ -46,6 +46,18 @@ opt-level = 3
|
|
|
46
46
|
lto = true
|
|
47
47
|
codegen-units = 1
|
|
48
48
|
|
|
49
|
+
[profile.native_release]
|
|
50
|
+
inherits = "release"
|
|
51
|
+
opt-level = 3
|
|
52
|
+
panic = "unwind"
|
|
53
|
+
|
|
54
|
+
[profile.python_release]
|
|
55
|
+
inherits = "release"
|
|
56
|
+
opt-level = 2
|
|
57
|
+
lto = "thin"
|
|
58
|
+
|
|
49
59
|
[profile.ffi_release]
|
|
50
60
|
inherits = "release"
|
|
61
|
+
opt-level = 2
|
|
62
|
+
lto = "thin"
|
|
51
63
|
panic = "unwind"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: polyglot-sql
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Classifier: Development Status :: 4 - Beta
|
|
5
5
|
Classifier: Intended Audience :: Developers
|
|
6
6
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -14,7 +14,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.13
|
|
15
15
|
Classifier: Topic :: Database
|
|
16
16
|
Classifier: Topic :: Software Development :: Libraries
|
|
17
|
-
Summary: Rust-powered SQL transpiler for
|
|
17
|
+
Summary: Rust-powered SQL transpiler for more than 30 SQL dialects. Parse, generate, transpile, format, and validate SQL.
|
|
18
18
|
Keywords: sql,transpiler,parser,dialect,database
|
|
19
19
|
Home-Page: https://github.com/tobilg/polyglot
|
|
20
20
|
License: MIT
|
|
@@ -27,7 +27,7 @@ Project-URL: Repository, https://github.com/tobilg/polyglot
|
|
|
27
27
|
|
|
28
28
|
# polyglot-sql (Python)
|
|
29
29
|
|
|
30
|
-
Rust-powered SQL transpiler for 30
|
|
30
|
+
Rust-powered SQL transpiler for more than 30 SQL dialects.
|
|
31
31
|
|
|
32
32
|
The `polyglot-sql` Python package exposes an API backed by the Rust `polyglot-sql` engine for fast parse/transpile/generate/format/validate workflows.
|
|
33
33
|
|
|
@@ -108,7 +108,12 @@ pretty = polyglot_sql.format_sql(
|
|
|
108
108
|
```
|
|
109
109
|
|
|
110
110
|
```python
|
|
111
|
-
result = polyglot_sql.validate(
|
|
111
|
+
result = polyglot_sql.validate(
|
|
112
|
+
"SELECT * FROM users LIMIT 10",
|
|
113
|
+
dialect="postgres",
|
|
114
|
+
strict_syntax=True,
|
|
115
|
+
semantic=True,
|
|
116
|
+
)
|
|
112
117
|
if result:
|
|
113
118
|
print("valid")
|
|
114
119
|
```
|
|
@@ -214,7 +219,7 @@ All functions are exported from `polyglot_sql`.
|
|
|
214
219
|
- `generate(ast: dict | list[dict], dialect: str = "generic", *, pretty: bool = False) -> list[str]`
|
|
215
220
|
- `format_sql(sql: str, dialect: str = "generic", *, max_input_bytes: int | None = None, max_tokens: int | None = None, max_ast_nodes: int | None = None, max_set_op_chain: int | None = None) -> str`
|
|
216
221
|
- `format(sql: str, dialect: str = "generic", *, max_input_bytes: int | None = None, max_tokens: int | None = None, max_ast_nodes: int | None = None, max_set_op_chain: int | None = None) -> str` (alias of `format_sql`)
|
|
217
|
-
- `validate(sql: str, dialect: str = "generic") -> ValidationResult`
|
|
222
|
+
- `validate(sql: str, dialect: str = "generic", *, strict_syntax: bool = False, semantic: bool = False) -> ValidationResult`
|
|
218
223
|
- `optimize(sql: str, dialect: str = "generic") -> str`
|
|
219
224
|
- `lineage(column: str, sql: str, dialect: str = "generic") -> dict`
|
|
220
225
|
- `source_tables(column: str, sql: str, dialect: str = "generic") -> list[str]`
|
|
@@ -249,6 +254,11 @@ Unknown dialect names raise built-in `ValueError`.
|
|
|
249
254
|
- `result.errors: list[ValidationErrorInfo]`
|
|
250
255
|
- `bool(result)` works (`True` when valid)
|
|
251
256
|
|
|
257
|
+
`strict_syntax=True` rejects compatibility forms such as trailing commas before
|
|
258
|
+
clause boundaries. `semantic=True` adds warning diagnostics W001-W004 for
|
|
259
|
+
`SELECT *`, mixed aggregate projections, `DISTINCT` with `ORDER BY`, and
|
|
260
|
+
`LIMIT` without `ORDER BY`; warnings do not make the result invalid.
|
|
261
|
+
|
|
252
262
|
Each `ValidationErrorInfo` has:
|
|
253
263
|
- `message: str`
|
|
254
264
|
- `line: int`
|
|
@@ -259,6 +269,11 @@ Each `ValidationErrorInfo` has:
|
|
|
259
269
|
## Performance Note
|
|
260
270
|
|
|
261
271
|
The package uses Rust internals directly via PyO3 and has zero runtime Python dependencies for SQL processing.
|
|
272
|
+
Published wheels use the dedicated Cargo `python_release` profile with
|
|
273
|
+
`opt-level=2` and thin LTO. This favors Python query throughput without changing
|
|
274
|
+
the size-oriented release profile used by WASM. FFI/Go artifacts use their own
|
|
275
|
+
native throughput profile. Editable development installs continue to use
|
|
276
|
+
Cargo's `dev` profile.
|
|
262
277
|
|
|
263
278
|
## Development
|
|
264
279
|
|
|
@@ -268,7 +283,7 @@ uv sync --group dev
|
|
|
268
283
|
uv run maturin develop
|
|
269
284
|
uv run pytest
|
|
270
285
|
uv run pyright python/polyglot_sql/
|
|
271
|
-
uv run maturin build --
|
|
286
|
+
uv run maturin build --profile python_release
|
|
272
287
|
uv run --with mkdocs mkdocs build --strict --clean --config-file mkdocs.yml --site-dir ../../packages/python-docs/dist
|
|
273
288
|
```
|
|
274
289
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# polyglot-sql (Python)
|
|
2
2
|
|
|
3
|
-
Rust-powered SQL transpiler for 30
|
|
3
|
+
Rust-powered SQL transpiler for more than 30 SQL dialects.
|
|
4
4
|
|
|
5
5
|
The `polyglot-sql` Python package exposes an API backed by the Rust `polyglot-sql` engine for fast parse/transpile/generate/format/validate workflows.
|
|
6
6
|
|
|
@@ -81,7 +81,12 @@ pretty = polyglot_sql.format_sql(
|
|
|
81
81
|
```
|
|
82
82
|
|
|
83
83
|
```python
|
|
84
|
-
result = polyglot_sql.validate(
|
|
84
|
+
result = polyglot_sql.validate(
|
|
85
|
+
"SELECT * FROM users LIMIT 10",
|
|
86
|
+
dialect="postgres",
|
|
87
|
+
strict_syntax=True,
|
|
88
|
+
semantic=True,
|
|
89
|
+
)
|
|
85
90
|
if result:
|
|
86
91
|
print("valid")
|
|
87
92
|
```
|
|
@@ -187,7 +192,7 @@ All functions are exported from `polyglot_sql`.
|
|
|
187
192
|
- `generate(ast: dict | list[dict], dialect: str = "generic", *, pretty: bool = False) -> list[str]`
|
|
188
193
|
- `format_sql(sql: str, dialect: str = "generic", *, max_input_bytes: int | None = None, max_tokens: int | None = None, max_ast_nodes: int | None = None, max_set_op_chain: int | None = None) -> str`
|
|
189
194
|
- `format(sql: str, dialect: str = "generic", *, max_input_bytes: int | None = None, max_tokens: int | None = None, max_ast_nodes: int | None = None, max_set_op_chain: int | None = None) -> str` (alias of `format_sql`)
|
|
190
|
-
- `validate(sql: str, dialect: str = "generic") -> ValidationResult`
|
|
195
|
+
- `validate(sql: str, dialect: str = "generic", *, strict_syntax: bool = False, semantic: bool = False) -> ValidationResult`
|
|
191
196
|
- `optimize(sql: str, dialect: str = "generic") -> str`
|
|
192
197
|
- `lineage(column: str, sql: str, dialect: str = "generic") -> dict`
|
|
193
198
|
- `source_tables(column: str, sql: str, dialect: str = "generic") -> list[str]`
|
|
@@ -222,6 +227,11 @@ Unknown dialect names raise built-in `ValueError`.
|
|
|
222
227
|
- `result.errors: list[ValidationErrorInfo]`
|
|
223
228
|
- `bool(result)` works (`True` when valid)
|
|
224
229
|
|
|
230
|
+
`strict_syntax=True` rejects compatibility forms such as trailing commas before
|
|
231
|
+
clause boundaries. `semantic=True` adds warning diagnostics W001-W004 for
|
|
232
|
+
`SELECT *`, mixed aggregate projections, `DISTINCT` with `ORDER BY`, and
|
|
233
|
+
`LIMIT` without `ORDER BY`; warnings do not make the result invalid.
|
|
234
|
+
|
|
225
235
|
Each `ValidationErrorInfo` has:
|
|
226
236
|
- `message: str`
|
|
227
237
|
- `line: int`
|
|
@@ -232,6 +242,11 @@ Each `ValidationErrorInfo` has:
|
|
|
232
242
|
## Performance Note
|
|
233
243
|
|
|
234
244
|
The package uses Rust internals directly via PyO3 and has zero runtime Python dependencies for SQL processing.
|
|
245
|
+
Published wheels use the dedicated Cargo `python_release` profile with
|
|
246
|
+
`opt-level=2` and thin LTO. This favors Python query throughput without changing
|
|
247
|
+
the size-oriented release profile used by WASM. FFI/Go artifacts use their own
|
|
248
|
+
native throughput profile. Editable development installs continue to use
|
|
249
|
+
Cargo's `dev` profile.
|
|
235
250
|
|
|
236
251
|
## Development
|
|
237
252
|
|
|
@@ -241,7 +256,7 @@ uv sync --group dev
|
|
|
241
256
|
uv run maturin develop
|
|
242
257
|
uv run pytest
|
|
243
258
|
uv run pyright python/polyglot_sql/
|
|
244
|
-
uv run maturin build --
|
|
259
|
+
uv run maturin build --profile python_release
|
|
245
260
|
uv run --with mkdocs mkdocs build --strict --clean --config-file mkdocs.yml --site-dir ../../packages/python-docs/dist
|
|
246
261
|
```
|
|
247
262
|
|
|
@@ -100,18 +100,20 @@ function-catalog-all-dialects = [
|
|
|
100
100
|
]
|
|
101
101
|
|
|
102
102
|
[dependencies]
|
|
103
|
+
polyglot-sql-ast-derive = { path = "../polyglot-sql-ast-derive" }
|
|
103
104
|
serde = { workspace = true }
|
|
104
105
|
serde_json = { workspace = true }
|
|
105
106
|
thiserror = { workspace = true }
|
|
106
107
|
unicode-segmentation = { workspace = true }
|
|
107
108
|
stacker = { version = "0.1", optional = true }
|
|
108
109
|
ts-rs = { version = "12.0", features = ["serde-compat"], optional = true }
|
|
109
|
-
polyglot-sql-function-catalogs = { path = "../polyglot-sql-function-catalogs", version = "0.
|
|
110
|
+
polyglot-sql-function-catalogs = { path = "../polyglot-sql-function-catalogs", version = "0.6.0", optional = true, default-features = false }
|
|
110
111
|
|
|
111
112
|
[dev-dependencies]
|
|
112
113
|
pretty_assertions = "1.4"
|
|
113
114
|
once_cell = "1.19"
|
|
114
115
|
criterion = { version = "0.5", features = ["html_reports"] }
|
|
116
|
+
stats_alloc = "0.1"
|
|
115
117
|
|
|
116
118
|
[[bench]]
|
|
117
119
|
name = "parsing"
|
|
@@ -121,6 +123,10 @@ harness = false
|
|
|
121
123
|
name = "transpile"
|
|
122
124
|
harness = false
|
|
123
125
|
|
|
126
|
+
[[bench]]
|
|
127
|
+
name = "ast_traversal"
|
|
128
|
+
harness = false
|
|
129
|
+
|
|
124
130
|
[[bench]]
|
|
125
131
|
name = "in_list"
|
|
126
132
|
harness = false
|
|
@@ -128,3 +134,11 @@ harness = false
|
|
|
128
134
|
[[bench]]
|
|
129
135
|
name = "rust_parsing"
|
|
130
136
|
harness = false
|
|
137
|
+
|
|
138
|
+
[[bench]]
|
|
139
|
+
name = "performance_hotspots"
|
|
140
|
+
harness = false
|
|
141
|
+
|
|
142
|
+
[[bench]]
|
|
143
|
+
name = "allocation_hotspots"
|
|
144
|
+
harness = false
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# polyglot-sql
|
|
2
2
|
|
|
3
|
-
Core SQL parsing and dialect translation library for Rust. Parses, generates, transpiles, and formats SQL across
|
|
3
|
+
Core SQL parsing and dialect translation library for Rust. Parses, generates, transpiles, and formats SQL across more than 30 SQL dialects.
|
|
4
4
|
|
|
5
5
|
Part of the [Polyglot](https://github.com/tobilg/polyglot) project.
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ Part of the [Polyglot](https://github.com/tobilg/polyglot) project.
|
|
|
9
9
|
- **Parse** SQL into a fully-typed AST with 200+ expression types
|
|
10
10
|
- **Parse standalone data types** such as `DECIMAL(10, 2)` without a statement wrapper
|
|
11
11
|
- **Generate** SQL from AST nodes for any target dialect
|
|
12
|
-
- **Transpile** between any pair of
|
|
12
|
+
- **Transpile** between any pair of more than 30 SQL dialects in one call
|
|
13
13
|
- **Format** / pretty-print SQL
|
|
14
14
|
- **Fluent builder API** for constructing queries programmatically
|
|
15
15
|
- **AST traversal** utilities (DFS/BFS iterators, transform, walk)
|
|
@@ -25,7 +25,7 @@ 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.6.0", default-features = false }
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
```toml
|
|
@@ -245,10 +245,17 @@ let tables = get_tables(&ast[0]);
|
|
|
245
245
|
### Validation
|
|
246
246
|
|
|
247
247
|
```rust
|
|
248
|
-
use polyglot_sql::{
|
|
248
|
+
use polyglot_sql::{validate_with_options, DialectType, ValidationOptions};
|
|
249
249
|
|
|
250
|
-
let result =
|
|
251
|
-
|
|
250
|
+
let result = validate_with_options(
|
|
251
|
+
"SELECT * FROM users LIMIT 10",
|
|
252
|
+
DialectType::Generic,
|
|
253
|
+
&ValidationOptions {
|
|
254
|
+
strict_syntax: false,
|
|
255
|
+
semantic: true,
|
|
256
|
+
},
|
|
257
|
+
);
|
|
258
|
+
// W001 and W004 are warnings, so result.valid remains true.
|
|
252
259
|
```
|
|
253
260
|
|
|
254
261
|
```rust
|
|
@@ -448,7 +455,7 @@ assert_eq!(err.line(), None);
|
|
|
448
455
|
|
|
449
456
|
## Supported Dialects
|
|
450
457
|
|
|
451
|
-
Athena, BigQuery, ClickHouse, CockroachDB, Databricks, Doris, Dremio, Drill, Druid, DuckDB, Dune, Exasol, Fabric, Hive, Materialize, MySQL, Oracle, PostgreSQL, Presto, Redshift, RisingWave, SingleStore, Snowflake, Solr, Spark, SQLite, StarRocks, Tableau, Teradata, TiDB, Trino, TSQL
|
|
458
|
+
Athena, BigQuery, ClickHouse, CockroachDB, DataFusion, Databricks, Doris, Dremio, Drill, Druid, DuckDB, Dune, Exasol, Fabric, Generic SQL, Hive, Materialize, MySQL, Oracle, PostgreSQL, Presto, Redshift, RisingWave, SingleStore, Snowflake, Solr, Spark, SQLite, StarRocks, Tableau, Teradata, TiDB, Trino, TSQL
|
|
452
459
|
|
|
453
460
|
## Feature Flags
|
|
454
461
|
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
use polyglot_sql::dialects::{Dialect, DialectType};
|
|
2
|
+
use stats_alloc::{Region, Stats, StatsAlloc, INSTRUMENTED_SYSTEM};
|
|
3
|
+
use std::alloc::System;
|
|
4
|
+
use std::hint::black_box;
|
|
5
|
+
|
|
6
|
+
#[global_allocator]
|
|
7
|
+
static GLOBAL: &StatsAlloc<System> = &INSTRUMENTED_SYSTEM;
|
|
8
|
+
|
|
9
|
+
const SHORT_ASCII: &str =
|
|
10
|
+
"SELECT a, b, SUM(c) AS total FROM events WHERE created_at >= '2025-01-01' GROUP BY a, b";
|
|
11
|
+
const UNICODE: &str =
|
|
12
|
+
"SELECT \"Kundennummer\", 'Gr\u{00fc}\u{00df}e aus Z\u{00fc}rich' AS \"Mitteilung\" FROM \"Bestellungen\" WHERE \"Stadt\" = 'M\u{00fc}nchen'";
|
|
13
|
+
const COMMENT_AND_STRING_HEAVY: &str = r#"
|
|
14
|
+
-- leading comment
|
|
15
|
+
SELECT 'alpha''beta' AS value, "quoted name", E'line\nvalue'
|
|
16
|
+
FROM events /* source comment */
|
|
17
|
+
WHERE payload = '{"key":"value"}' -- trailing comment
|
|
18
|
+
"#;
|
|
19
|
+
|
|
20
|
+
fn large_token_list() -> String {
|
|
21
|
+
let values = (0..20_000)
|
|
22
|
+
.map(|value| value.to_string())
|
|
23
|
+
.collect::<Vec<_>>()
|
|
24
|
+
.join(", ");
|
|
25
|
+
format!("SELECT * FROM events WHERE event_id IN ({values})")
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
fn many_columns() -> String {
|
|
29
|
+
format!(
|
|
30
|
+
"SELECT {} FROM t",
|
|
31
|
+
(0..1_000)
|
|
32
|
+
.map(|index| format!("c{index}"))
|
|
33
|
+
.collect::<Vec<_>>()
|
|
34
|
+
.join(", ")
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
fn nested_functions() -> String {
|
|
39
|
+
format!(
|
|
40
|
+
"SELECT {}x{} FROM t",
|
|
41
|
+
"COALESCE(".repeat(20),
|
|
42
|
+
", NULL)".repeat(20)
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
fn large_strings() -> String {
|
|
47
|
+
format!(
|
|
48
|
+
"SELECT {} FROM t",
|
|
49
|
+
vec![format!("'{}'", "x".repeat(100)); 500].join(", ")
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
fn many_numbers() -> String {
|
|
54
|
+
format!(
|
|
55
|
+
"SELECT {} FROM t",
|
|
56
|
+
(0..10_000)
|
|
57
|
+
.map(|value| value.to_string())
|
|
58
|
+
.collect::<Vec<_>>()
|
|
59
|
+
.join(", ")
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
fn measure<T>(operation: impl FnOnce() -> T) -> Stats {
|
|
64
|
+
let region = Region::new(GLOBAL);
|
|
65
|
+
black_box(operation());
|
|
66
|
+
region.change()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
fn print_stats(case: &str, operation: &str, input_bytes: usize, stats: Stats) {
|
|
70
|
+
println!(
|
|
71
|
+
"{{\"case\":\"{case}\",\"operation\":\"{operation}\",\"input_bytes\":{input_bytes},\"allocations\":{},\"deallocations\":{},\"bytes_allocated\":{},\"bytes_deallocated\":{}}}",
|
|
72
|
+
stats.allocations,
|
|
73
|
+
stats.deallocations,
|
|
74
|
+
stats.bytes_allocated,
|
|
75
|
+
stats.bytes_deallocated,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
fn main() {
|
|
80
|
+
let dialect = Dialect::get(DialectType::PostgreSQL);
|
|
81
|
+
let large = large_token_list();
|
|
82
|
+
let columns = many_columns();
|
|
83
|
+
let functions = nested_functions();
|
|
84
|
+
let strings = large_strings();
|
|
85
|
+
let numbers = many_numbers();
|
|
86
|
+
let inputs = [
|
|
87
|
+
("short_ascii", SHORT_ASCII),
|
|
88
|
+
("unicode", UNICODE),
|
|
89
|
+
("comments_strings", COMMENT_AND_STRING_HEAVY),
|
|
90
|
+
("large_tokens", large.as_str()),
|
|
91
|
+
("many_columns", columns.as_str()),
|
|
92
|
+
("nested_functions", functions.as_str()),
|
|
93
|
+
("large_strings", strings.as_str()),
|
|
94
|
+
("many_numbers", numbers.as_str()),
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
black_box(dialect.tokenize(SHORT_ASCII).unwrap());
|
|
98
|
+
black_box(dialect.parse(SHORT_ASCII).unwrap());
|
|
99
|
+
black_box(Dialect::get(DialectType::PostgreSQL));
|
|
100
|
+
|
|
101
|
+
for (case, sql) in inputs {
|
|
102
|
+
print_stats(
|
|
103
|
+
case,
|
|
104
|
+
"tokenize",
|
|
105
|
+
sql.len(),
|
|
106
|
+
measure(|| dialect.tokenize(sql).unwrap()),
|
|
107
|
+
);
|
|
108
|
+
print_stats(
|
|
109
|
+
case,
|
|
110
|
+
"parse",
|
|
111
|
+
sql.len(),
|
|
112
|
+
measure(|| dialect.parse(sql).unwrap()),
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
print_stats(
|
|
117
|
+
"postgresql",
|
|
118
|
+
"dialect_get",
|
|
119
|
+
0,
|
|
120
|
+
measure(|| Dialect::get(DialectType::PostgreSQL)),
|
|
121
|
+
);
|
|
122
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
use criterion::{black_box, criterion_group, criterion_main, BatchSize, Criterion};
|
|
2
|
+
use polyglot_sql::dialects::transform_recursive;
|
|
3
|
+
use polyglot_sql::{ExpressionWalk, Parser};
|
|
4
|
+
|
|
5
|
+
const COMPLEX_QUERY: &str = r#"
|
|
6
|
+
WITH active_users AS (
|
|
7
|
+
SELECT id, name FROM users WHERE active = TRUE
|
|
8
|
+
), order_totals AS (
|
|
9
|
+
SELECT user_id, SUM(amount) AS total
|
|
10
|
+
FROM orders
|
|
11
|
+
GROUP BY user_id
|
|
12
|
+
)
|
|
13
|
+
SELECT u.id, u.name, COALESCE(o.total, 0) AS total
|
|
14
|
+
FROM active_users AS u
|
|
15
|
+
LEFT JOIN order_totals AS o ON u.id = o.user_id
|
|
16
|
+
WHERE o.total > 100 OR o.total IS NULL
|
|
17
|
+
ORDER BY total DESC
|
|
18
|
+
LIMIT 100
|
|
19
|
+
"#;
|
|
20
|
+
|
|
21
|
+
fn benchmark_ast_traversal(c: &mut Criterion) {
|
|
22
|
+
let expression = Parser::parse_sql(COMPLEX_QUERY)
|
|
23
|
+
.expect("benchmark query should parse")
|
|
24
|
+
.remove(0);
|
|
25
|
+
|
|
26
|
+
let mut group = c.benchmark_group("ast_traversal");
|
|
27
|
+
group.bench_function("dfs", |b| b.iter(|| black_box(&expression).dfs().count()));
|
|
28
|
+
group.bench_function("bfs", |b| b.iter(|| black_box(&expression).bfs().count()));
|
|
29
|
+
group.bench_function("direct_children", |b| {
|
|
30
|
+
b.iter(|| black_box(&expression).children())
|
|
31
|
+
});
|
|
32
|
+
group.bench_function("noop_transform", |b| {
|
|
33
|
+
b.iter_batched(
|
|
34
|
+
|| expression.clone(),
|
|
35
|
+
|expression| transform_recursive(expression, &|node| Ok(node)).unwrap(),
|
|
36
|
+
BatchSize::SmallInput,
|
|
37
|
+
)
|
|
38
|
+
});
|
|
39
|
+
group.finish();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
criterion_group!(benches, benchmark_ast_traversal);
|
|
43
|
+
criterion_main!(benches);
|