Skip to content

CteWorkTable does not properly apply projection #18992

@Tpt

Description

@Tpt

Describe the bug

The CteWorkTable discards the projection argument of the TableProvider::scan instead of properly applying it. It can cause issues when the projection is not the identity

To Reproduce

Use CteWorkTable with a projection that is not the identity

Example of query plan where the optimizer create a projection:

RecursiveQuery: is_distinct=true
  Projection: quads.subject, quads.predicate, quads.object
    Inner Join: 98c0b23282ec3edfa32aea6fa0af5240 = quads.subject
      Projection: Binary("1,98,167,105,102,76,38,234,212,25,70,164,18,107,5,43,205") AS 98c0b23282ec3edfa32aea6fa0af5240
        EmptyRelation: rows=1
      TableScan: quads projection=[subject, predicate, object], full_filters=[quads.graph_name IS NULL]
  Projection: quads.subject, quads.predicate, quads.object
    Inner Join: cbd.object = quads.subject
      Filter: sparql:isBlank(cbd.object)
        TableScan: cbd projection=[object]
      TableScan: quads projection=[subject, predicate, object], full_filters=[quads.graph_name IS NULL]

Note the TableScan: cbd projection=[object] that is using `CteWorkTable

Expected behavior

Projection properly applied

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions