parquet 0.4.2 → 0.5.0
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 +4 -4
- data/Cargo.lock +66 -59
- data/README.md +105 -1
- data/ext/parquet/Cargo.toml +4 -3
- data/ext/parquet/src/enumerator.rs +8 -0
- data/ext/parquet/src/header_cache.rs +7 -3
- data/ext/parquet/src/lib.rs +1 -0
- data/ext/parquet/src/logger.rs +171 -0
- data/ext/parquet/src/reader/common.rs +113 -0
- data/ext/parquet/src/reader/mod.rs +27 -13
- data/ext/parquet/src/reader/parquet_column_reader.rs +38 -78
- data/ext/parquet/src/reader/parquet_row_reader.rs +42 -19
- data/ext/parquet/src/types/core_types.rs +57 -1
- data/ext/parquet/src/types/mod.rs +8 -1
- data/ext/parquet/src/types/parquet_value.rs +211 -35
- data/ext/parquet/src/types/record_types.rs +18 -15
- data/ext/parquet/src/types/schema_converter.rs +349 -0
- data/ext/parquet/src/types/schema_node.rs +329 -0
- data/ext/parquet/src/types/timestamp.rs +18 -8
- data/ext/parquet/src/types/type_conversion.rs +1106 -511
- data/ext/parquet/src/types/writer_types.rs +78 -107
- data/ext/parquet/src/utils.rs +29 -9
- data/ext/parquet/src/writer/mod.rs +828 -280
- data/lib/parquet/schema.rb +154 -0
- data/lib/parquet/version.rb +1 -1
- data/lib/parquet.rb +1 -0
- metadata +7 -2
@@ -1,6 +1,8 @@
|
|
1
|
+
use crate::reader::ReaderError;
|
2
|
+
|
1
3
|
use super::*;
|
2
4
|
|
3
|
-
pub fn parse_zoned_timestamp(value: &ParquetValue) -> jiff::Timestamp {
|
5
|
+
pub fn parse_zoned_timestamp(value: &ParquetValue) -> Result<jiff::Timestamp, ReaderError> {
|
4
6
|
let (ts, tz) = match value {
|
5
7
|
ParquetValue::TimestampSecond(ts, tz) => (jiff::Timestamp::from_second(*ts).unwrap(), tz),
|
6
8
|
ParquetValue::TimestampMillis(ts, tz) => {
|
@@ -12,7 +14,12 @@ pub fn parse_zoned_timestamp(value: &ParquetValue) -> jiff::Timestamp {
|
|
12
14
|
ParquetValue::TimestampNanos(ts, tz) => {
|
13
15
|
(jiff::Timestamp::from_nanosecond(*ts as i128).unwrap(), tz)
|
14
16
|
}
|
15
|
-
_ =>
|
17
|
+
_ => {
|
18
|
+
return Err(MagnusError::new(
|
19
|
+
magnus::exception::type_error(),
|
20
|
+
"Invalid timestamp value".to_string(),
|
21
|
+
))?
|
22
|
+
}
|
16
23
|
};
|
17
24
|
|
18
25
|
// If timezone is provided, convert to zoned timestamp
|
@@ -42,17 +49,17 @@ pub fn parse_zoned_timestamp(value: &ParquetValue) -> jiff::Timestamp {
|
|
42
49
|
|
43
50
|
// Create fixed timezone
|
44
51
|
let tz = jiff::tz::TimeZone::fixed(jiff::tz::offset((total_minutes / 60) as i8));
|
45
|
-
ts.to_zoned(tz).timestamp()
|
52
|
+
Ok(ts.to_zoned(tz).timestamp())
|
46
53
|
} else {
|
47
54
|
// Try IANA timezone
|
48
55
|
match ts.in_tz(&tz) {
|
49
|
-
Ok(zoned) => zoned.timestamp(),
|
50
|
-
Err(_) => ts, // Fall back to UTC if timezone is invalid
|
56
|
+
Ok(zoned) => Ok(zoned.timestamp()),
|
57
|
+
Err(_) => Ok(ts), // Fall back to UTC if timezone is invalid
|
51
58
|
}
|
52
59
|
}
|
53
60
|
} else {
|
54
61
|
// No timezone provided - treat as UTC
|
55
|
-
ts
|
62
|
+
Ok(ts)
|
56
63
|
}
|
57
64
|
}
|
58
65
|
|
@@ -62,13 +69,16 @@ macro_rules! impl_timestamp_conversion {
|
|
62
69
|
($value:expr, $unit:ident, $handle:expr) => {{
|
63
70
|
match $value {
|
64
71
|
ParquetValue::$unit(ts, tz) => {
|
65
|
-
let ts = parse_zoned_timestamp(&ParquetValue::$unit(ts, tz))
|
72
|
+
let ts = parse_zoned_timestamp(&ParquetValue::$unit(ts, tz))?;
|
66
73
|
let time_class = $handle.class_time();
|
67
74
|
Ok(time_class
|
68
75
|
.funcall::<_, _, Value>("parse", (ts.to_string(),))?
|
69
76
|
.into_value_with($handle))
|
70
77
|
}
|
71
|
-
_ =>
|
78
|
+
_ => Err(ReaderError::Ruby(MagnusErrorWrapper(MagnusError::new(
|
79
|
+
magnus::exception::type_error(),
|
80
|
+
"Invalid timestamp type".to_string(),
|
81
|
+
)))),
|
72
82
|
}
|
73
83
|
}};
|
74
84
|
}
|