You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/02/15 05:31:02 UTC
[GitHub] [arrow-datafusion] matthewmturner opened a new issue #1836: Register multiple tables into `ExecutionContext` at once
matthewmturner opened a new issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836
**Is your feature request related to a problem or challenge? Please describe what you are trying to do.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
(This section helps Arrow developers understand the context and *why* for this feature, in addition to the *what*)
I want to make it really easy to register multiple tables in a directory into a `ExecutionContext` so I can write SQL queries on them.
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
For example if their is a data directory like the below:
s3://bucket/active/table1/abc.parquet
s3://bucket/active/table2/abc.parquet
s3://bucket/active/table3/abc.parquet
s3://bucket/historical/table1/abc.parquet
s3://bucket/historical/table2/abc.parquet
s3://bucket/historical/table3/abc.parquet
I would like to be able to do something like the below.
```
ctx.register_object_store("s3", object_store);
// Provide a list of tables and table name prefix
// Registers active_table1, active_table2 into ctx
let tables = vec!["table1", "table2"];
ctx.register_listing_tables(
object_store: "s3",
object_store_prefix: "bucket/active",
tables: Some(&tables),
table_prefix: Some("active")
);
// Provide a prefix and register everything in the level below that as a table with a table name prefix
// Registers active_table1, active_table2, active_table3 into ctx
ctx.register_listing_tables(
object_store: "s3",
object_store_prefix: "bucket/active",
tables: None
table_prefix: "active"
);
// Provide a prefix and register everything in the level below that as a table with a no prefix
// Registers table1, table2, table3 into ctx
ctx.register_listing_tables(
object_store: "s3",
object_store_prefix: "bucket/active",
tables: None
table_prefix: "active"
);
```
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] alamb commented on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
alamb commented on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1042856074
It seems to me that if your goal is to basically do some object store calls, get the list of files from S3 and then build a catalog from that snapshot the memory provider / builder is probably the simplest route to take
However, if you want to do more sophisticated things (like, for example, not traverse the s3 directory / prefix structure up front and do it more on demand) a specialized implementation of `S3Catalog` might be more helpful
For example of "on demand" if you had object store like this:
```
s3://active/schema1/tableA
s3://active/schema1/tableB
s3://active/schema1/tableC
s3://active/schema2/tableD
s3://hist/...
...
```
You could make an `S3Catalog` for each of the first prefixes (`active` and `hist`).
If you wrote a query that did like `SELECT * from active.schema1.tableA` then
1. the `S3Catalog` for `active` would be asked for what schemas do you have (it could ask object store and return `S3Schemas` for `schema1` and `schema2`
2. The `S3Schema` for `schema2` could then be asked for what tables do you know, and it would ask object store and return table providers for `tableA`, `tableB` and `tableC`
As you can imagine there are tradeoffs in the two approaches: the first will take longer to setup but be much faster to query each time (but also won't see any new files that appear in S3). The second will be very fast to setup and will see new files that appear, but will make object store requests during planning so will be slower.
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] matthewmturner commented on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
matthewmturner commented on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1040879854
@alamb thank you for that info - it looks great.
I'm wondering if it makes sense to add a method to `ObjectStore` to facilitate creating a `Schema` or `Catalog`. I made an issue in `datafusion-objectstore-s3` to look into this and play around with the API. Of course if any part of that makes sense to bring back into `datafusion` I can make a PR here.
Thx for the feedback @Igosuki @seddonm1. Let me know if you have any thoughts on the above point.
https://github.com/datafusion-contrib/datafusion-objectstore-s3/issues/44
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] alamb closed issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
alamb closed issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] returnString commented on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
returnString commented on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1041417998
Yeah, my intent when adding the catalog/schema abstractions initially was to support exactly this use case 😊 You can compose an execution context with any crazy combination of catalog/schema providers (e.g. @alamb built a wrapper catalog that automatically builds an `information_schema` based on your _real_ catalog) which can then provide arbitrary `TableProvider` instances for actual planning/execution work.
I think using this as a common interface for contrib projects (rather than say building execution contexts directly) would allow for maximum flexibility; for example, I might want to build a queryable context like:
```
my_warehouse_project (catalog):
raw (objstore provider):
- events (objstore table)
derived (in-mem schema provider):
- daily_event_counts (memtable)
```
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] alamb commented on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
alamb commented on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1055564923
Sorry for the late reply here -- I have been away and am catching up on my notes.
The only hesitation I have with the proposal you lay out is that it will put an `ObjectStore` in all `MemorySchmaProvider`s that may / may not make sense. It might be better to make an entirely new schema provider (`ObjectStoreSchemaProvider` perhaps?) with the functionality you describe -- I will try and look at the linked PR shortly
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] Igosuki commented on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
Igosuki commented on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1040075677
I think what you're looking for is defining 'namespaces' or 'databases' rather than prefixes, which could then be :
```rust
for table in ["table1", "table2"] {
ctx.register(uri: format!("s3://bucket/active/{table}"))
}
// trailing space = list
ctx.register(uri: "s3://bucket/active/", namespace: "active")
// supports globs
ctx.register(urI: "s3://bucket/active/{*}")
```
```rust
ctx.sql("select * from active.table1");
```
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] alamb commented on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
alamb commented on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1041540603
Maybe it is worth spiking / prototyping out what facilities you imagine adding to the object store @matthewmturner
Maybe something like this to create in memory catalogs could help lower the barrier to creating catalogs:
```rust
/// Helper for creating in memory catalogs
struct CatalogBuilder {
...
}
impl CatalogBuilder {
pub fn add_schema(&mut self, schema_name: &str) -> CatalogSchemaBuilder {
..
}
pub fn build(self) -> Arc<Catalog> {
...
}
}
struct CatalogSchemaBuilder {
...
}
impl CatalogSchemaBuilder {
// adds the table provider to the specified schema
pub fn add_table(&mut self, table_name: &str, table_provider: Arc<dyn TableProvider)) {
..
}
// todo add methods perhaps for easily creating ListingTables or something?
}
```
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] Igosuki commented on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
Igosuki commented on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1040075677
I think what you're looking for is defining 'namespaces' or 'databases' rather than prefixes, which could then be :
```rust
for table in ["table1", "table2"] {
ctx.register(uri: format!("s3://bucket/active/{table}"))
}
// trailing space = list
ctx.register(uri: "s3://bucket/active/", namespace: "active")
// supports globs
ctx.register(urI: "s3://bucket/active/{*}")
```
```rust
ctx.sql("select * from active.table1");
```
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] matthewmturner commented on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
matthewmturner commented on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1040289061
Indeed, that does basically look like the functionality I am looking for and looks like a nicer API.
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] alamb commented on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
alamb commented on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1042849158
Here is an example of `CatalogProvider` from IOx: https://github.com/influxdata/influxdb_iox/blob/be662ec7318e83fc54f8a6e942a3dc8abbc84bc4/db/src/access.rs#L316
Here is an example of a `SchemaProvider` (from IOx) that is used to provide some virtual system tables: https://github.com/influxdata/influxdb_iox/blob/d9f331ba2ae3885497c480a5e5b6940698ae0f63/db/src/system_tables.rs#L106-L134
The main use case is "we have some other structure that already keeps track of schemas / tables and we want to expose that information to DataFusion without having DtaFusion manage it"
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] seddonm1 commented on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
seddonm1 commented on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1039961634
Given that some of the API is still changing (like https://github.com/apache/arrow-datafusion/pull/1779) - which in my head means that requirements are not fully understood - I would be tempted to leave the current API. Maybe this request could stay open for a while as people try the ObjectStore abstractions?
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] matthewmturner commented on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
matthewmturner commented on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1039876376
@seddonm1 @alamb @houqp im interested in your thoughts on this.
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] matthewmturner edited a comment on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
matthewmturner edited a comment on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1043725945
@alamb thanks much for explanations. I've been giving this some thought and came up with a potentially simple solution for a first step that would facilitate adding tables to a schema from an `ObjectStore`.
What if we update `MemorySchemaProvider` to look like the following:
```
pub struct MemorySchemaProvider {
tables: RwLock<HashMap<String, Arc<dyn TableProvider>>>,
object_store: Option<Arc<dyn ObjectStore>>,
}
```
then we add the following methods (either to `SchemaProvider` trait or just to `MemorySchemaProvider`:
```
impl SchemaProvider for MemorySchemaProvider {
...
pub fn register_store(self, object_store: Arc<dyn ObjectStore>) {
...
}
pub fn register_listing_table(self, uri, config: Option<ListingTableConfig>) {
...
}
}
```
Then, leverage further on an `ObjectStore` implementation. Depending on the structure, either `object_store.list_file` or `object_store.list_dir` could be used to get the relevant paths. I think this would look roughly like the following:
```
let object_store = S3FileSystem::default();
let schema = MemorySchemaProvider::new();
schema.register_store(object_store);
let tables = object_store.list_dir("s3://active/schema1");
tables.iter().map(|file| {
let config = ListingTableConfig::new(..);
let name = extract_name_from_file(&file);
schema.register_listing_table(name, file, config);
}
```
This could all be done within datafusion and work with a s3 object store which would achieve my short term objective. Then I could look into whether a more sophisticated catalog or schema provider, like you outllined, is needed.
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] matthewmturner commented on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
matthewmturner commented on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1040060775
Just to clarify - this would be for a new API. Existing one would remain unchanged.
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] Igosuki edited a comment on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
Igosuki edited a comment on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1040075677
I think what you're looking for is defining 'namespaces' or 'databases' rather than prefixes, which could then be :
```rust
for table in ["table1", "table2"] {
ctx.register(uri: format!("s3://bucket/active/{table}"))
}
// trailing space = list
ctx.register(uri: "s3://bucket/active/", namespace: "active")
// supports globs
ctx.register(urI: "s3://bucket/active/{*}")
```
```rust
ctx.sql("select * from active.table1");
```
This is kinda the way spark works
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] matthewmturner commented on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
matthewmturner commented on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1043725945
@alamb thanks much for explanations. I've been giving this some thought and came up with a potentially simple solution for a first step that would facilitate adding tables to a schema from an `ObjectStore`.
What if we update `MemorySchemaProvider` to look like the following:
```
pub struct MemorySchemaProvider {
tables: RwLock<HashMap<String, Arc<dyn TableProvider>>>,
object_store: Option<Arc<dyn ObjectStore>>,
}
```
then we add the following methods (either to `SchemaProvider` trait or just to `MemorySchemaProvider`:
```
impl SchemaProvider for MemorySchemaProvider {
...
pub fn register_store(self, object_store: Arc<dyn ObjectStore>) {
...
}
pub fn register_listing_table(self, uri, config: Option<ListingTableConfig>) {
...
}
}
```
Then, to leverage further on `ObjectStore` implementation i'm wondering if the `list_dir` method could be used to achieve my objective(if this is what `list_dir` is intended for - if not maybe we could add a method for this). I think this would look something roughly like the following:
```
let object_store = S3FileSystem::default();
let schema = MemorySchemaProvider::new();
schema.register_store(object_store);
let schema1_files = object_store.list_dir("s3://active/schema1");
files.iter().map(|file| {
let config = ListingTableConfig::new(..);
schema.register_listing_table(file, config);
}
```
This could all be done within datafusion and work with a s3 object store which would achieve my short term objective. Then I could look into whether a more sophisticated catalog or schema provider, like you outllined, is needed.
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] seddonm1 commented on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
seddonm1 commented on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1039961634
Given that some of the API is still changing (like https://github.com/apache/arrow-datafusion/pull/1779) - which in my head means that requirements are not fully understood - I would be tempted to leave the current API. Maybe this request could stay open for a while as people try the ObjectStore abstractions?
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] matthewmturner commented on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
matthewmturner commented on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1055878711
I hear your point - it would be unnecessary in the cases that it is not used. Fine on my end to have the functionality in a `ObjectStoreSchemaProvider`
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] Igosuki edited a comment on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
Igosuki edited a comment on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1040075677
I think what you're looking for is defining 'namespaces' or 'databases' rather than prefixes, which could then be :
```rust
for table in ["table1", "table2"] {
ctx.register(uri: format!("s3://bucket/active/{table}"))
}
// trailing space = list
ctx.register(uri: "s3://bucket/active/", namespace: "active")
// supports globs
ctx.register(urI: "s3://bucket/active/{*}")
```
```rust
ctx.sql("select * from active.table1");
```
This is kinda the way spark works
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] matthewmturner commented on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
matthewmturner commented on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1039876376
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] matthewmturner edited a comment on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
matthewmturner edited a comment on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1043725945
@alamb thanks much for explanations. I've been giving this some thought and came up with a potentially simple solution for a first step that would facilitate adding tables to a schema from an `ObjectStore`.
What if we update `MemorySchemaProvider` to look like the following:
```
pub struct MemorySchemaProvider {
tables: RwLock<HashMap<String, Arc<dyn TableProvider>>>,
object_store: Option<Arc<dyn ObjectStore>>,
}
```
then we add the following methods (either to `SchemaProvider` trait or just to `MemorySchemaProvider`:
```
impl SchemaProvider for MemorySchemaProvider {
...
pub fn register_store(self, object_store: Arc<dyn ObjectStore>) {
...
}
pub fn register_listing_table(self, uri, config: Option<ListingTableConfig>) {
...
}
}
```
Then, to leverage further on `ObjectStore` implementation i'm wondering if the `list_dir` method could be used to achieve my objective(if this is what `list_dir` is intended for - if not maybe we could add a method for this). I think this would look something roughly like the following:
```
let object_store = S3FileSystem::default();
let schema = MemorySchemaProvider::new();
schema.register_store(object_store);
let tables = object_store.list_dir("s3://active/schema1");
tables.iter().map(|file| {
let config = ListingTableConfig::new(..);
schema.register_listing_table(file, config);
}
```
This could all be done within datafusion and work with a s3 object store which would achieve my short term objective. Then I could look into whether a more sophisticated catalog or schema provider, like you outllined, is needed.
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] alamb commented on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
alamb commented on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1040796346
DataFusion has a notion of `Catalog` and `Schema` (thanks @returnString 👋 ) now that seems similar to what you are describing.
Here is an example of how it is used:
https://github.com/apache/arrow-datafusion/blob/e5f69695da103ceab60f8410d129e4e7a2d5bca7/datafusion/src/execution/context.rs#L3160-L3191
So in the example @Igosuki provided, you would create a schema called "active" and register `table1` and `table2` in there.
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] matthewmturner commented on issue #1836: Register multiple tables into `ExecutionContext` at once
Posted by GitBox <gi...@apache.org>.
matthewmturner commented on issue #1836:
URL: https://github.com/apache/arrow-datafusion/issues/1836#issuecomment-1042422114
@returnString thanks for your work to enable this! it's going to be very helpful on these next steps.
One question, what would be an example of an implementer of `CatalogProvider` or `SchemaProvider` traits that doesnt end up essentially being a `MemoryCatalogProvider` or `MemorySchemaProvider`? I would have thought these could have been a struct but I'm probably missing something.
As some additional context - I'm working on a s3 extension for datafusion (https://github.com/datafusion-contrib/datafusion-objectstore-s3) and im trying to figure out if I should be making something like a `S3Catalog` and / or `S3Schema` that implement the aforementioned traits or if I should just use the Memory ones complemented with a builder pattern like @alamb mentioned or just add methods to create a schema from an `ObjectStore` instance.
The way I'm thinking about it now is that the majority of the heavy lifting / logic will be on creating many tables in a schema - for example by looking at a directory and reading all sub directories or files within as tables. So I think I will focus my efforts on playing with an API for that. I have the below in mind right now but I guess that's why I was interested in learning more about how the `CatalogProvider` and `SchemaProvider` traits were intended to be used outside of their memory implementations.
```
let s3 = S3FileSystem::default();
let active_schema = s3.create_schema(uri: "s3://bucket/active");
let hist_schema = s3.create_schema(uri: "s3://bucket/hist");
let catalog = MemoryCatalogProvider::new().register_schema(name: "active", schema: active_shema).register_schema(name: "hist", schema: hist_schema);
```
Thanks again for your input! Hope I'm not over complicating this.
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org