-
Notifications
You must be signed in to change notification settings - Fork 13
feat(datasource): add Java-implemented data sources #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
b64accb
build(native): add async-trait and futures deps for Java data sources
andygrove 484cd12
refactor(native): lift jthrowable_to_string into shared jni_util module
andygrove b699291
feat(datasource): add DataSource interface and SessionContext.registe…
andygrove e16a99e
feat(native): add JavaDataSource TableProvider and JNI registration
andygrove 79213dc
docs(native): clarify JavaScanExec safety + schema check + JVM attach
andygrove 9c60f3c
feat(datasource)!: pass framework allocator to DataSource.scan
andygrove cd03d90
test(datasource): cover repeated scans within a single query
andygrove 1004f6c
test(datasource): cover empty-stream scan
andygrove bf9c435
test(datasource): cover column projection through DataFusion
andygrove 0ff2d8c
test(datasource): reject scan whose schema differs from registered sc…
andygrove 248dc70
test(datasource): surface Java exception class and message from scan()
andygrove 82d13fb
test(datasource): reject null ArrowReader from scan()
andygrove 953fcf2
test(datasource): cover joining two registered Java data sources
andygrove af57098
docs(datasource): document SessionContext.registerDataSource
andygrove a4eb41e
docs(datasource): clarify scan() is per-physical-scan, not per-query
andygrove 82c740a
feat(examples): add JDBC-backed DataSource example using H2 + arrow-jdbc
andygrove 1df2bd2
refactor(datasource)!: rename DataSource API to TableProvider
andygrove 9e8279d
Merge remote-tracking branch 'apache/main' into feat/columnar-value-udf
andygrove File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat(datasource): add DataSource interface and SessionContext.registe…
…rDataSource Java API
- Loading branch information
commit b69929183011f1d48b547c49e795b7f0568f1047
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.datafusion; | ||
|
|
||
| import org.apache.arrow.vector.ipc.ArrowReader; | ||
| import org.apache.arrow.vector.types.pojo.Schema; | ||
|
|
||
| /** | ||
| * A Java-implemented table that can be registered with a {@link SessionContext}. | ||
| * | ||
| * <p>Each call to {@link #scan()} must return a fresh, independent {@link ArrowReader} so that | ||
| * queries which touch the table more than once (self-joins, {@code UNION ALL}, repeated reads) work | ||
| * correctly. The returned reader is closed by the framework when the stream ends. | ||
| * | ||
| * <p>The schema returned by {@link #schema()} is captured once at registration time. Every batch | ||
| * produced by every {@code ArrowReader} returned from {@link #scan()} must conform to it; a | ||
| * mismatch fails the query. | ||
| */ | ||
| public interface DataSource { | ||
| /** The fixed schema of this table. Called once, at registration time. */ | ||
| Schema schema(); | ||
|
|
||
| /** | ||
| * Open a fresh batch stream for this table. Called once per query that scans the table. | ||
| * | ||
| * <p>Each invocation MUST return an independent {@link ArrowReader}. The reader's schema MUST | ||
| * equal {@link #schema()}. | ||
| */ | ||
| ArrowReader scan(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is basically a simplified API on top of the
SessionContext::register_tablerust function, what if we called the java function that instead (registerTable), and made the interface it acceptsTableProvider?I get that this PR is basically barebones support for custom table registration in java, and that
data_source.rsis handling a lot so the java user gets a simplescan()callback. I think only providing that for now makes sense as a first step (and will always be useful for simple cases), but I'd like to make sure this can evolve towards all the flexibility of theTableProvidertrait that interacts withExecutionPlanand ultimately anArrowReader. The LiteralGuaranteeTest from my bindings demonstrates what this could look like and what it enables (filter pushdown).To keep things minimal for PR, maybe we could just
registerDataSourcetoregisterTableDataSourceinterface toTableProviderTableProviderthat just holds what the currentDataSourcedoes - not sure about a name for that, but maybe likeSimpleTableProviderorFullScanTableProvideror somethingThen we can make
TableProvidermore featured over time. Totally open to other ideas too.Part of my motivation in renaming is that in the back of my head I'm thinking about eventual support for the separate DataSource, so don't want to clash on naming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @pgwhalen. I have addressed your feedback.