Skip to content

Commit

Permalink
Start query rewriting on alg nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Hafner committed Dec 6, 2024
1 parent 3183db5 commit f1aa0ae
Show file tree
Hide file tree
Showing 8 changed files with 578 additions and 297 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.polypheny.db.algebra.AlgWriter;
import org.polypheny.db.algebra.constant.Kind;
import org.polypheny.db.algebra.core.common.Modify;
import org.polypheny.db.algebra.logical.relational.LogicalRelModify;
import org.polypheny.db.algebra.logical.relational.LogicalRelValues;
import org.polypheny.db.algebra.metadata.AlgMetadataQuery;
import org.polypheny.db.algebra.type.AlgDataType;
Expand Down Expand Up @@ -105,33 +104,17 @@ protected RelModify(
this.operation = operation;
this.updateColumns = updateColumns;
this.sourceExpressions = sourceExpressions;
switch(operation) {
case UPDATE -> {
Objects.requireNonNull( updateColumns );
Objects.requireNonNull( sourceExpressions );
Preconditions.checkArgument( sourceExpressions.size() == updateColumns.size() );
}
case INSERT -> {
Preconditions.checkArgument( updateColumns == null );
Preconditions.checkArgument( sourceExpressions == null );
addIdentifiers();
}
default -> {
Preconditions.checkArgument( updateColumns == null );
Preconditions.checkArgument( sourceExpressions == null );
}
if (operation == Operation.UPDATE) {
Objects.requireNonNull( updateColumns );
Objects.requireNonNull( sourceExpressions );
Preconditions.checkArgument( sourceExpressions.size() == updateColumns.size() );
} else {
Preconditions.checkArgument( updateColumns == null );
Preconditions.checkArgument( sourceExpressions == null );
}
this.flattened = flattened;
}

private void addIdentifiers() {
if (!(input instanceof LogicalRelValues values) ) {
LOGGER.warn("New source type detected: {}", input);
return;
}
input = IdentifierUtils.overwriteIdentifierInInput( values );
}


public boolean isInsert() {
return operation == Operation.INSERT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.polypheny.db.processing.QueryContext.ParsedQueryContext;
import org.polypheny.db.transaction.Statement;
import org.polypheny.db.transaction.Transaction;
import org.polypheny.db.transaction.locking.IdentifierAdder;
import org.polypheny.db.util.DeadlockException;
import org.polypheny.db.util.Pair;

Expand Down Expand Up @@ -184,6 +185,7 @@ public List<ImplementationContext> anyPrepareQuery( QueryContext context, Statem
}

AlgRoot root = processor.translate( statement, parsed );
root = IdentifierAdder.process( root );

if ( transaction.isAnalyze() ) {
statement.getOverviewDuration().stop( "Translation" );
Expand Down
Loading

0 comments on commit f1aa0ae

Please sign in to comment.