Skip to content

Commit

Permalink
fixing docOnLpg tests
Browse files Browse the repository at this point in the history
  • Loading branch information
datomo committed Dec 18, 2023
1 parent e975ef1 commit 161f437
Show file tree
Hide file tree
Showing 24 changed files with 139 additions and 64 deletions.
6 changes: 3 additions & 3 deletions core/src/main/java/org/polypheny/db/adapter/Modifiable.java
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,12 @@ static AlgNode getDocModifySubstitute( Modifiable modifiable, long allocId, Docu

if ( !modify.getInput().getTraitSet().contains( ModelTrait.RELATIONAL ) ) {
// push a transform under the modify for collector(right side of Streamer)
builder.transform( ModelTrait.RELATIONAL, DocumentType.asRelational(), false );
builder.transform( ModelTrait.RELATIONAL, DocumentType.asRelational(), false, null );
}

if ( updates.left == null && modify.operation != Operation.UPDATE && modify.operation != Operation.DELETE ) {
// Values require additional effort but less than updates
builder.transform( ModelTrait.RELATIONAL, DocumentType.asRelational(), false );
builder.transform( ModelTrait.RELATIONAL, DocumentType.asRelational(), false, null );
AlgNode provider = builder.build();
// right side prepared
builder.push( LogicalValues.createOneRow( modify.getCluster() ) );
Expand Down Expand Up @@ -368,7 +368,7 @@ static AlgNode getDocModifySubstitute( Modifiable modifiable, long allocId, Docu
builder.push( LogicalStreamer.create( provider, collector ) );
}

return builder.transform( ModelTrait.DOCUMENT, modify.getRowType(), false ).build();
return builder.transform( ModelTrait.DOCUMENT, modify.getRowType(), false, null ).build();
}

static Pair<List<String>, List<RexNode>> replaceUpdates( Pair<List<String>, List<RexNode>> updates, AlgBuilder builder ) {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/polypheny/db/adapter/Scannable.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static AlgNode getGraphScanSubstitute( Scannable scannable, long allocId, AlgBui
builder.scan( physicals.get( 2 ) );//edge
builder.scan( physicals.get( 3 ) );//edge Props

builder.transform( ModelTrait.GRAPH, GraphType.of(), false );
builder.transform( ModelTrait.GRAPH, GraphType.of(), false, null );

return builder.build();
}
Expand All @@ -128,7 +128,7 @@ static AlgNode getDocumentScanSubstitute( Scannable scannable, long allocId, Alg
PhysicalTable table = scannable.getCatalog().getPhysicalsFromAllocs( allocId ).get( 0 ).unwrap( PhysicalTable.class ).orElseThrow();
builder.scan( table );
AlgDataType rowType = DocumentType.ofId();
builder.transform( ModelTrait.DOCUMENT, rowType, false );
builder.transform( ModelTrait.DOCUMENT, rowType, false, null );
return builder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
package org.polypheny.db.algebra.core.common;

import lombok.Getter;
import lombok.experimental.SuperBuilder;
import org.polypheny.db.algebra.AbstractAlgNode;
import org.polypheny.db.catalog.entity.Entity;
import org.polypheny.db.plan.AlgOptCluster;
import org.polypheny.db.plan.AlgTraitSet;

@Getter
@SuperBuilder(toBuilder = true)
public abstract class Scan<E extends Entity> extends AbstractAlgNode {

public final E entity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.polypheny.db.algebra.core.document;

import lombok.experimental.SuperBuilder;
import org.polypheny.db.algebra.AlgWriter;
import org.polypheny.db.algebra.core.common.Scan;
import org.polypheny.db.algebra.type.DocumentType;
Expand All @@ -24,7 +25,7 @@
import org.polypheny.db.plan.AlgTraitSet;
import org.polypheny.db.schema.trait.ModelTrait;


@SuperBuilder(toBuilder = true)
public abstract class DocumentScan<E extends Entity> extends Scan<E> implements DocumentAlg {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ private Result implementDocumentOnGraph( EnumerableAlgImplementor implementor, P
Type outputJavaType = physType.getJavaRowType();
final Type enumeratorType = Types.of( Enumerator.class, outputJavaType );

MethodCallExpression call = Expressions.call( BuiltInMethod.X_MODEL_NODE_TO_COLLECTION.method, nodesExp );
MethodCallExpression call = Expressions.call( BuiltInMethod.X_MODEL_NODE_TO_COLLECTION.method, nodesExp, PolyString.of( names.get( 0 ) ).asExpression() );
Expression body = Expressions.new_(
enumeratorType,
EnumUtils.NO_EXPRS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,29 +371,31 @@ public Expression implement( RexToLixTranslator translator, RexCall call, List<E

private void defineCypherMethods() {
CypherImplementor implementor = new CypherImplementor();
map.put( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_ALL_MATCH ), implementor );
map.put( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_ANY_MATCH ), implementor );
map.put( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_SINGLE_MATCH ), implementor );
map.put( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_NONE_MATCH ), implementor );
defineMethod( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_LIKE ), BuiltInMethod.CYPHER_LIKE.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_PATH_MATCH ), BuiltInMethod.CYPHER_PATH_MATCH.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_NODE_EXTRACT ), BuiltInMethod.CYPHER_NODE_EXTRACT.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_EXTRACT_FROM_PATH ), BuiltInMethod.CYPHER_EXTRACT_FROM_PATH.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_NODE_MATCH ), BuiltInMethod.CYPHER_NODE_MATCH.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_HAS_LABEL ), BuiltInMethod.CYPHER_HAS_LABEL.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_HAS_PROPERTY ), BuiltInMethod.CYPHER_HAS_PROPERTY.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_EXTRACT_PROPERTY ), BuiltInMethod.CYPHER_EXTRACT_PROPERTY.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_EXTRACT_PROPERTIES ), BuiltInMethod.CYPHER_EXTRACT_PROPERTIES.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_EXTRACT_ID ), BuiltInMethod.CYPHER_EXTRACT_ID.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_EXTRACT_LABELS ), BuiltInMethod.CYPHER_EXTRACT_LABELS.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_EXTRACT_LABEL ), BuiltInMethod.CYPHER_EXTRACT_LABEL.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_TO_LIST ), BuiltInMethod.CYPHER_TO_LIST.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_ADJUST_EDGE ), BuiltInMethod.CYPHER_ADJUST_EDGE.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_SET_PROPERTY ), BuiltInMethod.CYPHER_SET_PROPERTY.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_SET_PROPERTIES ), BuiltInMethod.CYPHER_SET_PROPERTIES.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_SET_LABELS ), BuiltInMethod.CYPHER_SET_LABELS.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_REMOVE_LABELS ), BuiltInMethod.CYPHER_REMOVE_LABELS.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_REMOVE_PROPERTY ), BuiltInMethod.CYPHER_REMOVE_PROPERTY.method, NullPolicy.NONE );
QueryLanguage cypher = QueryLanguage.from( "cypher" );
map.put( OperatorRegistry.get( cypher, OperatorName.CYPHER_ALL_MATCH ), implementor );
map.put( OperatorRegistry.get( cypher, OperatorName.CYPHER_ANY_MATCH ), implementor );
map.put( OperatorRegistry.get( cypher, OperatorName.CYPHER_SINGLE_MATCH ), implementor );
map.put( OperatorRegistry.get( cypher, OperatorName.CYPHER_NONE_MATCH ), implementor );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_LIKE ), BuiltInMethod.CYPHER_LIKE.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_PATH_MATCH ), BuiltInMethod.CYPHER_PATH_MATCH.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_NODE_EXTRACT ), BuiltInMethod.CYPHER_NODE_EXTRACT.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_EXTRACT_FROM_PATH ), BuiltInMethod.CYPHER_EXTRACT_FROM_PATH.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_NODE_MATCH ), BuiltInMethod.CYPHER_NODE_MATCH.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_HAS_LABEL ), BuiltInMethod.CYPHER_HAS_LABEL.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_HAS_PROPERTY ), BuiltInMethod.CYPHER_HAS_PROPERTY.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_EXTRACT_PROPERTY ), BuiltInMethod.CYPHER_EXTRACT_PROPERTY.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_EXTRACT_PROPERTIES ), BuiltInMethod.CYPHER_EXTRACT_PROPERTIES.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_EXTRACT_ID ), BuiltInMethod.CYPHER_EXTRACT_ID.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_EXTRACT_LABELS ), BuiltInMethod.CYPHER_EXTRACT_LABELS.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_EXTRACT_LABEL ), BuiltInMethod.CYPHER_EXTRACT_LABEL.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_TO_LIST ), BuiltInMethod.CYPHER_TO_LIST.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_ADJUST_EDGE ), BuiltInMethod.CYPHER_ADJUST_EDGE.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_SET_PROPERTY ), BuiltInMethod.CYPHER_SET_PROPERTY.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_SET_PROPERTIES ), BuiltInMethod.CYPHER_SET_PROPERTIES.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_SET_LABELS ), BuiltInMethod.CYPHER_SET_LABELS.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_REMOVE_LABELS ), BuiltInMethod.CYPHER_REMOVE_LABELS.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_REMOVE_PROPERTY ), BuiltInMethod.CYPHER_REMOVE_PROPERTY.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_GRAPH_ONLY_LABEL ), BuiltInMethod.X_MODEL_GRAPH_ONLY_LABEL.method, NullPolicy.NONE );
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.polypheny.db.algebra.logical.common;

import java.util.List;
import lombok.Setter;
import org.polypheny.db.algebra.AlgNode;
import org.polypheny.db.algebra.AlgWriter;
import org.polypheny.db.algebra.core.common.Transformer;
Expand All @@ -27,6 +28,7 @@
import org.polypheny.db.schema.trait.ModelTrait;


@Setter
public class LogicalTransformer extends Transformer {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.polypheny.db.algebra.logical.document;

import java.util.List;
import lombok.experimental.SuperBuilder;
import org.polypheny.db.algebra.AlgNode;
import org.polypheny.db.algebra.AlgShuttle;
import org.polypheny.db.algebra.core.document.DocumentScan;
Expand All @@ -29,7 +30,7 @@
import org.polypheny.db.plan.AlgTraitSet;
import org.polypheny.db.schema.trait.ModelTrait;


@SuperBuilder(toBuilder = true)
public class LogicalDocumentScan extends DocumentScan<Entity> implements RelationalTransformable {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,8 @@ public enum OperatorName {

CYPHER_LIKE( LangFunctionOperator.class ),

CYPHER_GRAPH_ONLY_LABEL( LangFunctionOperator.class ),

// CROSS MODEL FUNCTION

CROSS_MODEL_ITEM( LangFunctionOperator.class ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ private static AlgNode handleGraphEntity( AlgOptRuleCall call, Scan<?> scan, All

if ( scan.getModel() != scan.entity.dataModel ) {
// cross-model queries need a transformer first, we let another rule handle that
alg = call.builder().push( alg ).transform( scan.getTraitSet().getTrait( ModelTraitDef.INSTANCE ), scan.getRowType(), true ).build();
AlgBuilder builder = call.builder().push( alg );

alg = builder.transform( scan.getTraitSet().getTrait( ModelTraitDef.INSTANCE ), scan.getRowType(), true, alloc.name ).build();

}
return alg;
}
Expand All @@ -87,7 +90,7 @@ private static AlgNode handleDocumentEntity( AlgOptRuleCall call, Scan<?> scan,

if ( scan.getModel() != scan.entity.dataModel ) {
// cross-model queries need a transformer first, we let another rule handle that
alg = call.builder().push( alg ).transform( scan.getTraitSet().getTrait( ModelTraitDef.INSTANCE ), scan.getRowType(), true ).build();
alg = call.builder().push( alg ).transform( scan.getTraitSet().getTrait( ModelTraitDef.INSTANCE ), scan.getRowType(), true, null ).build();
}
return alg;
}
Expand All @@ -101,7 +104,7 @@ private AlgNode handleRelationalEntity( AlgOptRuleCall call, Scan<?> scan, Alloc

if ( scan.getModel() != scan.entity.dataModel ) {
// cross-model queries need a transformer first, we let another rule handle that
alg = call.builder().push( alg ).transform( scan.getTraitSet().getTrait( ModelTraitDef.INSTANCE ), scan.getRowType(), true ).build();
alg = call.builder().push( alg ).transform( scan.getTraitSet().getTrait( ModelTraitDef.INSTANCE ), scan.getRowType(), true, null ).build();
}
return alg;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@
import lombok.EqualsAndHashCode;
import lombok.Value;
import lombok.experimental.NonFinal;
import lombok.experimental.SuperBuilder;
import org.apache.calcite.linq4j.tree.Expression;
import org.apache.calcite.linq4j.tree.Expressions;
import org.polypheny.db.catalog.Catalog;
import org.polypheny.db.catalog.entity.Entity;
import org.polypheny.db.catalog.logistic.DataModel;

@EqualsAndHashCode(callSuper = true)
@Value
@NonFinal
@SuperBuilder(toBuilder = true)
public class AllocationCollection extends AllocationEntity {

public AllocationCollection(
Expand All @@ -53,4 +56,10 @@ public Expression asExpression() {
return Expressions.call( Catalog.CATALOG_EXPRESSION, "getAllocCollection", Expressions.constant( id ) );
}


@Override
public Entity withName( String name ) {
return toBuilder().name( name ).build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@Value
@NonFinal
@Slf4j
@SuperBuilder
@SuperBuilder(toBuilder = true)
@SerializeClass(subclasses = { AllocationTable.class, AllocationGraph.class, AllocationCollection.class })
public abstract class AllocationEntity extends Entity {

Expand Down Expand Up @@ -78,4 +78,7 @@ public PartitionType getPartitionType() {
return PartitionType.NONE;
}


public abstract Entity withName( String name );

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@
import lombok.EqualsAndHashCode;
import lombok.Value;
import lombok.experimental.NonFinal;
import lombok.experimental.SuperBuilder;
import org.apache.calcite.linq4j.tree.Expression;
import org.apache.calcite.linq4j.tree.Expressions;
import org.polypheny.db.catalog.Catalog;
import org.polypheny.db.catalog.entity.Entity;
import org.polypheny.db.catalog.logistic.DataModel;

@EqualsAndHashCode(callSuper = true)
@Value
@NonFinal
@SuperBuilder(toBuilder = true)
public class AllocationGraph extends AllocationEntity {


Expand All @@ -55,4 +58,9 @@ public Expression asExpression() {
}


@Override
public Entity withName( String name ) {
return toBuilder().name( name ).build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.polypheny.db.algebra.type.AlgDataTypeFactory;
import org.polypheny.db.algebra.type.AlgDataTypeImpl;
import org.polypheny.db.catalog.Catalog;
import org.polypheny.db.catalog.entity.Entity;
import org.polypheny.db.catalog.entity.logical.LogicalColumn;
import org.polypheny.db.catalog.logistic.DataModel;

Expand Down Expand Up @@ -96,4 +97,10 @@ public List<Long> getColumnIds() {
return getColumns().stream().map( c -> c.columnId ).collect( Collectors.toList() );
}


@Override
public Entity withName( String name ) {
return toBuilder().name( name ).build();
}

}
Loading

0 comments on commit 161f437

Please sign in to comment.