Skip to content

Comet Native Executors: pass scalar subquery results to the cluster without rewriting the plan #7374

Open

Description

@andygrove

What is the problem the feature request solves?

Before submitting a query, the driver (#7289) replaces each scalar subquery in the plan with a literal of its result. It parses the serialized plan of every stage that holds a subquery, and every partition's own plan for a stage that reads files, walks them, and serializes them again. For a scan over many files, that is the bulk of the request, redone on the driver for every query.

Describe the potential solution

Send the results once, as map<int64, Expr> subquery_results on QueryRequest and Fragment. Have PhysicalPlanner look up ExprStruct::Subquery in that map when it plans a block with native inputs, where today it fails because there is no JVM. The driver would then serialize only the literals.

Additional context

The rewrite is withSubqueryResults in CometNativeExecutorsExec.scala.

Part of #7288.

Willingness to contribute

Yes. I can contribute this feature independently.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions