Skip to content

[Discussion] Efficient Row Selection for Multi-Engine Support #14816

Open
@alchemist51

Description

@alchemist51

Background

We have an usecase where data is stored in multiple engines/formats and Parquet is the primary format containing all the data. While text queries are handled by inverted index format, numeric data queries and aggregations are processed via Parquet files. While the file formats are different, the data is sorted and stored in the same order across them.

We are using DataFusion to query Parquet files and wondering if the result of the query can be represented as a bit set of the document position (example below). Bit sets from the different engines can be intersected to identify the documents which meets the criteria. The resulting bit set then can be used to fetch the relevant documents from Parquet.

Example:

Assume we have the following data stored in parquet file:
colA colB
200 Autumn leaves
200 Salty breeze
100 Misty mountains
100 Misty mountains
200 Velvet curtains

For example, assume have an query like SELECT colB where colA = 100

The matching documents can be represented in the form of bitset : 00110 (row number starts from left). We want to use the matching document information collected from any underlying engine to fetch the relevant documents in the parquet file using DataFusion.

What we explored

We explored that one of the ways to fetch specific rows in DataFusion is by creating an access plan and passing it to ParquetExec. Since we need the complete plan, we can't parallelize it and start collecting data from Parquet, which reduces the overall query performance and is also memory-inefficient as we need to iterate the complete stream and convert it to the AccessPlan.

Possible Solution

If there is a way to:
  1. Pass the iterator directly to DataFusion, or
  2. Process the matching rows in batches.
Then it will enable on-demand conversion from the matching rows iterator to RowSelection in DataFusion thus improving efficiency by reducing memory overhead.

Questions

  1. Are there existing mechanisms in DataFusion to handle external iterators or row sources?
  2. What are the best practices for integrating DataFusion with external data sources in a streaming or batched manner?
  3. Are there any plans or ongoing work in the DataFusion project that might address this use case?
  4. Any alternative approaches or design patterns that might help us achieve efficient row selection in our multi-engine implementation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions