[Variant] `variant_get` string and binary cast errors show Rust builder type names
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
- #12280 di @Subodh-17 — chiusa senza merge
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 61/100
Direzione di ricerca
Leggi parquet-variant-compute/src/variant_to_arrow.rs, in particolare i rami per stringhe e dati binari di define_variant_to_primitive_builder! intorno alle righe collegate nell’issue. Confronta come questi rami formattano gli errori di conversione con gli altri rami. Il lavoro è completato quando gli errori per Utf8, LargeUtf8, Utf8View, Binary, LargeBinary e BinaryView indicano il tipo di dati Arrow richiesto e i test confermano i nomi previsti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
When variant_get cannot convert a value to a string or binary type, the error names the Rust builder type instead of the Arrow data type. Other targets name the data type, such as Int32.
This affects Utf8, LargeUtf8, Utf8View, Binary, LargeBinary, and BinaryView. Reported downstream in datafusion-contrib/datafusion-variant#173, where SELECT parse_json('{"status":200}'):status::VARCHAR shows this message to SQL users.
To Reproduce
Reproduced with arrow, parquet-variant, and parquet-variant-compute 60.1.0:
use std::sync::Arc;
use arrow::array::{ArrayRef, StringArray};
use arrow::compute::CastOptions;
use arrow::datatypes::{DataType, Field};
use parquet_variant::VariantPath;
use parquet_variant_compute::{GetOptions, json_to_variant, variant_get};
fn get_error(json: &str, data_type: DataType) -> String {
let input: ArrayRef = Arc::new(StringArray::from(vec![json]));
let variant = ArrayRef::from(json_to_variant(&input).unwrap());
let options = GetOptions::new_with_path(VariantPath::try_from("status").unwrap())
.with_as_type(Some(Arc::new(Field::new("result", data_type, true))))
.with_cast_options(CastOptions {
safe: false,
..Default::default()
});
variant_get(&variant, options).unwrap_err().to_string()
}
fn main() {
println!("{}", get_error(r#"{"status":"n/a"}"#, DataType::Int32));
println!("{}", get_error(r#"{"status":200}"#, DataType::Utf8));
println!("{}", get_error(r#"{"status":200}"#, DataType::Utf8View));
println!("{}", get_error(r#"{"status":200}"#, DataType::Binary));
}
Output:
Cast error: Failed to extract primitive of type Int32 from variant ShortString(ShortString("n/a")) at path VariantPath([])
Cast error: Failed to extract primitive of type arrow_array::builder::generic_bytes_builder::GenericByteBuilder<arrow_array::types::GenericStringType<i32>> from variant Int16(200) at path VariantPath([])
Cast error: Failed to extract primitive of type arrow_array::builder::generic_bytes_view_builder::GenericByteViewBuilder<arrow_array::types::StringViewType> from variant Int16(200) at path VariantPath([])
Cast error: Failed to extract primitive of type arrow_array::builder::generic_bytes_builder::GenericByteBuilder<arrow_array::types::GenericBinaryType<i32>> from variant Int16(200) at path VariantPath([])
Expected behavior
The error names the requested Arrow type, as it does for Int32. For example, Utf8, Utf8View, and Binary for the last three lines above.
Additional context
The string and binary arms of define_variant_to_primitive_builder! pass B::type_name() into the message, while the other arms pass an Arrow DataType. StringLikeArrayBuilder::type_name and BinaryLikeArrayBuilder::type_name are documented as human-readable, but every implementation returns std::any::type_name. These two arms are their only callers. The code is unchanged on main at b2b7d47051.
#10651 tracks the other parts of this message: the hardcoded VariantPath([]) and the Debug formatting of the value. Whether a numeric variant should convert to a string at all is a separate question.
Willingness to contribute
I plan to contribute a fix for this bug independently
- Lingua principale
- Rust
- Stelle
- 3.7k
- Fork
- 1.5k
- Merge medio
- 2g 16h
- PR unite (30g)
- 183
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/arrow-rs
-
parquet: `ArrowWriter::try_new` panics on a schema with a Union field instead of returning an errorAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
`RunArray::try_new` rejects run ends whose null buffer has no nullsForse già presa @Surajsuthar l’ha presa 2 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
apache/arrow-rs#12427 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
parquet: GZip/Brotli page decompression is not bounded by the page's uncompressed sizeForse già presa @Subodh-17 l’ha presa 11 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di apache/arrow-rs
Issue simili
-
area:ui effort:medium enhancement P7 source:agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
marketing
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
machine rename accepts a label already used by another machine, making --machine <label> ambiguousApertamaintainer-needed p2 remote triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
bug help wanted ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
userFRM/egui-charts#4605 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno