Skip to content

Commit edd9b70

Browse files
committed
Remove primitive map key assertion on record reader
1 parent 2b40d1d commit edd9b70

File tree

1 file changed

+94
-5
lines changed

1 file changed

+94
-5
lines changed

parquet/src/record/reader.rs

Lines changed: 94 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,6 @@ impl TreeBuilder {
230230
path.push(String::from(key_value_type.name()));
231231

232232
let key_type = &key_value_type.get_fields()[0];
233-
assert!(
234-
key_type.is_primitive(),
235-
"Map key type is expected to be a primitive type, but found {key_type:?}"
236-
);
237233
let key_reader = self.reader_tree(
238234
key_type.clone(),
239235
path,
@@ -840,7 +836,7 @@ impl Iterator for ReaderIter {
840836
mod tests {
841837
use super::*;
842838

843-
use crate::data_type::Int64Type;
839+
use crate::data_type::{ByteArray, Decimal, Int64Type};
844840
use crate::file::reader::SerializedFileReader;
845841
use crate::file::writer::SerializedFileWriter;
846842
use crate::record::api::RowAccessor;
@@ -1259,6 +1255,99 @@ mod tests {
12591255
assert_eq!(rows, expected_rows);
12601256
}
12611257

1258+
#[test]
1259+
fn test_file_reader_rows_nullable1() {
1260+
let rows = test_file_reader_rows("databricks.parquet", None).unwrap();
1261+
let expected_rows = vec![row![
1262+
("bigint".to_string(), Field::Long(42)),
1263+
("binary".to_string(), Field::Bytes(ByteArray::from("Spark"))),
1264+
("boolean".to_string(), Field::Bool(true)),
1265+
("boolean_null".to_string(), Field::Null),
1266+
("date_zero".to_string(), Field::Date(-719530)),
1267+
("date".to_string(), Field::Date(20236)),
1268+
(
1269+
"decimal".to_string(),
1270+
Field::Decimal(Decimal::Int64 {
1271+
value: [0, 0, 0, 0, 0, 0, 0, 5],
1272+
precision: 10,
1273+
scale: 0,
1274+
})
1275+
),
1276+
(
1277+
"decimal3".to_string(),
1278+
Field::Decimal(Decimal::Int32 {
1279+
value: [0, 0, 0, 5],
1280+
precision: 3,
1281+
scale: 0,
1282+
})
1283+
),
1284+
(
1285+
"decimal32".to_string(),
1286+
Field::Decimal(Decimal::Int32 {
1287+
value: [0, 0, 2, 23],
1288+
precision: 3,
1289+
scale: 2,
1290+
})
1291+
),
1292+
("double".to_string(), Field::Double(4.2)),
1293+
("float".to_string(), Field::Float(4.2)),
1294+
("int".to_string(), Field::Int(42)),
1295+
("smallint".to_string(), Field::Short(1)),
1296+
("string".to_string(), Field::Str("Spark".to_string())),
1297+
(
1298+
"timestamp".to_string(),
1299+
Field::TimestampMillis(1748390400000)
1300+
),
1301+
(
1302+
"timestamp_tz".to_string(),
1303+
Field::TimestampMillis(1625118208000)
1304+
),
1305+
(
1306+
"timestamp_ntz".to_string(),
1307+
Field::TimestampMicros(1748434348000000)
1308+
),
1309+
(
1310+
"timestamp_ntz_nanos".to_string(),
1311+
Field::TimestampMicros(1748434348123456)
1312+
),
1313+
("tinyint".to_string(), Field::Byte(1)),
1314+
(
1315+
"array".to_string(),
1316+
list![Field::Int(1), Field::Int(2), Field::Int(3)]
1317+
),
1318+
(
1319+
"nested_array".to_string(),
1320+
list![
1321+
list![Field::Long(1), Field::Long(2)],
1322+
list![Field::Long(3), Field::Long(4)]
1323+
]
1324+
),
1325+
(
1326+
"struct".to_string(),
1327+
group![
1328+
("col1".to_string(), Field::Str("Spark".to_string())),
1329+
("col2".to_string(), Field::Int(5))
1330+
]
1331+
),
1332+
(
1333+
"map".to_string(),
1334+
map![
1335+
(Field::Str("red".to_string()), Field::Int(1)),
1336+
(Field::Str("green".to_string()), Field::Int(2))
1337+
]
1338+
),
1339+
(
1340+
"map_nested".to_string(),
1341+
map![(
1342+
list![Field::Int(1), Field::Int(2)],
1343+
map![(Field::Str("green".to_string()), Field::Int(5))]
1344+
)]
1345+
),
1346+
("interval".to_string(), Field::Long(720830300000))
1347+
]];
1348+
assert_eq!(rows, expected_rows);
1349+
}
1350+
12621351
#[test]
12631352
fn test_file_reader_rows_projection() {
12641353
let schema = "

0 commit comments

Comments
 (0)