parquet 0.2.12 → 0.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  use crate::header_cache::StringCache;
2
+ use crate::types::{ArrayWrapper, TryIntoValue};
2
3
  use crate::{
3
4
  create_column_enumerator, utils::*, ColumnEnumeratorArgs, ColumnRecord, ForgottenFileHandle,
4
5
  ParquetValueVec, ParserResultType, SeekableRubyValue,
@@ -27,6 +28,7 @@ pub fn parse_parquet_columns<'a>(rb_self: Value, args: &[Value]) -> Result<Value
27
28
  result_type,
28
29
  columns,
29
30
  batch_size,
31
+ strict,
30
32
  } = parse_parquet_columns_args(&ruby, args)?;
31
33
 
32
34
  if !ruby.block_given() {
@@ -36,6 +38,7 @@ pub fn parse_parquet_columns<'a>(rb_self: Value, args: &[Value]) -> Result<Value
36
38
  result_type,
37
39
  columns,
38
40
  batch_size,
41
+ strict,
39
42
  })
40
43
  .map(|yield_enum| yield_enum.into_value_with(&ruby));
41
44
  }
@@ -150,7 +153,7 @@ pub fn parse_parquet_columns<'a>(rb_self: Value, args: &[Value]) -> Result<Value
150
153
  map.insert(*field, vec![]);
151
154
  }
152
155
  let record = ColumnRecord::Map(map);
153
- let _: Value = ruby.yield_value(record)?;
156
+ let _: Value = ruby.yield_value(record.try_into_value_with(&ruby)?)?;
154
157
  return Ok(ruby.qnil().into_value_with(&ruby));
155
158
  }
156
159
 
@@ -160,24 +163,37 @@ pub fn parse_parquet_columns<'a>(rb_self: Value, args: &[Value]) -> Result<Value
160
163
  let headers_clone = headers.clone();
161
164
  let iter = batch_reader.map(move |batch| {
162
165
  batch.map_err(ReaderError::Arrow).and_then(|batch| {
163
- let headers = headers_clone.get_or_init(|| {
164
- let schema = batch.schema();
165
- let fields = schema.fields();
166
- let mut header_string = Vec::with_capacity(fields.len());
167
- for field in fields {
168
- header_string.push(field.name().to_owned());
169
- }
170
- StringCache::intern_many(&header_string).unwrap()
171
- });
172
-
173
- let mut map =
174
- HashMap::with_capacity_and_hasher(headers.len(), RandomState::default());
175
-
176
- batch.columns().iter().enumerate().for_each(|(i, column)| {
177
- let header = headers[i];
178
- let values = ParquetValueVec::try_from(column.clone()).unwrap();
179
- map.insert(header, values.into_inner());
180
- });
166
+ let local_headers = headers_clone
167
+ .get_or_init(|| {
168
+ let schema = batch.schema();
169
+ let fields = schema.fields();
170
+ let mut header_string = Vec::with_capacity(fields.len());
171
+ for field in fields {
172
+ header_string.push(field.name().to_owned());
173
+ }
174
+ StringCache::intern_many(&header_string)
175
+ })
176
+ .as_ref()
177
+ .map_err(|e| ReaderError::HeaderIntern(e.clone()))?;
178
+
179
+ let mut map = HashMap::with_capacity_and_hasher(
180
+ local_headers.len(),
181
+ RandomState::default(),
182
+ );
183
+
184
+ batch
185
+ .columns()
186
+ .iter()
187
+ .enumerate()
188
+ .try_for_each(|(i, column)| {
189
+ let header = local_headers[i];
190
+ let values = ParquetValueVec::try_from(ArrayWrapper {
191
+ array: &*column,
192
+ strict: strict,
193
+ })?;
194
+ map.insert(header, values.into_inner());
195
+ Ok::<_, ReaderError>(())
196
+ })?;
181
197
 
182
198
  Ok(ColumnRecord::Map::<RandomState>(map))
183
199
  })
@@ -185,7 +201,7 @@ pub fn parse_parquet_columns<'a>(rb_self: Value, args: &[Value]) -> Result<Value
185
201
 
186
202
  for result in iter {
187
203
  let record = result?;
188
- let _: Value = ruby.yield_value(record)?;
204
+ let _: Value = ruby.yield_value(record.try_into_value_with(&ruby)?)?;
189
205
  }
190
206
  }
191
207
  ParserResultType::Array => {
@@ -195,17 +211,20 @@ pub fn parse_parquet_columns<'a>(rb_self: Value, args: &[Value]) -> Result<Value
195
211
  .columns()
196
212
  .into_iter()
197
213
  .map(|column| {
198
- let values = ParquetValueVec::try_from(column.clone()).unwrap();
199
- values.into_inner()
214
+ let values = ParquetValueVec::try_from(ArrayWrapper {
215
+ array: &*column,
216
+ strict: strict,
217
+ })?;
218
+ Ok::<_, ReaderError>(values.into_inner())
200
219
  })
201
- .collect();
220
+ .collect::<Result<Vec<_>, _>>()?;
202
221
  Ok(ColumnRecord::Vec::<RandomState>(vec))
203
222
  })
204
223
  });
205
224
 
206
225
  for result in iter {
207
226
  let record = result?;
208
- let _: Value = ruby.yield_value(record)?;
227
+ let _: Value = ruby.yield_value(record.try_into_value_with(&ruby)?)?;
209
228
  }
210
229
  }
211
230
  }
@@ -1,4 +1,5 @@
1
1
  use crate::header_cache::StringCache;
2
+ use crate::types::TryIntoValue;
2
3
  use crate::{
3
4
  create_row_enumerator, utils::*, ForgottenFileHandle, ParquetField, ParserResultType,
4
5
  ReaderError, RowEnumeratorArgs, RowRecord, SeekableRubyValue,
@@ -25,6 +26,7 @@ pub fn parse_parquet_rows<'a>(rb_self: Value, args: &[Value]) -> Result<Value, M
25
26
  to_read,
26
27
  result_type,
27
28
  columns,
29
+ strict,
28
30
  } = parse_parquet_rows_args(&ruby, args)?;
29
31
 
30
32
  if !ruby.block_given() {
@@ -33,6 +35,7 @@ pub fn parse_parquet_rows<'a>(rb_self: Value, args: &[Value]) -> Result<Value, M
33
35
  to_read,
34
36
  result_type,
35
37
  columns,
38
+ strict,
36
39
  })
37
40
  .map(|yield_enum| yield_enum.into_value_with(&ruby));
38
41
  }
@@ -102,7 +105,7 @@ pub fn parse_parquet_rows<'a>(rb_self: Value, args: &[Value]) -> Result<Value, M
102
105
  let mut map =
103
106
  HashMap::with_capacity_and_hasher(headers.len(), RandomState::default());
104
107
  row.get_column_iter().enumerate().for_each(|(i, (_, v))| {
105
- map.insert(headers[i], ParquetField(v.clone()));
108
+ map.insert(headers[i], ParquetField(v.clone(), strict));
106
109
  });
107
110
  Ok(map)
108
111
  })
@@ -112,7 +115,7 @@ pub fn parse_parquet_rows<'a>(rb_self: Value, args: &[Value]) -> Result<Value, M
112
115
 
113
116
  for result in iter {
114
117
  let record = result?;
115
- let _: Value = ruby.yield_value(record)?;
118
+ let _: Value = ruby.yield_value(record.try_into_value_with(&ruby)?)?;
116
119
  }
117
120
  }
118
121
  ParserResultType::Array => {
@@ -121,7 +124,7 @@ pub fn parse_parquet_rows<'a>(rb_self: Value, args: &[Value]) -> Result<Value, M
121
124
  let column_count = row.get_column_iter().count();
122
125
  let mut vec = Vec::with_capacity(column_count);
123
126
  row.get_column_iter()
124
- .for_each(|(_, v)| vec.push(ParquetField(v.clone())));
127
+ .for_each(|(_, v)| vec.push(ParquetField(v.clone(), strict)));
125
128
  Ok(vec)
126
129
  })
127
130
  .and_then(|row| Ok(RowRecord::Vec::<RandomState>(row)))
@@ -130,7 +133,7 @@ pub fn parse_parquet_rows<'a>(rb_self: Value, args: &[Value]) -> Result<Value, M
130
133
 
131
134
  for result in iter {
132
135
  let record = result?;
133
- let _: Value = ruby.yield_value(record)?;
136
+ let _: Value = ruby.yield_value(record.try_into_value_with(&ruby)?)?;
134
137
  }
135
138
  }
136
139
  }
@@ -1,4 +1,7 @@
1
- use crate::{impl_date_conversion, impl_timestamp_array_conversion, impl_timestamp_conversion};
1
+ use crate::{
2
+ impl_date_conversion, impl_timestamp_array_conversion, impl_timestamp_conversion,
3
+ reader::ReaderError,
4
+ };
2
5
 
3
6
  use super::*;
4
7
 
@@ -103,23 +106,23 @@ impl std::hash::Hash for ParquetValue {
103
106
  }
104
107
  }
105
108
 
106
- impl IntoValue for ParquetValue {
107
- fn into_value_with(self, handle: &Ruby) -> Value {
109
+ impl TryIntoValue for ParquetValue {
110
+ fn try_into_value_with(self, handle: &Ruby) -> Result<Value, ReaderError> {
108
111
  match self {
109
- ParquetValue::Int8(i) => i.into_value_with(handle),
110
- ParquetValue::Int16(i) => i.into_value_with(handle),
111
- ParquetValue::Int32(i) => i.into_value_with(handle),
112
- ParquetValue::Int64(i) => i.into_value_with(handle),
113
- ParquetValue::UInt8(i) => i.into_value_with(handle),
114
- ParquetValue::UInt16(i) => i.into_value_with(handle),
115
- ParquetValue::UInt32(i) => i.into_value_with(handle),
116
- ParquetValue::UInt64(i) => i.into_value_with(handle),
117
- ParquetValue::Float16(f) => f.into_value_with(handle),
118
- ParquetValue::Float32(f) => f.into_value_with(handle),
119
- ParquetValue::Float64(f) => f.into_value_with(handle),
120
- ParquetValue::Boolean(b) => b.into_value_with(handle),
121
- ParquetValue::String(s) => s.into_value_with(handle),
122
- ParquetValue::Bytes(b) => handle.str_from_slice(&b).as_value(),
112
+ ParquetValue::Int8(i) => Ok(i.into_value_with(handle)),
113
+ ParquetValue::Int16(i) => Ok(i.into_value_with(handle)),
114
+ ParquetValue::Int32(i) => Ok(i.into_value_with(handle)),
115
+ ParquetValue::Int64(i) => Ok(i.into_value_with(handle)),
116
+ ParquetValue::UInt8(i) => Ok(i.into_value_with(handle)),
117
+ ParquetValue::UInt16(i) => Ok(i.into_value_with(handle)),
118
+ ParquetValue::UInt32(i) => Ok(i.into_value_with(handle)),
119
+ ParquetValue::UInt64(i) => Ok(i.into_value_with(handle)),
120
+ ParquetValue::Float16(f) => Ok(f.into_value_with(handle)),
121
+ ParquetValue::Float32(f) => Ok(f.into_value_with(handle)),
122
+ ParquetValue::Float64(f) => Ok(f.into_value_with(handle)),
123
+ ParquetValue::Boolean(b) => Ok(b.into_value_with(handle)),
124
+ ParquetValue::String(s) => Ok(s.into_value_with(handle)),
125
+ ParquetValue::Bytes(b) => Ok(handle.str_from_slice(&b).as_value()),
123
126
  ParquetValue::Date32(d) => impl_date_conversion!(d, handle),
124
127
  ParquetValue::Date64(d) => impl_date_conversion!(d, handle),
125
128
  timestamp @ ParquetValue::TimestampSecond(_, _) => {
@@ -136,21 +139,23 @@ impl IntoValue for ParquetValue {
136
139
  }
137
140
  ParquetValue::List(l) => {
138
141
  let ary = handle.ary_new_capa(l.len());
139
- l.into_iter()
140
- .try_for_each(|v| ary.push(v.into_value_with(handle)))
141
- .unwrap();
142
- ary.into_value_with(handle)
142
+ l.into_iter().try_for_each(|v| {
143
+ ary.push(v.try_into_value_with(handle)?)?;
144
+ Ok::<_, ReaderError>(())
145
+ })?;
146
+ Ok(ary.into_value_with(handle))
143
147
  }
144
148
  ParquetValue::Map(m) => {
145
149
  let hash = handle.hash_new_capa(m.len());
146
- m.into_iter()
147
- .try_for_each(|(k, v)| {
148
- hash.aset(k.into_value_with(handle), v.into_value_with(handle))
149
- })
150
- .unwrap();
151
- hash.into_value_with(handle)
152
- }
153
- ParquetValue::Null => handle.qnil().as_value(),
150
+ m.into_iter().try_for_each(|(k, v)| {
151
+ hash.aset(
152
+ k.try_into_value_with(handle)?,
153
+ v.try_into_value_with(handle)?,
154
+ )
155
+ })?;
156
+ Ok(hash.into_value_with(handle))
157
+ }
158
+ ParquetValue::Null => Ok(handle.qnil().as_value()),
154
159
  }
155
160
  }
156
161
  }
@@ -260,18 +265,10 @@ impl std::cmp::PartialEq for ParquetValueVec {
260
265
 
261
266
  impl std::cmp::Eq for ParquetValueVec {}
262
267
 
263
- impl TryFrom<Arc<dyn Array>> for ParquetValueVec {
264
- type Error = String;
265
-
266
- fn try_from(column: Arc<dyn Array>) -> Result<Self, Self::Error> {
267
- ParquetValueVec::try_from(&*column)
268
- }
269
- }
270
-
271
268
  macro_rules! impl_numeric_array_conversion {
272
269
  ($column:expr, $array_type:ty, $variant:ident) => {{
273
270
  let array = downcast_array::<$array_type>($column);
274
- if array.is_nullable() {
271
+ Ok(ParquetValueVec(if array.is_nullable() {
275
272
  array
276
273
  .values()
277
274
  .iter()
@@ -290,13 +287,13 @@ macro_rules! impl_numeric_array_conversion {
290
287
  .iter()
291
288
  .map(|x| ParquetValue::$variant(*x))
292
289
  .collect()
293
- }
290
+ }))
294
291
  }};
295
292
  }
296
293
  macro_rules! impl_boolean_array_conversion {
297
294
  ($column:expr, $array_type:ty, $variant:ident) => {{
298
295
  let array = downcast_array::<$array_type>($column);
299
- if array.is_nullable() {
296
+ Ok(ParquetValueVec(if array.is_nullable() {
300
297
  array
301
298
  .values()
302
299
  .iter()
@@ -315,34 +312,50 @@ macro_rules! impl_boolean_array_conversion {
315
312
  .iter()
316
313
  .map(|x| ParquetValue::$variant(x))
317
314
  .collect()
318
- }
315
+ }))
319
316
  }};
320
317
  }
321
318
 
322
- impl TryFrom<&dyn Array> for ParquetValueVec {
323
- type Error = String;
319
+ pub struct ArrayWrapper<'a> {
320
+ pub array: &'a dyn Array,
321
+ pub strict: bool,
322
+ }
323
+
324
+ impl<'a> TryFrom<ArrayWrapper<'a>> for ParquetValueVec {
325
+ type Error = ReaderError;
324
326
 
325
- fn try_from(column: &dyn Array) -> Result<Self, Self::Error> {
326
- let tmp_vec = match column.data_type() {
327
- DataType::Boolean => impl_boolean_array_conversion!(column, BooleanArray, Boolean),
328
- DataType::Int8 => impl_numeric_array_conversion!(column, Int8Array, Int8),
329
- DataType::Int16 => impl_numeric_array_conversion!(column, Int16Array, Int16),
330
- DataType::Int32 => impl_numeric_array_conversion!(column, Int32Array, Int32),
331
- DataType::Int64 => impl_numeric_array_conversion!(column, Int64Array, Int64),
332
- DataType::UInt8 => impl_numeric_array_conversion!(column, UInt8Array, UInt8),
333
- DataType::UInt16 => impl_numeric_array_conversion!(column, UInt16Array, UInt16),
334
- DataType::UInt32 => impl_numeric_array_conversion!(column, UInt32Array, UInt32),
335
- DataType::UInt64 => impl_numeric_array_conversion!(column, UInt64Array, UInt64),
336
- DataType::Float32 => impl_numeric_array_conversion!(column, Float32Array, Float32),
337
- DataType::Float64 => impl_numeric_array_conversion!(column, Float64Array, Float64),
338
- DataType::Date32 => impl_numeric_array_conversion!(column, Date32Array, Date32),
339
- DataType::Date64 => impl_numeric_array_conversion!(column, Date64Array, Date64),
327
+ fn try_from(column: ArrayWrapper<'a>) -> Result<Self, Self::Error> {
328
+ match column.array.data_type() {
329
+ DataType::Boolean => {
330
+ impl_boolean_array_conversion!(column.array, BooleanArray, Boolean)
331
+ }
332
+ DataType::Int8 => impl_numeric_array_conversion!(column.array, Int8Array, Int8),
333
+ DataType::Int16 => impl_numeric_array_conversion!(column.array, Int16Array, Int16),
334
+ DataType::Int32 => impl_numeric_array_conversion!(column.array, Int32Array, Int32),
335
+ DataType::Int64 => impl_numeric_array_conversion!(column.array, Int64Array, Int64),
336
+ DataType::UInt8 => impl_numeric_array_conversion!(column.array, UInt8Array, UInt8),
337
+ DataType::UInt16 => impl_numeric_array_conversion!(column.array, UInt16Array, UInt16),
338
+ DataType::UInt32 => impl_numeric_array_conversion!(column.array, UInt32Array, UInt32),
339
+ DataType::UInt64 => impl_numeric_array_conversion!(column.array, UInt64Array, UInt64),
340
+ DataType::Float32 => {
341
+ impl_numeric_array_conversion!(column.array, Float32Array, Float32)
342
+ }
343
+ DataType::Float64 => {
344
+ impl_numeric_array_conversion!(column.array, Float64Array, Float64)
345
+ }
346
+ DataType::Date32 => impl_numeric_array_conversion!(column.array, Date32Array, Date32),
347
+ DataType::Date64 => impl_numeric_array_conversion!(column.array, Date64Array, Date64),
340
348
  DataType::Timestamp(TimeUnit::Second, tz) => {
341
- impl_timestamp_array_conversion!(column, TimestampSecondArray, TimestampSecond, tz)
349
+ impl_timestamp_array_conversion!(
350
+ column.array,
351
+ TimestampSecondArray,
352
+ TimestampSecond,
353
+ tz
354
+ )
342
355
  }
343
356
  DataType::Timestamp(TimeUnit::Millisecond, tz) => {
344
357
  impl_timestamp_array_conversion!(
345
- column,
358
+ column.array,
346
359
  TimestampMillisecondArray,
347
360
  TimestampMillis,
348
361
  tz
@@ -350,7 +363,7 @@ impl TryFrom<&dyn Array> for ParquetValueVec {
350
363
  }
351
364
  DataType::Timestamp(TimeUnit::Microsecond, tz) => {
352
365
  impl_timestamp_array_conversion!(
353
- column,
366
+ column.array,
354
367
  TimestampMicrosecondArray,
355
368
  TimestampMicros,
356
369
  tz
@@ -358,72 +371,93 @@ impl TryFrom<&dyn Array> for ParquetValueVec {
358
371
  }
359
372
  DataType::Timestamp(TimeUnit::Nanosecond, tz) => {
360
373
  impl_timestamp_array_conversion!(
361
- column,
374
+ column.array,
362
375
  TimestampNanosecondArray,
363
376
  TimestampNanos,
364
377
  tz
365
378
  )
366
379
  }
367
380
  DataType::Float16 => {
368
- let array = downcast_array::<Float16Array>(column);
381
+ let array = downcast_array::<Float16Array>(column.array);
369
382
  if array.is_nullable() {
370
- array
371
- .values()
372
- .iter()
373
- .enumerate()
374
- .map(|(i, x)| {
375
- if array.is_null(i) {
376
- ParquetValue::Null
377
- } else {
378
- ParquetValue::Float16(f32::from(*x))
379
- }
380
- })
381
- .collect()
383
+ Ok(ParquetValueVec(
384
+ array
385
+ .values()
386
+ .iter()
387
+ .enumerate()
388
+ .map(|(i, x)| {
389
+ if array.is_null(i) {
390
+ ParquetValue::Null
391
+ } else {
392
+ ParquetValue::Float16(f32::from(*x))
393
+ }
394
+ })
395
+ .collect(),
396
+ ))
382
397
  } else {
383
- array
384
- .values()
385
- .iter()
386
- .map(|x| ParquetValue::Float16(f32::from(*x)))
387
- .collect()
398
+ Ok(ParquetValueVec(
399
+ array
400
+ .values()
401
+ .iter()
402
+ .map(|x| ParquetValue::Float16(f32::from(*x)))
403
+ .collect(),
404
+ ))
388
405
  }
389
406
  }
390
407
  DataType::Utf8 => {
391
- let array = downcast_array::<StringArray>(column);
392
- array
393
- .iter()
394
- .map(|opt_x| match opt_x {
395
- Some(x) => ParquetValue::String(x.to_string()),
396
- None => ParquetValue::Null,
397
- })
398
- .collect()
408
+ let array = downcast_array::<StringArray>(column.array);
409
+ let mut tmp_vec = Vec::with_capacity(array.len());
410
+ let iter = array.iter().map(|opt_x| match opt_x {
411
+ Some(x) => {
412
+ if column.strict {
413
+ Ok::<_, ReaderError>(ParquetValue::String(
414
+ simdutf8::basic::from_utf8(x.as_bytes())?.to_string(),
415
+ ))
416
+ } else {
417
+ Ok::<_, ReaderError>(ParquetValue::String(x.to_string()))
418
+ }
419
+ }
420
+ None => Ok(ParquetValue::Null),
421
+ });
422
+ for x in iter {
423
+ tmp_vec.push(x?);
424
+ }
425
+ Ok(ParquetValueVec(tmp_vec))
399
426
  }
400
427
  DataType::Binary => {
401
- let array = downcast_array::<BinaryArray>(column);
402
- array
403
- .iter()
404
- .map(|opt_x| match opt_x {
405
- Some(x) => ParquetValue::Bytes(x.to_vec()),
406
- None => ParquetValue::Null,
407
- })
408
- .collect()
428
+ let array = downcast_array::<BinaryArray>(column.array);
429
+ Ok(ParquetValueVec(
430
+ array
431
+ .iter()
432
+ .map(|opt_x| match opt_x {
433
+ Some(x) => ParquetValue::Bytes(x.to_vec()),
434
+ None => ParquetValue::Null,
435
+ })
436
+ .collect(),
437
+ ))
409
438
  }
410
439
  DataType::List(_field) => {
411
- let list_array = downcast_array::<ListArray>(column);
412
- list_array
413
- .iter()
414
- .map(|x| match x {
415
- Some(values) => match ParquetValueVec::try_from(values) {
416
- Ok(vec) => ParquetValue::List(vec.into_inner()),
417
- Err(e) => {
418
- panic!("Error converting list array to ParquetValueVec: {}", e)
419
- }
420
- },
421
- None => ParquetValue::Null,
422
- })
423
- .collect()
440
+ let list_array = downcast_array::<ListArray>(column.array);
441
+ Ok(ParquetValueVec(
442
+ list_array
443
+ .iter()
444
+ .map(|x| match x {
445
+ Some(values) => match ParquetValueVec::try_from(ArrayWrapper {
446
+ array: &*values,
447
+ strict: column.strict,
448
+ }) {
449
+ Ok(vec) => ParquetValue::List(vec.into_inner()),
450
+ Err(e) => {
451
+ panic!("Error converting list array to ParquetValueVec: {}", e)
452
+ }
453
+ },
454
+ None => ParquetValue::Null,
455
+ })
456
+ .collect(),
457
+ ))
424
458
  }
425
459
  DataType::Struct(_) => {
426
- let struct_array = downcast_array::<StructArray>(column);
460
+ let struct_array = downcast_array::<StructArray>(column.array);
427
461
  let mut values = Vec::with_capacity(struct_array.len());
428
462
  for i in 0..struct_array.len() {
429
463
  if struct_array.is_null(i) {
@@ -433,8 +467,11 @@ impl TryFrom<&dyn Array> for ParquetValueVec {
433
467
 
434
468
  let mut map = std::collections::HashMap::new();
435
469
  for (field_idx, field) in struct_array.fields().iter().enumerate() {
436
- let column = struct_array.column(field_idx);
437
- let field_values = match ParquetValueVec::try_from(column.slice(i, 1)) {
470
+ let c = struct_array.column(field_idx);
471
+ let field_values = match ParquetValueVec::try_from(ArrayWrapper {
472
+ array: &*c.slice(i, 1),
473
+ strict: column.strict,
474
+ }) {
438
475
  Ok(vec) => vec.into_inner(),
439
476
  Err(e) => {
440
477
  panic!("Error converting struct field to ParquetValueVec: {}", e)
@@ -447,16 +484,18 @@ impl TryFrom<&dyn Array> for ParquetValueVec {
447
484
  }
448
485
  values.push(ParquetValue::Map(map));
449
486
  }
450
- values
487
+ Ok(ParquetValueVec(values))
451
488
  }
452
489
  DataType::Null => {
453
- let x = downcast_array::<NullArray>(column);
454
- vec![ParquetValue::Null; x.len()]
490
+ let x = downcast_array::<NullArray>(column.array);
491
+ Ok(ParquetValueVec(vec![ParquetValue::Null; x.len()]))
455
492
  }
456
493
  _ => {
457
- return Err(format!("Unsupported data type: {:?}", column.data_type()));
494
+ return Err(ReaderError::Ruby(format!(
495
+ "Unsupported data type: {:?}",
496
+ column.array.data_type()
497
+ )));
458
498
  }
459
- };
460
- Ok(ParquetValueVec(tmp_vec))
499
+ }
461
500
  }
462
501
  }