Skip to content

Commit c3f71d7

Browse files
committed
add integration test
1 parent aea9f8a commit c3f71d7

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

rust/datafusion/src/datasource/parquet.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ impl ParquetTable {
5454
}
5555

5656
impl Table for ParquetTable {
57+
5758
fn schema(&self) -> &Arc<Schema> {
5859
&self.schema
5960
}

rust/datafusion/tests/sql.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717

1818
use std::cell::RefCell;
19+
use std::env;
1920
use std::rc::Rc;
2021
use std::sync::Arc;
2122

@@ -27,9 +28,22 @@ use arrow::datatypes::{DataType, Field, Schema};
2728

2829
use datafusion::execution::context::ExecutionContext;
2930
use datafusion::execution::relation::Relation;
31+
use datafusion::datasource::parquet::ParquetFile;
32+
use datafusion::datasource::parquet::ParquetTable;
33+
use datafusion::datasource::{RecordBatchIterator, Table};
3034

3135
const DEFAULT_BATCH_SIZE: usize = 1024 * 1024;
3236

37+
#[test]
38+
fn parquet_query() {
39+
let mut ctx = ExecutionContext::new();
40+
ctx.register_table("alltypes_plain", load_parquet_table("alltypes_plain.parquet"));
41+
let sql = "SELECT id, string_col FROM alltypes_plain";
42+
let actual = execute(&mut ctx, sql);
43+
let expected = "tbd".to_string();
44+
assert_eq!(expected, actual);
45+
}
46+
3347
#[test]
3448
fn csv_query_with_predicate() {
3549
let mut ctx = ExecutionContext::new();
@@ -163,6 +177,14 @@ fn register_csv(
163177
ctx.register_csv(name, filename, &schema, true);
164178
}
165179

180+
fn load_parquet_table(name: &str) -> Rc<Table> {
181+
let testdata = env::var("PARQUET_TEST_DATA").unwrap();
182+
let filename = format!("{}/{}", testdata, name);
183+
let table = ParquetTable::new(&filename);
184+
println!("{:?}", table.schema());
185+
Rc::new(table)
186+
}
187+
166188
/// Execute query and return result set as tab delimited string
167189
fn execute(ctx: &mut ExecutionContext, sql: &str) -> String {
168190
let results = ctx.sql(&sql, DEFAULT_BATCH_SIZE).unwrap();

0 commit comments

Comments
 (0)