From 161f43741941efec0542251347f56b5fe5c14a63 Mon Sep 17 00:00:00 2001 From: datomo Date: Tue, 19 Dec 2023 00:37:36 +0100 Subject: [PATCH] fixing docOnLpg tests --- .../org/polypheny/db/adapter/Modifiable.java | 6 +-- .../org/polypheny/db/adapter/Scannable.java | 4 +- .../db/algebra/core/common/Scan.java | 2 + .../algebra/core/document/DocumentScan.java | 3 +- .../enumerable/EnumerableTransformer.java | 2 +- .../db/algebra/enumerable/RexImpTable.java | 48 ++++++++++--------- .../logical/common/LogicalTransformer.java | 2 + .../logical/document/LogicalDocumentScan.java | 3 +- .../db/algebra/operators/OperatorName.java | 2 + .../rules/AllocationToPhysicalScanRule.java | 9 ++-- .../allocation/AllocationCollection.java | 9 ++++ .../entity/allocation/AllocationEntity.java | 5 +- .../entity/allocation/AllocationGraph.java | 8 ++++ .../entity/allocation/AllocationTable.java | 7 +++ .../db/functions/CrossModelFunctions.java | 43 +++++++++-------- .../java/org/polypheny/db/rex/RexBuilder.java | 16 +++++++ .../polypheny/db/rex/RexProgramBuilder.java | 6 +++ .../org/polypheny/db/tools/AlgBuilder.java | 10 ++-- .../org/polypheny/db/util/BuiltInMethod.java | 5 +- .../db/routing/routers/BaseRouter.java | 2 +- .../db/crossmodel/DocumentOnLpgTest.java | 2 + .../polypheny/db/cypher/CypherRegisterer.java | 2 + .../languages/mql2alg/MqlToAlgConverter.java | 5 ++ .../org/polypheny/db/webui/HttpServer.java | 2 +- 24 files changed, 139 insertions(+), 64 deletions(-) diff --git a/core/src/main/java/org/polypheny/db/adapter/Modifiable.java b/core/src/main/java/org/polypheny/db/adapter/Modifiable.java index 0ad5688311..09cf2533ca 100644 --- a/core/src/main/java/org/polypheny/db/adapter/Modifiable.java +++ b/core/src/main/java/org/polypheny/db/adapter/Modifiable.java @@ -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() ) ); @@ -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> replaceUpdates( Pair, List> updates, AlgBuilder builder ) { diff --git a/core/src/main/java/org/polypheny/db/adapter/Scannable.java b/core/src/main/java/org/polypheny/db/adapter/Scannable.java index 5d1f5b3482..4856bc6c08 100644 --- a/core/src/main/java/org/polypheny/db/adapter/Scannable.java +++ b/core/src/main/java/org/polypheny/db/adapter/Scannable.java @@ -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(); } @@ -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(); } diff --git a/core/src/main/java/org/polypheny/db/algebra/core/common/Scan.java b/core/src/main/java/org/polypheny/db/algebra/core/common/Scan.java index 54eae3b536..471e5149a0 100644 --- a/core/src/main/java/org/polypheny/db/algebra/core/common/Scan.java +++ b/core/src/main/java/org/polypheny/db/algebra/core/common/Scan.java @@ -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 extends AbstractAlgNode { public final E entity; diff --git a/core/src/main/java/org/polypheny/db/algebra/core/document/DocumentScan.java b/core/src/main/java/org/polypheny/db/algebra/core/document/DocumentScan.java index 0c5c1bc05b..4f8b8408df 100644 --- a/core/src/main/java/org/polypheny/db/algebra/core/document/DocumentScan.java +++ b/core/src/main/java/org/polypheny/db/algebra/core/document/DocumentScan.java @@ -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; @@ -24,7 +25,7 @@ import org.polypheny.db.plan.AlgTraitSet; import org.polypheny.db.schema.trait.ModelTrait; - +@SuperBuilder(toBuilder = true) public abstract class DocumentScan extends Scan implements DocumentAlg { diff --git a/core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableTransformer.java b/core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableTransformer.java index 7127b5181f..8202b052e5 100644 --- a/core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableTransformer.java +++ b/core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableTransformer.java @@ -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, diff --git a/core/src/main/java/org/polypheny/db/algebra/enumerable/RexImpTable.java b/core/src/main/java/org/polypheny/db/algebra/enumerable/RexImpTable.java index 76f74a54b3..66196758c1 100644 --- a/core/src/main/java/org/polypheny/db/algebra/enumerable/RexImpTable.java +++ b/core/src/main/java/org/polypheny/db/algebra/enumerable/RexImpTable.java @@ -371,29 +371,31 @@ public Expression implement( RexToLixTranslator translator, RexCall call, List implements RelationalTransformable { /** diff --git a/core/src/main/java/org/polypheny/db/algebra/operators/OperatorName.java b/core/src/main/java/org/polypheny/db/algebra/operators/OperatorName.java index 81f731feb3..4c6bae20c4 100644 --- a/core/src/main/java/org/polypheny/db/algebra/operators/OperatorName.java +++ b/core/src/main/java/org/polypheny/db/algebra/operators/OperatorName.java @@ -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 ), diff --git a/core/src/main/java/org/polypheny/db/algebra/rules/AllocationToPhysicalScanRule.java b/core/src/main/java/org/polypheny/db/algebra/rules/AllocationToPhysicalScanRule.java index 77f655f41d..c4250dba71 100644 --- a/core/src/main/java/org/polypheny/db/algebra/rules/AllocationToPhysicalScanRule.java +++ b/core/src/main/java/org/polypheny/db/algebra/rules/AllocationToPhysicalScanRule.java @@ -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; } @@ -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; } @@ -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; } diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationCollection.java b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationCollection.java index 31b207c0bc..23ff965a4d 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationCollection.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationCollection.java @@ -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( @@ -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(); + } + } diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationEntity.java b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationEntity.java index 520148dba1..58b442ed22 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationEntity.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationEntity.java @@ -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 { @@ -78,4 +78,7 @@ public PartitionType getPartitionType() { return PartitionType.NONE; } + + public abstract Entity withName( String name ); + } diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationGraph.java b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationGraph.java index 0c0f89e8d0..3599c6226d 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationGraph.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationGraph.java @@ -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 { @@ -55,4 +58,9 @@ public Expression asExpression() { } + @Override + public Entity withName( String name ) { + return toBuilder().name( name ).build(); + } + } diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationTable.java b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationTable.java index dfe05cc57d..2a126e8434 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationTable.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationTable.java @@ -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; @@ -96,4 +97,10 @@ public List getColumnIds() { return getColumns().stream().map( c -> c.columnId ).collect( Collectors.toList() ); } + + @Override + public Entity withName( String name ) { + return toBuilder().name( name ).build(); + } + } diff --git a/core/src/main/java/org/polypheny/db/functions/CrossModelFunctions.java b/core/src/main/java/org/polypheny/db/functions/CrossModelFunctions.java index 70dfb1be89..9929dfcef2 100644 --- a/core/src/main/java/org/polypheny/db/functions/CrossModelFunctions.java +++ b/core/src/main/java/org/polypheny/db/functions/CrossModelFunctions.java @@ -24,16 +24,19 @@ import java.util.Map.Entry; import java.util.stream.Collectors; import java.util.stream.Stream; +import javax.annotation.Nullable; import org.apache.calcite.linq4j.AbstractEnumerable; import org.apache.calcite.linq4j.Enumerable; import org.apache.calcite.linq4j.Enumerator; import org.apache.calcite.linq4j.Linq4j; import org.apache.calcite.linq4j.function.Function0; +import org.apache.calcite.linq4j.function.Function1; import org.polypheny.db.adapter.DataContext; import org.polypheny.db.adapter.java.JavaTypeFactory; import org.polypheny.db.algebra.core.common.Modify; import org.polypheny.db.algebra.core.common.Modify.Operation; import org.polypheny.db.algebra.type.AlgDataType; +import org.polypheny.db.algebra.type.DocumentType; import org.polypheny.db.algebra.type.GraphType; import org.polypheny.db.type.PolyType; import org.polypheny.db.type.entity.PolyInteger; @@ -46,6 +49,7 @@ import org.polypheny.db.type.entity.graph.PolyEdge; import org.polypheny.db.type.entity.graph.PolyGraph; import org.polypheny.db.type.entity.graph.PolyNode; +import org.polypheny.db.type.entity.relational.PolyMap; public class CrossModelFunctions { @@ -143,12 +147,12 @@ public Enumerator enumerator() { PolyDocument doc = PolyDocument.parse( r.toString() ); Map map = new HashMap<>(); for ( Entry entry : doc.entrySet() ) { - if ( entry.getKey().equals( PolyString.of( "_id" ) ) ) { + if ( entry.getKey().equals( PolyString.of( DocumentType.DOCUMENT_ID ) ) ) { continue; } map.put( entry.getKey(), entry.getValue() ); } - return new PolyNode( doc.get( PolyString.of( "_id" ) ).asString(), new PolyDictionary( map ), PolyList.of( label ), PolyString.of( "n" ) ); + return new PolyNode( doc.get( PolyString.of( DocumentType.DOCUMENT_ID ) ).asString(), new PolyDictionary( map ), PolyList.of( label ), PolyString.of( "n" ) ); } ); } }; @@ -156,30 +160,29 @@ public Enumerator enumerator() { @SuppressWarnings("UnusedDeclaration") - public static Enumerable nodesToCollection( Enumerable enumerable ) { + public static Enumerable nodesToCollection( Enumerable enumerable, @Nullable PolyString label ) { PolyGraph graph = null; - for ( PolyGraph g : enumerable ) { - graph = g; + for ( PolyValue[] value : enumerable ) { + graph = value[0].asGraph(); } - return Linq4j.asEnumerable( Stream.concat( graph.getNodes().values().stream(), graph.getEdges().values().stream() ).map( n -> { + Function1, Stream> node = elements -> elements.values().stream(); + Function1, Stream> edge = elements -> elements.values().stream(); + if ( label != null ) { + node = elements -> elements.values().stream().filter( n -> n.labels.contains( label ) ); + edge = elements -> elements.values().stream().filter( n -> n.labels.contains( label ) ); + } + + return Linq4j.asEnumerable( Stream.concat( node.apply( graph.getNodes() ), edge.apply( graph.getEdges() ) ).map( n -> { PolyDocument doc = new PolyDocument( n.properties.entrySet().stream().collect( Collectors.toMap( Entry::getKey, Entry::getValue ) ) ); - doc.put( PolyString.of( "_id" ), PolyString.of( n.id.value.substring( 0, 23 ) ) ); - return doc; + doc.put( PolyString.of( DocumentType.DOCUMENT_ID ), PolyString.of( n.id.value.substring( 0, 23 ) ) ); + return new PolyValue[]{ doc }; } ).collect( Collectors.toList() ) ); + } + - /*return new AbstractEnumerable<>() { - @Override - public Enumerator enumerator() { - return Linq4j.transform( - enumerable.enumerator(), - r -> { - PolyDocument doc = new PolyDocument( r.properties.entrySet().stream().collect( Collectors.toMap( Entry::getKey, Entry::getValue ) ) ); - doc.put( PolyString.of( "_id" ), PolyString.of( r.id.value.substring( 0, 23 ) ) ); - return doc; - } ); - } - };*/ + public static PolyValue cypherOnlyLabelGraph( PolyValue value, PolyString label ) { + return null; } diff --git a/core/src/main/java/org/polypheny/db/rex/RexBuilder.java b/core/src/main/java/org/polypheny/db/rex/RexBuilder.java index ca606142e6..ece109b4cf 100644 --- a/core/src/main/java/org/polypheny/db/rex/RexBuilder.java +++ b/core/src/main/java/org/polypheny/db/rex/RexBuilder.java @@ -1626,5 +1626,21 @@ public RexCall makeLpgLabels() { List.of( makeInputRef( typeFactory.createPolyType( PolyType.NODE ), 0 ) ) ); } + + public RexCall makeHasLabel( String label ) { + return new RexCall( + typeFactory.createPolyType( PolyType.BOOLEAN ), + OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_HAS_LABEL ), + List.of( makeInputRef( typeFactory.createPolyType( PolyType.NODE ), 0 ), makeLiteral( label ) ) ); + } + + + public RexCall makeLabelFilter( String label ) { + return new RexCall( + typeFactory.createPolyType( PolyType.BOOLEAN ), + OperatorRegistry.get( QueryLanguage.from( "cypher" ), OperatorName.CYPHER_GRAPH_ONLY_LABEL ), + List.of( makeInputRef( typeFactory.createPolyType( PolyType.GRAPH ), 0 ), makeLiteral( label ) ) ); + } + } diff --git a/core/src/main/java/org/polypheny/db/rex/RexProgramBuilder.java b/core/src/main/java/org/polypheny/db/rex/RexProgramBuilder.java index bd59ee5c6b..1a9f3b7f26 100644 --- a/core/src/main/java/org/polypheny/db/rex/RexProgramBuilder.java +++ b/core/src/main/java/org/polypheny/db/rex/RexProgramBuilder.java @@ -42,6 +42,7 @@ import org.polypheny.db.algebra.operators.OperatorName; import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.algebra.type.AlgDataTypeField; +import org.polypheny.db.algebra.type.GraphType; import org.polypheny.db.languages.OperatorRegistry; import org.polypheny.db.plan.AlgOptPredicateList; import org.polypheny.db.plan.AlgOptUtil; @@ -754,6 +755,11 @@ public void clearCondition() { */ public void addIdentity() { assert projectRefList.isEmpty(); + if ( inputRowType instanceof GraphType ) { + addProject( 0, "graph" ); + return; + } + for ( AlgDataTypeField field : inputRowType.getFields() ) { addProject( new RexIndexRef( field.getIndex(), field.getType() ), diff --git a/core/src/main/java/org/polypheny/db/tools/AlgBuilder.java b/core/src/main/java/org/polypheny/db/tools/AlgBuilder.java index e6d7cab9d8..66c3edb952 100644 --- a/core/src/main/java/org/polypheny/db/tools/AlgBuilder.java +++ b/core/src/main/java/org/polypheny/db/tools/AlgBuilder.java @@ -232,9 +232,9 @@ protected AlgBuilder( Context context, AlgOptCluster cluster, Snapshot snapshot .orElse( AlgFactories.DEFAULT_DOCUMENTS_FACTORY ); final RexExecutor executor = context.unwrap( RexExecutor.class ).orElse( - Util.first( - cluster.getPlanner().getExecutor(), - RexUtil.EXECUTOR ) ); + Util.first( + cluster.getPlanner().getExecutor(), + RexUtil.EXECUTOR ) ); this.simplifier = new RexSimplify( cluster.getRexBuilder(), AlgOptPredicateList.EMPTY, executor ); } @@ -2494,7 +2494,7 @@ public AlgBuilder convert( AlgDataType castRowType, boolean rename ) { } - public AlgBuilder transform( ModelTrait model, AlgDataType rowType, boolean isCrossModel ) { + public AlgBuilder transform( ModelTrait model, AlgDataType rowType, boolean isCrossModel, String name ) { if ( peek().getTraitSet().contains( model ) ) { return this; } @@ -2514,7 +2514,7 @@ public AlgBuilder transform( ModelTrait model, AlgDataType rowType, boolean isCr return this; } - push( new LogicalTransformer( input.getCluster(), nodes, null, input.getTraitSet().getTrait( ModelTraitDef.INSTANCE ), model, rowType, isCrossModel ) ); + push( new LogicalTransformer( input.getCluster(), nodes, name == null ? null : List.of( name ), input.getTraitSet().getTrait( ModelTraitDef.INSTANCE ), model, rowType, isCrossModel ) ); return this; } diff --git a/core/src/main/java/org/polypheny/db/util/BuiltInMethod.java b/core/src/main/java/org/polypheny/db/util/BuiltInMethod.java index 48469a2551..f89a4c547a 100644 --- a/core/src/main/java/org/polypheny/db/util/BuiltInMethod.java +++ b/core/src/main/java/org/polypheny/db/util/BuiltInMethod.java @@ -493,10 +493,11 @@ public enum BuiltInMethod { X_MODEL_TABLE_TO_NODE( CrossModelFunctions.class, "tableToNodes", Enumerable.class, PolyString.class, List.class ), X_MODEL_MERGE_NODE_COLLECTIONS( CrossModelFunctions.class, "mergeNodeCollections", List.class ), X_MODEL_COLLECTION_TO_NODE( CrossModelFunctions.class, "collectionToNodes", Enumerable.class, PolyString.class ), - X_MODEL_NODE_TO_COLLECTION( CrossModelFunctions.class, "nodesToCollection", Enumerable.class ), + X_MODEL_NODE_TO_COLLECTION( CrossModelFunctions.class, "nodesToCollection", Enumerable.class, PolyString.class ), X_MODEL_ITEM( CrossModelFunctions.class, "docItem", String.class, String.class ), - SINGLE_TO_ARRAY_ENUMERABLE( Functions.class, "singleToArray", Enumerable.class ); + SINGLE_TO_ARRAY_ENUMERABLE( Functions.class, "singleToArray", Enumerable.class ), + X_MODEL_GRAPH_ONLY_LABEL( CrossModelFunctions.class, "cypherOnlyLabelGraph", PolyValue.class, PolyString.class ); private static final String toIntOptional = "toIntOptional"; public final Method method; diff --git a/dbms/src/main/java/org/polypheny/db/routing/routers/BaseRouter.java b/dbms/src/main/java/org/polypheny/db/routing/routers/BaseRouter.java index e70a4cf515..aca7068a4b 100644 --- a/dbms/src/main/java/org/polypheny/db/routing/routers/BaseRouter.java +++ b/dbms/src/main/java/org/polypheny/db/routing/routers/BaseRouter.java @@ -268,7 +268,7 @@ public DocumentScan handleDocScan( AllocationEntity allocation = snapshot.alloc().getAlloc( placement.id, partitions.get( 0 ).id ).orElseThrow(); // a native placement was used, we go with that - return new LogicalDocumentScan( scan.getCluster(), scan.getTraitSet(), allocation ); + return new LogicalDocumentScan( scan.getCluster(), scan.getTraitSet(), allocation.withName( scan.entity.name ) ); } throw new GenericRuntimeException( "Error while routing graph query." ); diff --git a/dbms/src/test/java/org/polypheny/db/crossmodel/DocumentOnLpgTest.java b/dbms/src/test/java/org/polypheny/db/crossmodel/DocumentOnLpgTest.java index 5d6d29c45a..a9d208238b 100644 --- a/dbms/src/test/java/org/polypheny/db/crossmodel/DocumentOnLpgTest.java +++ b/dbms/src/test/java/org/polypheny/db/crossmodel/DocumentOnLpgTest.java @@ -63,6 +63,8 @@ public void simpleFindUppercaseTest() { TestHelper.MongoConnection.checkDocResultSet( execute( format( "db.%s.find({})", DATA_LABEL.toUpperCase() ), GRAPH_NAME ), ImmutableList.of( "{\"key\":\"5\"}" ), true, true ); + + CypherTestTemplate.execute( format( "MATCH (n:%s {key: 5}) DELETE n", DATA_LABEL.toUpperCase() ), GRAPH_NAME ); } diff --git a/plugins/cypher-language/src/main/java/org/polypheny/db/cypher/CypherRegisterer.java b/plugins/cypher-language/src/main/java/org/polypheny/db/cypher/CypherRegisterer.java index bdd8df3b5f..937a447256 100644 --- a/plugins/cypher-language/src/main/java/org/polypheny/db/cypher/CypherRegisterer.java +++ b/plugins/cypher-language/src/main/java/org/polypheny/db/cypher/CypherRegisterer.java @@ -44,6 +44,8 @@ public static void registerOperators() { register( OperatorName.CYPHER_HAS_LABEL, new LangFunctionOperator( OperatorName.CYPHER_HAS_LABEL.name(), Kind.CYPHER_FUNCTION ) ); + register( OperatorName.CYPHER_GRAPH_ONLY_LABEL, new LangFunctionOperator( OperatorName.CYPHER_GRAPH_ONLY_LABEL.name(), Kind.CYPHER_FUNCTION ) ); + register( OperatorName.CYPHER_PATH_MATCH, new LangFunctionOperator( OperatorName.CYPHER_PATH_MATCH.name(), Kind.CYPHER_FUNCTION ) ); register( OperatorName.CYPHER_NODE_EXTRACT, new LangFunctionOperator( OperatorName.CYPHER_NODE_EXTRACT.name(), Kind.CYPHER_FUNCTION ) ); diff --git a/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql2alg/MqlToAlgConverter.java b/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql2alg/MqlToAlgConverter.java index d96944f490..3c1b27297c 100644 --- a/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql2alg/MqlToAlgConverter.java +++ b/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql2alg/MqlToAlgConverter.java @@ -67,6 +67,7 @@ import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.logical.LogicalCollection; import org.polypheny.db.catalog.entity.logical.LogicalGraph; +import org.polypheny.db.catalog.entity.logical.LogicalGraph.SubstitutionGraph; import org.polypheny.db.catalog.entity.logical.LogicalNamespace; import org.polypheny.db.catalog.entity.logical.LogicalTable; import org.polypheny.db.catalog.exceptions.GenericRuntimeException; @@ -314,6 +315,10 @@ private Entity getEntity( MqlCollectionStatement query, long namespaceId ) { } Optional optionalGraph = snapshot.graph().getGraph( namespace.id ); + if ( optionalGraph.isPresent() ) { + LogicalGraph graph = optionalGraph.get(); + return new SubstitutionGraph( graph.id, query.getCollection(), false, graph.caseSensitive ); + } return optionalGraph.orElseThrow(); } diff --git a/webui/src/main/java/org/polypheny/db/webui/HttpServer.java b/webui/src/main/java/org/polypheny/db/webui/HttpServer.java index 7d40b07c02..3d09bf1dd7 100644 --- a/webui/src/main/java/org/polypheny/db/webui/HttpServer.java +++ b/webui/src/main/java/org/polypheny/db/webui/HttpServer.java @@ -366,7 +366,7 @@ public void addSerializedRoute( String route, BiConsumer action, public void addSerializedRoute( String route, Consumer action, HandlerType type ) { - log.info( "Added route: {}", route ); + log.debug( "Added route: {}", route ); switch ( type ) { case GET: server.get( route, action::accept );