Why The World Needs Flarion. Read More

Streaming in Modern Query Engines: Where DataFusion Shines

By
Ran Reichman
read time
May 4, 2025

The landscape of data processing has evolved dramatically over the past few years. As datasets grow exponentially, query engines are adapting beyond traditional batch processing. Today's most innovative engines incorporate streaming capabilities to process data incrementally, enabling analysis of datasets larger than available memory while maintaining high performance. Among the leading contenders - Apache DataFusion, Polars, and DuckDB - the approaches to streaming differ significantly, with DataFusion emerging as the clear frontrunner for true streaming applications.

The Evolution of Streaming Query Execution

The term "streaming" has become somewhat ambiguous in the data processing world, spanning several distinct capabilities:

  1. Pipelined execution: Processing data in small chunks through a query plan
  2. Out-of-core processing: Handling datasets larger than available memory
  3. Continuous processing: Executing long-running queries on never-ending data streams
  4. Real-time ingestion: Continuously incorporating new data from external sources

While all three engines we're examining implement some form of streaming, they vary dramatically in their approach and capabilities. DuckDB and Polars primarily focus on the first two points—efficient execution of traditional queries—while DataFusion uniquely addresses all four aspects, providing a foundation for true streaming applications.

DataFusion's Native Streaming Architecture

Apache DataFusion, the Rust-based query engine at the heart of the Apache Arrow ecosystem, was designed with streaming as a core architectural principle. Most physical operators in DataFusion support an "Unbounded" execution mode specifically for handling infinite streams.

DataFusion's streaming architecture delivers several key advantages:

Streaming-First Design: While other engines adapted batch processing for streaming, DataFusion incorporates streaming principles natively. Its physical execution plan includes operators like StreamTableExec and SymmetricHashJoinExec specifically designed for unbounded data. This fundamental design choice enables true continuous query execution.

Streaming Join Support: Where traditional engines struggle with joins on streaming data, DataFusion's SymmetricHashJoinExec operator efficiently joins unbounded streams on the fly. This critical capability unlocks complex real-time analytics that would otherwise require batch window processing.

Arrow Integration: DataFusion processes data in Arrow record batches, providing memory-efficient, zero-copy operations on columnar data. This tight integration with Arrow gives DataFusion significant performance advantages when streaming data between systems or components.

Low-Level API Flexibility: DataFusion provides the foundational building blocks needed to construct sophisticated streaming applications. While higher-level functionality like watermarking is still emerging, its extensible architecture allows developers to implement these capabilities directly.

Polars and DuckDB: Streaming Capabilities

Both Polars and DuckDB offer capabilities related to data processing, though with important limitations for true streaming:

Polars' Streaming Status: Polars previously implemented a streaming execution mode that processed data in batches. However, it's worth noting that this streaming engine has been deprecated, and while the Polars team is working on a new streaming implementation, it's not currently something to build production systems on. Polars continues to excel at single-node workloads where memory isn't a significant constraint, offering exceptional performance for data transformation and analytics.

DuckDB Pipelined Execution: DuckDB employs a vectorized, pipelined execution model that processes data in small chunks (vectors) through query operators. This approach is particularly effective for quick in-memory operations and can handle streaming workloads efficiently when the data volumes definitively fit in memory. DuckDB's columnar architecture and parallel execution make analytical queries remarkably fast for these scenarios.

Neither engine is designed for continuous streaming of unbounded data. Both lack built-in stream ingestion capabilities and don't maintain persistent state across query executions. Each query runs to completion on the data available at execution time.

Choosing the Right Tool for Your Streaming Needs

Understanding the key differences in streaming capabilities helps select the right tool for specific use cases:

For True Streaming Applications: DataFusion stands out when you need continuous processing of unbounded data streams. Its ability to handle streaming joins, process Kafka data directly through StreamTableExec, and maintain state between batches makes it ideal for real-time applications with continuous data flows.

For Large Dataset Processing: Polars and DuckDB excel when processing large files or datasets that don't fit in memory. Their streaming execution modes efficiently handle out-of-core processing for analytics, ETL, and data transformation tasks with excellent performance.

Use Case Examples:

  • Real-time analytics pipeline: DataFusion provides the foundation for building systems that continuously ingest from Kafka and maintain up-to-date results.
  • Large log file analysis: Polars and DuckDB can efficiently process multi-gigabyte log files on modest hardware, even if the files exceed available memory.
  • Periodic batch processing: For scheduled ETL jobs that process accumulated data at intervals, Polars and DuckDB offer simpler implementation with excellent performance.

Each engine shines in its intended domain. DataFusion excels at true streaming while Polars and DuckDB deliver outstanding performance for analytical workloads and large dataset processing.

The Future of Streaming Query Engines

As data volumes continue growing and real-time analytics becomes increasingly critical, each engine is evolving to better serve its core use cases:

DataFusion continues advancing its streaming capabilities with ongoing development focused on:

  • Native watermarking support for proper event-time processing
  • Built-in state checkpointing for fault tolerance
  • Enhanced connector ecosystem for popular streaming sources

Polars and DuckDB continue to optimize their engines for analytical performance within their target domains, with Polars working on a new streaming engine and DuckDB enhancing its vectorized execution capabilities.

At Flarion, we believe in selecting the right tool for each specific task. We're always evaluating the strengths of different engines and are happy to give each one a chance in the domain where it shines. This pragmatic approach means using DataFusion when true streaming capabilities are required, while leveraging Polars for high-performance single-node analytics and DuckDB for quick in-memory operations.

Related Posts

The consumer of data infrastructure is changing. For two decades, the primary user of platforms like Spark, Ray, and Trino has been a human engineer - someone who writes queries, tunes configurations, debugs failures, and builds intuition about their cluster over months of operation. Now, AI agents are increasingly the ones writing SQL, submitting Spark jobs, orchestrating ETL pipelines, and running analytical workloads. Enterprises are increasingly adopting agentic data engineering workflows. At Flarion, we see a few key dynamics at play.

Tuning Will Converge - Then What?

Configuration tuning is getting automated. Agents can already follow runbooks, detect common failure patterns, and iterate on Spark configurations across runs. Auto-tuning systems are getting smarter. Over time, the combination of agents, automated tooling, and better platform defaults will squeeze most of the available performance out of configuration space. Executor sizing, partition counts, memory fractions, shuffle parameters - these will increasingly be handled by software rather than tribal knowledge.

Once configurations are well-tuned, the remaining performance gap is bounded by the execution engine itself. Spark's JVM-based, row-oriented architecture has fundamental overhead - garbage collection pauses, serialization costs, per-row function call overhead - that no amount of configuration tuning can eliminate. You can tune a Spark job perfectly and still leave 30-60% of potential performance on the table because of the engine's underlying execution model.

Flarion operates below this ceiling. Its native execution engine, built in Rust on Apache Arrow and DataFusion, replaces Spark's physical operators with vectorized execution. The gains come from a fundamentally different execution model. This means Flarion's acceleration stacks on top of whatever tuning an agent or auto-tuner has already done. Even the most optimized jobs get meaningfully faster.

For agents, this is the critical property. After exhausting configuration changes, an agent has two levers: continue building workload-specific tuning rules (low marginal benefit), or enable Flarion in a single configuration line and get 30-60% improvement immediately. In practice, it will do both - but the plugin delivers value on day one while tuning accumulates value over months.

Separation of Concerns

There's also a trust dimension. Even as agents become capable of modifying code and infrastructure, most organizations won't want them to. Separation of concerns applies to agents the same way it applies to engineering teams: the system writing analytical queries should not also be the system reconfiguring the cluster, rewriting pipeline code, or modifying deployment infrastructure. Giving an agent broad permissions to change Spark configurations, refactor ETL logic, or resize clusters introduces risk that most platform teams won't accept.

This means agents will operate within boundaries. They'll submit workloads, not redesign them. They'll use tools, not modify the toolchain. The performance improvements available to an agent are limited to what can be achieved without crossing those boundaries.

Flarion fits precisely within these boundaries - a single configuration change that delivers material performance gains without touching application code, cluster settings, or deployment infrastructure. The agent stays in its lane. The acceleration happens underneath.

Agents Are Measurement-Driven

Agents evaluate tools the way engineers wish they could: purely on observed results. An agent running a Spark job with Flarion enabled will observe that the job completed 40% faster at the same resource cost. It will observe this consistently across runs. Same input, same output, less time, less money. The signal is clean and unambiguous.

This matters because agents will increasingly be the ones deciding which tools to use within their permitted boundaries. They'll A/B test configurations, track cost-per-query over time, and converge on whatever delivers the best results. Tools that provide clear, repeatable value survive this selection process. Tools that require persuasion or organizational buy-in to demonstrate value don't - because agents aren't amenable to persuasion.

Flarion's 30-60% acceleration on real production workloads, validated across companies processing billions of records daily, is exactly the kind of signal that agents optimize for.

The Zero-Config Threshold

The combination of bounded permissions and measurement-driven evaluation creates clear selection pressure on infrastructure. The platforms that agents will adopt are the ones that cross what might be called the zero-config threshold: the point where a tool can be activated and deliver value without requiring expertise.

Consider what an agent requires of data infrastructure. First, activation must be trivial - a single parameter, a plugin, a flag. Something that's easily testable and verifiable. Second, failure modes must be graceful. If something isn't supported, the system should fall back silently rather than throw an error the agent must handle. Agents are poor at diagnosing infrastructure-specific failures; they need systems that degrade predictably rather than fail unexpectedly. Third, the cost model must be transparent. In cloud environments, wall-clock time is cost. An agent optimizing for efficiency needs tools where faster execution directly equals lower spend, without requiring hardware-specific provisioning decisions.

There's a broader principle at work here: infrastructure designed to be usable by an agent will also be easier for a human. Every property that makes a tool agent-friendly - trivial activation, graceful fallback, transparent cost - also makes it friendlier to the human engineer who doesn't have time to read a tuning guide. Building for agents raises the floor for everyone.

Flarion crosses this threshold by design. Its native execution engine intercepts Spark's physical execution plan and replaces supported operators with vectorized native execution. Unsupported operations fall back transparently to Spark. The agent never sees a Flarion-specific error. It never needs to know which operations are accelerated and which aren't. The entire acceleration layer is invisible to the caller, which is precisely what makes it usable by an agent.

Why Battle-Tested Ecosystems Win

Agents will prefer established ecosystems for the same reasons enterprises do: proven reliability at scale, broad connector support, extensive documentation that language models can reason about, and operational patterns that are well-understood. Spark processes petabytes daily across thousands of organizations. Ray orchestrates ML workloads at companies pushing the boundaries of model training. These platforms have accumulated years of production hardening that no new system can replicate quickly.

Making these ecosystems perform better without requiring expertise is where the real leverage lies. Flarion takes this approach across engines. Today it accelerates Spark workloads across every major deployment - open-source Spark, EMR, Dataproc, Databricks, and Spark on Kubernetes. The same Rust-based execution engine extends to Ray Data pipelines and Trino. An agent building a multi-engine analytical workflow gets consistent acceleration everywhere, through the same mechanism: enable the plugin, get faster results. No engine-specific optimization logic. No architectural trade-offs to evaluate.

This also means no new attack surface. Flarion runs as an in-process plugin inside the existing environment. No data leaves the perimeter. An agent can enable acceleration without triggering security reviews or compliance concerns - a friction reducer that matters enormously for enterprise adoption of agentic workflows.

Where This Goes

The logical endpoint of this trend is outcome-oriented infrastructure - systems where agents submit workloads with constraints like "as cheap as possible, under 20 minutes" and the platform figures out the rest. The infrastructure handles resource allocation, configuration tuning, hardware routing, and failure recovery autonomously.

Flarion is building toward this future. The vision is autonomous execution where workloads are submitted with SLA targets and the system handles everything else - auto-tuning, auto-scaling, auto-recovery. The interface an agent actually wants: declare the outcome, let the infrastructure deliver it.

The building blocks are here today. A native execution engine that eliminates JVM overhead. Vectorized processing that leverages modern hardware. Transparent fallback that guarantees compatibility. Cross-engine support that works wherever the workload runs.

The agents are already here. The question is which platforms are ready for them.

At the recent Open Lakehouse + AI Summit, OpenAI's data platform team gave a detailed account of how they run Spark internally. It's a revealing look at the operational reality of serving over a thousand internal customers across model training, analytics, safety research, and finance.

Their setup is representative of large-scale data platforms. They run both Databricks and a self-hosted "OpenAI Spark" on Kubernetes, unified through a shared Unity Catalog. Users switch between engines by changing a single configuration parameter. This hybrid pattern has become the norm for organizations processing data at serious volume, and OpenAI's experience illuminates why.

The Hybrid Reality

Three forces push enterprises toward running their own Spark alongside managed services. First, data security requirements often mandate that sensitive workloads stay within controlled infrastructure - no amount of compliance certifications fully satisfies some internal security teams. Second, the economics shift at scale: organizations processing petabytes daily often find that self-hosted deployments dramatically reduce costs for predictable, high-volume workloads. Third, operating your own stack means you can debug it. Full source code access and the ability to implement workload-specific optimizations matter when you're troubleshooting production incidents.

Building the Infrastructure Layer

The OpenAI team's account of scaling self-hosted Spark follows a familiar trajectory. Initial deployment is straightforward - Spark on Kubernetes, Airflow integration, jobs start flowing - and then usage grows.

Kubernetes control plane limits surface first - API servers buckling under listing operations from thousands of concurrent jobs. The response is multiple clusters, which immediately creates routing problems. Static routing (annotating jobs with target clusters) proves operationally painful. The solution is a gateway service that handles dynamic routing, access control, quota tracking, and auto-tuning based on historical patterns. This is infrastructure that managed services provide invisibly, and that self-hosted deployments must build explicitly.

Catalog integration across both managed and self-hosted environments requires careful coordination: permission verification, scoped credentials, distribution to executors. These are solved problems, but solving them yourself takes engineering time.

Performance at Petabyte Scale

OpenAI's talk gets more interesting when it turns to optimizations that don't appear in Spark documentation. Their CDC ingestion example is illustrative: at petabyte scale, Spark's default merge operation breaks down because mixed event types require outer joins that can't be broadcast. Their solution - splitting merges into separate operations for updates/deletes versus inserts - is the kind of pattern that emerges only from production experience.

Cloud storage API limits create another class of problems. Transaction-per-second caps become bottlenecks when scanning tables with extensive metadata. The optimizations are straightforward once you know to look: listing only from the last known commit, caching metadata, eliminating redundant status checks.

The most impactful optimization they described involves recognizing what data doesn't need to be read at all. Merge operations that update rows based on key matching don't need to scan target table columns if the CDC payload already contains the necessary data. This column pruning yielded 98% reductions in data scanned for some of their workloads.

The Architectural Ceiling

Even with these optimizations, OpenAI's team acknowledged limitations that configuration tuning can't address. PySpark's architecture creates both performance overhead and debugging complexity. JSON processing remains expensive. These are consequences of Spark's JVM-based architecture, and the industry is responding.

Remote shuffle services decouple shuffle data from executor lifecycles. Native acceleration engines process data in columnar format with SIMD instructions. This is the problem Flarion addresses directly - accelerating Spark workloads natively without requiring pipeline changes, targeting exactly the architectural constraints OpenAI describes. Organizations facing similar ceilings can evaluate whether native acceleration closes the gap before committing to the engineering investment of building their own optimization layer.

OpenAI's scale is unique, but its challenges are common. Hybrid deployments, control plane scaling, storage API limits, the performance ceiling of JVM-based processing - these are what enterprises running Spark at scale consistently encounter. Their solutions represent current best practice. The question for most organizations is when they'll face these problems, and whether they'll be ready.

Oops! Something went wrong while submitting the form.