sqlglot 26.27.1__tar.gz → 26.28.1__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 (217) hide show
  1. {sqlglot-26.27.1 → sqlglot-26.28.1}/CHANGELOG.md +42 -0
  2. {sqlglot-26.27.1 → sqlglot-26.28.1}/PKG-INFO +1 -1
  3. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/_version.py +2 -2
  4. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/expressions.py +2 -2
  5. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/optimizer/scope.py +5 -2
  6. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/parser.py +63 -48
  7. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot.egg-info/PKG-INFO +1 -1
  8. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot.egg-info/SOURCES.txt +1 -0
  9. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_dialect.py +0 -219
  10. sqlglot-26.28.1/tests/dialects/test_pipe_syntax.py +380 -0
  11. {sqlglot-26.27.1 → sqlglot-26.28.1}/.gitignore +0 -0
  12. {sqlglot-26.27.1 → sqlglot-26.28.1}/.gitpod.yml +0 -0
  13. {sqlglot-26.27.1 → sqlglot-26.28.1}/.pre-commit-config.yaml +0 -0
  14. {sqlglot-26.27.1 → sqlglot-26.28.1}/CONTRIBUTING.md +0 -0
  15. {sqlglot-26.27.1 → sqlglot-26.28.1}/LICENSE +0 -0
  16. {sqlglot-26.27.1 → sqlglot-26.28.1}/MANIFEST.in +0 -0
  17. {sqlglot-26.27.1 → sqlglot-26.28.1}/Makefile +0 -0
  18. {sqlglot-26.27.1 → sqlglot-26.28.1}/README.md +0 -0
  19. {sqlglot-26.27.1 → sqlglot-26.28.1}/pyproject.toml +0 -0
  20. {sqlglot-26.27.1 → sqlglot-26.28.1}/setup.cfg +0 -0
  21. {sqlglot-26.27.1 → sqlglot-26.28.1}/setup.py +0 -0
  22. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/__init__.py +0 -0
  23. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/__main__.py +0 -0
  24. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/_typing.py +0 -0
  25. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/__init__.py +0 -0
  26. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/athena.py +0 -0
  27. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/bigquery.py +0 -0
  28. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/clickhouse.py +0 -0
  29. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/databricks.py +0 -0
  30. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/dialect.py +0 -0
  31. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/doris.py +0 -0
  32. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/drill.py +0 -0
  33. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/druid.py +0 -0
  34. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/duckdb.py +0 -0
  35. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/dune.py +0 -0
  36. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/hive.py +0 -0
  37. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/materialize.py +0 -0
  38. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/mysql.py +0 -0
  39. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/oracle.py +0 -0
  40. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/postgres.py +0 -0
  41. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/presto.py +0 -0
  42. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/prql.py +0 -0
  43. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/redshift.py +0 -0
  44. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/risingwave.py +0 -0
  45. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/snowflake.py +0 -0
  46. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/spark.py +0 -0
  47. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/spark2.py +0 -0
  48. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/sqlite.py +0 -0
  49. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/starrocks.py +0 -0
  50. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/tableau.py +0 -0
  51. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/teradata.py +0 -0
  52. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/trino.py +0 -0
  53. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/dialects/tsql.py +0 -0
  54. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/diff.py +0 -0
  55. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/errors.py +0 -0
  56. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/executor/__init__.py +0 -0
  57. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/executor/context.py +0 -0
  58. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/executor/env.py +0 -0
  59. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/executor/python.py +0 -0
  60. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/executor/table.py +0 -0
  61. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/generator.py +0 -0
  62. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/helper.py +0 -0
  63. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/jsonpath.py +0 -0
  64. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/lineage.py +0 -0
  65. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/optimizer/__init__.py +0 -0
  66. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/optimizer/annotate_types.py +0 -0
  67. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/optimizer/canonicalize.py +0 -0
  68. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/optimizer/eliminate_ctes.py +0 -0
  69. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/optimizer/eliminate_joins.py +0 -0
  70. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/optimizer/eliminate_subqueries.py +0 -0
  71. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/optimizer/isolate_table_selects.py +0 -0
  72. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/optimizer/merge_subqueries.py +0 -0
  73. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/optimizer/normalize.py +0 -0
  74. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/optimizer/normalize_identifiers.py +0 -0
  75. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/optimizer/optimize_joins.py +0 -0
  76. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/optimizer/optimizer.py +0 -0
  77. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/optimizer/pushdown_predicates.py +0 -0
  78. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/optimizer/pushdown_projections.py +0 -0
  79. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/optimizer/qualify.py +0 -0
  80. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/optimizer/qualify_columns.py +0 -0
  81. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/optimizer/qualify_tables.py +0 -0
  82. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/optimizer/simplify.py +0 -0
  83. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/optimizer/unnest_subqueries.py +0 -0
  84. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/planner.py +0 -0
  85. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/py.typed +0 -0
  86. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/schema.py +0 -0
  87. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/serde.py +0 -0
  88. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/time.py +0 -0
  89. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/tokens.py +0 -0
  90. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/transforms.py +0 -0
  91. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot/trie.py +0 -0
  92. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot.egg-info/dependency_links.txt +0 -0
  93. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot.egg-info/requires.txt +0 -0
  94. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot.egg-info/top_level.txt +0 -0
  95. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglot.png +0 -0
  96. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglotrs/Cargo.lock +0 -0
  97. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglotrs/Cargo.toml +0 -0
  98. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglotrs/benches/dialect_settings.json +0 -0
  99. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglotrs/benches/long.rs +0 -0
  100. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglotrs/benches/token_type_settings.json +0 -0
  101. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglotrs/benches/tokenizer_dialect_settings.json +0 -0
  102. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglotrs/benches/tokenizer_settings.json +0 -0
  103. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglotrs/pyproject.toml +0 -0
  104. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglotrs/src/lib.rs +0 -0
  105. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglotrs/src/settings.rs +0 -0
  106. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglotrs/src/token.rs +0 -0
  107. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglotrs/src/tokenizer.rs +0 -0
  108. {sqlglot-26.27.1 → sqlglot-26.28.1}/sqlglotrs/src/trie.rs +0 -0
  109. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/__init__.py +0 -0
  110. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/__init__.py +0 -0
  111. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_athena.py +0 -0
  112. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_bigquery.py +0 -0
  113. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_clickhouse.py +0 -0
  114. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_databricks.py +0 -0
  115. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_doris.py +0 -0
  116. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_drill.py +0 -0
  117. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_druid.py +0 -0
  118. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_duckdb.py +0 -0
  119. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_dune.py +0 -0
  120. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_hive.py +0 -0
  121. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_materialize.py +0 -0
  122. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_mysql.py +0 -0
  123. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_oracle.py +0 -0
  124. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_postgres.py +0 -0
  125. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_presto.py +0 -0
  126. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_prql.py +0 -0
  127. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_redshift.py +0 -0
  128. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_risingwave.py +0 -0
  129. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_snowflake.py +0 -0
  130. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_spark.py +0 -0
  131. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_sqlite.py +0 -0
  132. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_starrocks.py +0 -0
  133. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_tableau.py +0 -0
  134. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_teradata.py +0 -0
  135. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_trino.py +0 -0
  136. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/dialects/test_tsql.py +0 -0
  137. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/identity.sql +0 -0
  138. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/jsonpath/LICENSE +0 -0
  139. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/jsonpath/cts.json +0 -0
  140. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/annotate_functions.sql +0 -0
  141. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/annotate_types.sql +0 -0
  142. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/canonicalize.sql +0 -0
  143. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/eliminate_ctes.sql +0 -0
  144. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/eliminate_joins.sql +0 -0
  145. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/eliminate_subqueries.sql +0 -0
  146. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/isolate_table_selects.sql +0 -0
  147. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/merge_subqueries.sql +0 -0
  148. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/normalize.sql +0 -0
  149. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/normalize_identifiers.sql +0 -0
  150. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/optimize_joins.sql +0 -0
  151. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/optimizer.sql +0 -0
  152. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/pushdown_cte_alias_columns.sql +0 -0
  153. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/pushdown_predicates.sql +0 -0
  154. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/pushdown_projections.sql +0 -0
  155. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/qualify_columns.sql +0 -0
  156. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/qualify_columns__invalid.sql +0 -0
  157. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/qualify_columns__with_invisible.sql +0 -0
  158. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/qualify_columns_ddl.sql +0 -0
  159. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/qualify_tables.sql +0 -0
  160. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/quote_identifiers.sql +0 -0
  161. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/simplify.sql +0 -0
  162. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/call_center.csv.gz +0 -0
  163. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/catalog_page.csv.gz +0 -0
  164. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/catalog_returns.csv.gz +0 -0
  165. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/catalog_sales.csv.gz +0 -0
  166. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/customer.csv.gz +0 -0
  167. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/customer_address.csv.gz +0 -0
  168. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/customer_demographics.csv.gz +0 -0
  169. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/date_dim.csv.gz +0 -0
  170. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/household_demographics.csv.gz +0 -0
  171. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/income_band.csv.gz +0 -0
  172. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/inventory.csv.gz +0 -0
  173. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/item.csv.gz +0 -0
  174. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/promotion.csv.gz +0 -0
  175. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/reason.csv.gz +0 -0
  176. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/ship_mode.csv.gz +0 -0
  177. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/store.csv.gz +0 -0
  178. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/store_returns.csv.gz +0 -0
  179. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/store_sales.csv.gz +0 -0
  180. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/time_dim.csv.gz +0 -0
  181. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/tpc-ds.sql +0 -0
  182. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/warehouse.csv.gz +0 -0
  183. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/web_page.csv.gz +0 -0
  184. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/web_returns.csv.gz +0 -0
  185. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/web_sales.csv.gz +0 -0
  186. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-ds/web_site.csv.gz +0 -0
  187. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-h/customer.csv.gz +0 -0
  188. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-h/lineitem.csv.gz +0 -0
  189. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-h/nation.csv.gz +0 -0
  190. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-h/orders.csv.gz +0 -0
  191. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-h/part.csv.gz +0 -0
  192. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-h/partsupp.csv.gz +0 -0
  193. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-h/region.csv.gz +0 -0
  194. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-h/supplier.csv.gz +0 -0
  195. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/tpc-h/tpc-h.sql +0 -0
  196. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/optimizer/unnest_subqueries.sql +0 -0
  197. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/partial.sql +0 -0
  198. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/fixtures/pretty.sql +0 -0
  199. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/gen_fixtures.py +0 -0
  200. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/helpers.py +0 -0
  201. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/test_build.py +0 -0
  202. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/test_diff.py +0 -0
  203. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/test_docs.py +0 -0
  204. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/test_executor.py +0 -0
  205. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/test_expressions.py +0 -0
  206. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/test_generator.py +0 -0
  207. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/test_helper.py +0 -0
  208. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/test_jsonpath.py +0 -0
  209. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/test_lineage.py +0 -0
  210. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/test_optimizer.py +0 -0
  211. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/test_parser.py +0 -0
  212. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/test_schema.py +0 -0
  213. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/test_serde.py +0 -0
  214. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/test_time.py +0 -0
  215. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/test_tokens.py +0 -0
  216. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/test_transforms.py +0 -0
  217. {sqlglot-26.27.1 → sqlglot-26.28.1}/tests/test_transpile.py +0 -0
@@ -1,6 +1,47 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## [v26.27.0] - 2025-06-12
5
+ ### :boom: BREAKING CHANGES
6
+ - due to [`ac6555b`](https://github.com/tobymao/sqlglot/commit/ac6555b4d6c162ef7b14b63307d01fd560138ea0) - preserve DIV binary operator, fixes [#5198](https://github.com/tobymao/sqlglot/pull/5198) *(PR [#5199](https://github.com/tobymao/sqlglot/pull/5199) by [@georgesittas](https://github.com/georgesittas))*:
7
+
8
+ preserve DIV binary operator, fixes #5198 (#5199)
9
+
10
+ - due to [`dfdd84b`](https://github.com/tobymao/sqlglot/commit/dfdd84bbc50da70f40a17b39935f8171d961f7d2) - CTEs instead of subqueries for pipe syntax *(PR [#5205](https://github.com/tobymao/sqlglot/pull/5205) by [@geooo109](https://github.com/geooo109))*:
11
+
12
+ CTEs instead of subqueries for pipe syntax (#5205)
13
+
14
+ - due to [`5f95299`](https://github.com/tobymao/sqlglot/commit/5f9529940d83e89704f7d25eda63cd73fdb503ae) - support multi-part (>3) dotted functions *(PR [#5211](https://github.com/tobymao/sqlglot/pull/5211) by [@georgesittas](https://github.com/georgesittas))*:
15
+
16
+ support multi-part (>3) dotted functions (#5211)
17
+
18
+ - due to [`02afa2a`](https://github.com/tobymao/sqlglot/commit/02afa2a1941fc67086d50dffac2857262f1c3c4f) - Preserve quoting for UDT *(PR [#5216](https://github.com/tobymao/sqlglot/pull/5216) by [@VaggelisD](https://github.com/VaggelisD))*:
19
+
20
+ Preserve quoting for UDT (#5216)
21
+
22
+
23
+ ### :sparkles: New Features
24
+ - [`c20f85e`](https://github.com/tobymao/sqlglot/commit/c20f85e3e171e502fc51f74894d3313f0ad61535) - **spark**: support ALTER ADD PARTITION *(PR [#5208](https://github.com/tobymao/sqlglot/pull/5208) by [@georgesittas](https://github.com/georgesittas))*
25
+ - :arrow_lower_right: *addresses issue [#5204](https://github.com/tobymao/sqlglot/issues/5204) opened by [@cosinequanon](https://github.com/cosinequanon)*
26
+
27
+ ### :bug: Bug Fixes
28
+ - [`99bbae3`](https://github.com/tobymao/sqlglot/commit/99bbae370329c5f5cd132b711c714359cf96ba58) - **sqlite**: allow ALTER RENAME without COLUMN keyword fixes [#5195](https://github.com/tobymao/sqlglot/pull/5195) *(commit by [@georgesittas](https://github.com/georgesittas))*
29
+ - [`ac6555b`](https://github.com/tobymao/sqlglot/commit/ac6555b4d6c162ef7b14b63307d01fd560138ea0) - **hive**: preserve DIV binary operator, fixes [#5198](https://github.com/tobymao/sqlglot/pull/5198) *(PR [#5199](https://github.com/tobymao/sqlglot/pull/5199) by [@georgesittas](https://github.com/georgesittas))*
30
+ - [`d0eeb26`](https://github.com/tobymao/sqlglot/commit/d0eeb2639e771e8f8b6feabd41c65f16ed5a9829) - eliminate_join_marks has multiple issues fixes [#5188](https://github.com/tobymao/sqlglot/pull/5188) *(PR [#5189](https://github.com/tobymao/sqlglot/pull/5189) by [@snovik75](https://github.com/snovik75))*
31
+ - :arrow_lower_right: *fixes issue [#5188](https://github.com/tobymao/sqlglot/issues/5188) opened by [@snovik75](https://github.com/snovik75)*
32
+ - [`dfdd84b`](https://github.com/tobymao/sqlglot/commit/dfdd84bbc50da70f40a17b39935f8171d961f7d2) - **parser**: CTEs instead of subqueries for pipe syntax *(PR [#5205](https://github.com/tobymao/sqlglot/pull/5205) by [@geooo109](https://github.com/geooo109))*
33
+ - [`77e9d9a`](https://github.com/tobymao/sqlglot/commit/77e9d9a0269e2013379967cf2f46fbd79c036277) - **mysql**: properly parse STORED/VIRTUAL computed columns *(PR [#5210](https://github.com/tobymao/sqlglot/pull/5210) by [@georgesittas](https://github.com/georgesittas))*
34
+ - :arrow_lower_right: *fixes issue [#5203](https://github.com/tobymao/sqlglot/issues/5203) opened by [@mdebski](https://github.com/mdebski)*
35
+ - [`5f95299`](https://github.com/tobymao/sqlglot/commit/5f9529940d83e89704f7d25eda63cd73fdb503ae) - **parser**: support multi-part (>3) dotted functions *(PR [#5211](https://github.com/tobymao/sqlglot/pull/5211) by [@georgesittas](https://github.com/georgesittas))*
36
+ - :arrow_lower_right: *fixes issue [#5200](https://github.com/tobymao/sqlglot/issues/5200) opened by [@mateuszpoleski](https://github.com/mateuszpoleski)*
37
+ - [`02afa2a`](https://github.com/tobymao/sqlglot/commit/02afa2a1941fc67086d50dffac2857262f1c3c4f) - **postgres**: Preserve quoting for UDT *(PR [#5216](https://github.com/tobymao/sqlglot/pull/5216) by [@VaggelisD](https://github.com/VaggelisD))*
38
+ - :arrow_lower_right: *fixes issue [#5212](https://github.com/tobymao/sqlglot/issues/5212) opened by [@NickCrews](https://github.com/NickCrews)*
39
+ - [`f37c0b1`](https://github.com/tobymao/sqlglot/commit/f37c0b1197321dd610648ce652a171ab063deeeb) - **snowflake**: ensure a standalone GET() expression can be parsed *(PR [#5219](https://github.com/tobymao/sqlglot/pull/5219) by [@georgesittas](https://github.com/georgesittas))*
40
+
41
+ ### :wrench: Chores
42
+ - [`ad8a4e7`](https://github.com/tobymao/sqlglot/commit/ad8a4e73e1a9e4234f0b711163fb49630acf736c) - refactor join mark elimination to use is_correlated_subquery *(commit by [@georgesittas](https://github.com/georgesittas))*
43
+
44
+
4
45
  ## [v26.26.0] - 2025-06-09
5
46
  ### :boom: BREAKING CHANGES
6
47
  - due to [`434c45b`](https://github.com/tobymao/sqlglot/commit/434c45b547c3a5ea155dc8d7da2baab326eb6d4f) - improve support for ENDSWITH closes [#5170](https://github.com/tobymao/sqlglot/pull/5170) *(commit by [@georgesittas](https://github.com/georgesittas))*:
@@ -4840,3 +4881,4 @@ Changelog
4840
4881
  [v26.25.2]: https://github.com/tobymao/sqlglot/compare/v26.25.1...v26.25.2
4841
4882
  [v26.25.3]: https://github.com/tobymao/sqlglot/compare/v26.25.2...v26.25.3
4842
4883
  [v26.26.0]: https://github.com/tobymao/sqlglot/compare/v26.25.3...v26.26.0
4884
+ [v26.27.0]: https://github.com/tobymao/sqlglot/compare/v26.26.0...v26.27.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlglot
3
- Version: 26.27.1
3
+ Version: 26.28.1
4
4
  Summary: An easily customizable SQL parser and transpiler
5
5
  Author-email: Toby Mao <toby.mao@gmail.com>
6
6
  License: MIT License
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '26.27.1'
21
- __version_tuple__ = version_tuple = (26, 27, 1)
20
+ __version__ = version = '26.28.1'
21
+ __version_tuple__ = version_tuple = (26, 28, 1)
@@ -51,8 +51,8 @@ class _Expression(type):
51
51
  def __new__(cls, clsname, bases, attrs):
52
52
  klass = super().__new__(cls, clsname, bases, attrs)
53
53
 
54
- # When an Expression class is created, its key is automatically set to be
55
- # the lowercase version of the class' name.
54
+ # When an Expression class is created, its key is automatically set
55
+ # to be the lowercase version of the class' name.
56
56
  klass.key = clsname.lower()
57
57
 
58
58
  # This is so that docstrings are not inherited in pdoc
@@ -758,6 +758,8 @@ def _traverse_tables(scope):
758
758
  expressions.extend(join.this for join in expression.args.get("joins") or [])
759
759
  continue
760
760
 
761
+ child_scope = None
762
+
761
763
  for child_scope in _traverse_scope(
762
764
  scope.branch(
763
765
  expression,
@@ -775,8 +777,9 @@ def _traverse_tables(scope):
775
777
  sources[expression.alias] = child_scope
776
778
 
777
779
  # append the final child_scope yielded
778
- scopes.append(child_scope)
779
- scope.table_scopes.append(child_scope)
780
+ if child_scope:
781
+ scopes.append(child_scope)
782
+ scope.table_scopes.append(child_scope)
780
783
 
781
784
  scope.sources.update(sources)
782
785
 
@@ -932,13 +932,14 @@ class Parser(metaclass=_Parser):
932
932
 
933
933
  PIPE_SYNTAX_TRANSFORM_PARSERS = {
934
934
  "SELECT": lambda self, query: self._parse_pipe_syntax_select(query),
935
- "WHERE": lambda self, query: self._parse_pipe_syntax_where(query),
935
+ "WHERE": lambda self, query: query.where(self._parse_where(), copy=False),
936
936
  "ORDER BY": lambda self, query: query.order_by(
937
937
  self._parse_order(), append=False, copy=False
938
938
  ),
939
939
  "LIMIT": lambda self, query: self._parse_pipe_syntax_limit(query),
940
- "OFFSET": lambda self, query: query.offset(self._parse_offset(), copy=False),
941
940
  "AGGREGATE": lambda self, query: self._parse_pipe_syntax_aggregate(query),
941
+ "PIVOT": lambda self, query: self._parse_pipe_syntax_pivot(query),
942
+ "UNPIVOT": lambda self, query: self._parse_pipe_syntax_pivot(query),
942
943
  }
943
944
 
944
945
  PROPERTY_PARSERS: t.Dict[str, t.Callable] = {
@@ -8327,40 +8328,33 @@ class Parser(metaclass=_Parser):
8327
8328
  expression.update_positions(token)
8328
8329
  return expression
8329
8330
 
8330
- def _build_pipe_cte(self, query: exp.Query, expressions: t.List[exp.Expression]) -> exp.Query:
8331
- if query.selects:
8332
- self._pipe_cte_counter += 1
8333
- new_cte = f"__tmp{self._pipe_cte_counter}"
8334
-
8335
- # For `exp.Select`, generated CTEs are attached to its `with`
8336
- # For `exp.SetOperation`, generated CTEs are attached to the `with` of its LHS, accessed via `this`
8337
- with_ = (
8338
- query.args.get("with")
8339
- if isinstance(query, exp.Select)
8340
- else query.this.args.get("with")
8341
- )
8342
- ctes = with_.pop() if with_ else None
8331
+ def _build_pipe_cte(self, query: exp.Query, expressions: t.List[exp.Expression]) -> exp.Select:
8332
+ if not query.selects:
8333
+ query = query.select("*", copy=False)
8334
+
8335
+ self._pipe_cte_counter += 1
8336
+ new_cte = f"__tmp{self._pipe_cte_counter}"
8343
8337
 
8344
- new_select = exp.select(*expressions, copy=False).from_(new_cte, copy=False)
8345
- if ctes:
8346
- new_select.set("with", ctes)
8338
+ with_ = query.args.get("with")
8339
+ ctes = with_.pop() if with_ else None
8347
8340
 
8348
- return new_select.with_(new_cte, as_=query, copy=False)
8341
+ new_select = exp.select(*expressions, copy=False).from_(new_cte, copy=False)
8342
+ if ctes:
8343
+ new_select.set("with", ctes)
8349
8344
 
8350
- return query.select(*expressions, copy=False)
8345
+ return new_select.with_(new_cte, as_=query, copy=False)
8351
8346
 
8352
- def _parse_pipe_syntax_select(self, query: exp.Query) -> exp.Query:
8347
+ def _parse_pipe_syntax_select(self, query: exp.Select) -> exp.Select:
8353
8348
  select = self._parse_select()
8354
- if isinstance(select, exp.Select):
8355
- return self._build_pipe_cte(query, select.expressions)
8349
+ if not select:
8350
+ return query
8356
8351
 
8357
- return query
8352
+ if not query.selects:
8353
+ return self._build_pipe_cte(query.select(*select.expressions), [exp.Star()])
8358
8354
 
8359
- def _parse_pipe_syntax_where(self, query: exp.Query) -> exp.Query:
8360
- where = self._parse_where()
8361
- return query.where(where, copy=False)
8355
+ return self._build_pipe_cte(query, select.expressions)
8362
8356
 
8363
- def _parse_pipe_syntax_limit(self, query: exp.Query) -> exp.Query:
8357
+ def _parse_pipe_syntax_limit(self, query: exp.Select) -> exp.Select:
8364
8358
  limit = self._parse_limit()
8365
8359
  offset = self._parse_offset()
8366
8360
  if limit:
@@ -8371,6 +8365,7 @@ class Parser(metaclass=_Parser):
8371
8365
  curr_offset = query.args.get("offset")
8372
8366
  curr_offset = curr_offset.expression.to_py() if curr_offset else 0
8373
8367
  query.offset(exp.Literal.number(curr_offset + offset.expression.to_py()), copy=False)
8368
+
8374
8369
  return query
8375
8370
 
8376
8371
  def _parse_pipe_syntax_aggregate_fields(self) -> t.Optional[exp.Expression]:
@@ -8386,8 +8381,8 @@ class Parser(metaclass=_Parser):
8386
8381
  return this
8387
8382
 
8388
8383
  def _parse_pipe_syntax_aggregate_group_order_by(
8389
- self, query: exp.Query, group_by_exists: bool = True
8390
- ) -> exp.Query:
8384
+ self, query: exp.Select, group_by_exists: bool = True
8385
+ ) -> exp.Select:
8391
8386
  expr = self._parse_csv(self._parse_pipe_syntax_aggregate_fields)
8392
8387
  aggregates_or_groups, orders = [], []
8393
8388
  for element in expr:
@@ -8400,45 +8395,46 @@ class Parser(metaclass=_Parser):
8400
8395
  this = element
8401
8396
  aggregates_or_groups.append(this)
8402
8397
 
8403
- if group_by_exists and isinstance(query, exp.Select):
8398
+ if group_by_exists:
8404
8399
  query = query.select(*aggregates_or_groups, copy=False).group_by(
8405
8400
  *[projection.args.get("alias", projection) for projection in aggregates_or_groups],
8406
8401
  copy=False,
8407
8402
  )
8408
8403
  else:
8409
- query = query.select(*aggregates_or_groups, append=False, copy=False)
8404
+ query = query.select(*aggregates_or_groups, copy=False)
8410
8405
 
8411
8406
  if orders:
8412
8407
  return query.order_by(*orders, append=False, copy=False)
8413
8408
 
8414
8409
  return query
8415
8410
 
8416
- def _parse_pipe_syntax_aggregate(self, query: exp.Query) -> exp.Query:
8411
+ def _parse_pipe_syntax_aggregate(self, query: exp.Select) -> exp.Select:
8417
8412
  self._match_text_seq("AGGREGATE")
8418
8413
  query = self._parse_pipe_syntax_aggregate_group_order_by(query, group_by_exists=False)
8419
8414
 
8420
8415
  if self._match(TokenType.GROUP_BY) or (
8421
8416
  self._match_text_seq("GROUP", "AND") and self._match(TokenType.ORDER_BY)
8422
8417
  ):
8423
- return self._parse_pipe_syntax_aggregate_group_order_by(query)
8418
+ query = self._parse_pipe_syntax_aggregate_group_order_by(query)
8424
8419
 
8425
- return query
8420
+ return self._build_pipe_cte(query, [exp.Star()])
8426
8421
 
8427
8422
  def _parse_pipe_syntax_set_operator(
8428
8423
  self, query: t.Optional[exp.Query]
8429
- ) -> t.Optional[exp.Query]:
8424
+ ) -> t.Optional[exp.Select]:
8430
8425
  first_setop = self.parse_set_operation(this=query)
8431
8426
 
8432
8427
  if not first_setop or not query:
8433
8428
  return None
8434
8429
 
8435
- if not query.selects:
8436
- query.select("*", copy=False)
8437
-
8438
- this = first_setop.this.pop()
8430
+ first_setop.this.pop()
8439
8431
  distinct = first_setop.args.pop("distinct")
8440
8432
  setops = [first_setop.expression.pop(), *self._parse_expressions()]
8441
8433
 
8434
+ query = self._build_pipe_cte(query, [exp.Star()])
8435
+ with_ = query.args.get("with")
8436
+ ctes = with_.pop() if with_ else None
8437
+
8442
8438
  if isinstance(first_setop, exp.Union):
8443
8439
  query = query.union(*setops, distinct=distinct, copy=False, **first_setop.args)
8444
8440
  elif isinstance(first_setop, exp.Except):
@@ -8446,22 +8442,41 @@ class Parser(metaclass=_Parser):
8446
8442
  else:
8447
8443
  query = query.intersect(*setops, distinct=distinct, copy=False, **first_setop.args)
8448
8444
 
8449
- return self._build_pipe_cte(
8450
- query, [projection.args.get("alias", projection) for projection in this.expressions]
8451
- )
8445
+ query.set("with", ctes)
8446
+
8447
+ return self._build_pipe_cte(query, [exp.Star()])
8448
+
8449
+ def _parse_pipe_syntax_join(self, query: exp.Select) -> t.Optional[exp.Select]:
8450
+ join = self._parse_join()
8451
+ if not join:
8452
+ return None
8453
+
8454
+ return query.join(join, copy=False)
8452
8455
 
8453
- def _parse_pipe_syntax_query(self, query: exp.Query) -> t.Optional[exp.Query]:
8456
+ def _parse_pipe_syntax_pivot(self, query: exp.Select) -> exp.Select:
8457
+ pivots = self._parse_pivots()
8458
+ if not pivots:
8459
+ return query
8460
+
8461
+ from_ = query.args.get("from")
8462
+ if from_:
8463
+ from_.this.set("pivots", pivots)
8464
+
8465
+ return self._build_pipe_cte(query, [exp.Star()])
8466
+
8467
+ def _parse_pipe_syntax_query(self, query: exp.Select) -> t.Optional[exp.Select]:
8454
8468
  while self._match(TokenType.PIPE_GT):
8455
8469
  start = self._curr
8456
8470
  parser = self.PIPE_SYNTAX_TRANSFORM_PARSERS.get(self._curr.text.upper())
8457
8471
  if not parser:
8458
- set_op_query = self._parse_pipe_syntax_set_operator(query)
8459
- if not set_op_query:
8472
+ parsed_query = self._parse_pipe_syntax_set_operator(
8473
+ query
8474
+ ) or self._parse_pipe_syntax_join(query)
8475
+ if not parsed_query:
8460
8476
  self._retreat(start)
8461
8477
  self.raise_error(f"Unsupported pipe syntax operator: '{start.text.upper()}'.")
8462
8478
  break
8463
-
8464
- query = set_op_query
8479
+ query = parsed_query
8465
8480
  else:
8466
8481
  query = parser(self, query)
8467
8482
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlglot
3
- Version: 26.27.1
3
+ Version: 26.28.1
4
4
  Summary: An easily customizable SQL parser and transpiler
5
5
  Author-email: Toby Mao <toby.mao@gmail.com>
6
6
  License: MIT License
@@ -138,6 +138,7 @@ tests/dialects/test_hive.py
138
138
  tests/dialects/test_materialize.py
139
139
  tests/dialects/test_mysql.py
140
140
  tests/dialects/test_oracle.py
141
+ tests/dialects/test_pipe_syntax.py
141
142
  tests/dialects/test_postgres.py
142
143
  tests/dialects/test_presto.py
143
144
  tests/dialects/test_prql.py
@@ -3504,222 +3504,3 @@ FROM subquery2""",
3504
3504
  parse_one("SELECT 0xCC", read=read_dialect).sql(other_integer_dialects),
3505
3505
  "SELECT 0xCC",
3506
3506
  )
3507
-
3508
- def test_pipe_syntax(self):
3509
- self.validate_identity("FROM x", "SELECT * FROM x")
3510
- self.validate_identity("FROM x |> SELECT x1, x2", "SELECT x1, x2 FROM x")
3511
- self.validate_identity(
3512
- "FROM x |> SELECT x1 as c1, x2 as c2",
3513
- "SELECT x1 AS c1, x2 AS c2 FROM x",
3514
- )
3515
- self.validate_identity(
3516
- "FROM x |> SELECT x1 + 1 as x1_a, x2 - 1 as x2_a |> WHERE x1_a > 1",
3517
- "SELECT x1 + 1 AS x1_a, x2 - 1 AS x2_a FROM x WHERE x1_a > 1",
3518
- )
3519
- self.validate_identity(
3520
- "FROM x |> SELECT x1 + 1 as x1_a, x2 - 1 as x2_a |> WHERE x1_a > 1 |> SELECT x2_a",
3521
- "WITH __tmp1 AS (SELECT x1 + 1 AS x1_a, x2 - 1 AS x2_a FROM x WHERE x1_a > 1) SELECT x2_a FROM __tmp1",
3522
- )
3523
- self.validate_identity(
3524
- "FROM x |> WHERE x1 > 0 OR x2 > 0 |> WHERE x3 > 1 AND x4 > 1 |> SELECT x1, x4",
3525
- "SELECT x1, x4 FROM x WHERE (x1 > 0 OR x2 > 0) AND (x3 > 1 AND x4 > 1)",
3526
- )
3527
- self.validate_identity(
3528
- "FROM x |> WHERE x1 > 1 |> WHERE x2 > 2 |> SELECT x1 as gt1, x2 as gt2",
3529
- "SELECT x1 AS gt1, x2 AS gt2 FROM x WHERE x1 > 1 AND x2 > 2",
3530
- )
3531
- self.validate_identity(
3532
- "FROM x |> WHERE x1 > 1 AND x2 > 2 |> SELECT x1 as gt1, x2 as gt2 |> SELECT gt1 * 2 + gt2 * 2 AS gt2_2",
3533
- "WITH __tmp1 AS (SELECT x1 AS gt1, x2 AS gt2 FROM x WHERE x1 > 1 AND x2 > 2) SELECT gt1 * 2 + gt2 * 2 AS gt2_2 FROM __tmp1",
3534
- )
3535
- self.validate_identity("FROM x |> ORDER BY x1", "SELECT * FROM x ORDER BY x1")
3536
- self.validate_identity(
3537
- "FROM x |> ORDER BY x1 |> ORDER BY x2", "SELECT * FROM x ORDER BY x2"
3538
- )
3539
- self.validate_identity(
3540
- "FROM x |> ORDER BY x1 |> WHERE x1 > 0 OR x1 != 1 |> ORDER BY x2 |> WHERE x2 > 0 AND x2 != 1 |> SELECT x1, x2",
3541
- "SELECT x1, x2 FROM x WHERE (x1 > 0 OR x1 <> 1) AND (x2 > 0 AND x2 <> 1) ORDER BY x2",
3542
- )
3543
- self.validate_identity(
3544
- "FROM x |> ORDER BY x1 |> WHERE x1 > 0 |> SELECT x1",
3545
- "SELECT x1 FROM x WHERE x1 > 0 ORDER BY x1",
3546
- )
3547
- self.validate_identity(
3548
- "FROM x |> WHERE x1 > 0 |> SELECT x1 |> ORDER BY x1",
3549
- "SELECT x1 FROM x WHERE x1 > 0 ORDER BY x1",
3550
- )
3551
- self.validate_identity(
3552
- "FROM x |> SELECT x1, x2, x3 |> ORDER BY x1 DESC NULLS FIRST, x2 ASC NULLS LAST, x3",
3553
- "SELECT x1, x2, x3 FROM x ORDER BY x1 DESC NULLS FIRST, x2 ASC NULLS LAST, x3",
3554
- )
3555
- for option in ("LIMIT 1", "OFFSET 2", "LIMIT 1 OFFSET 2"):
3556
- with self.subTest(f"Testing pipe syntax LIMIT and OFFSET option: {option}"):
3557
- self.validate_identity(f"FROM x |> {option}", f"SELECT * FROM x {option}")
3558
- self.validate_identity(f"FROM x |> {option}", f"SELECT * FROM x {option}")
3559
- self.validate_identity(
3560
- f"FROM x |> {option} |> SELECT x1, x2 |> WHERE x1 > 0 |> WHERE x2 > 0 |> ORDER BY x1, x2 ",
3561
- f"SELECT x1, x2 FROM x WHERE x1 > 0 AND x2 > 0 ORDER BY x1, x2 {option}",
3562
- )
3563
- self.validate_identity(
3564
- f"FROM x |> SELECT x1, x2 |> WHERE x1 > 0 |> WHERE x2 > 0 |> ORDER BY x1, x2 |> {option}",
3565
- f"SELECT x1, x2 FROM x WHERE x1 > 0 AND x2 > 0 ORDER BY x1, x2 {option}",
3566
- )
3567
- self.validate_identity(
3568
- "FROM x |> SELECT x1, x2 |> LIMIT 2 |> LIMIT 4", "SELECT x1, x2 FROM x LIMIT 2"
3569
- )
3570
- self.validate_identity(
3571
- "FROM x |> SELECT x1, x2 |> LIMIT 2 OFFSET 2 |> LIMIT 4 OFFSET 2",
3572
- "SELECT x1, x2 FROM x LIMIT 2 OFFSET 4",
3573
- )
3574
- self.validate_identity(
3575
- "FROM x |> AGGREGATE SUM(x1), MAX(x2), MIN(x3)",
3576
- "SELECT SUM(x1), MAX(x2), MIN(x3) FROM x",
3577
- )
3578
- self.validate_identity(
3579
- "FROM x |> AGGREGATE SUM(x1) AS s_x1 |> SELECT s_x1",
3580
- "WITH __tmp1 AS (SELECT SUM(x1) AS s_x1 FROM x) SELECT s_x1 FROM __tmp1",
3581
- )
3582
- self.validate_identity(
3583
- "FROM x |> AGGREGATE SUM(x1), MAX(x2), MIN(x3) GROUP BY x4, x5",
3584
- "SELECT SUM(x1), MAX(x2), MIN(x3), x4, x5 FROM x GROUP BY x4, x5",
3585
- )
3586
- self.validate_identity(
3587
- "FROM x |> AGGREGATE SUM(x1), MAX(x2), MIN(x3) GROUP BY x4 AS a_x4, x5 AS a_x5",
3588
- "SELECT SUM(x1), MAX(x2), MIN(x3), x4 AS a_x4, x5 AS a_x5 FROM x GROUP BY a_x4, a_x5",
3589
- )
3590
- self.validate_identity(
3591
- "FROM x |> AGGREGATE SUM(x1) as s_x1 GROUP BY x1 |> SELECT s_x1, x1 as ss_x1",
3592
- "WITH __tmp1 AS (SELECT SUM(x1) AS s_x1, x1 FROM x GROUP BY x1) SELECT s_x1, x1 AS ss_x1 FROM __tmp1",
3593
- )
3594
- self.validate_identity(
3595
- "FROM x |> AGGREGATE SUM(x1) GROUP", "SELECT SUM(x1) AS GROUP FROM x"
3596
- )
3597
- for order_option in ("ASC", "DESC", "ASC NULLS LAST", "DESC NULLS FIRST"):
3598
- with self.subTest(f"Testing pipe syntax AGGREGATE for order option: {order_option}"):
3599
- self.validate_all(
3600
- f"SELECT SUM(x1) AS x_s FROM x ORDER BY x_s {order_option}",
3601
- read={
3602
- "bigquery": f"FROM x |> AGGREGATE SUM(x1) AS x_s {order_option}",
3603
- },
3604
- )
3605
- self.validate_all(
3606
- f"SELECT SUM(x1) AS x_s, x1 AS g_x1 FROM x GROUP BY g_x1 ORDER BY x_s {order_option}",
3607
- read={
3608
- "bigquery": f"FROM x |> AGGREGATE SUM(x1) AS x_s {order_option} GROUP BY x1 AS g_x1",
3609
- },
3610
- )
3611
- with self.subTest(
3612
- f"Testing pipe syntax AGGREGATE with GROUP AND ORDER BY for order option: {order_option}"
3613
- ):
3614
- self.validate_all(
3615
- f"WITH __tmp1 AS (SELECT SUM(x1) AS x_s, x1 AS g_x1 FROM x GROUP BY g_x1 ORDER BY g_x1 {order_option}) SELECT g_x1, x_s FROM __tmp1",
3616
- read={
3617
- "bigquery": f"FROM x |> AGGREGATE SUM(x1) AS x_s GROUP AND ORDER BY x1 AS g_x1 {order_option} |> SELECT g_x1, x_s",
3618
- },
3619
- )
3620
-
3621
- for op_operator in (
3622
- "UNION ALL",
3623
- "UNION DISTINCT",
3624
- "INTERSECT DISTINCT",
3625
- "EXCEPT DISTINCT",
3626
- ):
3627
- with self.subTest(f"Testing pipe syntax SET OPERATORS: {op_operator}"):
3628
- self.validate_all(
3629
- f"FROM x|> {op_operator} (SELECT y1 FROM y), (SELECT z1 FROM z)",
3630
- write={
3631
- "bigquery": f"WITH __tmp1 AS (SELECT * FROM x {op_operator} (SELECT y1 FROM y) {op_operator} (SELECT z1 FROM z)) SELECT * FROM __tmp1",
3632
- },
3633
- )
3634
-
3635
- for op_prefix in ("LEFT OUTER", "FULL OUTER"):
3636
- for op_operator in (
3637
- "UNION ALL",
3638
- "UNION DISTINCT",
3639
- "INTERSECT DISTINCT",
3640
- "EXCEPT DISTINCT",
3641
- ):
3642
- for suffix_operator in ("BY NAME", "CORRESPONDING"):
3643
- with self.subTest(
3644
- f"Testing pipe syntax SET OPERATORS: {op_prefix} {op_operator} {suffix_operator}"
3645
- ):
3646
- self.validate_all(
3647
- f"FROM x|> SELECT x1, x2 FROM x |> {op_prefix} {op_operator} {suffix_operator} (SELECT y1, y2 FROM y), (SELECT z1, z2 FROM z)",
3648
- write={
3649
- "bigquery": f"WITH __tmp1 AS (SELECT x1, x2 FROM x {op_prefix} {op_operator} BY NAME (SELECT y1, y2 FROM y) {op_prefix} {op_operator} BY NAME (SELECT z1, z2 FROM z)) SELECT x1, x2 FROM __tmp1",
3650
- },
3651
- )
3652
-
3653
- self.validate_identity(
3654
- "FROM d.x |> SELECT x.x1 |> UNION (SELECT 2 AS a1) |> SELECT x1 |> UNION (SELECT 3 as a2) |> SELECT x1 |> WHERE x1 > 100",
3655
- """WITH __tmp1 AS (
3656
- SELECT
3657
- x.x1
3658
- FROM d.x
3659
- UNION
3660
- (
3661
- SELECT
3662
- 2 AS a1
3663
- )
3664
- ), __tmp2 AS (
3665
- SELECT
3666
- x.x1
3667
- FROM __tmp1
3668
- ), __tmp3 AS (
3669
- SELECT
3670
- x1
3671
- FROM __tmp2
3672
- UNION
3673
- (
3674
- SELECT
3675
- 3 AS a2
3676
- )
3677
- ), __tmp4 AS (
3678
- SELECT
3679
- x1
3680
- FROM __tmp3
3681
- )
3682
- SELECT
3683
- x1
3684
- FROM __tmp4
3685
- WHERE
3686
- x1 > 100""",
3687
- pretty=True,
3688
- )
3689
-
3690
- self.validate_identity(
3691
- "FROM c.x |> UNION ALL (SELECT 2 AS a1, '2' as a2) |> AGGREGATE AVG(x1) as m_x1 |> SELECT * |> UNION ALL (SELECT y1 FROM c.y) |> SELECT m_x1",
3692
- """WITH __tmp1 AS (
3693
- SELECT
3694
- *
3695
- FROM c.x
3696
- UNION ALL
3697
- (
3698
- SELECT
3699
- 2 AS a1,
3700
- '2' AS a2
3701
- )
3702
- ), __tmp2 AS (
3703
- SELECT
3704
- AVG(x1) AS m_x1
3705
- FROM __tmp1
3706
- ), __tmp3 AS (
3707
- SELECT
3708
- *
3709
- FROM __tmp2
3710
- UNION ALL
3711
- (
3712
- SELECT
3713
- y1
3714
- FROM c.y
3715
- )
3716
- ), __tmp4 AS (
3717
- SELECT
3718
- *
3719
- FROM __tmp3
3720
- )
3721
- SELECT
3722
- m_x1
3723
- FROM __tmp4""",
3724
- pretty=True,
3725
- )