Skip to content

Commit ff3e5b7

Browse files
committed
test
1 parent 10710a2 commit ff3e5b7

File tree

1 file changed

+55
-6
lines changed

1 file changed

+55
-6
lines changed

rust/datafusion/src/datasource/parquet.rs

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,16 @@ impl ParquetFile {
144144
let mut row_count = 0;
145145
for i in 0..self.column_readers.len() {
146146
let array: Arc<Array> = match self.column_readers[i] {
147+
ColumnReader::BoolColumnReader(ref mut r) => {
148+
return Err(ExecutionError::NotImplemented(
149+
"unsupported column reader type (BOOL)".to_string(),
150+
));
151+
}
147152
ColumnReader::Int32ColumnReader(ref mut r) => {
148153
let mut builder = Int32Builder::new(self.batch_size);
149154
let mut read_buffer: Vec<i32> =
150155
Vec::with_capacity(self.batch_size);
156+
151157
match r.read_batch(
152158
self.batch_size,
153159
None,
@@ -156,6 +162,8 @@ impl ParquetFile {
156162
) {
157163
//TODO this isn't handling null values
158164
Ok((count, _)) => {
165+
println!("Read {} rows", count);
166+
159167
builder.append_slice(&read_buffer).unwrap();
160168
row_count = count;
161169
Arc::new(builder.finish())
@@ -168,6 +176,21 @@ impl ParquetFile {
168176
}
169177
}
170178
}
179+
ColumnReader::Int64ColumnReader(ref mut r) => {
180+
return Err(ExecutionError::NotImplemented(
181+
"unsupported column reader type (INT64)".to_string(),
182+
));
183+
}
184+
ColumnReader::Int96ColumnReader(ref mut r) => {
185+
return Err(ExecutionError::NotImplemented(
186+
"unsupported column reader type (INT96)".to_string(),
187+
));
188+
}
189+
ColumnReader::FloatColumnReader(ref mut r) => {
190+
return Err(ExecutionError::NotImplemented(
191+
"unsupported column reader type (FLOAT)".to_string(),
192+
));
193+
}
171194
ColumnReader::DoubleColumnReader(ref mut r) => {
172195
let mut builder = Float64Builder::new(self.batch_size);
173196
let mut read_buffer: Vec<f64> =
@@ -192,6 +215,12 @@ impl ParquetFile {
192215
}
193216
}
194217
}
218+
ColumnReader::FixedLenByteArrayColumnReader(ref mut r) => {
219+
return Err(ExecutionError::NotImplemented(
220+
"unsupported column reader type (FixedLenByteArray)"
221+
.to_string(),
222+
));
223+
}
195224
ColumnReader::ByteArrayColumnReader(ref mut r) => {
196225
let mut b: Vec<ByteArray> =
197226
Vec::with_capacity(self.batch_size);
@@ -221,17 +250,13 @@ impl ParquetFile {
221250
}
222251
}
223252
}
224-
_ => {
225-
return Err(ExecutionError::NotImplemented(
226-
"unsupported column reader type".to_string(),
227-
));
228-
}
229253
};
230254

255+
println!("Adding array to batch");
231256
batch.push(array);
232257
}
233258

234-
// println!("Loaded batch of {} rows", row_count);
259+
println!("Loaded batch of {} rows", row_count);
235260

236261
if row_count == 0 {
237262
Ok(None)
@@ -308,3 +333,27 @@ impl RecordBatchIterator for ParquetFile {
308333
}
309334
}
310335
}
336+
337+
#[cfg(test)]
338+
mod tests {
339+
use super::*;
340+
use std::env;
341+
342+
#[test]
343+
fn read_parquet_file() {
344+
let testdata = env::var("PARQUET_TEST_DATA").unwrap();
345+
let filename = format!("{}/alltypes_plain.parquet", testdata);
346+
347+
let table = ParquetTable::new(&filename);
348+
349+
println!("{:?}", table.schema());
350+
351+
let projection = Some(vec![0]);
352+
let scan = table.scan(&projection, 1024).unwrap();
353+
let mut it = scan.borrow_mut();
354+
let batch = it.next().unwrap().unwrap();
355+
356+
assert_eq!(1, batch.num_columns());
357+
assert_eq!(1, batch.num_rows());
358+
}
359+
}

0 commit comments

Comments
 (0)