MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / csv_extract

Function csv_extract

src/expr/src/relation/func.rs:3438–3451  ·  view source on GitHub ↗
(a: Datum<'_>, n_cols: usize)

Source from the content-addressed store, hash-verified

3436}
3437
3438pub fn csv_extract(a: Datum<'_>, n_cols: usize) -> impl Iterator<Item = (Row, Diff)> + '_ {
3439 let bytes = a.unwrap_str().as_bytes();
3440 let mut row = Row::default();
3441 let csv_reader = csv::ReaderBuilder::new()
3442 .has_headers(false)
3443 .from_reader(bytes);
3444 csv_reader.into_records().filter_map(move |res| match res {
3445 Ok(sr) if sr.len() == n_cols => {
3446 row.packer().extend(sr.iter().map(Datum::String));
3447 Some((row.clone(), Diff::ONE))
3448 }
3449 _ => None,
3450 })
3451}
3452
3453pub fn repeat_row(a: Datum) -> Option<(Row, Diff)> {
3454 let n = a.unwrap_int64();

Callers 1

evalMethod · 0.85

Calls 9

unwrap_strMethod · 0.80
from_readerMethod · 0.80
packerMethod · 0.80
as_bytesMethod · 0.45
lenMethod · 0.45
extendMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected