matthewmturner commented on a change in pull request #1863:
URL: https://github.com/apache/arrow-datafusion/pull/1863#discussion_r819290028



##########
File path: datafusion/src/catalog/schema.rs
##########
@@ -154,4 +208,100 @@ mod tests {
             provider.register_table(table_name.to_string(), 
Arc::new(other_table));
         assert!(result.is_err());
     }
+
+    #[tokio::test]
+    async fn test_schema_register_listing_table() {
+        let testdata = crate::test_util::parquet_test_data();
+        let filename = format!("{}/{}", testdata, "alltypes_plain.parquet");
+
+        let schema = MemorySchemaProvider::new();
+        let _store = schema.register_object_store("test", 
Arc::new(LocalFileSystem {}));
+
+        schema
+            .register_listing_table("alltypes_plain", &filename, None)
+            .await
+            .unwrap();
+
+        let catalog = MemoryCatalogProvider::new();
+        catalog.register_schema("active", Arc::new(schema));
+
+        let mut ctx = ExecutionContext::new();
+
+        ctx.register_catalog("cat", Arc::new(catalog));
+
+        let df = ctx
+            .sql("SELECT id, bool_col FROM cat.active.alltypes_plain")
+            .await
+            .unwrap();
+
+        let actual = df.collect().await.unwrap();
+
+        let expected = vec![
+            "+----+----------+",
+            "| id | bool_col |",
+            "+----+----------+",
+            "| 4  | true     |",
+            "| 5  | false    |",
+            "| 6  | true     |",
+            "| 7  | false    |",
+            "| 2  | true     |",
+            "| 3  | false    |",
+            "| 0  | true     |",
+            "| 1  | false    |",
+            "+----+----------+",
+        ];
+        assert_batches_eq!(expected, &actual);
+    }
+
+    #[tokio::test]
+    async fn test_schema_register_listing_tables() {
+        let testdata = crate::test_util::parquet_test_data();
+
+        let schema = MemorySchemaProvider::new();
+        let store = schema
+            .register_object_store("file", Arc::new(LocalFileSystem {}))
+            .unwrap();
+
+        let mut files = store.list_file(&testdata).await.unwrap();
+        while let Some(file) = files.next().await {
+            let sized_file = file.unwrap().sized_file;
+            let file = sized_file.path.split('/').last().unwrap();
+            if file == "alltypes_dictionary.parquet" || file == 
"alltypes_plain.parquet" {
+                let (name, _) = file.split_once(".").unwrap();

Review comment:
       @yjshen thx much




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to