You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/04/25 16:38:39 UTC

(datafusion) 01/01: perf: Use bulk-NULL builder in `uuid` (#21845)

This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-21845-6f1040bac3e549c2fd4bb69e17c50987ca6c5fbf
in repository https://gitbox.apache.org/repos/asf/datafusion.git

commit 65f337d6637aa069012e0e9286f859fb3a743253
Author: Neil Conway <ne...@gmail.com>
AuthorDate: Sat Apr 25 12:38:15 2026 -0400

    perf: Use bulk-NULL builder in `uuid` (#21845)
    
    ## Which issue does this PR close?
    
    - Closes #21844.
    
    ## Rationale for this change
    
    `uuid()` never emits NULLs, so this is a straightforward win.
    Benchmarks:
    
    ```
    uuid (1024 rows): 21.618 µs → 20.133 µs, −6.90% (`p < 0.05`)
    ```
    
    ## What changes are included in this PR?
    
    * `GenericStringBuilder` -> `GenericStringArrayBuilder` in `uuid()`
    implementation
    
    ## Are these changes tested?
    
    Yes.
    
    ## Are there any user-facing changes?
    
    No.
---
 datafusion/functions/src/string/uuid.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/datafusion/functions/src/string/uuid.rs b/datafusion/functions/src/string/uuid.rs
index b2dd18683e..0bf680b44a 100644
--- a/datafusion/functions/src/string/uuid.rs
+++ b/datafusion/functions/src/string/uuid.rs
@@ -17,12 +17,12 @@
 
 use std::sync::Arc;
 
-use arrow::array::GenericStringBuilder;
 use arrow::datatypes::DataType;
 use arrow::datatypes::DataType::Utf8;
 use rand::Rng;
 use uuid::Uuid;
 
+use crate::strings::GenericStringArrayBuilder;
 use datafusion_common::{Result, assert_or_internal_err};
 use datafusion_expr::{ColumnarValue, Documentation, Volatility};
 use datafusion_expr::{ScalarFunctionArgs, ScalarUDFImpl, Signature};
@@ -87,7 +87,7 @@ impl ScalarUDFImpl for UuidFunc {
         let mut randoms = vec![0u128; args.number_rows];
         rng.fill(&mut randoms[..]);
 
-        let mut builder = GenericStringBuilder::<i32>::with_capacity(
+        let mut builder = GenericStringArrayBuilder::<i32>::with_capacity(
             args.number_rows,
             args.number_rows * 36,
         );
@@ -101,7 +101,7 @@ impl ScalarUDFImpl for UuidFunc {
             builder.append_value(fmt.encode_lower(&mut buffer));
         }
 
-        Ok(ColumnarValue::Array(Arc::new(builder.finish())))
+        Ok(ColumnarValue::Array(Arc::new(builder.finish(None)?)))
     }
 
     fn documentation(&self) -> Option<&Documentation> {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org