Skip to content

Commit da4160f

Browse files
committed
removed allow_multiple_generators
1 parent 8c6909f commit da4160f

2 files changed

Lines changed: 3 additions & 66 deletions

File tree

datafusion/sql/src/select.rs

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -672,19 +672,8 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
672672
// `NullHandling::PreserveAndExpandEmpty`. Mixing the two in a
673673
// single SELECT is a planning error because `UnnestOptions` is
674674
// per-`UnnestExec`, not per-column.
675-
//
676-
// When `datafusion.spark.allow_multiple_generators = false`, any
677-
// SELECT with more than one generator (even same-mode) is rejected
678-
// to match Spark's `UNSUPPORTED_GENERATOR.MULTI_GENERATOR`.
679-
let allow_multiple_generators = self
680-
.context_provider
681-
.options()
682-
.spark
683-
.allow_multiple_generators;
684-
let null_handling = collect_unnest_null_handling(
685-
&intermediate_expr_groups,
686-
allow_multiple_generators,
687-
)?;
675+
let null_handling =
676+
collect_unnest_null_handling(&intermediate_expr_groups)?;
688677
let mut unnest_options =
689678
UnnestOptions::new().with_null_handling(null_handling);
690679
let mut unnest_col_vec = vec![];
@@ -1482,18 +1471,9 @@ fn has_unnest_expr_recursively(expr: &Expr) -> bool {
14821471
/// * A mix of `outer = true` and `outer = false` in one SELECT → planning
14831472
/// error, because `UnnestOptions` applies per `Unnest` plan node, not
14841473
/// per output column.
1485-
/// * When `allow_multiple_generators` is `false`, any SELECT with more than
1486-
/// one generator is rejected with
1487-
/// `[UNSUPPORTED_GENERATOR.MULTI_GENERATOR]` (Spark-strict mode). When
1488-
/// `true` (the default), DataFusion's native multi-generator support is
1489-
/// preserved.
1490-
fn collect_unnest_null_handling(
1491-
expr_groups: &[Vec<Expr>],
1492-
allow_multiple_generators: bool,
1493-
) -> Result<NullHandling> {
1474+
fn collect_unnest_null_handling(expr_groups: &[Vec<Expr>]) -> Result<NullHandling> {
14941475
let mut saw_outer = false;
14951476
let mut saw_inner = false;
1496-
let mut generator_count: usize = 0;
14971477
for group in expr_groups {
14981478
for expr in group {
14991479
expr.apply(|e| {
@@ -1503,7 +1483,6 @@ fn collect_unnest_null_handling(
15031483
} else {
15041484
saw_inner = true;
15051485
}
1506-
generator_count += 1;
15071486
}
15081487
Ok(TreeNodeRecursion::Continue)
15091488
})?;
@@ -1517,14 +1496,6 @@ fn collect_unnest_null_handling(
15171496
unnest projection uses one mode."
15181497
);
15191498
}
1520-
if !allow_multiple_generators && generator_count > 1 {
1521-
return plan_err!(
1522-
"[UNSUPPORTED_GENERATOR.MULTI_GENERATOR] Only one generator \
1523-
function (`unnest`, `explode`, `explode_outer`, ...) is allowed \
1524-
per SELECT under Spark-strict mode \
1525-
(`datafusion.spark.allow_multiple_generators = false`)."
1526-
);
1527-
}
15281499
Ok(if saw_outer {
15291500
NullHandling::PreserveAndExpandEmpty
15301501
} else {

datafusion/sqllogictest/test_files/spark/generator/explode_outer.slt

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -128,40 +128,6 @@ SELECT unnest(xs), explode_outer(xs) FROM int_lists;
128128
statement error DataFusion error: Error during planning: Cannot mix `unnest\(\.\.\.\)` \(or `explode\(\.\.\.\)`\) with `explode_outer\(\.\.\.\)` in the same SELECT
129129
SELECT explode(xs), explode_outer(xs) FROM int_lists;
130130

131-
##############################
132-
# 5b. Spark-strict mode: `datafusion.spark.allow_multiple_generators = false`
133-
# rejects ANY second generator in one SELECT (matches Spark's
134-
# `UNSUPPORTED_GENERATOR.MULTI_GENERATOR`). Default DataFusion behavior
135-
# (`true`) permits multiple same-mode generators.
136-
##############################
137-
138-
statement ok
139-
set datafusion.spark.allow_multiple_generators = false;
140-
141-
# Two same-mode generators in one SELECT — rejected only under strict mode.
142-
# (Aliases sidestep the unique-output-name check so we hit the new error path.)
143-
statement error DataFusion error: Error during planning: \[UNSUPPORTED_GENERATOR\.MULTI_GENERATOR\] Only one generator function
144-
SELECT explode(xs) AS a, explode(xs) AS b FROM int_lists;
145-
146-
statement error DataFusion error: Error during planning: \[UNSUPPORTED_GENERATOR\.MULTI_GENERATOR\] Only one generator function
147-
SELECT explode_outer(xs) AS a, explode_outer(xs) AS b FROM int_lists;
148-
149-
# Mixed-mode is rejected regardless of this flag (the mix message wins
150-
# because it's a technical constraint, not a stylistic one).
151-
statement error DataFusion error: Error during planning: Cannot mix `unnest\(\.\.\.\)` \(or `explode\(\.\.\.\)`\) with `explode_outer\(\.\.\.\)` in the same SELECT
152-
SELECT unnest(xs) AS a, explode_outer(xs) AS b FROM int_lists;
153-
154-
# A single generator still works under strict mode.
155-
query I
156-
SELECT explode_outer(xs) AS x FROM int_lists WHERE id = 1 ORDER BY x;
157-
----
158-
10
159-
20
160-
30
161-
162-
statement ok
163-
set datafusion.spark.allow_multiple_generators = true;
164-
165131
##############################
166132
# 6. Chained explode → explode_outer via subquery.
167133
# `explode(xs)` (inner) drops NULL and empty outer rows, then

0 commit comments

Comments
 (0)