alamb commented on code in PR #4143:
URL: https://github.com/apache/arrow-datafusion/pull/4143#discussion_r1017144754


##########
datafusion/core/tests/sql/create_drop.rs:
##########
@@ -387,6 +387,36 @@ async fn create_custom_table() -> Result<()> {
     Ok(())
 }
 
+#[tokio::test]
+async fn create_external_table_with_ddl() -> Result<()> {
+    let mut table_factories: HashMap<String, Arc<dyn TableProviderFactory>> =
+        HashMap::new();
+    table_factories.insert("mocktable".to_string(), Arc::new(TestTableFactory 
{}));
+    let cfg = RuntimeConfig::new().with_table_factories(table_factories);
+    let env = RuntimeEnv::new(cfg).unwrap();
+    let ses = SessionConfig::new();
+    let ctx = SessionContext::with_config_rt(ses, Arc::new(env));
+
+    let sql = "CREATE EXTERNAL TABLE dt (a_id integer, a_str string, a_bool 
boolean) STORED AS MOCKTABLE LOCATION 'mockprotocol://path/to/table';";
+    ctx.sql(sql).await.unwrap();
+
+    let cat = ctx.catalog("datafusion").unwrap();
+    let schema = cat.schema("public").unwrap();
+
+    let exists = schema.table_exist("dt");
+    assert!(exists, "Table should have been created!");
+
+    let table_schema = schema.table("dt").unwrap().schema();
+
+    assert_eq!(3, table_schema.fields().len());
+
+    assert_eq!(&DataType::Int32, table_schema.field(0).data_type());

Review Comment:
   👍 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to