alamb commented on code in PR #20534:
URL: https://github.com/apache/datafusion/pull/20534#discussion_r2849297898


##########
datafusion/physical-expr/src/simplifier/const_evaluator.rs:
##########
@@ -146,11 +146,23 @@ pub(crate) fn simplify_const_expr_immediate(
 /// that only contain literals, the batch content is irrelevant.
 ///
 /// This is the same approach used in the logical expression `ConstEvaluator`.
-pub(crate) fn create_dummy_batch() -> Result<RecordBatch> {
-    // RecordBatch requires at least one column
-    let dummy_schema = Arc::new(Schema::new(vec![Field::new("_", 
DataType::Null, true)]));
-    let col = new_null_array(&DataType::Null, 1);
-    Ok(RecordBatch::try_new(dummy_schema, vec![col])?)
+pub(crate) fn create_dummy_batch() -> Result<&'static RecordBatch> {
+    static DUMMY_BATCH: std::sync::OnceLock<Result<RecordBatch>> =

Review Comment:
   The idea is to compute the result once and then reuse it each time rather 
than create a new batch and array each time



-- 
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