Skip to content

Commit

Permalink
Small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
vogti committed Aug 25, 2024
1 parent 61d6f1a commit d7ad4b9
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 40 deletions.
3 changes: 0 additions & 3 deletions dbms/src/test/java/org/polypheny/db/cypher/DdlTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ public void addPlacementTest() throws SQLException {
execute( "DROP DATABASE " + graphName );

} finally {

removeStore( "store1" );
}
}
Expand Down Expand Up @@ -203,9 +202,7 @@ private void removeStore( String name ) throws SQLException {
try ( JdbcConnection polyphenyDbConnection = new JdbcConnection( true ) ) {
Connection connection = polyphenyDbConnection.getConnection();
try ( Statement statement = connection.createStatement() ) {

statement.executeUpdate( String.format( "ALTER ADAPTERS DROP \"%s\"", name ) );

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ public void simpleCaseTest() {
ELSE 3
END AS result, n.eyes""" );

containsRows( res, true, false, Row.of( TestLiteral.from( "Alice" ), TestLiteral.from( 2 ) ), Row.of( TestLiteral.from( "Bob" ), TestLiteral.from( 1 ) ), Row.of( TestLiteral.from( "Charlie" ), TestLiteral.from( 3 ) ) );
containsRows( res, true, false,
Row.of( TestLiteral.from( "Alice" ), TestLiteral.from( 2 ) ),
Row.of( TestLiteral.from( "Bob" ), TestLiteral.from( 1 ) ),
Row.of( TestLiteral.from( "Charlie" ), TestLiteral.from( 3 ) ) );
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,10 @@ public void missingPropertyFilterTest() {
execute( SINGLE_NODE_PERSON_COMPLEX_2 );
GraphResult res = execute( """
MATCH (n:Person)
WHERE n.age >= 40\s
WHERE n.age >= 40
RETURN n.name, n.age""" );
containsRows( res, true, false,
Row.of( TestLiteral.from( "Ann" ), TestLiteral.from( 45 ) ) );

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public void orderByLimitTest() {
Row.of( TestLiteral.from( "Max" ) ),
Row.of( TestLiteral.from( "Max" ) ),
Row.of( TestLiteral.from( "Kira" ) ) );

}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2019-2024 The Polypheny Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.polypheny.db.cypher.clause.general;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -9,6 +25,7 @@
import org.polypheny.db.cypher.helper.TestLiteral;
import org.polypheny.db.webui.models.results.GraphResult;


public class UnwindTest extends CypherTestTemplate {

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void simpleMatchSinglePropertyTest() {

GraphResult res = execute( "MATCH (n {name: 'Max'}) RETURN n" );
assertNode( res, 0 );
assertEmpty( res );
containsNodes( res, true, MAX );

res = execute( "MATCH (n {name: 'Hans'}) RETURN n" );
assertNode( res, 0 );
Expand Down Expand Up @@ -418,9 +418,9 @@ public void returnEdgesByAsteriskMatchTest() {
@Test
public void shortestPathMatchTest() {
execute( SINGLE_EDGE_1 );
GraphResult res = execute( "MATCH (b:Person {name: 'Max'}), (a:Animal {name: 'Kira'})\n"
+ "MATCH p = shortestPath((b)-[*]-(a))\n"
+ "RETURN p\n" );
GraphResult res = execute( "MATCH (b:Person {name: 'Max'}), (a:Animal {name: 'Kira'}) "
+ "MATCH p = shortestPath((b)-[*]-(a)) "
+ "RETURN p" );
containsRows( res, true, true,
Row.of( TestPath.of(
TestNode.from( List.of( "Person" ), Pair.of( "name", "Max" ) ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ public void reset() {
@Test
public void simpleEmptyNodeDeleteTest() {
execute( SINGLE_NODE_PERSON_1 );
execute( "MATCH (p:Person)\n"
+ "DELETE p" );
execute( "MATCH (p:Person) DELETE p" );
GraphResult res = matchAndReturnAllNodes();
assertEmpty( res );
}
Expand All @@ -49,8 +48,7 @@ public void simpleEmptyNodeDeleteTest() {
@Test
public void simpleNodeDeleteTest() {
execute( SINGLE_NODE_PERSON_1 );
execute( "MATCH (p:Person {name: 'Max'})\n"
+ "DELETE p" );
execute( "MATCH (p:Person {name: 'Max'}) DELETE p" );
GraphResult res = matchAndReturnAllNodes();
assertEmpty( res );
}
Expand All @@ -60,8 +58,7 @@ public void simpleNodeDeleteTest() {
public void simpleFilteredNodeDeleteTest() {
execute( SINGLE_NODE_PERSON_1 );
execute( SINGLE_NODE_PERSON_2 );
execute( "MATCH (p:Person {name: 'Max'})\n"
+ "DELETE p" );
execute( "MATCH (p:Person {name: 'Max'}) DELETE p" );
GraphResult res = matchAndReturnAllNodes();
containsRows( res, true, false,
Row.of( TestNode.from( List.of( "Person" ), Pair.of( "name", "Hans" ) ) ) );
Expand All @@ -84,8 +81,7 @@ public void simpleRelationshipDeleteTest() {
execute( "MATCH (:Person {name: 'Max'})-[rel:OWNER_OF]->(:Animal {name: 'Kira'}) \n"
+ "DELETE rel" );

GraphResult res = execute( "MATCH (n)-[rel:OWNER_OF]->(a) \n"
+ "RETURN rel" );
GraphResult res = execute( "MATCH (n)-[rel:OWNER_OF]->(a) RETURN rel" );
assertEmpty( res );

res = matchAndReturnAllNodes();
Expand All @@ -102,7 +98,7 @@ public void simpleRelationshipDeleteTest() {
@Test
public void relationshipWithPropertiesDeleteTest() {
execute( SINGLE_EDGE_2 );
execute( "MATCH (:Person {name: 'Max'})-[rel:KNOWS {since: 1994}]->(:Person {name:'Hans'}) \n"
execute( "MATCH (:Person {name: 'Max'})-[rel:KNOWS {since: 1994}]->(:Person {name:'Hans'})\n"
+ "DELETE rel" );

GraphResult res = execute( "MATCH (p1)-[rel:KNOWS ]->(p2) RETURN rel " );
Expand All @@ -121,10 +117,7 @@ public void relationshipWithPropertiesDeleteTest() {
@Test
public void pathDeleteTest() {
execute( SINGLE_EDGE_1 );
execute( """
MATCH p = (person:Person {name: 'Max'})-[rel:OWNER_OF]->( animal :Animal {name: 'Kira'})
DELETE p
""" );
execute( "MATCH p = (person:Person {name: 'Max'})-[rel:OWNER_OF]->( animal :Animal {name: 'Kira'}) DELETE p" );

GraphResult res = matchAndReturnAllNodes();
GraphResult relations = execute( "MATCH (p:Person) -[rel:OWNER_OF]->(A:Animal) RETURN rel " );
Expand All @@ -135,8 +128,7 @@ public void pathDeleteTest() {
@Test
public void nodeWithAllRelationshipsDeleteTest() {
execute( SINGLE_EDGE_2 );
execute( "MATCH (n:Person {name: 'MAX'})\n"
+ "DETACH DELETE n" );
execute( "MATCH (n:Person {name: 'MAX'}) DETACH DELETE n" );

GraphResult res = matchAndReturnAllNodes();
GraphResult relations = execute( "MATCH (p:Person) -[rel:OWNER_OF]->(A:Animal) Return rel" );
Expand All @@ -149,8 +141,7 @@ public void allNodesAndRelationshipsDeleteTest() {
execute( SINGLE_NODE_PERSON_1 );
execute( SINGLE_NODE_PERSON_2 );
execute( SINGLE_EDGE_1 );
execute( "MATCH (n)\n"
+ "DETACH DELETE n" );
execute( "MATCH (n) DETACH DELETE n" );

GraphResult res = matchAndReturnAllNodes();
GraphResult relations = execute( "MATCH (p:Person) -[rel:OWNER_OF]->(A:Animal) Return rel" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.polypheny.db.util.Pair;
import org.polypheny.db.webui.models.results.GraphResult;


public class ForeachTest extends CypherTestTemplate {

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.polypheny.db.util.Pair;
import org.polypheny.db.webui.models.results.GraphResult;


@Slf4j
public class MergeTest extends CypherTestTemplate {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.polypheny.db.cypher.helper.TestLiteral;
import org.polypheny.db.webui.models.results.GraphResult;


public class NumericFunTest extends CypherTestTemplate {

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.polypheny.db.type.entity.PolyValue;
import org.polypheny.db.util.Pair;


public class TestNode extends TestGraphObject {

public TestNode( @Nullable String id, @Nullable Map<PolyString, PolyValue> properties, @Nullable List<PolyString> labels ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

package org.polypheny.db.cypher.operators;


import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.polypheny.db.cypher.CypherTestTemplate;
import org.polypheny.db.cypher.helper.TestLiteral;
import org.polypheny.db.webui.models.results.GraphResult;


public class BooleanOperatorsTest extends CypherTestTemplate {

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public void reset() {

@Test
public void simpleCallTest() {
GraphResult res = execute( " CALL { RETURN 'hello' AS innerReturn} \n"
+ "RETURN innerReturn" );
GraphResult res = execute( " CALL { RETURN 'hello' AS innerReturn} RETURN innerReturn" );

containsRows( res, true, false,
Row.of( TestLiteral.from( "hello" ) ) );
Expand Down Expand Up @@ -183,12 +182,12 @@ public void unitSubQueryCallTest() {
execute( SINGLE_NODE_PERSON_2 );

GraphResult res = execute( """
MATCH (p:Person) CALL { \s
WITH p
CREATE (:Person {name: p.name})\s
MATCH (p:Person) CALL {
WITH p
CREATE (:Person {name: p.name})
} RETURN count(*)""" );

//the number of rows present after the subquery is the same as was going into the subquery
// The number of rows present after the subquery is the same as was going into the subquery
containsRows( res, true, false, Row.of( TestLiteral.from( 2 ) ) );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,12 @@ public void whereWithCollectSubQueryTest() {
execute( EDGE_3 );

GraphResult res = execute( """
MATCH (person:Person)
RETURN person.name as name, COLLECT {
MATCH (person)-[r:OWNER_OF]->(a:Dog)
WHERE a.age <= 3
RETURN a.name
} as youngDog\s
""" );
} as youngDog """ );

containsRows( res, true, false,
Row.of( TestLiteral.from( "Max" ), TestLiteral.from( "Andy" ) ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public void simpleCountSubQueryTest() {
public void useCountSubQueryInReturnTest() {
execute( EDGE_3 );

GraphResult res = execute( "MATCH (person:Person)\n"
+ "RETURN person.name, COUNT { (person)-[:OWNER_OF]->(:Dog) } as howManyDogs" );
GraphResult res = execute( "MATCH (person:Person) RETURN person.name, COUNT { (person)-[:OWNER_OF]->(:Dog) } as howManyDogs" );

containsRows( res, true, false,
Row.of( TestLiteral.from( "Max" ), TestLiteral.from( 1 ) ) );
Expand Down

0 comments on commit d7ad4b9

Please sign in to comment.