SessionContext#
SessionContext is the entry point into DataFusion from Java. It owns the
catalog of registered tables and the query planner.
Lifecycle#
try (SessionContext ctx = new SessionContext()) {
// register tables, build queries...
}
SessionContext is AutoCloseable. Closing it releases the underlying
native context. Use try-with-resources so the native side is freed even
on exception.
Threading#
A SessionContext is not thread-safe. Do not share one across threads
without external synchronization. The simplest pattern is one context per
thread.
Configuration#
SessionContext.builder() exposes a fluent builder for overriding
DataFusion defaults — batch size, target partitions, statistics
collection, information schema, memory pool size, and the spill
directory. See the
SessionContextBuilder
Javadoc for the full list.
try (SessionContext ctx = SessionContext.builder()
.batchSize(4096)
.targetPartitions(8)
.build()) {
// ...
}