@@ -1436,59 +1436,59 @@ mod tests {
14361436 Ok ( ( ) )
14371437 }
14381438
1439- // #[tokio::test]
1440- // async fn test_struct_filter_parquet() -> Result<()> {
1441- // let tmp_dir = TempDir::new()?;
1442- // let path = tmp_dir.path().to_str().unwrap().to_string() + "/test.parquet";
1443- // write_file(&path);
1444- // let ctx = SessionContext::new();
1445- // let opt = ListingOptions::new(Arc::new(ParquetFormat::default()));
1446- // ctx.register_listing_table("base_table", path, opt, None, None)
1447- // .await
1448- // .unwrap();
1449- // let sql = "select * from base_table where name='test02'";
1450- // let batch = ctx.sql(sql).await.unwrap().collect().await.unwrap();
1451- // assert_eq!(batch.len(), 1);
1452- // let expected = [
1453- // "+---------------------+----+--------+",
1454- // "| struct | id | name |",
1455- // "+---------------------+----+--------+",
1456- // "| {id: 4, name: aaa2} | 2 | test02 |",
1457- // "+---------------------+----+--------+",
1458- // ];
1459- // assert_batches_eq!(expected, &batch);
1460- // Ok(())
1461- // }
1462-
1463- // #[tokio::test]
1464- // async fn test_struct_filter_parquet_with_view_types() -> Result<()> {
1465- // let tmp_dir = TempDir::new().unwrap();
1466- // let path = tmp_dir.path().to_str().unwrap().to_string() + "/test.parquet";
1467- // write_file(&path);
1468-
1469- // let ctx = SessionContext::new();
1470-
1471- // let mut options = TableParquetOptions::default();
1472- // options.global.schema_force_view_types = true;
1473- // let opt =
1474- // ListingOptions::new(Arc::new(ParquetFormat::default().with_options(options)));
1475-
1476- // ctx.register_listing_table("base_table", path, opt, None, None)
1477- // .await
1478- // .unwrap();
1479- // let sql = "select * from base_table where name='test02'";
1480- // let batch = ctx.sql(sql).await.unwrap().collect().await.unwrap();
1481- // assert_eq!(batch.len(), 1);
1482- // let expected = [
1483- // "+---------------------+----+--------+",
1484- // "| struct | id | name |",
1485- // "+---------------------+----+--------+",
1486- // "| {id: 4, name: aaa2} | 2 | test02 |",
1487- // "+---------------------+----+--------+",
1488- // ];
1489- // assert_batches_eq!(expected, &batch);
1490- // Ok(())
1491- // }
1439+ #[ tokio:: test]
1440+ async fn test_struct_filter_parquet ( ) -> Result < ( ) > {
1441+ let tmp_dir = TempDir :: new ( ) ?;
1442+ let path = tmp_dir. path ( ) . to_str ( ) . unwrap ( ) . to_string ( ) + "/test.parquet" ;
1443+ write_file ( & path) ;
1444+ let ctx = SessionContext :: new ( ) ;
1445+ let opt = ListingOptions :: new ( Arc :: new ( ParquetFormat :: default ( ) ) ) ;
1446+ ctx. register_listing_table ( "base_table" , path, opt, None , None )
1447+ . await
1448+ . unwrap ( ) ;
1449+ let sql = "select * from base_table where name='test02'" ;
1450+ let batch = ctx. sql ( sql) . await . unwrap ( ) . collect ( ) . await . unwrap ( ) ;
1451+ assert_eq ! ( batch. len( ) , 1 ) ;
1452+ let expected = [
1453+ "+---------------------+----+--------+" ,
1454+ "| struct | id | name |" ,
1455+ "+---------------------+----+--------+" ,
1456+ "| {id: 4, name: aaa2} | 2 | test02 |" ,
1457+ "+---------------------+----+--------+" ,
1458+ ] ;
1459+ assert_batches_eq ! ( expected, & batch) ;
1460+ Ok ( ( ) )
1461+ }
1462+
1463+ #[ tokio:: test]
1464+ async fn test_struct_filter_parquet_with_view_types ( ) -> Result < ( ) > {
1465+ let tmp_dir = TempDir :: new ( ) . unwrap ( ) ;
1466+ let path = tmp_dir. path ( ) . to_str ( ) . unwrap ( ) . to_string ( ) + "/test.parquet" ;
1467+ write_file ( & path) ;
1468+
1469+ let ctx = SessionContext :: new ( ) ;
1470+
1471+ let mut options = TableParquetOptions :: default ( ) ;
1472+ options. global . schema_force_view_types = true ;
1473+ let opt =
1474+ ListingOptions :: new ( Arc :: new ( ParquetFormat :: default ( ) . with_options ( options) ) ) ;
1475+
1476+ ctx. register_listing_table ( "base_table" , path, opt, None , None )
1477+ . await
1478+ . unwrap ( ) ;
1479+ let sql = "select * from base_table where name='test02'" ;
1480+ let batch = ctx. sql ( sql) . await . unwrap ( ) . collect ( ) . await . unwrap ( ) ;
1481+ assert_eq ! ( batch. len( ) , 1 ) ;
1482+ let expected = [
1483+ "+---------------------+----+--------+" ,
1484+ "| struct | id | name |" ,
1485+ "+---------------------+----+--------+" ,
1486+ "| {id: 4, name: aaa2} | 2 | test02 |" ,
1487+ "+---------------------+----+--------+" ,
1488+ ] ;
1489+ assert_batches_eq ! ( expected, & batch) ;
1490+ Ok ( ( ) )
1491+ }
14921492
14931493 fn write_file ( file : & String ) {
14941494 let struct_fields = Fields :: from ( vec ! [
0 commit comments