rich7420 commented on code in PR #7316:
URL: https://github.com/apache/datafusion-comet/pull/7316#discussion_r4704359507


##########
spark/src/test/resources/sql-tests/operators/large_scalar_string_small_batch.sql:
##########
@@ -0,0 +1,33 @@
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--   http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+
+-- The filter case of large_scalar_string.sql with a session batch size that a 
256 KiB scalar
+-- fits as is. The projection above the filter still bounds its input, 
whatever the filter
+-- emits.
+-- See https://github.com/apache/datafusion-comet/issues/7247.
+-- Config: spark.sql.adaptive.enabled=false
+-- Config: spark.comet.batchSize=256
+-- ConstantFolding: enabled
+
+statement
+CREATE TABLE test_large_scalar_small_batch(k int) USING parquet
+
+statement
+INSERT INTO test_large_scalar_small_batch SELECT /*+ COALESCE(1) */ CAST(id % 
2 AS INT) FROM range(8192)
+
+query
+SELECT sum(length(c)) FROM (SELECT concat(repeat('x', 262144), CAST(k AS 
STRING)) AS c FROM test_large_scalar_small_batch WHERE k >= 0)

Review Comment:
   This passes for me with the split off, since #7280 keeps the filter at 256 
rows. Could it use the `ntile` window query instead?



##########
spark/src/test/resources/sql-tests/operators/large_scalar_string.sql:
##########
@@ -0,0 +1,95 @@
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--   http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+
+-- A string scalar, from a scalar subquery or a literal, is expanded to the 
batch length by the
+-- aggregate, the hash partitioner and string kernels. A 256 KiB string over 
the default 8192-row
+-- batch needs 2 GiB of value bytes, past Arrow's 32-bit offsets. Spark 
evaluates row by row.
+-- The ids are written in one task so they arrive in one batch. Constant 
folding is on so that
+-- `repeat('x', 262144)` reaches Comet as the literal it is in a Spark 
session. Null propagation
+-- is off so that the grouped count keeps the literal as its argument instead 
of `count(1)`.
+-- See https://github.com/apache/datafusion-comet/issues/7247.
+-- Config: spark.sql.adaptive.enabled=false
+-- Config: spark.comet.exec.range.enabled=true
+-- ConstantFolding: enabled
+-- ExcludeRules: org.apache.spark.sql.catalyst.optimizer.NullPropagation
+
+statement
+CREATE TABLE test_large_scalar_wide(s string) USING parquet
+
+statement
+INSERT INTO test_large_scalar_wide SELECT repeat('x', 262144)
+
+statement
+CREATE TABLE test_large_scalar_ids(k int) USING parquet
+
+statement
+INSERT INTO test_large_scalar_ids SELECT /*+ COALESCE(1) */ CAST(id % 2 AS 
INT) FROM range(8192)
+
+-- count of the scalar in a grouped aggregate, which expands it to the batch 
length. A literal
+-- rather than the subquery: the harness's missingInput check trips on a 
grouped count of a
+-- scalar subquery whatever the string's size, which is a separate plan issue.
+query
+SELECT k, count(repeat('x', 262144)) FROM test_large_scalar_ids GROUP BY k 
ORDER BY k
+
+-- the scalar as a hash partitioning key
+query
+SELECT count(*) FROM (SELECT k FROM test_large_scalar_ids DISTRIBUTE BY k, 
(SELECT max(s) FROM test_large_scalar_wide))
+
+-- a string kernel whose output exceeds 2 GiB per 8192-row batch
+query
+SELECT sum(length(c)) FROM (SELECT concat((SELECT max(s) FROM 
test_large_scalar_wide), CAST(k AS STRING)) AS c FROM test_large_scalar_ids)
+
+-- the same with a literal instead of a subquery
+query
+SELECT sum(length(c)) FROM (SELECT concat(repeat('x', 262144), CAST(k AS 
STRING)) AS c FROM test_large_scalar_ids)
+
+-- the literal over the native range source, which sizes its own batches, in 
one slice
+query
+SELECT sum(length(concat(repeat('x', 262144), CAST(id AS STRING)))) FROM 
range(0, 8192, 1, 1)
+
+-- a filter under the projection coalesces its output to its own batch size
+query
+SELECT sum(length(c)) FROM (SELECT concat((SELECT max(s) FROM 
test_large_scalar_wide), CAST(k AS STRING)) AS c FROM test_large_scalar_ids 
WHERE k >= 0)

Review Comment:
   Could one query put the scalar in the `WHERE` itself, to cover the filter's 
own split? This overflows for me with the split off:
   
   ```sql
   SELECT count(*) FROM range(0, 8192, 1, 1)
   WHERE length(concat(repeat('x', 262144), CAST(id AS STRING))) > 262144
   ```



##########
native/core/src/execution/planner/scalar_expansion.rs:
##########
@@ -0,0 +1,469 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Bounds the rows per batch under an operator that expands a large string 
scalar.
+//!
+//! An aggregate, a hash partitioner and most string kernels expand a scalar 
argument to the
+//! batch's length: a 256 KiB string over the default 8192-row batch needs 2 
GiB of value bytes,
+//! past the 32-bit offsets of Arrow's `Utf8` and `Binary` arrays. Spark 
evaluates such scalars
+//! row by row and never materializes the column. See
+//! <https://github.com/apache/datafusion-comet/issues/7247>.
+//!
+//! The bound is enforced right under the operator that evaluates the 
expressions, with a
+//! [`BatchSplitExec`], because the operators below do not keep the batch size 
they were
+//! handed: a filter coalesces its output back up to the session's batch size, 
a window emits
+//! its whole partition and a broadcast arrives as a few wide batches. No 
width can be assumed,
+//! so the split is installed whenever the operator expands a string or binary 
scalar at all.
+//! It splits only at the scalar's own cap: a batch at or under it passes 
through unsliced, so a
+//! scalar of ordinary size never hands the operator zero-copy slices of a 
shared buffer, which
+//! DataFusion's `ExternalSorter` would reserve one by one
+//! (<https://github.com/apache/datafusion/issues/25804>).
+
+use std::sync::Arc;
+
+use arrow::array::{Array, ArrayRef, AsArray};
+use arrow::datatypes::{DataType, Schema};
+use arrow::record_batch::{RecordBatch, RecordBatchOptions};
+use datafusion::logical_expr::{ColumnarValue, Operator, Volatility};
+use datafusion::physical_expr::expressions::{BinaryExpr, Column, InListExpr};
+use datafusion::physical_expr::{PhysicalExpr, ScalarFunctionExpr};
+use datafusion::physical_plan::ExecutionPlan;
+use datafusion_comet_operators::BatchSplitExec;
+use datafusion_comet_spark_expr::jvm_udf::JvmScalarUdfExpr;
+use 
datafusion_comet_spark_expr::monotonically_increasing_id::MonotonicallyIncreasingId;
+use datafusion_comet_spark_expr::{
+    RandExpr, RandStrExpr, RandnExpr, ShuffleExpr, Subquery, UuidExpr,
+};
+
+use super::{PhysicalPlanner, TEST_EXEC_CONTEXT_ID};
+
+/// The most value bytes the string and binary scalars of one operator may 
take once expanded to
+/// a batch's length. Arrow's 32-bit offsets make 2 GiB the hard limit; half 
of it leaves room for
+/// kernels that append to the expanded value, such as `concat`, and matches 
what an Arrow Java
+/// vector can hold before its reallocation fails.
+const SCALAR_EXPANSION_BYTES: usize = 1 << 30;
+
+/// The most rows per batch at which `scalar_bytes`, expanded to the batch's 
length, stay within
+/// `SCALAR_EXPANSION_BYTES`; unbounded when there is nothing to expand.
+fn scalar_rows_cap(scalar_bytes: usize) -> usize {
+    if scalar_bytes == 0 {
+        return usize::MAX;
+    }
+    (SCALAR_EXPANSION_BYTES / scalar_bytes).max(1)
+}
+
+impl PhysicalPlanner {
+    /// Wraps `input` so that the batches it emits keep the string and binary 
scalars in `exprs`,
+    /// expanded to a batch's length, within `SCALAR_EXPANSION_BYTES`. Returns 
`input` as is when
+    /// `exprs` expand no scalar.
+    pub(crate) fn bound_scalar_expansion<'a>(
+        &self,
+        input: Arc<dyn ExecutionPlan>,
+        exprs: impl IntoIterator<Item = &'a Arc<dyn PhysicalExpr>>,
+    ) -> Arc<dyn ExecutionPlan> {
+        let schema = input.schema();
+        let bytes: usize = exprs
+            .into_iter()
+            .map(|expr| self.expanded_scalar_bytes(expr, &schema))
+            .sum();
+        if bytes == 0 {
+            return input;
+        }
+        Arc::new(BatchSplitExec::new(input, scalar_rows_cap(bytes)))
+    }
+
+    /// The bytes of the string and binary scalars that evaluating `expr` 
expands to the batch's
+    /// length, including those inside a list, struct or map scalar, added up, 
so that a scalar
+    /// used twice counts twice.
+    ///
+    /// A scalar is any subtree without a column reference or a volatile 
function, evaluated
+    /// here on a one-row batch: `repeat(<subquery>, 8)` is wider than the 
subquery result it is
+    /// built from. A subtree that is not a scalar is evaluated per row, so 
only the scalars
+    /// among its children count. A subtree that fails to evaluate counts 
nothing, so that its
+    /// error surfaces where Spark's would, at execution. A scalar that a 
comparison or an `IN`
+    /// list takes as a constant is compared and never expanded; an operand 
computed per row
+    /// counts the scalars it contains.
+    fn expanded_scalar_bytes(&self, expr: &Arc<dyn PhysicalExpr>, schema: 
&Schema) -> usize {
+        if let Some(in_list) = expr.downcast_ref::<InListExpr>() {
+            // The tested value is expanded to the batch's length. A member 
that IN compares as
+            // a constant is not; one computed per row is, along with the 
scalars it contains.
+            return self.expanded_scalar_bytes(in_list.expr(), schema)
+                + self.per_row_operand_bytes(in_list.list().iter(), schema);
+        }
+        if let Some(comparison) = expr
+            .downcast_ref::<BinaryExpr>()
+            .filter(|binary| compares_as_datum(binary.op()))
+        {
+            return self.per_row_operand_bytes(
+                [comparison.left(), comparison.right()].into_iter(),
+                schema,
+            );
+        }
+        if !self.is_scalar(expr) {
+            return expr
+                .children()
+                .into_iter()
+                .map(|child| self.expanded_scalar_bytes(child, schema))
+                .sum();
+        }
+        if !expr
+            .data_type(schema)
+            .is_ok_and(|data_type| holds_offset_bytes(&data_type))
+        {
+            return 0;
+        }
+        // One row, so that a kernel that expands its scalar arguments still 
yields one value.
+        let Ok(one_row) = RecordBatch::try_new_with_options(
+            Arc::new(Schema::empty()),
+            vec![],
+            &RecordBatchOptions::new().with_row_count(Some(1)),
+        ) else {
+            return 0;
+        };
+        let value = match expr.evaluate(&one_row) {
+            Ok(ColumnarValue::Scalar(value)) => match 
value.to_array_of_size(1) {
+                Ok(array) => array,
+                Err(_) => return 0,
+            },
+            Ok(ColumnarValue::Array(array)) if array.len() == 1 => array,
+            _ => return 0,
+        };
+        offset_bytes(&value)
+    }
+
+    /// The bytes of the scalars inside the `operands` computed per row. An 
operand that is a
+    /// scalar is compared as it is.
+    fn per_row_operand_bytes<'a>(
+        &self,
+        operands: impl Iterator<Item = &'a Arc<dyn PhysicalExpr>>,
+        schema: &Schema,
+    ) -> usize {
+        operands
+            .filter(|operand| !self.is_scalar(operand))

Review Comment:
   Could this skip an operand only when it evaluates to a 
`ColumnarValue::Scalar`? `ListExtract` expands its array first, so this still 
overflows for me at 8192 rows:
   
   ```sql
   SELECT sum(CASE WHEN CAST(id AS STRING) =
     element_at(array(repeat('x', 262144)), (SELECT CAST(min(k) + 1 AS INT) 
FROM test_large_scalar_ids))
     THEN 1 ELSE 0 END)
   FROM range(0, 8192, 1, 1)
   ```



##########
native/core/src/execution/planner/scalar_expansion.rs:
##########
@@ -0,0 +1,469 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Bounds the rows per batch under an operator that expands a large string 
scalar.
+//!
+//! An aggregate, a hash partitioner and most string kernels expand a scalar 
argument to the
+//! batch's length: a 256 KiB string over the default 8192-row batch needs 2 
GiB of value bytes,
+//! past the 32-bit offsets of Arrow's `Utf8` and `Binary` arrays. Spark 
evaluates such scalars
+//! row by row and never materializes the column. See
+//! <https://github.com/apache/datafusion-comet/issues/7247>.
+//!
+//! The bound is enforced right under the operator that evaluates the 
expressions, with a
+//! [`BatchSplitExec`], because the operators below do not keep the batch size 
they were
+//! handed: a filter coalesces its output back up to the session's batch size, 
a window emits
+//! its whole partition and a broadcast arrives as a few wide batches. No 
width can be assumed,
+//! so the split is installed whenever the operator expands a string or binary 
scalar at all.
+//! It splits only at the scalar's own cap: a batch at or under it passes 
through unsliced, so a
+//! scalar of ordinary size never hands the operator zero-copy slices of a 
shared buffer, which
+//! DataFusion's `ExternalSorter` would reserve one by one
+//! (<https://github.com/apache/datafusion/issues/25804>).
+
+use std::sync::Arc;
+
+use arrow::array::{Array, ArrayRef, AsArray};
+use arrow::datatypes::{DataType, Schema};
+use arrow::record_batch::{RecordBatch, RecordBatchOptions};
+use datafusion::logical_expr::{ColumnarValue, Operator, Volatility};
+use datafusion::physical_expr::expressions::{BinaryExpr, Column, InListExpr};
+use datafusion::physical_expr::{PhysicalExpr, ScalarFunctionExpr};
+use datafusion::physical_plan::ExecutionPlan;
+use datafusion_comet_operators::BatchSplitExec;
+use datafusion_comet_spark_expr::jvm_udf::JvmScalarUdfExpr;
+use 
datafusion_comet_spark_expr::monotonically_increasing_id::MonotonicallyIncreasingId;
+use datafusion_comet_spark_expr::{
+    RandExpr, RandStrExpr, RandnExpr, ShuffleExpr, Subquery, UuidExpr,
+};
+
+use super::{PhysicalPlanner, TEST_EXEC_CONTEXT_ID};
+
+/// The most value bytes the string and binary scalars of one operator may 
take once expanded to
+/// a batch's length. Arrow's 32-bit offsets make 2 GiB the hard limit; half 
of it leaves room for
+/// kernels that append to the expanded value, such as `concat`, and matches 
what an Arrow Java
+/// vector can hold before its reallocation fails.
+const SCALAR_EXPANSION_BYTES: usize = 1 << 30;
+
+/// The most rows per batch at which `scalar_bytes`, expanded to the batch's 
length, stay within
+/// `SCALAR_EXPANSION_BYTES`; unbounded when there is nothing to expand.
+fn scalar_rows_cap(scalar_bytes: usize) -> usize {
+    if scalar_bytes == 0 {
+        return usize::MAX;
+    }
+    (SCALAR_EXPANSION_BYTES / scalar_bytes).max(1)
+}
+
+impl PhysicalPlanner {
+    /// Wraps `input` so that the batches it emits keep the string and binary 
scalars in `exprs`,
+    /// expanded to a batch's length, within `SCALAR_EXPANSION_BYTES`. Returns 
`input` as is when
+    /// `exprs` expand no scalar.
+    pub(crate) fn bound_scalar_expansion<'a>(
+        &self,
+        input: Arc<dyn ExecutionPlan>,
+        exprs: impl IntoIterator<Item = &'a Arc<dyn PhysicalExpr>>,
+    ) -> Arc<dyn ExecutionPlan> {
+        let schema = input.schema();
+        let bytes: usize = exprs
+            .into_iter()
+            .map(|expr| self.expanded_scalar_bytes(expr, &schema))
+            .sum();
+        if bytes == 0 {
+            return input;
+        }
+        Arc::new(BatchSplitExec::new(input, scalar_rows_cap(bytes)))
+    }
+
+    /// The bytes of the string and binary scalars that evaluating `expr` 
expands to the batch's
+    /// length, including those inside a list, struct or map scalar, added up, 
so that a scalar
+    /// used twice counts twice.
+    ///
+    /// A scalar is any subtree without a column reference or a volatile 
function, evaluated
+    /// here on a one-row batch: `repeat(<subquery>, 8)` is wider than the 
subquery result it is
+    /// built from. A subtree that is not a scalar is evaluated per row, so 
only the scalars
+    /// among its children count. A subtree that fails to evaluate counts 
nothing, so that its
+    /// error surfaces where Spark's would, at execution. A scalar that a 
comparison or an `IN`
+    /// list takes as a constant is compared and never expanded; an operand 
computed per row
+    /// counts the scalars it contains.
+    fn expanded_scalar_bytes(&self, expr: &Arc<dyn PhysicalExpr>, schema: 
&Schema) -> usize {
+        if let Some(in_list) = expr.downcast_ref::<InListExpr>() {
+            // The tested value is expanded to the batch's length. A member 
that IN compares as
+            // a constant is not; one computed per row is, along with the 
scalars it contains.
+            return self.expanded_scalar_bytes(in_list.expr(), schema)
+                + self.per_row_operand_bytes(in_list.list().iter(), schema);
+        }
+        if let Some(comparison) = expr
+            .downcast_ref::<BinaryExpr>()
+            .filter(|binary| compares_as_datum(binary.op()))
+        {
+            return self.per_row_operand_bytes(
+                [comparison.left(), comparison.right()].into_iter(),
+                schema,
+            );
+        }
+        if !self.is_scalar(expr) {
+            return expr
+                .children()
+                .into_iter()
+                .map(|child| self.expanded_scalar_bytes(child, schema))
+                .sum();
+        }
+        if !expr
+            .data_type(schema)
+            .is_ok_and(|data_type| holds_offset_bytes(&data_type))
+        {
+            return 0;
+        }
+        // One row, so that a kernel that expands its scalar arguments still 
yields one value.
+        let Ok(one_row) = RecordBatch::try_new_with_options(
+            Arc::new(Schema::empty()),
+            vec![],
+            &RecordBatchOptions::new().with_row_count(Some(1)),
+        ) else {
+            return 0;
+        };
+        let value = match expr.evaluate(&one_row) {
+            Ok(ColumnarValue::Scalar(value)) => match 
value.to_array_of_size(1) {
+                Ok(array) => array,
+                Err(_) => return 0,
+            },
+            Ok(ColumnarValue::Array(array)) if array.len() == 1 => array,
+            _ => return 0,
+        };
+        offset_bytes(&value)
+    }
+
+    /// The bytes of the scalars inside the `operands` computed per row. An 
operand that is a
+    /// scalar is compared as it is.
+    fn per_row_operand_bytes<'a>(
+        &self,
+        operands: impl Iterator<Item = &'a Arc<dyn PhysicalExpr>>,
+        schema: &Schema,
+    ) -> usize {
+        operands
+            .filter(|operand| !self.is_scalar(operand))
+            .map(|operand| self.expanded_scalar_bytes(operand, schema))
+            .sum()
+    }
+}
+
+/// Whether a value of `data_type` holds string or binary bytes behind 32-bit 
offsets, at the
+/// top level or inside a list, struct or map, all of which an expansion 
repeats.
+fn holds_offset_bytes(data_type: &DataType) -> bool {
+    match data_type {
+        DataType::Utf8 | DataType::Binary => true,
+        DataType::List(field)
+        | DataType::LargeList(field)
+        | DataType::FixedSizeList(field, _)
+        | DataType::Map(field, _) => holds_offset_bytes(field.data_type()),
+        DataType::Struct(fields) => fields
+            .iter()
+            .any(|field| holds_offset_bytes(field.data_type())),
+        _ => false,
+    }
+}
+
+/// The string and binary value bytes in `array`, at the top level and inside 
its lists, structs
+/// and maps.
+fn offset_bytes(array: &ArrayRef) -> usize {
+    match array.data_type() {
+        DataType::Utf8 => array.as_string::<i32>().value_data().len(),
+        DataType::Binary => array.as_binary::<i32>().value_data().len(),
+        DataType::List(_) => offset_bytes(array.as_list::<i32>().values()),
+        DataType::LargeList(_) => 
offset_bytes(array.as_list::<i64>().values()),
+        DataType::FixedSizeList(_, _) => 
offset_bytes(array.as_fixed_size_list().values()),
+        DataType::Map(_, _) => {
+            let entries: ArrayRef = Arc::new(array.as_map().entries().clone());
+            offset_bytes(&entries)
+        }
+        DataType::Struct(_) => 
array.as_struct().columns().iter().map(offset_bytes).sum(),
+        _ => 0,
+    }
+}
+
+/// Whether DataFusion's `BinaryExpr` evaluates `op` with `apply_cmp`, which 
takes a scalar
+/// operand as a `Datum` instead of expanding it to the batch's length.
+fn compares_as_datum(op: &Operator) -> bool {
+    matches!(
+        op,
+        Operator::Eq
+            | Operator::NotEq
+            | Operator::Lt
+            | Operator::LtEq
+            | Operator::Gt
+            | Operator::GtEq
+            | Operator::IsDistinctFrom
+            | Operator::IsNotDistinctFrom
+            | Operator::LikeMatch
+            | Operator::ILikeMatch
+            | Operator::NotLikeMatch
+            | Operator::NotILikeMatch
+    )
+}
+
+impl PhysicalPlanner {
+    /// Whether `expr` yields one value for a batch that can be computed at 
plan time. A column
+    /// reference and a volatile function yield a value per row, and 
evaluating a volatile
+    /// function advances its seeded generator. A JVM UDF is the user's code, 
which may have
+    /// side effects or be slow, and a planner unit test has no JVM to read a 
subquery result
+    /// from.
+    fn is_scalar(&self, expr: &Arc<dyn PhysicalExpr>) -> bool {
+        let per_row = expr.is::<Column>()

Review Comment:
   The lambda body counts as 0 bytes since `LambdaVariable` isn't per-row, so 
this overflows on `main` too. Could it go in #7689?
   
   ```sql
   SELECT sum(size(filter(array(id),
     x -> length(concat(repeat('x', 262144), CAST(x AS STRING))) > 0)))
   FROM range(0, 8192, 1, 1)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to