You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add a config to disable subquery_sort_elimination (#21614)
## Which issue does this PR close?
- Closes#15886
## Rationale for this change
- see
#15886 (comment)
## What changes are included in this PR?
- Added a new optimizer config option:
`datafusion.sql_parser.enable_subquery_sort_elimination`
- Added a `SessionConfig` builder method:
`with_enable_subquery_sort_elimination(...)`
- Updated SQL relation planning so subquery/CTE `ORDER BY` elimination
only happens when this config is enabled
- Kept the current behavior as the default to avoid changing existing
behavior unexpectedly
## Are these changes tested?
Added SQL integration tests that verify:
- subquery `ORDER BY` is removed by default
- subquery `ORDER BY` is preserved when
`enable_subquery_sort_elimination` is set to `false`
- add slt test case
## Are there any user-facing changes?
no
@@ -489,6 +490,7 @@ datafusion.sql_parser.default_null_ordering nulls_max Specifies the default null
489
490
datafusion.sql_parser.dialect generic Configure the SQL dialect used by DataFusion's parser; supported values include: Generic, MySQL, PostgreSQL, Hive, SQLite, Snowflake, Redshift, MsSQL, ClickHouse, BigQuery, Ansi, DuckDB and Databricks.
490
491
datafusion.sql_parser.enable_ident_normalization true When set to true, SQL parser will normalize ident (convert ident to lowercase when not quoted)
491
492
datafusion.sql_parser.enable_options_value_normalization false When set to true, SQL parser will normalize options value (convert value to lowercase). Note that this option is ignored and will be removed in the future. All case-insensitive values are normalized automatically.
493
+
datafusion.sql_parser.enable_subquery_sort_elimination true When set to true, DataFusion may remove `ORDER BY` clauses from subqueries or CTEs during SQL planning when their ordering cannot affect the result, such as when no `LIMIT` or other order-sensitive operator depends on them. Disable this option to preserve explicit subquery ordering in the planned query.
492
494
datafusion.sql_parser.map_string_types_to_utf8view true If true, string types (VARCHAR, CHAR, Text, and String) are mapped to `Utf8View` during SQL planning. If false, they are mapped to `Utf8`. Default is true.
493
495
datafusion.sql_parser.parse_float_as_decimal false When set to true, SQL parser will parse float as decimal type
494
496
datafusion.sql_parser.recursion_limit 50 Specifies the recursion depth limit when parsing complex SQL Queries
Copy file name to clipboardExpand all lines: docs/source/user-guide/configs.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -191,6 +191,7 @@ The following configuration settings are available:
191
191
| datafusion.sql_parser.collect_spans | false | When set to true, the source locations relative to the original SQL query (i.e. [`Span`](https://docs.rs/sqlparser/latest/sqlparser/tokenizer/struct.Span.html)) will be collected and recorded in the logical plan nodes. |
192
192
| datafusion.sql_parser.recursion_limit | 50 | Specifies the recursion depth limit when parsing complex SQL Queries |
193
193
| datafusion.sql_parser.default_null_ordering | nulls_max | Specifies the default null ordering for query results. There are 4 options: - `nulls_max`: Nulls appear last in ascending order. - `nulls_min`: Nulls appear first in ascending order. - `nulls_first`: Nulls always be first in any order. - `nulls_last`: Nulls always be last in any order. By default, `nulls_max` is used to follow Postgres's behavior. postgres rule: <https://www.postgresql.org/docs/current/queries-order.html> |
194
+
| datafusion.sql_parser.enable_subquery_sort_elimination | true | When set to true, DataFusion may remove `ORDER BY` clauses from subqueries or CTEs during SQL planning when their ordering cannot affect the result, such as when no `LIMIT` or other order-sensitive operator depends on them. Disable this option to preserve explicit subquery ordering in the planned query. |
194
195
| datafusion.format.safe | true | If set to `true` any formatting errors will be written to the output instead of being converted into a [`std::fmt::Error`] |
195
196
| datafusion.format.null | | Format string for nulls |
196
197
| datafusion.format.date_format | %Y-%m-%d | Date format for date arrays |
0 commit comments