Skip to content

[Variant] Align cast logic related to utf8 with arrow-cast kernel - #10114

Open
klion26 wants to merge 6 commits into
apache:mainfrom
klion26:variant-cast-utf8
Open

[Variant] Align cast logic related to utf8 with arrow-cast kernel#10114
klion26 wants to merge 6 commits into
apache:mainfrom
klion26:variant-cast-utf8

Conversation

@klion26

@klion26 klion26 commented Jun 11, 2026

Copy link
Copy Markdown
Member

Which issue does this PR close?

What changes are included in this PR?

  • Align the variant to arrow logic(utf8 related) with arrow-cast kernel
  • make some function public in arrow-rs

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions Bot added arrow Changes to the arrow crate parquet-variant parquet-variant* crates labels Jun 11, 2026
@klion26
klion26 marked this pull request as draft June 11, 2026 10:36
@klion26
klion26 force-pushed the variant-cast-utf8 branch from ba2dcbd to 408a83f Compare June 12, 2026 09:57
@sdf-jkl

sdf-jkl commented Aug 8, 2026

Copy link
Copy Markdown
Member

Now that #10145 is fixed we can go back to this!

@klion26

klion26 commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

Rebased on the latest main branch, there are too many changes, I need to have a self review, will make this ready when self review done.

@klion26
klion26 force-pushed the variant-cast-utf8 branch 3 times, most recently from 7a55774 to d2e09e8 Compare August 24, 2026 06:47
@klion26
klion26 marked this pull request as ready for review August 24, 2026 06:48

@klion26 klion26 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sdf-jkl This is ready for review now, the ci failed because of #10708 , will rebase the master after #10814 has been merged

use std::iter::zip;

#[test]
fn test_compatible_cast_logic_with_cast_kernel() {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some cast logic was implemented directly here, add a test to cover it.

) {
Ok(Some(v)) => {
self.builder.append_value(v);
let $builder = &mut self.builder;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this because that variant_to_string return String now, but the builder.append_value receives a &str

@klion26
klion26 force-pushed the variant-cast-utf8 branch 2 times, most recently from 971f155 to 9f05bca Compare August 26, 2026 11:05
@klion26
klion26 force-pushed the variant-cast-utf8 branch from 9f05bca to 829e8cf Compare August 26, 2026 11:36
Comment thread arrow-cast/src/display.rs

fn write_timestamp(
/// Writes a timestamp value to the output using the given representation.
pub fn write_timestamp(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not sure about adding this to our public api; we could probably get away with leaving it public and just copying the code required into the variant crate? especially as they seem to use default format + either no timezone or the default utc timezone

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

realized there was a typo here; i meant get away with leaving it private*

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed; I meant to make the logic aligned with arrow-cast, even if we change the logic in arrow-cast later, but we have a test to cover this, and the logic is simple; copied to parquet-variant crate.

Comment thread arrow-cast/src/parse.rs Outdated
/// let expected_d4 = NaiveDate::from_ymd_opt(2026, 6, 10).unwrap();
/// assert_eq!(expected_d4, d4);
/// ```
pub fn parse_date(string: &str) -> Option<NaiveDate> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a leftover change? cant seem to find where this now being used in the diff

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case just wants to show the supported format of this function; it is not used in the current change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so it doesnt need to be made public?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this belongs to a future pr, leftover when rebasing and splitting the original pr. changed.

// boolean -> string
let boolean_array = BooleanArray::from(vec![Some(true), Some(false)]);
let cast_array = cast(&boolean_array, &DataType::Utf8).unwrap();
let boolean_utf8_array = cast_array.as_any().downcast_ref::<StringArray>().unwrap();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let boolean_utf8_array = cast_array.as_any().downcast_ref::<StringArray>().unwrap();
let boolean_utf8_array = cast_array.as_string::<i32>();

can use the downcasters here to make it more succinct: https://docs.rs/arrow/latest/arrow/array/trait.AsArray.html

@klion26

klion26 commented Aug 31, 2026

Copy link
Copy Markdown
Member Author

@Jefffrey Thanks for the review, I've addressed the comments, please take another look when you're free.

Comment thread arrow-cast/src/display.rs

fn write_timestamp(
/// Writes a timestamp value to the output using the given representation.
pub fn write_timestamp(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

realized there was a typo here; i meant get away with leaving it private*

Comment thread arrow-cast/src/parse.rs Outdated
/// let expected_d4 = NaiveDate::from_ymd_opt(2026, 6, 10).unwrap();
/// assert_eq!(expected_d4, d4);
/// ```
pub fn parse_date(string: &str) -> Option<NaiveDate> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so it doesnt need to be made public?

cast(&timestamp_nano_arrow_array, &DataType::Utf8).unwrap();
let timestamp_nano_cast_utf8_array = timestamp_nano_arrow_cast_array
.as_any()
.downcast_ref::<StringArray>()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi can replace more usages of this downcast pattern with just as_string::<i32>() in more of these tests, etc.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@github-actions github-actions Bot removed arrow Changes to the arrow crate arrow-cast labels Sep 1, 2026

@klion26 klion26 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jefffrey I've updated the code, please take another look when you're free, thanks.

@Jefffrey Jefffrey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be good once ci is green

@sdf-jkl

sdf-jkl commented Sep 1, 2026

Copy link
Copy Markdown
Member

I'll take a look today

@sdf-jkl sdf-jkl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @klion26, left some comments that need to be addressed before merging.

fyi @Jefffrey

Variant::Int16(i) => Some(lexical_to_string(*i)),
Variant::Int32(i) => Some(lexical_to_string(*i)),
Variant::Int64(i) => Some(lexical_to_string(*i)),
Variant::Float(f) => Some(lexical_to_string(*f)),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arrow-cast's ArrayFormatter uses ryu for float

($($t:ty),+) => {
$(impl<'a> DisplayIndex for &'a PrimitiveArray<$t>
{
fn write(&self, idx: usize, f: &mut dyn Write) -> FormatResult {
let value = self.value(idx);
let mut buffer = ryu::Buffer::new();
f.write_str(buffer.format(value))?;
Ok(())
}
})+
};
}

the difference:

  #[test]
  fn reproduce_float_string_difference() {
      let value = f32::from_bits(0xd378_62a7);

      // What #10114 currently produces
      let variant_output = lexical_to_string(value);

      // What arrow-cast produces
      let array = Float32Array::from(vec![value]);
      let casted = cast(&array, &DataType::Utf8).unwrap();
      let arrow_output = casted.as_string::<i32>().value(0);

      assert_eq!(variant_output, "-1.066807e12");
      assert_eq!(arrow_output, "-1066807000000.0");

      // Fails:
      assert_eq!(variant_output, arrow_output);
  }

}

// convert a variant to an owned string.
pub(crate) fn variant_to_string(variant: &Variant<'_, '_>) -> Option<String> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add FormatOptions parameter to pick how to write Date/Time/Timestamps to a string. It shouldn't be just default like it is in write_utc_timestamp_with_default_format and Date/Time arms.

let _ = write!(
ret_str,
", {}",
variant_to_string(&item).unwrap_or_default()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By calling variant_to_string recursively we drop the Variant::Object values inside a list.

arrow-cast doesn't support Objects -> String, but supports them inside a List via ArrayFormatter 🤷 (separate issue maybe?)

regardless of correctness of the Object support above, variant-cast to String shouldn't lose data.

  #[test]
  fn reproduce_list_of_objects_utf8_difference() {
      // Build the Variant value: [{"x": 1}]
      let mut variant_builder = VariantBuilder::new();
      let mut variant_list = variant_builder.new_list();

      variant_list
          .new_object()
          .with_field("x", 1_i32)
          .finish();

      variant_list.finish();

      let (metadata, value) = variant_builder.finish();
      let variant = Variant::new(&metadata, &value);

      // Current #10114 result
      let variant_output = variant_to_string(&variant).unwrap();

      // Build the equivalent Arrow List<Struct<x: Int32>>
      let fields = vec![Field::new("x", DataType::Int32, true)];
      let struct_builder = StructBuilder::from_fields(fields, 1);
      let mut arrow_list = ListBuilder::new(struct_builder);

      let struct_builder = arrow_list.values();
      struct_builder
          .field_builder::<Int32Builder>(0)
          .unwrap()
          .append_value(1);
      struct_builder.append(true);
      arrow_list.append(true);

      let arrow_list = arrow_list.finish();

      // Arrow List<Struct> → Utf8 result
      let casted = cast(&arrow_list, &DataType::Utf8).unwrap();
      let arrow_output = casted.as_string::<i32>().value(0);

      assert_eq!(variant_output, "[]");
      assert_eq!(arrow_output, "[{x: 1}]");

      // Fails
      assert_eq!(variant_output, arrow_output);
  }

@klion26

klion26 commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

@sdf-jkl Thank for the review, filed a new issue to track the Variant::Object in Variant::List case,

I've update the code, and will run some benchmark to see if there are any performance regression in arrow-cast, will ping you for another review when ready.

@klion26

klion26 commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

run benchmark cast_kernels

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c5539582603-2130-rs4xr 6.12.94+ #1 SMP Fri Jul 17 09:42:57 UTC 2026 aarch64 GNU/Linux

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected

Comparing variant-cast-utf8 (4eb2a37) to f299971 (merge-base) diff

Run configuration
run benchmark cast_kernels

BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench cast_kernels
Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

Comparing variant-cast-utf8 (4eb2a37) to f299971 (merge-base) diff

Run configuration
run benchmark cast_kernels
CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Details

group                                                              main                                   variant-cast-utf8
-----                                                              ----                                   -----------------
"cast decimal128 to float64"                                       1.00     27.1±0.01µs        ? ?/sec    1.00     27.2±0.03µs        ? ?/sec
"cast decimal128 to int64"                                         1.00     48.2±0.46µs        ? ?/sec    1.00     48.1±0.44µs        ? ?/sec
"cast decimal128 to int8"                                          1.00     60.8±0.78µs        ? ?/sec    1.00     60.9±0.52µs        ? ?/sec
"cast decimal256 to float64"                                       1.00     68.7±0.11µs        ? ?/sec    1.00     68.6±0.12µs        ? ?/sec
"cast decimal256 to int64"                                         1.00    152.1±0.17µs        ? ?/sec    1.00    152.0±0.14µs        ? ?/sec
"cast float64 to decimal128(32, 3)"                                1.00     32.2±0.03µs        ? ?/sec    1.00     32.2±0.03µs        ? ?/sec
"cast invalid float64 to to decimal128(32, 3)"                     1.00     15.7±0.02µs        ? ?/sec    1.00     15.7±0.02µs        ? ?/sec
"cast string to decimal128(38, 3)"                                 1.00    119.2±0.36µs        ? ?/sec    1.01    119.9±0.32µs        ? ?/sec
"cast string to decimal256(76, 3)"                                 1.00    147.7±0.86µs        ? ?/sec    1.00    147.3±0.40µs        ? ?/sec
cast binary dict to string view (sparse)                           1.00     45.9±0.09µs        ? ?/sec    1.10     50.4±5.34µs        ? ?/sec
cast binary to dict high cardinality                               1.00    185.7±0.63µs        ? ?/sec    1.00    186.0±0.39µs        ? ?/sec
cast binary to dict high cardinality no nulls                      1.00    162.1±0.45µs        ? ?/sec    1.00    161.9±0.34µs        ? ?/sec
cast binary to dict low cardinality                                1.00    153.6±0.44µs        ? ?/sec    1.01    154.7±0.49µs        ? ?/sec
cast binary to dict low cardinality no nulls                       1.00    130.3±0.22µs        ? ?/sec    1.00    130.1±0.31µs        ? ?/sec
cast binary to dict medium cardinality                             1.00    154.8±0.27µs        ? ?/sec    1.01    155.9±0.36µs        ? ?/sec
cast binary to dict medium cardinality no nulls                    1.00    131.8±0.22µs        ? ?/sec    1.00    131.8±0.33µs        ? ?/sec
cast binary view to string                                         1.07     73.5±3.28µs        ? ?/sec    1.00     68.6±0.83µs        ? ?/sec
cast binary view to string view                                    1.00     62.5±1.25µs        ? ?/sec    1.02     63.9±2.21µs        ? ?/sec
cast binary view to wide string                                    1.00     68.8±0.85µs        ? ?/sec    1.00     69.0±0.80µs        ? ?/sec
cast date32 to date64 512                                          1.03    331.2±0.35ns        ? ?/sec    1.00    322.7±0.32ns        ? ?/sec
cast date64 to date32 512                                          1.14    944.3±1.34ns        ? ?/sec    1.00    830.8±1.62ns        ? ?/sec
cast decimal128 to decimal128 512                                  1.01      6.9±0.02µs        ? ?/sec    1.00      6.9±0.01µs        ? ?/sec
cast decimal128 to decimal128 512 lower precision                  1.00     19.8±0.02µs        ? ?/sec    1.00     19.7±0.04µs        ? ?/sec
cast decimal128 to decimal128 512 with lower scale (infallible)    1.00     45.9±0.08µs        ? ?/sec    1.00     45.9±0.07µs        ? ?/sec
cast decimal128 to decimal128 512 with same scale                  1.01     75.5±0.52ns        ? ?/sec    1.00     75.1±0.74ns        ? ?/sec
cast decimal128 to decimal256 512                                  1.00     26.3±0.05µs        ? ?/sec    1.00     26.3±0.02µs        ? ?/sec
cast decimal256 to decimal128 512                                  1.00    317.9±0.27µs        ? ?/sec    1.00    317.8±0.31µs        ? ?/sec
cast decimal256 to decimal256 512                                  1.00     80.8±0.21µs        ? ?/sec    1.00     80.9±0.38µs        ? ?/sec
cast decimal256 to decimal256 512 with same scale                  1.00     75.4±0.97ns        ? ?/sec    1.00     75.1±0.79ns        ? ?/sec
cast dict to string view                                           1.00     14.9±0.02µs        ? ?/sec    1.03     15.3±0.23µs        ? ?/sec
cast dict to string view (sparse)                                  1.00      5.3±0.07µs        ? ?/sec    1.00      5.3±0.08µs        ? ?/sec
cast f32 to string 512                                             1.00     11.9±0.04µs        ? ?/sec    1.00     11.9±0.06µs        ? ?/sec
cast f64 to string 512                                             1.00     15.3±0.03µs        ? ?/sec    1.01     15.4±0.04µs        ? ?/sec
cast float32 to int32 512                                          1.00    626.5±1.31ns        ? ?/sec    1.24    775.3±0.97ns        ? ?/sec
cast float64 to float32 512                                        1.00    621.7±1.17ns        ? ?/sec    1.03    639.1±1.49ns        ? ?/sec
cast float64 to uint64 512                                         1.00    640.6±1.67ns        ? ?/sec    1.01    644.0±1.03ns        ? ?/sec
cast i64 to string 512                                             1.00      8.7±0.03µs        ? ?/sec    1.01      8.7±0.04µs        ? ?/sec
cast int32 to float32 512                                          1.00    621.2±1.09ns        ? ?/sec    1.02    630.9±3.30ns        ? ?/sec
cast int32 to float64 512                                          1.01    644.7±4.26ns        ? ?/sec    1.00    636.0±3.22ns        ? ?/sec
cast int32 to int32 512                                            1.00    170.0±0.57ns        ? ?/sec    1.00    170.5±3.10ns        ? ?/sec
cast int32 to int64 512                                            1.00    635.5±3.67ns        ? ?/sec    1.01    639.2±3.42ns        ? ?/sec
cast int32 to uint32 512                                           1.00    873.7±1.09ns        ? ?/sec    1.02    888.4±1.20ns        ? ?/sec
cast int64 to decimal32(9, -1) 512                                 1.01      3.4±0.00µs        ? ?/sec    1.00      3.4±0.00µs        ? ?/sec
cast int64 to decimal32(9, 0) 512                                  1.02   1292.3±3.18ns        ? ?/sec    1.00   1266.7±1.56ns        ? ?/sec
cast int64 to int32 512                                            1.00    839.3±1.01ns        ? ?/sec    1.13    948.5±1.11ns        ? ?/sec
cast nested dict to dict                                           1.11      5.0±0.31µs        ? ?/sec    1.00      4.5±0.01µs        ? ?/sec
cast no runs of int32s to ree<int32>                               1.00     57.8±0.72µs        ? ?/sec    1.01     58.3±0.85µs        ? ?/sec
cast runs of 10 string to ree<int32>                               1.02      8.9±0.02µs        ? ?/sec    1.00      8.8±0.02µs        ? ?/sec
cast runs of 1000 int32s to ree<int32>                             1.02      3.5±0.01µs        ? ?/sec    1.00      3.4±0.01µs        ? ?/sec
cast string single run to ree<int32>                               1.00     27.4±0.02µs        ? ?/sec    1.01     27.7±0.35µs        ? ?/sec
cast string to binary view 512                                     1.00      2.3±0.01µs        ? ?/sec    1.00      2.3±0.02µs        ? ?/sec
cast string view to binary view                                    1.01     82.0±1.43ns        ? ?/sec    1.00     81.4±1.44ns        ? ?/sec
cast string view to dict                                           1.00    154.3±0.61µs        ? ?/sec    1.00    154.5±0.48µs        ? ?/sec
cast string view to string                                         1.05     45.3±1.22µs        ? ?/sec    1.00     42.9±0.79µs        ? ?/sec
cast string view to wide string                                    1.01     43.3±0.83µs        ? ?/sec    1.00     43.0±0.86µs        ? ?/sec
cast time32s to time32ms 512                                       1.01    851.3±2.09ns        ? ?/sec    1.00    842.3±1.21ns        ? ?/sec
cast time32s to time64us 512                                       1.00    333.3±0.60ns        ? ?/sec    1.00    334.1±0.35ns        ? ?/sec
cast time64ns to time32s 512                                       1.00    413.0±0.92ns        ? ?/sec    1.02    419.8±0.86ns        ? ?/sec
cast timestamp_ms to i64 512                                       1.00    250.1±1.15ns        ? ?/sec    1.03    257.4±5.73ns        ? ?/sec
cast timestamp_ms to timestamp_ns 512                              1.00   1268.5±5.69ns        ? ?/sec    1.02   1291.6±6.37ns        ? ?/sec
cast timestamp_ns to timestamp_s 512                               1.00    168.7±1.59ns        ? ?/sec    1.02    171.5±2.82ns        ? ?/sec
cast utf8 to date32 512                                            1.03      7.2±0.07µs        ? ?/sec    1.00      6.9±0.05µs        ? ?/sec
cast utf8 to date64 512                                            1.00     31.9±0.12µs        ? ?/sec    1.00     31.8±0.12µs        ? ?/sec
cast utf8 to f32                                                   1.00      5.6±0.03µs        ? ?/sec    1.00      5.6±0.03µs        ? ?/sec
cast utf8 to i32                                                   1.01      5.3±0.06µs        ? ?/sec    1.00      5.3±0.04µs        ? ?/sec
cast wide string to binary view 512                                1.00      3.9±0.07µs        ? ?/sec    1.02      4.0±0.09µs        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 655.1s
Peak memory 18.2 MiB
Avg memory 17.3 MiB
CPU user 650.4s
CPU sys 0.0s
Peak spill 0 B

branch

Metric Value
Wall time 650.1s
Peak memory 18.2 MiB
Avg memory 17.5 MiB
CPU user 647.8s
CPU sys 0.0s
Peak spill 0 B

File an issue against this benchmark runner

@sdf-jkl

sdf-jkl commented Sep 4, 2026

Copy link
Copy Markdown
Member

Sorry @klion26, I wasn’t clear. The Variant::Object value being silently dropped when formatting a Variant::List is a regression introduced by this PR, so I think it should be addressed here rather than deferred to #10982.

What I meant could be tracked separately is the pre-existing inconsistency in arrow-cast: it does not support a top-level StructUtf8 cast, but it does format a Struct nested inside a List via ArrayFormatter.

@sdf-jkl

sdf-jkl commented Sep 4, 2026

Copy link
Copy Markdown
Member

thanks @klion26, I think we need to work on some benchmarks before proceeding.

  • The existing cast_kernels bench doesn't cover the temporal -> utf8 path touched in this PR.

  • We should also benchmark variant_get/shred_variant on string/binary types to see if there are any regressions to avoid variant_to_json has no benchmark, and it got slower #10906 situations. The existing variant_get/shred_variant benchmarks don't cover it, so we should add them.

I will file the tickets to track this.

@sdf-jkl

sdf-jkl commented Sep 4, 2026

Copy link
Copy Markdown
Member

@klion26

klion26 commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

The Variant::Object value being silently dropped when formatting a Variant::List is a regression introduced by this PR, so I think it should be addressed here rather than deferred to #10982.

It's fine to merge #10982 into the current pr; I thought that you preferred to separate them. and thanks for the double confirmation.

Will take a look at this tomorrow.

@alamb

alamb commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

@sdf-jkl / @klion26 -- is this one ready to merge? I am hoping to make a release soon (like tomorrow) -- if we want this one, we should get it merged asap

@sdf-jkl

sdf-jkl commented Sep 9, 2026

Copy link
Copy Markdown
Member

is this one ready to merge?

I thought the existing benchmarks are not exhaustive enough and we should work on them first. Want to make sure we don't introduce regressions

@klion26

klion26 commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

For the benchmarks, maybe need to complete until next week, still some inner work to be done today and tomorrow.
I'll finish them asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate arrow-cast parquet-variant parquet-variant* crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Align cast logic betwee variant_get and cast kernel for utf8 type

5 participants