parquet 0.2.5 → 0.2.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90e876ca198a0e1871f692a382f09ceaeec670d162da26f2c102ea4eca4244bf
4
- data.tar.gz: 96743e260cbd2fb55f6cdeaf256fbb1e915c57651fdc3f20fdd58b6a34596544
3
+ metadata.gz: 794d11142b73d13b665ecdb4ffd46df6ab7d97e5f99336e2bc91b79dbb55a514
4
+ data.tar.gz: eb2843d724e7aad70445a8b992a527e3bee0a79055fdeab7f2ebd2cdfb6247d6
5
5
  SHA512:
6
- metadata.gz: 1609a37c5a9bd9f1d57bb31dd02b2fdb5b608a7c044686e6ef2513c95e53e830bd7bf7048a36904465a32a5915425c7b6bf581c5b35a4fb19f950cbca20913b2
7
- data.tar.gz: 96ec18377fc5944556760329c126f440de61d3b378bfa976a66437db03f0a51220c880afd14098a5b1968daa968d2e836c50f83bef21507789ba4df314c48148
6
+ metadata.gz: 8b97550fb18f2ab4db0b5fbb170d12448237665d9372242d4027760f1c697be0d1e7a8bb47d43886f704e0923ddf57544961fe5af29c596b49aac188f714b9e6
7
+ data.tar.gz: 1ea56a23e39a084d40690d4e7bd108ec2a4cb20b61714bd564e68600d3f3edda3ffd5c3e646d49d4bb85632ad14f2c7d5735e645610e7a863d9e25d6f1d2b90d
@@ -157,6 +157,10 @@ impl IntoValue for ParquetValue {
157
157
 
158
158
  impl ParquetValue {
159
159
  pub fn from_value(value: Value, type_: &ParquetSchemaType) -> Result<Self, MagnusError> {
160
+ if value.is_nil() {
161
+ return Ok(ParquetValue::Null);
162
+ }
163
+
160
164
  match type_ {
161
165
  ParquetSchemaType::Int8 => {
162
166
  let v = NumericConverter::<i8>::convert_with_string_fallback(value)?;
@@ -592,12 +592,12 @@ pub fn convert_parquet_values_to_arrow(
592
592
  };
593
593
 
594
594
  let mut list_builder = ListBuilder::new(value_builder);
595
+
595
596
  for value in values {
596
597
  match value {
597
598
  ParquetValue::List(items) => {
598
- list_builder.append(true);
599
599
  for item in items {
600
- match list_field.item_type {
600
+ match &list_field.item_type {
601
601
  ParquetSchemaType::Int8 => append_list_value_copy!(
602
602
  list_builder,
603
603
  ParquetSchemaType::Int8,
@@ -185,6 +185,11 @@ impl ColumnCollector {
185
185
  NumericConverter,
186
186
  };
187
187
 
188
+ if value.is_nil() {
189
+ self.values.push(ParquetValue::Null);
190
+ return Ok(());
191
+ }
192
+
188
193
  let parquet_value = match &self.type_ {
189
194
  ParquetSchemaType::Int8 => {
190
195
  let v = NumericConverter::<i8>::convert_with_string_fallback(value)?;
@@ -39,7 +39,7 @@ pub fn parse_parquet_rows_args(ruby: &Ruby, args: &[Value]) -> Result<ParquetRow
39
39
  let parsed_args = scan_args::<(Value,), (), (), (), _, ()>(args)?;
40
40
  let (to_read,) = parsed_args.required;
41
41
 
42
- let kwargs = get_kwargs::<_, (), (Option<Value>, Option<Vec<String>>), ()>(
42
+ let kwargs = get_kwargs::<_, (), (Option<Option<Value>>, Option<Option<Vec<String>>>), ()>(
43
43
  parsed_args.keywords,
44
44
  &[],
45
45
  &["result_type", "columns"],
@@ -48,6 +48,7 @@ pub fn parse_parquet_rows_args(ruby: &Ruby, args: &[Value]) -> Result<ParquetRow
48
48
  let result_type: ParserResultType = match kwargs
49
49
  .optional
50
50
  .0
51
+ .flatten()
51
52
  .map(|value| parse_string_or_symbol(ruby, value))
52
53
  {
53
54
  Some(Ok(Some(parsed))) => parsed.try_into().map_err(|e| {
@@ -75,7 +76,7 @@ pub fn parse_parquet_rows_args(ruby: &Ruby, args: &[Value]) -> Result<ParquetRow
75
76
  Ok(ParquetRowsArgs {
76
77
  to_read,
77
78
  result_type,
78
- columns: kwargs.optional.1,
79
+ columns: kwargs.optional.1.flatten(),
79
80
  })
80
81
  }
81
82
 
@@ -95,7 +96,16 @@ pub fn parse_parquet_columns_args(
95
96
  let parsed_args = scan_args::<(Value,), (), (), (), _, ()>(args)?;
96
97
  let (to_read,) = parsed_args.required;
97
98
 
98
- let kwargs = get_kwargs::<_, (), (Option<Value>, Option<Vec<String>>, Option<usize>), ()>(
99
+ let kwargs = get_kwargs::<
100
+ _,
101
+ (),
102
+ (
103
+ Option<Option<Value>>,
104
+ Option<Option<Vec<String>>>,
105
+ Option<Option<usize>>,
106
+ ),
107
+ (),
108
+ >(
99
109
  parsed_args.keywords,
100
110
  &[],
101
111
  &["result_type", "columns", "batch_size"],
@@ -104,6 +114,7 @@ pub fn parse_parquet_columns_args(
104
114
  let result_type: ParserResultType = match kwargs
105
115
  .optional
106
116
  .0
117
+ .flatten()
107
118
  .map(|value| parse_string_or_symbol(ruby, value))
108
119
  {
109
120
  Some(Ok(Some(parsed))) => parsed.try_into().map_err(|e| {
@@ -131,7 +142,7 @@ pub fn parse_parquet_columns_args(
131
142
  Ok(ParquetColumnsArgs {
132
143
  to_read,
133
144
  result_type,
134
- columns: kwargs.optional.1,
135
- batch_size: kwargs.optional.2,
145
+ columns: kwargs.optional.1.flatten(),
146
+ batch_size: kwargs.optional.2.flatten(),
136
147
  })
137
148
  }
@@ -28,7 +28,7 @@ pub fn parse_parquet_write_args(args: &[Value]) -> Result<ParquetWriteArgs, Magn
28
28
  let parsed_args = scan_args::<(Value,), (), (), (), _, ()>(args)?;
29
29
  let (read_from,) = parsed_args.required;
30
30
 
31
- let kwargs = get_kwargs::<_, (Value, Value), (Option<usize>,), ()>(
31
+ let kwargs = get_kwargs::<_, (Value, Value), (Option<Option<usize>>,), ()>(
32
32
  parsed_args.keywords,
33
33
  &["schema", "write_to"],
34
34
  &["batch_size"],
@@ -70,7 +70,7 @@ pub fn parse_parquet_write_args(args: &[Value]) -> Result<ParquetWriteArgs, Magn
70
70
  read_from,
71
71
  write_to: kwargs.required.1,
72
72
  schema,
73
- batch_size: kwargs.optional.0,
73
+ batch_size: kwargs.optional.0.flatten(),
74
74
  })
75
75
  }
76
76
 
@@ -1,3 +1,3 @@
1
1
  module Parquet
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parquet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Jaremko