|
1 | | -# DataFusion Java Bindings |
| 1 | +# Apache DataFusion Java |
| 2 | + |
| 3 | +Java bindings for [Apache DataFusion]. Queries run in native Rust and results |
| 4 | +return to the JVM as [Apache Arrow] batches via the Arrow C Data Interface. |
| 5 | + |
| 6 | +[Apache DataFusion]: https://datafusion.apache.org/ |
| 7 | +[Apache Arrow]: https://arrow.apache.org/ |
| 8 | + |
| 9 | +> Early development: no releases yet, API will change. Bug reports and |
| 10 | +> contributions welcome. |
| 11 | +
|
| 12 | +## Quickstart |
| 13 | + |
| 14 | +```java |
| 15 | +import org.apache.arrow.memory.RootAllocator; |
| 16 | +import org.apache.arrow.vector.ipc.ArrowReader; |
| 17 | +import org.apache.datafusion.DataFrame; |
| 18 | +import org.apache.datafusion.SessionContext; |
| 19 | + |
| 20 | +try (var allocator = new RootAllocator(); |
| 21 | + var ctx = new SessionContext()) { |
| 22 | + |
| 23 | + ctx.registerParquet("orders", "/path/to/orders.parquet"); |
| 24 | + |
| 25 | + try (DataFrame df = ctx.sql( |
| 26 | + "SELECT o_orderpriority, COUNT(*) AS n " + |
| 27 | + "FROM orders GROUP BY o_orderpriority"); |
| 28 | + ArrowReader reader = df.collect(allocator)) { |
| 29 | + while (reader.loadNextBatch()) { |
| 30 | + var batch = reader.getVectorSchemaRoot(); |
| 31 | + // ... |
| 32 | + } |
| 33 | + } |
| 34 | +} |
| 35 | +``` |
| 36 | + |
| 37 | +`SessionContext` and `DataFrame` are `AutoCloseable` and not thread-safe. |
| 38 | + |
| 39 | +## Documentation |
| 40 | + |
| 41 | +The full documentation lives under [`docs/source/`](docs/source/index.md) |
| 42 | +and is built with Sphinx (see [`docs/README.md`](docs/README.md) for the |
| 43 | +build steps): |
| 44 | + |
| 45 | +- [User guide](docs/source/user-guide/index.md) — installation, the |
| 46 | + DataFrame and SQL APIs, Parquet ingestion, project status. |
| 47 | +- [Contributor guide](docs/source/contributor-guide/index.md) — build, |
| 48 | + test, code style, and how to bump the DataFusion version. |
| 49 | + |
| 50 | +## Requirements |
| 51 | + |
| 52 | +JDK 17+. Building from source: see |
| 53 | +[`docs/source/contributor-guide/development.md`](docs/source/contributor-guide/development.md). |
| 54 | + |
| 55 | +## Contributing |
| 56 | + |
| 57 | +Open an issue to discuss non-trivial changes before sending a PR. See the |
| 58 | +[contributor guide](docs/source/contributor-guide/index.md). |
| 59 | + |
| 60 | +## License |
| 61 | + |
| 62 | +Apache License 2.0. See [LICENSE.txt](LICENSE.txt) and [NOTICE.txt](NOTICE.txt). |
0 commit comments