Skip to content

Commit

Permalink
Fix selects with conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Hafner committed Dec 31, 2024
1 parent c735156 commit 994b645
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import org.polypheny.db.algebra.logical.relational.LogicalRelTableFunctionScan;
import org.polypheny.db.algebra.logical.relational.LogicalRelUnion;
import org.polypheny.db.algebra.logical.relational.LogicalRelValues;
import org.polypheny.db.catalog.entity.Entity;
import org.polypheny.db.transaction.Transaction;

public class AlgTreeRewriter extends AlgShuttleImpl {
Expand Down Expand Up @@ -116,13 +117,24 @@ public AlgNode visit( LogicalRelFilter filter ) {
public AlgNode visit( LogicalRelProject project ) {
AlgNode input = project.getInput();
if ( input instanceof LogicalRelScan || input instanceof LogicalRelFilter ) {
//TODO TH: some inputs might not have an entity and thus return null here...
LogicalRelIdCollector collector = LogicalRelIdCollector.create( input, transaction, input.getEntity() );
Entity entity = findEntity( project );
LogicalRelIdCollector collector = LogicalRelIdCollector.create( input, transaction, entity );
return project.copy( project.getTraitSet(), List.of(collector) );
}
return visitChildren( project );
}

public Entity findEntity(AlgNode node) {
Entity entity = null;
while (entity == null && node != null) {
entity = node.getEntity();
if (node.getInputs().isEmpty()) {
continue;
}
node = node.getInput( 0 );
}
return entity;
}

@Override
public AlgNode visit( LogicalRelJoin join ) {
Expand Down

0 comments on commit 994b645

Please sign in to comment.