polyglot-sql 0.14.2__tar.gz → 0.14.4__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.
Files changed (259) hide show
  1. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/Cargo.lock +7 -7
  2. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/Cargo.toml +1 -1
  3. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/PKG-INFO +1 -1
  4. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/Cargo.toml +3 -3
  5. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/README.md +4 -4
  6. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/binding.rs +13 -0
  7. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/mod.rs +40 -1
  8. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/normalization/duckdb.rs +19 -1
  9. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/normalization/mod.rs +50 -10
  10. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/normalization/operators.rs +164 -20
  11. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/normalization/scalar.rs +125 -0
  12. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/normalization/statements.rs +4 -0
  13. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/normalization/temporal.rs +20 -1
  14. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/sqlite.rs +0 -39
  15. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/tsql.rs +1 -0
  16. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/expressions.rs +45 -0
  17. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/generator.rs +9 -0
  18. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/lineage.rs +513 -344
  19. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/openlineage.rs +6 -6
  20. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/optimizer/annotate_types.rs +10 -13
  21. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/optimizer/isolate_table_selects.rs +1 -0
  22. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/optimizer/qualify_columns.rs +70 -103
  23. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/optimizer/qualify_tables.rs +13 -7
  24. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/parser.rs +56 -9
  25. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/query_analysis/column_uses.rs +289 -29
  26. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/query_analysis.rs +97 -17
  27. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/resolver.rs +57 -35
  28. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/schema.rs +55 -41
  29. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/scope.rs +75 -12
  30. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/transforms.rs +2 -1
  31. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/validation/semantics.rs +42 -8
  32. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/validation/tests.rs +186 -1
  33. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/validation.rs +213 -212
  34. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/common/upstream_semantic_exceptions.json +8 -0
  35. polyglot_sql-0.14.4/crates/polyglot-sql/tests/duckdb_strftime_sqlite.rs +108 -0
  36. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/query_analysis.rs +349 -7
  37. polyglot_sql-0.14.4/crates/polyglot-sql/tests/query_analysis_regression.rs +861 -0
  38. polyglot_sql-0.14.4/crates/polyglot-sql/tests/spark_date_trunc_regression.rs +82 -0
  39. polyglot_sql-0.14.4/crates/polyglot-sql/tests/sqlite_integer_division.rs +148 -0
  40. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-function-catalogs/README.md +1 -1
  41. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/python/polyglot_sql/analysis_types.py +1 -1
  42. polyglot_sql-0.14.2/crates/polyglot-sql/tests/query_analysis_regression.rs +0 -418
  43. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/README.md +0 -0
  44. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/benches/allocation_hotspots.rs +0 -0
  45. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/benches/ast_traversal.rs +0 -0
  46. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/benches/common/mod.rs +0 -0
  47. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/benches/in_list.rs +0 -0
  48. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/benches/lineage.rs +0 -0
  49. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/benches/parsing.rs +0 -0
  50. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/benches/performance_hotspots.rs +0 -0
  51. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/benches/rust_parsing.rs +0 -0
  52. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/benches/transpile.rs +0 -0
  53. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/examples/basic_usage.rs +0 -0
  54. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/examples/bench_json.rs +0 -0
  55. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/examples/performance_review.rs +0 -0
  56. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/ast_children.rs +0 -0
  57. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/ast_json.rs +0 -0
  58. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/ast_mutation.rs +0 -0
  59. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/ast_transforms.rs +0 -0
  60. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/builder/mod.rs +0 -0
  61. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/builder/plan.rs +0 -0
  62. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/athena.rs +0 -0
  63. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/bigquery.rs +0 -0
  64. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/clickhouse.rs +0 -0
  65. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/cockroachdb.rs +0 -0
  66. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/databricks.rs +0 -0
  67. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/datafusion.rs +0 -0
  68. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/doris.rs +0 -0
  69. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/dremio.rs +0 -0
  70. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/drill.rs +0 -0
  71. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/druid.rs +0 -0
  72. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/duckdb.rs +0 -0
  73. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/dune.rs +0 -0
  74. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/exasol.rs +0 -0
  75. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/fabric.rs +0 -0
  76. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/generic.rs +0 -0
  77. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/hana.rs +0 -0
  78. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/hive.rs +0 -0
  79. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/materialize.rs +0 -0
  80. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/mysql.rs +0 -0
  81. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/normalization/aggregates.rs +0 -0
  82. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/normalization/collections.rs +0 -0
  83. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/normalization/hana.rs +0 -0
  84. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/normalization/json.rs +0 -0
  85. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/normalization/postgres_interval.rs +0 -0
  86. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/normalization/types.rs +0 -0
  87. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/normalization/vertica.rs +0 -0
  88. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/oracle.rs +0 -0
  89. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/postgres.rs +0 -0
  90. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/presto.rs +0 -0
  91. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/redshift.rs +0 -0
  92. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/risingwave.rs +0 -0
  93. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/singlestore.rs +0 -0
  94. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/snowflake.rs +0 -0
  95. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/solr.rs +0 -0
  96. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/spark.rs +0 -0
  97. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/starrocks.rs +0 -0
  98. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/tableau.rs +0 -0
  99. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/teradata.rs +0 -0
  100. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/tidb.rs +0 -0
  101. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/trino.rs +0 -0
  102. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/dialects/vertica.rs +0 -0
  103. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/diff.rs +0 -0
  104. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/error.rs +0 -0
  105. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/expressions/explain.rs +0 -0
  106. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/format_tokens.rs +0 -0
  107. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/function_catalog.rs +0 -0
  108. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/function_registry.rs +0 -0
  109. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/generator/explain.rs +0 -0
  110. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/generator/pipes.rs +0 -0
  111. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/generator/routines.rs +0 -0
  112. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/guard.rs +0 -0
  113. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/helper.rs +0 -0
  114. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/lib.rs +0 -0
  115. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/optimizer/canonicalize.rs +0 -0
  116. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/optimizer/eliminate_ctes.rs +0 -0
  117. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/optimizer/eliminate_joins.rs +0 -0
  118. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/optimizer/mod.rs +0 -0
  119. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/optimizer/normalize.rs +0 -0
  120. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/optimizer/normalize_identifiers.rs +0 -0
  121. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/optimizer/optimize_joins.rs +0 -0
  122. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/optimizer/optimizer.rs +0 -0
  123. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/optimizer/pushdown_predicates.rs +0 -0
  124. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/optimizer/pushdown_projections.rs +0 -0
  125. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/optimizer/set_operation_types.rs +0 -0
  126. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/optimizer/simplify.rs +0 -0
  127. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/optimizer/subquery.rs +0 -0
  128. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/parser/explain.rs +0 -0
  129. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/parser/pipes.rs +0 -0
  130. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/parser/routines.rs +0 -0
  131. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/planner.rs +0 -0
  132. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/set_operation.rs +0 -0
  133. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/time.rs +0 -0
  134. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/tokens.rs +0 -0
  135. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/traversal.rs +0 -0
  136. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/src/trie.rs +0 -0
  137. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/analyze_failures.rs +0 -0
  138. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/clickhouse_regression.rs +0 -0
  139. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/common/known_failures.rs +0 -0
  140. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/common/mod.rs +0 -0
  141. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/common/test_data.rs +0 -0
  142. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/common/test_runner.rs +0 -0
  143. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/create_view_security_comment_regression.rs +0 -0
  144. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_clickhouse_coverage.rs +0 -0
  145. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_clickhouse_parser.rs +0 -0
  146. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_dialect.rs +0 -0
  147. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_dialect_tests.rs +0 -0
  148. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_fixtures/datafusion/ddl.json +0 -0
  149. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_fixtures/datafusion/dml.json +0 -0
  150. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_fixtures/datafusion/functions.json +0 -0
  151. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_fixtures/datafusion/identity.json +0 -0
  152. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_fixtures/datafusion/operators.json +0 -0
  153. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_fixtures/datafusion/select.json +0 -0
  154. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_fixtures/datafusion/transpilation.json +0 -0
  155. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_fixtures/datafusion/types.json +0 -0
  156. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_fixtures/hana/ddl.json +0 -0
  157. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_fixtures/hana/dml.json +0 -0
  158. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_fixtures/hana/functions.json +0 -0
  159. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_fixtures/hana/identity.json +0 -0
  160. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_fixtures/hana/select.json +0 -0
  161. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_fixtures/hana/types.json +0 -0
  162. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_fixtures/vertica/identity.json +0 -0
  163. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_fixtures/vertica/transpilation.json +0 -0
  164. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/custom_fixtures/vertica/types.json +0 -0
  165. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/data_type_api.rs +0 -0
  166. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/deep_nesting_regression.rs +0 -0
  167. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/deserialize_payloads.rs +0 -0
  168. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/dialect_matrix.rs +0 -0
  169. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/duckdb_decimal_precision.rs +0 -0
  170. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/duckdb_integer_division.rs +0 -0
  171. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/duckdb_json_arrow_context.rs +0 -0
  172. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/duckdb_order_by_all.rs +0 -0
  173. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/duckdb_regex_operators.rs +0 -0
  174. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/duckdb_unreserved_relation_aliases.rs +0 -0
  175. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/error_handling.rs +0 -0
  176. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/fabric_regression.rs +0 -0
  177. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/fabric_tpch_regression.rs +0 -0
  178. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/fixture_update_regression.rs +0 -0
  179. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/identity_roundtrip.rs +0 -0
  180. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/is_predicate_precedence.rs +0 -0
  181. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/mod_precedence.rs +0 -0
  182. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/numeric_exponent_boundaries.rs +0 -0
  183. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/oracle_data_types_regression.rs +0 -0
  184. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/oracle_flashback.rs +0 -0
  185. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/postgres_explain_options.rs +0 -0
  186. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/postgres_regexp_clickhouse.rs +0 -0
  187. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/postgres_sqlite_regression.rs +0 -0
  188. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/quoted_relation_columns.rs +0 -0
  189. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/snowflake_regression_test.rs +0 -0
  190. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/sqlglot_compat.rs +0 -0
  191. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/sqlglot_dialect_identity.rs +0 -0
  192. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/sqlglot_identity.rs +0 -0
  193. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/sqlglot_identity_detailed.rs +0 -0
  194. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/sqlglot_parser.rs +0 -0
  195. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/sqlglot_pretty.rs +0 -0
  196. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/sqlglot_transpilation.rs +0 -0
  197. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/sqlglot_transpile.rs +0 -0
  198. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/tpch_transpile_stack.rs +0 -0
  199. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/transform_regression.rs +0 -0
  200. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/tsql_regression.rs +0 -0
  201. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql/tests/unicode_token_ranges.rs +0 -0
  202. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-ast-derive/Cargo.toml +0 -0
  203. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-ast-derive/src/lib.rs +0 -0
  204. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-function-catalogs/Cargo.toml +0 -0
  205. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-function-catalogs/src/clickhouse.rs +0 -0
  206. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-function-catalogs/src/duckdb.rs +0 -0
  207. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-function-catalogs/src/lib.rs +0 -0
  208. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-function-catalogs/tools/clickhouse/extract_functions.py +0 -0
  209. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-function-catalogs/tools/duckdb/extract_functions.py +0 -0
  210. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/Cargo.toml +0 -0
  211. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/README.md +0 -0
  212. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/docs/api.md +0 -0
  213. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/docs/index.md +0 -0
  214. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/mkdocs.yml +0 -0
  215. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/annotate_types.rs +0 -0
  216. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/builders.rs +0 -0
  217. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/dialects.rs +0 -0
  218. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/diff.rs +0 -0
  219. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/errors.rs +0 -0
  220. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/expr.rs +0 -0
  221. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/expr_types.rs +0 -0
  222. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/format.rs +0 -0
  223. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/generate.rs +0 -0
  224. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/helpers.rs +0 -0
  225. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/lib.rs +0 -0
  226. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/lineage.rs +0 -0
  227. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/openlineage.rs +0 -0
  228. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/optimize.rs +0 -0
  229. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/parse.rs +0 -0
  230. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/query_analysis.rs +0 -0
  231. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/shared_expression.rs +0 -0
  232. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/tokenize.rs +0 -0
  233. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/transforms.rs +0 -0
  234. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/transpile.rs +0 -0
  235. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/types.rs +0 -0
  236. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/src/validate.rs +0 -0
  237. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/tests/conftest.py +0 -0
  238. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/tests/test_builders.py +0 -0
  239. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/tests/test_compat.py +0 -0
  240. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/tests/test_dialects.py +0 -0
  241. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/tests/test_diff.py +0 -0
  242. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/tests/test_duckdb_datafusion_execution.py +0 -0
  243. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/tests/test_duckdb_regex_execution.py +0 -0
  244. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/tests/test_expression.py +0 -0
  245. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/tests/test_format.py +0 -0
  246. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/tests/test_generate.py +0 -0
  247. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/tests/test_lineage.py +0 -0
  248. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/tests/test_optimize.py +0 -0
  249. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/tests/test_parse.py +0 -0
  250. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/tests/test_query_analysis.py +0 -0
  251. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/tests/test_shared_expression.py +0 -0
  252. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/tests/test_transforms.py +0 -0
  253. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/tests/test_transpile.py +0 -0
  254. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/tests/test_validate.py +0 -0
  255. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/crates/polyglot-sql-python/uv.lock +0 -0
  256. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/pyproject.toml +0 -0
  257. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/python/polyglot_sql/__init__.py +0 -0
  258. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/python/polyglot_sql/__init__.pyi +0 -0
  259. {polyglot_sql-0.14.2 → polyglot_sql-0.14.4}/python/polyglot_sql/py.typed +0 -0
@@ -605,7 +605,7 @@ dependencies = [
605
605
 
606
606
  [[package]]
607
607
  name = "polyglot-sql"
608
- version = "0.14.2"
608
+ version = "0.14.4"
609
609
  dependencies = [
610
610
  "criterion",
611
611
  "once_cell",
@@ -623,7 +623,7 @@ dependencies = [
623
623
 
624
624
  [[package]]
625
625
  name = "polyglot-sql-ast-derive"
626
- version = "0.14.2"
626
+ version = "0.14.4"
627
627
  dependencies = [
628
628
  "proc-macro2",
629
629
  "quote",
@@ -632,7 +632,7 @@ dependencies = [
632
632
 
633
633
  [[package]]
634
634
  name = "polyglot-sql-ffi"
635
- version = "0.14.2"
635
+ version = "0.14.4"
636
636
  dependencies = [
637
637
  "cbindgen",
638
638
  "polyglot-sql",
@@ -642,11 +642,11 @@ dependencies = [
642
642
 
643
643
  [[package]]
644
644
  name = "polyglot-sql-function-catalogs"
645
- version = "0.14.2"
645
+ version = "0.14.4"
646
646
 
647
647
  [[package]]
648
648
  name = "polyglot-sql-python"
649
- version = "0.14.2"
649
+ version = "0.14.4"
650
650
  dependencies = [
651
651
  "polyglot-sql",
652
652
  "pyo3",
@@ -657,7 +657,7 @@ dependencies = [
657
657
 
658
658
  [[package]]
659
659
  name = "polyglot-sql-wasi"
660
- version = "0.14.2"
660
+ version = "0.14.4"
661
661
  dependencies = [
662
662
  "polyglot-sql",
663
663
  "serde",
@@ -666,7 +666,7 @@ dependencies = [
666
666
 
667
667
  [[package]]
668
668
  name = "polyglot-sql-wasm"
669
- version = "0.14.2"
669
+ version = "0.14.4"
670
670
  dependencies = [
671
671
  "console_error_panic_hook",
672
672
  "js-sys",
@@ -6,7 +6,7 @@ exclude = [
6
6
  ]
7
7
 
8
8
  [workspace.package]
9
- version = "0.14.2"
9
+ version = "0.14.4"
10
10
  edition = "2021"
11
11
  license = "MIT"
12
12
  authors = ["polyglot contributors"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polyglot-sql
3
- Version: 0.14.2
3
+ Version: 0.14.4
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -25,7 +25,7 @@ default = [
25
25
  ]
26
26
  bindings = ["dep:ts-rs"]
27
27
  generate = []
28
- transpile = ["generate"]
28
+ transpile = ["generate", "semantic"]
29
29
  builder = ["generate"]
30
30
  ast-tools = []
31
31
  semantic = ["ast-tools"]
@@ -103,14 +103,14 @@ function-catalog-all-dialects = [
103
103
  ]
104
104
 
105
105
  [dependencies]
106
- polyglot-sql-ast-derive = { path = "../polyglot-sql-ast-derive", version = "0.14.2" }
106
+ polyglot-sql-ast-derive = { path = "../polyglot-sql-ast-derive", version = "0.14.4" }
107
107
  serde = { workspace = true }
108
108
  serde_json = { workspace = true }
109
109
  thiserror = { workspace = true }
110
110
  unicode-segmentation = { workspace = true }
111
111
  stacker = { version = "0.1", optional = true }
112
112
  ts-rs = { version = "12.0", features = ["serde-compat"], optional = true }
113
- polyglot-sql-function-catalogs = { path = "../polyglot-sql-function-catalogs", version = "0.14.2", optional = true, default-features = false }
113
+ polyglot-sql-function-catalogs = { path = "../polyglot-sql-function-catalogs", version = "0.14.4", optional = true, default-features = false }
114
114
 
115
115
  [dev-dependencies]
116
116
  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.14.2", default-features = false }
28
+ polyglot-sql = { version = "0.14.4", default-features = false }
29
29
  ```
30
30
 
31
31
  ```toml
32
32
  polyglot-sql = {
33
- version = "0.14.2",
33
+ version = "0.14.4",
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.14.2",
47
+ version = "0.14.4",
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.14.2",
54
+ version = "0.14.4",
55
55
  default-features = false,
56
56
  features = ["transpile", "dialect-clickhouse", "dialect-postgresql"],
57
57
  }
@@ -82,6 +82,19 @@ pub(crate) fn identifier_name(identifier: &crate::expressions::Identifier) -> St
82
82
  identifier.to_type_field_name()
83
83
  }
84
84
 
85
+ /// Render a table path for schema lookup, retaining identifier boundaries and quoting.
86
+ pub(crate) fn schema_table_name(table: &crate::expressions::TableRef) -> String {
87
+ let mut parts = Vec::new();
88
+ if let Some(catalog) = &table.catalog {
89
+ parts.push(identifier_name(catalog));
90
+ }
91
+ if let Some(schema) = &table.schema {
92
+ parts.push(identifier_name(schema));
93
+ }
94
+ parts.push(identifier_name(&table.name));
95
+ parts.join(".")
96
+ }
97
+
85
98
  /// Boolean contexts are inline AST fields as well as standalone nodes. Keep
86
99
  /// their discovery shared so DML does not silently miss the SELECT checks.
87
100
  pub(crate) fn predicates(expression: &Expression) -> Vec<(&'static str, &Expression)> {
@@ -312,6 +312,29 @@ impl DialectType {
312
312
  | DialectType::Spark
313
313
  )
314
314
  }
315
+
316
+ /// Whether `/` between two integers truncates in this dialect (`7 / 2` is 3).
317
+ /// Elsewhere `/` divides fractionally (`7 / 2` is 3.5).
318
+ pub(crate) const fn truncates_integer_division(self) -> bool {
319
+ matches!(
320
+ self,
321
+ DialectType::SQLite
322
+ | DialectType::PostgreSQL
323
+ | DialectType::Redshift
324
+ | DialectType::Materialize
325
+ | DialectType::RisingWave
326
+ | DialectType::TSQL
327
+ | DialectType::Fabric
328
+ | DialectType::Teradata
329
+ | DialectType::Drill
330
+ | DialectType::Dremio
331
+ | DialectType::DataFusion
332
+ | DialectType::Presto
333
+ | DialectType::Trino
334
+ | DialectType::Athena
335
+ | DialectType::Dune
336
+ )
337
+ }
315
338
  }
316
339
 
317
340
  impl Default for DialectType {
@@ -3202,6 +3225,15 @@ impl Dialect {
3202
3225
  &self,
3203
3226
  sql: &str,
3204
3227
  complexity_guard: ComplexityGuardOptions,
3228
+ ) -> Result<Vec<Expression>> {
3229
+ self.parse_tracking_placeholders(sql, complexity_guard, false)
3230
+ }
3231
+
3232
+ fn parse_tracking_placeholders(
3233
+ &self,
3234
+ sql: &str,
3235
+ complexity_guard: ComplexityGuardOptions,
3236
+ track: bool,
3205
3237
  ) -> Result<Vec<Expression>> {
3206
3238
  enforce_input(sql, &complexity_guard)?;
3207
3239
  let source: Arc<str> = Arc::from(sql);
@@ -3212,6 +3244,7 @@ impl Dialect {
3212
3244
  ..Default::default()
3213
3245
  };
3214
3246
  let mut parser = Parser::with_parser_tokens(tokens, token_guard_stats, config, source);
3247
+ parser.track_placeholder_positions = track;
3215
3248
  parser.parse()
3216
3249
  }
3217
3250
 
@@ -3744,7 +3777,10 @@ impl Dialect {
3744
3777
  {
3745
3778
  self.reject_pgvector_distance_operators_for_sqlite(sql)?;
3746
3779
  }
3747
- let expressions = self.parse_with_guard(sql, opts.complexity_guard)?;
3780
+ let track = self.dialect_type == DialectType::DuckDB
3781
+ && target == DialectType::SQLite
3782
+ && sql.contains('?');
3783
+ let expressions = self.parse_tracking_placeholders(sql, opts.complexity_guard, track)?;
3748
3784
  let generic_identity =
3749
3785
  self.dialect_type == DialectType::Generic && target == DialectType::Generic;
3750
3786
 
@@ -3761,6 +3797,7 @@ impl Dialect {
3761
3797
  expressions
3762
3798
  .into_iter()
3763
3799
  .map(|expr| {
3800
+ let expr = if track { normalization::sqlite_placeholder_indices(expr)? } else { expr };
3764
3801
  // Reject unsupported source semantics before normalization can
3765
3802
  // erase them. This AST-only pass shares conversion decisions with
3766
3803
  // the generator and never renders throwaway SQL.
@@ -4304,6 +4341,7 @@ impl Dialect {
4304
4341
  // Build COUNT_BIG(...) as an AggregateFunction
4305
4342
  let args = if c.star {
4306
4343
  vec![Expression::Star(crate::expressions::Star {
4344
+ ilike: None,
4307
4345
  table: None,
4308
4346
  except: None,
4309
4347
  replace: None,
@@ -9855,6 +9893,7 @@ impl Dialect {
9855
9893
 
9856
9894
  // Outer: SELECT ARRAY_AGG(*) FROM (inner_subquery)
9857
9895
  let star = Expression::Star(Star {
9896
+ ilike: None,
9858
9897
  table: None,
9859
9898
  except: None,
9860
9899
  replace: None,
@@ -2,7 +2,9 @@
2
2
 
3
3
  use super::scalar::{expression_numeric_kind, NumericKind};
4
4
  use super::*;
5
- use crate::expressions::{Annotated, DateTimeField, DateTruncFunc, ParameterStyle, RoundFunc};
5
+ use crate::expressions::{
6
+ Annotated, BinaryFunc, DateTimeField, DateTruncFunc, ParameterStyle, RoundFunc,
7
+ };
6
8
 
7
9
  fn bigquery_conversion_error(feature: impl Into<String>) -> crate::error::Error {
8
10
  crate::error::Error::unsupported(feature, "BigQuery")
@@ -413,6 +415,22 @@ pub(in crate::dialects) fn prepare_integer_division(
413
415
  source: DialectType,
414
416
  target: DialectType,
415
417
  ) -> Result<Expression> {
418
+ if source == DialectType::SQLite && target == DialectType::DuckDB {
419
+ return crate::traversal::transform_all(expr, &|expr| {
420
+ let Expression::Div(op) = expr else {
421
+ return Ok(expr);
422
+ };
423
+ Ok(Expression::IntDiv(Box::new(BinaryFunc {
424
+ this: op.left,
425
+ expression: Expression::Function(Box::new(Function::new(
426
+ "NULLIF",
427
+ vec![op.right, Expression::number(0)],
428
+ ))),
429
+ original_name: None,
430
+ inferred_type: None,
431
+ })))
432
+ });
433
+ }
416
434
  if source != DialectType::DuckDB || target == DialectType::DuckDB {
417
435
  return Ok(expr);
418
436
  }
@@ -93,7 +93,7 @@ pub(super) fn normalize(
93
93
  };
94
94
  let expr = statements::normalize_root(expr, &context);
95
95
 
96
- transform_recursive(expr, &|e| {
96
+ let expr = transform_recursive(expr, &|e| {
97
97
  // Source-bound nodes share the ordinary AST categories, but their lowering
98
98
  // must retain the semantics recorded by the parser through serialization.
99
99
  if e.source_dialect().is_some()
@@ -3031,7 +3031,7 @@ pub(super) fn normalize(
3031
3031
  }
3032
3032
  // Safe-division source -> non-safe target: NULLIF wrapping and/or CAST
3033
3033
  // Safe-division dialects: MySQL, DuckDB, SingleStore, TiDB, ClickHouse, Doris
3034
- Expression::Div(ref op)
3034
+ Expression::Div(_)
3035
3035
  if matches!(
3036
3036
  source,
3037
3037
  DialectType::MySQL
@@ -3059,13 +3059,7 @@ pub(super) fn normalize(
3059
3059
  | DialectType::RisingWave
3060
3060
  ) =>
3061
3061
  {
3062
- // Only wrap if RHS is not already NULLIF
3063
- if !matches!(&op.right, Expression::Function(f) if f.name.eq_ignore_ascii_case("NULLIF"))
3064
- {
3065
- Action::Operators(operators::Action::MySQLSafeDivide)
3066
- } else {
3067
- Action::None
3068
- }
3062
+ Action::Operators(operators::Action::MySQLSafeDivide)
3069
3063
  }
3070
3064
  // ALTER TABLE ... RENAME TO <schema>.<table> -> strip schema for most targets
3071
3065
  // For TSQL/Fabric, convert to sp_rename instead
@@ -4166,7 +4160,15 @@ pub(super) fn normalize(
4166
4160
  };
4167
4161
 
4168
4162
  Ok(outcome.into_expression())
4169
- })
4163
+ })?;
4164
+
4165
+ // Division that was fractional in the source must stay fractional in SQLite,
4166
+ // including division introduced above (e.g. by SAFE_DIVIDE).
4167
+ if target == DialectType::SQLite && source != DialectType::SQLite {
4168
+ operators::cast_division_to_real(expr, source)
4169
+ } else {
4170
+ Ok(expr)
4171
+ }
4170
4172
  }
4171
4173
 
4172
4174
  /// Convert source format models while quoted literal text is still available.
@@ -4216,3 +4218,41 @@ pub(super) fn prepare_source_formats(
4216
4218
  Ok(Expression::Function(f))
4217
4219
  })
4218
4220
  }
4221
+
4222
+ /// Assign SQLite bind slots in source-token order before STRFTIME can reorder
4223
+ /// its arguments. A single bind, or binds in only one argument, keep plain '?'.
4224
+ pub(super) fn sqlite_placeholder_indices(expr: Expression) -> Result<Expression> {
4225
+ use crate::traversal::ExpressionWalk;
4226
+ let placeholder = |e: &Expression| matches!(e, Expression::Placeholder(_));
4227
+ let mut positions = Vec::new();
4228
+ let mut reordered = false;
4229
+ for node in expr.dfs() {
4230
+ match node {
4231
+ Expression::Placeholder(p) => positions.extend(p.index),
4232
+ Expression::Function(f)
4233
+ if f.name.eq_ignore_ascii_case("STRFTIME") && f.args.len() == 2 =>
4234
+ {
4235
+ reordered |= f.args.iter().all(|arg| arg.contains(placeholder))
4236
+ && !scalar::duckdb_strftime_format_first(&f.args[0], &f.args[1]);
4237
+ }
4238
+ _ => {}
4239
+ }
4240
+ }
4241
+ if positions.is_empty() {
4242
+ return Ok(expr);
4243
+ }
4244
+ positions.sort_unstable();
4245
+ positions.dedup();
4246
+ crate::traversal::transform_all(expr, &|mut node| {
4247
+ if let Expression::Placeholder(p) = &mut node {
4248
+ p.index = p.index.and_then(|pos| {
4249
+ if reordered {
4250
+ positions.binary_search(&pos).ok().map(|i| i as u32 + 1)
4251
+ } else {
4252
+ None
4253
+ }
4254
+ });
4255
+ }
4256
+ Ok(node)
4257
+ })
4258
+ }
@@ -354,30 +354,24 @@ pub(super) fn rewrite(
354
354
  if let Expression::Div(op) = e {
355
355
  let left = op.left;
356
356
  let right = op.right;
357
- // For SQLite: CAST left as REAL but NO NULLIF wrapping
357
+ // SQLite: no NULLIF wrapping; the REAL cast is added by
358
+ // cast_division_to_real after normalization
358
359
  if matches!(target, DialectType::SQLite) {
359
- let new_left = Expression::Cast(Box::new(Cast {
360
- this: left,
361
- to: DataType::Float {
362
- precision: None,
363
- scale: None,
364
- real_spelling: true,
365
- },
366
- trailing_comments: Vec::new(),
367
- double_colon_syntax: false,
368
- format: None,
369
- default: None,
370
- inferred_type: None,
371
- }));
372
- return Ok(Expression::Div(Box::new(BinaryOp::new(new_left, right))));
360
+ return Ok(Expression::Div(Box::new(BinaryOp::new(left, right))));
373
361
  }
374
- // Wrap right in NULLIF(right, 0)
375
- let nullif_right = Expression::Function(Box::new(Function::new(
376
- "NULLIF".to_string(),
377
- vec![right, Expression::number(0)],
378
- )));
362
+ // Wrap right in NULLIF(right, 0) unless it already is one
363
+ let nullif_right = if matches!(&right, Expression::Function(f) if f.name.eq_ignore_ascii_case("NULLIF"))
364
+ {
365
+ right
366
+ } else {
367
+ Expression::Function(Box::new(Function::new(
368
+ "NULLIF".to_string(),
369
+ vec![right, Expression::number(0)],
370
+ )))
371
+ };
379
372
  // For some dialects, also CAST the left side
380
373
  let new_left = match target {
374
+ _ if is_float_cast(&left) => left,
381
375
  DialectType::PostgreSQL
382
376
  | DialectType::Redshift
383
377
  | DialectType::Teradata
@@ -1753,6 +1747,156 @@ fn snowflake_regex_inline_flags(flags: Option<&Expression>) -> std::result::Resu
1753
1747
  }
1754
1748
  }
1755
1749
 
1750
+ /// Whether `expr` is already a CAST to a floating-point type.
1751
+ fn is_float_cast(expr: &Expression) -> bool {
1752
+ match expr {
1753
+ Expression::Cast(cast) => match &cast.to {
1754
+ DataType::Double { .. } | DataType::Float { .. } => true,
1755
+ DataType::Custom { name } => {
1756
+ name.eq_ignore_ascii_case("REAL") || name.eq_ignore_ascii_case("DOUBLE")
1757
+ }
1758
+ _ => false,
1759
+ },
1760
+ _ => false,
1761
+ }
1762
+ }
1763
+
1764
+ /// Whether `expr` has an exact decimal type: a CAST to DECIMAL/NUMERIC, or an
1765
+ /// expression that keeps such an operand's type (parentheses, sign, arithmetic,
1766
+ /// NULLIF, COALESCE, GREATEST/LEAST, ABS, CASE, aggregates), or a decimal literal.
1767
+ fn is_decimal_typed(expr: &Expression, source: DialectType) -> bool {
1768
+ let is_decimal_typed = |expr: &Expression| is_decimal_typed(expr, source);
1769
+ let promotes_nullif = matches!(
1770
+ source,
1771
+ DialectType::PostgreSQL | DialectType::Materialize | DialectType::RisingWave
1772
+ );
1773
+ let is_tsql = matches!(source, DialectType::TSQL | DialectType::Fabric);
1774
+ match expr {
1775
+ Expression::Cast(cast) => match &cast.to {
1776
+ DataType::Decimal { .. } => true,
1777
+ DataType::Custom { name } => {
1778
+ name.eq_ignore_ascii_case("NUMERIC") || name.eq_ignore_ascii_case("DECIMAL")
1779
+ }
1780
+ _ => false,
1781
+ },
1782
+ Expression::Paren(p) => is_decimal_typed(&p.this),
1783
+ Expression::Neg(u) => is_decimal_typed(&u.this),
1784
+ Expression::Abs(f) => is_decimal_typed(&f.this),
1785
+ Expression::Add(op)
1786
+ | Expression::Sub(op)
1787
+ | Expression::Mul(op)
1788
+ | Expression::Div(op)
1789
+ | Expression::Mod(op) => is_decimal_typed(&op.left) || is_decimal_typed(&op.right),
1790
+ // A decimal literal such as 2.5 or 0.0 is numeric in PostgreSQL.
1791
+ Expression::Literal(lit) => {
1792
+ matches!(lit.as_ref(), Literal::Number(n) if n.contains(['.', 'e', 'E']))
1793
+ }
1794
+ // PostgreSQL promotes the first operand to the comparison type.
1795
+ Expression::NullIf(f) => {
1796
+ is_decimal_typed(&f.this) || (promotes_nullif && is_decimal_typed(&f.expression))
1797
+ }
1798
+ Expression::Nullif(f) => {
1799
+ is_decimal_typed(&f.this) || (promotes_nullif && is_decimal_typed(&f.expression))
1800
+ }
1801
+ // SQL Server returns an integer from AVG of an integer.
1802
+ Expression::Avg(f) => !is_tsql || is_decimal_typed(&f.this),
1803
+ Expression::Sum(f) | Expression::Min(f) | Expression::Max(f) => is_decimal_typed(&f.this),
1804
+ Expression::Coalesce(f) | Expression::Greatest(f) | Expression::Least(f) => {
1805
+ f.expressions.iter().any(is_decimal_typed)
1806
+ }
1807
+ Expression::Case(c) => {
1808
+ c.whens.iter().any(|(_, then)| is_decimal_typed(then))
1809
+ || c.else_.as_ref().is_some_and(is_decimal_typed)
1810
+ }
1811
+ Expression::Column(_) => matches!(
1812
+ expr.inferred_type(),
1813
+ Some(DataType::Decimal { .. } | DataType::Float { .. } | DataType::Double { .. })
1814
+ ),
1815
+ Expression::Function(f) if f.name.eq_ignore_ascii_case("AVG") => {
1816
+ !is_tsql || f.args.iter().any(is_decimal_typed)
1817
+ }
1818
+ Expression::Function(f) if f.name.eq_ignore_ascii_case("NULLIF") && !promotes_nullif => {
1819
+ f.args.first().is_some_and(is_decimal_typed)
1820
+ }
1821
+ Expression::Function(f)
1822
+ if [
1823
+ "NULLIF", "GREATEST", "LEAST", "COALESCE", "ABS", "ROUND", "SUM", "MIN", "MAX",
1824
+ ]
1825
+ .iter()
1826
+ .any(|name| f.name.eq_ignore_ascii_case(name)) =>
1827
+ {
1828
+ f.args.iter().any(is_decimal_typed)
1829
+ }
1830
+ _ => false,
1831
+ }
1832
+ }
1833
+
1834
+ /// Cast the left operand of each `/` to REAL so SQLite divides fractionally,
1835
+ /// unless an operand is already a float cast or the right one a float literal.
1836
+ /// For sources that truncate integer division, promote only fractional operands.
1837
+ /// SQLite can store a whole-number DECIMAL value as an integer.
1838
+ pub(super) fn cast_division_to_real(
1839
+ mut expr: Expression,
1840
+ source: DialectType,
1841
+ ) -> Result<Expression> {
1842
+ use crate::traversal::ExpressionWalk;
1843
+ if !expr.contains(|e| matches!(e, Expression::Div(_))) {
1844
+ return Ok(expr);
1845
+ }
1846
+ let decimal_only = source.truncates_integer_division();
1847
+ let resolve_columns = decimal_only && expr.contains(|e| matches!(e, Expression::Column(_)));
1848
+ if resolve_columns {
1849
+ crate::optimizer::annotate_types(&mut expr, None, Some(source));
1850
+ }
1851
+ // SQLite AVG returns REAL even for integers. Preserve SQL Server's integer
1852
+ // result before tracing projections into any enclosing division.
1853
+ if matches!(source, DialectType::TSQL | DialectType::Fabric)
1854
+ && expr.contains(|e| matches!(e, Expression::Avg(_)))
1855
+ {
1856
+ expr = crate::traversal::transform_all(expr, &|e| {
1857
+ if let Expression::Avg(avg) = &e {
1858
+ if expression_integer_type(&avg.this, source).is_some() {
1859
+ return Ok(cast_expr(
1860
+ e,
1861
+ DataType::Int {
1862
+ length: None,
1863
+ integer_spelling: true,
1864
+ },
1865
+ ));
1866
+ }
1867
+ }
1868
+ Ok(e)
1869
+ })?;
1870
+ if resolve_columns {
1871
+ crate::optimizer::annotate_types(&mut expr, None, Some(source));
1872
+ }
1873
+ }
1874
+ crate::dialects::transform_recursive(expr, &|e| match e {
1875
+ Expression::Div(mut op) => {
1876
+ let right_is_float = matches!(&op.right, Expression::Literal(lit) if matches!(lit.as_ref(), Literal::Number(n) if n.contains('.')));
1877
+ let fractional = !decimal_only
1878
+ || is_decimal_typed(&op.left, source)
1879
+ || is_decimal_typed(&op.right, source);
1880
+ if fractional
1881
+ && !is_float_cast(&op.left)
1882
+ && !is_float_cast(&op.right)
1883
+ && !right_is_float
1884
+ {
1885
+ op.left = cast_expr(
1886
+ op.left,
1887
+ DataType::Float {
1888
+ precision: None,
1889
+ scale: None,
1890
+ real_spelling: true,
1891
+ },
1892
+ );
1893
+ }
1894
+ Ok(Expression::Div(op))
1895
+ }
1896
+ _ => Ok(e),
1897
+ })
1898
+ }
1899
+
1756
1900
  pub(super) fn cast_expr(this: Expression, to: DataType) -> Expression {
1757
1901
  Expression::Cast(Box::new(Cast {
1758
1902
  this,