avantgardnerio commented on code in PR #3311:
URL: https://github.com/apache/arrow-datafusion/pull/3311#discussion_r960781711
##########
datafusion/core/tests/sql/create_drop.rs:
##########
@@ -262,6 +267,69 @@ async fn create_pipe_delimited_csv_table() -> Result<()> {
Ok(())
}
+struct TestTableProvider {
+ name: String,
+ path: String,
+}
+
+impl TestTableProvider {
+ pub fn new(name: &str, path: &str) -> Self {
+ Self {
+ name: name.to_string(),
+ path: path.to_string()
+ }
+ }
+}
+
+#[async_trait]
+impl TableProvider for TestTableProvider {
+ fn as_any(&self) -> &dyn Any {
+ todo!()
+ }
+
+ fn schema(&self) -> SchemaRef {
+ todo!()
+ }
+
+ fn table_type(&self) -> TableType {
+ todo!()
+ }
+
+ async fn scan(
+ &self,
+ ctx: &SessionState,
+ projection: &Option<Vec<usize>>,
+ filters: &[Expr],
+ limit: Option<usize>
+ ) -> Result<Arc<dyn ExecutionPlan>> {
+ todo!()
+ }
+}
+
+struct TestTableFactory {}
+
+impl TableProviderFactory for TestTableFactory {
+ fn create(&self, name: &str, path: &str) -> Arc<dyn TableProvider> {
+ Arc::new(TestTableProvider::new(name, path))
+ }
+}
+
+#[tokio::test]
+async fn create_custom_table() -> Result<()> {
+ let mut ctx = SessionContext::new();
+ ctx.register_table_factory("DELTATABLE", Arc::new(TestTableFactory {}));
+
+ let sql = "CREATE EXTERNAL TABLE dt STORED AS DELTATABLE LOCATION
's3://bucket/schema/table';";
+ ctx.sql(sql).await.unwrap();
+
Review Comment:
Cool, affirmation of general direction was what I was looking for, I'll
clean it up and get it submitted, ty!
--
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]