Skip to content

Convert SqlToRel::statement_to_pan to take ownership rather than references. #1469

Description

@alamb

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
While working on some other code, I noticed that SqlToRel::statement_to_plan takes a reference to the parse tree -- this results in having to clone() many values (identifiers, etc) while converting a parsed SQL query to a LogicalPlan

The only callsite I could find throws away the parsed query immediately; Doing this would likely save lots of cloning internal to SqlToRel

Describe the solution you'd like

If someone wanted a fun project, they could convert SqlToRel::statement_to_pan to take ownership rather than references.
https://github.com/apache/arrow-datafusion/blob/0052667afae33ba9e549256d0d5d47e2f45e6ffb/datafusion/src/sql/planner.rs#L121

Specifically, change:

    pub fn statement_to_plan(&self, statement: &DFStatement) -> Result<LogicalPlan> {

To

    pub fn statement_to_plan(&self, statement: DFStatement) -> Result<LogicalPlan> {

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
This would be a software engineering exercise -- it wouldn't really require much in the way of knowledge of the guts of DataFusion

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions