Skip to content

Unparsing TableScan with an alias and a pushdown filter to SQL string #12368

@goldmedal

Description

@goldmedal

Is your feature request related to a problem or challenge?

In #12158 , we support unparse a TableScan with some pushdown options(e.g. projection, filter, or fetch ...). However, there are some issues with unparsing a TableScan with an alias and a filter.
Consider the following case:

    let table_scan_with_filter_alias = table_scan_with_filters(
        Some("t1"),  // projection
        &schema, // schema
        None,  // alias
        vec![col("id").gt(col("age"))],  // filter
    )?.alias("ta")?.build()?;

The implementation of #12158 will produce a SQL like

SELECT * FROM t1 AS ta WHERE (t1.id > t1.age)

but the SQL should be

SELECT * FROM t1 AS ta WHERE (ta.id > ta.age)

We need also to process the expression of the filter.

Describe the solution you'd like

Rewrite the columns used by the filter. Make their relation prefix be the alias instead of the table name.

Describe alternatives you've considered

No response

Additional context

No response

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