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

github-bot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new 6f86c8d878 Used constant with mapping instead of write! to display 
scalar value bytes  (#20719)
6f86c8d878 is described below

commit 6f86c8d87889ec983729c97330c03b1d505a188e
Author: Burak Şen <[email protected]>
AuthorDate: Tue Mar 10 18:32:22 2026 +0300

    Used constant with mapping instead of write! to display scalar value bytes  
(#20719)
    
    ## Which issue does this PR close?
    
    - Closes #19569.
    
    ## Rationale for this change
    This was the latest usage as far as I can see so I've changed it. I
    think this is not on the hot path so if you want we can close the PR and
    issue with it.
    
    ## What changes are included in this PR?
    Instead of using write! format string write hex with using constant char
    mapping
    
    ## Are these changes tested?
    Runned debug display tests:
    ```
    running 1 test
    test scalar::tests::test_binary_display ... ok
    
    test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 364 filtered 
out; finished in 0.00s
    ```
    
    
    ## Are there any user-facing changes?
    No
---
 datafusion/common/src/scalar/mod.rs | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/datafusion/common/src/scalar/mod.rs 
b/datafusion/common/src/scalar/mod.rs
index c21d3e21f0..d759bbedd9 100644
--- a/datafusion/common/src/scalar/mod.rs
+++ b/datafusion/common/src/scalar/mod.rs
@@ -26,6 +26,7 @@ use std::cmp::Ordering;
 use std::collections::{HashSet, VecDeque};
 use std::convert::Infallible;
 use std::fmt;
+use std::fmt::Write;
 use std::hash::Hash;
 use std::hash::Hasher;
 use std::iter::repeat_n;
@@ -4959,8 +4960,10 @@ impl fmt::Display for ScalarValue {
             | ScalarValue::BinaryView(e) => match e {
                 Some(bytes) => {
                     // print up to first 10 bytes, with trailing ... if needed
+                    const HEX_CHARS_UPPER: &[u8; 16] = b"0123456789ABCDEF";
                     for b in bytes.iter().take(10) {
-                        write!(f, "{b:02X}")?;
+                        f.write_char(HEX_CHARS_UPPER[(b >> 4) as usize] as 
char)?;
+                        f.write_char(HEX_CHARS_UPPER[(b & 0x0f) as usize] as 
char)?;
                     }
                     if bytes.len() > 10 {
                         write!(f, "...")?;


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

Reply via email to