Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph Features for Prism Interface #519

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
93e474e
Prepare statement processing for the introduction of graphs
May 16, 2024
bb40400
Improve code readability
May 16, 2024
cc9e6b6
Add basic graph execution
May 16, 2024
d92e9bc
Add relational graph results
May 16, 2024
585dbd6
Add graph results
May 16, 2024
eb63649
Add graph serialization tests
May 17, 2024
e536fed
Use mavenLocal for driver
May 17, 2024
c44d234
Add testcase for relational multimodel operations
May 17, 2024
28989ed
Add testcase for multi-model relational metadata
May 17, 2024
e89ad2a
Add test for multimodel mql
May 17, 2024
8933073
Fix ddl result bug
May 17, 2024
aad24ef
Rephrase error message
May 17, 2024
5cc1df7
Add cypher tests
May 17, 2024
a660672
Remove broken assertion
Jul 4, 2024
c1642f8
Adjust test
Jul 4, 2024
eb4b060
Fix node serialization
Jul 5, 2024
aa036e5
Add not implemented exception and todo for paths
Jul 18, 2024
5091b41
Update api version
Jul 18, 2024
0a86c9d
Put classes into corresponding packages
Jul 19, 2024
3bedb68
Fix method access
Jul 19, 2024
208d7c3
Update to new Prism API files
gartens Oct 4, 2024
7ce3517
Use switch expression
gartens Oct 4, 2024
c1635e6
Rename source/target to left/right
gartens Oct 4, 2024
7b00a38
Fix fallout from rebase
gartens Oct 9, 2024
038d96d
Fix instances missed in previous
gartens Oct 9, 2024
5a65a20
Improve switch expression
gartens Oct 9, 2024
badae33
Use .toList() instead of Collectors.toList()
gartens Oct 9, 2024
c748e29
Remove unused state and errorCode from PIServiceExceptions
gartens Oct 9, 2024
45ba7a9
Make getExecutor switch over the data models
gartens Oct 9, 2024
e4ca96e
Fix tests
gartens Oct 4, 2024
74d36ef
Make conditionals easier to read
gartens Oct 9, 2024
23b8eec
Format code & optimize imports
gartens Oct 9, 2024
24efde1
Use Map.of instead of new HashMap
gartens Oct 9, 2024
5e2d29e
Fix PrismUtilsTest
gartens Oct 10, 2024
83e9e11
Add back GEOMETRY
gartens Oct 10, 2024
634792b
Clean up after CypherTests
gartens Oct 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Put classes into corresponding packages
Tobias Hafner authored and gartens committed Oct 21, 2024
commit 0a86c9d6fcca9647bbc115276af0aac63f135350
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
import lombok.extern.slf4j.Slf4j;
import org.polypheny.db.catalog.entity.LogicalUser;
import org.polypheny.db.catalog.entity.logical.LogicalNamespace;
import org.polypheny.db.prisminterface.metaRetrieval.PIClientInfoProperties;
import org.polypheny.db.prisminterface.statements.StatementManager;
import org.polypheny.db.transaction.Transaction;
import org.polypheny.db.transaction.TransactionException;
@@ -39,7 +40,7 @@ public class PIClient {
@Getter
private final StatementManager statementManager;
@Getter
private final PIClientInfoProperties PIClientInfoProperties;
private final org.polypheny.db.prisminterface.metaRetrieval.PIClientInfoProperties PIClientInfoProperties;
@Getter
@Setter
private boolean isAutoCommit;
Original file line number Diff line number Diff line change
@@ -30,6 +30,8 @@
import org.polypheny.db.catalog.exceptions.GenericRuntimeException;
import org.polypheny.db.iface.AuthenticationException;
import org.polypheny.db.languages.QueryLanguage;
import org.polypheny.db.prisminterface.metaRetrieval.DbMetaRetriever;
import org.polypheny.db.prisminterface.metaRetrieval.PIClientInfoProperties;
import org.polypheny.db.prisminterface.statementProcessing.StatementProcessor;
import org.polypheny.db.prisminterface.statements.PIPreparedIndexedStatement;
import org.polypheny.db.prisminterface.statements.PIPreparedNamedStatement;
Original file line number Diff line number Diff line change
@@ -14,12 +14,13 @@
* limitations under the License.
*/

package org.polypheny.db.prisminterface;
package org.polypheny.db.prisminterface.metaRetrieval;

import java.sql.DatabaseMetaData;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.polypheny.db.PolyphenyDb;
import org.polypheny.db.algebra.constant.FunctionCategory;
import org.polypheny.db.algebra.type.AlgDataTypeSystem;
@@ -38,6 +39,8 @@
import org.polypheny.db.catalog.logistic.Pattern;
import org.polypheny.db.languages.OperatorRegistry;
import org.polypheny.db.languages.QueryLanguage;
import org.polypheny.db.prisminterface.metaRetrieval.PIClientInfoProperties;
import org.polypheny.db.prisminterface.PIServiceException;
import org.polypheny.db.type.PolyType;
import org.polypheny.prism.ClientInfoPropertyMeta;
import org.polypheny.prism.ClientInfoPropertyMetaResponse;
@@ -73,12 +76,12 @@ static NamespacesResponse searchNamespaces( String namespacePattern, String name

private static List<LogicalNamespace> getLogicalNamespaces( String namespacePattern, String namespaceType ) {
Pattern catalogNamespacePattern = getPatternOrNull( namespacePattern );
List<LogicalNamespace> logicalNamespaces = Catalog.snapshot().getNamespaces( catalogNamespacePattern );
List<LogicalNamespace> logicalNamespaces = Catalog.getInstance().getSnapshot().getNamespaces( catalogNamespacePattern );
if ( namespaceType == null ) {
return logicalNamespaces;
}
DataModel catalogNamespaceType = DataModel.valueOf( namespaceType );
return logicalNamespaces.stream().filter( n -> n.getDataModel() == catalogNamespaceType ).toList();
return logicalNamespaces.stream().filter( n -> n.getDataModel() == catalogNamespaceType ).collect( Collectors.toList() );
}


@@ -96,27 +99,34 @@ private static Pattern getPatternOrNull( String pattern ) {


public static Namespace getNamespace( String namespaceName ) {
return getNamespaceMeta( Catalog.snapshot().getNamespace( namespaceName ).orElseThrow() );
return getNamespaceMeta( Catalog.getInstance().getSnapshot().getNamespace( namespaceName ).orElseThrow() );
}


// Entity search by namespace
static EntitiesResponse searchEntities( String namespaceName, String entityPattern ) {
EntitiesResponse.Builder responseBuilder = EntitiesResponse.newBuilder();
LogicalNamespace namespace = Catalog.snapshot().getNamespace( namespaceName ).orElseThrow();
return switch ( namespace.getDataModel() ) {
case RELATIONAL -> responseBuilder.addAllEntities( getRelationalEntities( namespace.getId(), entityPattern ) ).build();
case GRAPH -> responseBuilder.addAllEntities( getGraphEntities( namespace.getId(), entityPattern ) ).build();
case DOCUMENT -> responseBuilder.addAllEntities( getDocumentEntities( namespace.getId(), entityPattern ) ).build();
};
LogicalNamespace namespace = Catalog.getInstance().getSnapshot().getNamespace( namespaceName ).orElseThrow();
switch ( namespace.getDataModel() ) {
case RELATIONAL:
responseBuilder.addAllEntities( getRelationalEntities( namespace.getId(), entityPattern ) );
break;
case GRAPH:
responseBuilder.addAllEntities( getGraphEntities( namespace.getId(), entityPattern ) );
break;
case DOCUMENT:
responseBuilder.addAllEntities( getDocumentEntities( namespace.getId(), entityPattern ) );
break;
}
return responseBuilder.build();
}


// Relational entities
private static List<Entity> getRelationalEntities( long namespaceId, String entityPattern ) {
Pattern catalogEntityPattern = getPatternOrNull( entityPattern );
final List<LogicalTable> tables = Catalog.snapshot().rel().getTables( namespaceId, catalogEntityPattern );
return tables.stream().map( logicalTable -> buildEntityFromTable( getTableMeta( logicalTable ) ) ).toList();
final List<LogicalTable> tables = Catalog.getInstance().getSnapshot().rel().getTables( namespaceId, catalogEntityPattern );
return tables.stream().map( logicalTable -> buildEntityFromTable( getTableMeta( logicalTable ) ) ).collect( Collectors.toList() );
}


@@ -144,20 +154,20 @@ private static Table getTableMeta( LogicalTable logicalTable ) {


private static List<Column> getColumns( LogicalTable logicalTable ) {
return logicalTable.getColumns().stream().map( DbMetaRetriever::getColumnMeta ).toList();
return logicalTable.getColumns().stream().map( DbMetaRetriever::getColumnMeta ).collect( Collectors.toList() );
}


private static boolean hasPrimaryKey( LogicalTable logicalTable ) {
if ( logicalTable.primaryKey == null ) {
return false;
}
return Catalog.snapshot().rel().getPrimaryKey( logicalTable.primaryKey ).isPresent();
return Catalog.getInstance().getSnapshot().rel().getPrimaryKey( logicalTable.primaryKey ).isPresent();
}


private static PrimaryKey getPrimaryKeyMeta( LogicalTable logicalTable ) {
LogicalPrimaryKey logicalPrimaryKey = Catalog.snapshot().rel().getPrimaryKey( logicalTable.primaryKey ).orElseThrow();
LogicalPrimaryKey logicalPrimaryKey = Catalog.getInstance().getSnapshot().rel().getPrimaryKey( logicalTable.primaryKey ).orElseThrow();
return PrimaryKey.newBuilder()
.setDatabaseName( logicalPrimaryKey.getSchemaName() )
.setNamespaceName( logicalPrimaryKey.getSchemaName() )
@@ -191,8 +201,8 @@ private static Column getColumnMeta( LogicalColumn logicalColumn ) {


private static List<ForeignKey> getForeignKeys( LogicalTable logicalTable ) {
return Catalog.snapshot().rel().getForeignKeys( logicalTable.getId() )
.stream().map( DbMetaRetriever::getForeignKeyMeta ).toList();
return Catalog.getInstance().getSnapshot().rel().getForeignKeys( logicalTable.getId() )
.stream().map( DbMetaRetriever::getForeignKeyMeta ).collect( Collectors.toList() );
}


@@ -210,19 +220,19 @@ private static ForeignKey getForeignKeyMeta( LogicalForeignKey logicalForeignKey


private static List<Column> getReferencedColumns( LogicalForeignKey logicalForeignKey ) {
return logicalForeignKey.referencedKeyFieldIds.stream().map( id -> Catalog.snapshot().rel().getColumn( id ).orElseThrow() ).map( DbMetaRetriever::getColumnMeta ).toList();
return logicalForeignKey.referencedKeyFieldIds.stream().map( id -> Catalog.snapshot().rel().getColumn( id ).orElseThrow() ).map( DbMetaRetriever::getColumnMeta ).collect( Collectors.toList() );
}


private static List<ForeignKey> getExportedKeys( LogicalTable logicalTable ) {
return Catalog.snapshot().rel().getExportedKeys( logicalTable.getId() )
.stream().map( DbMetaRetriever::getForeignKeyMeta ).toList();
return Catalog.getInstance().getSnapshot().rel().getExportedKeys( logicalTable.getId() )
.stream().map( DbMetaRetriever::getForeignKeyMeta ).collect( Collectors.toList() );
}


private static List<Index> getIndexes( LogicalTable logicalTable, boolean unique ) {
return Catalog.snapshot().rel().getIndexes( logicalTable.getId(), unique )
.stream().map( DbMetaRetriever::getIndexMeta ).toList();
return Catalog.getInstance().getSnapshot().rel().getIndexes( logicalTable.getId(), unique )
.stream().map( DbMetaRetriever::getIndexMeta ).collect( Collectors.toList() );
}


@@ -301,7 +311,7 @@ static ProceduresResponse getProcedures( String languageName, String procedureNa

static ClientInfoPropertyMetaResponse getClientInfoProperties() {
List<ClientInfoPropertyMeta> propertyInfoMetas = PIClientInfoProperties.DEFAULTS.stream()
.map( DbMetaRetriever::getClientInfoPropertyMeta ).toList();
.map( DbMetaRetriever::getClientInfoPropertyMeta ).collect( Collectors.toList() );
return ClientInfoPropertyMetaResponse.newBuilder()
.addAllClientInfoPropertyMetas( propertyInfoMetas )
.build();
@@ -324,7 +334,7 @@ static FunctionsResponse getFunctions( QueryLanguage language, FunctionCategory
.map( org.polypheny.db.nodes.Function.class::cast )
.filter( f -> f.getFunctionCategory() == functionCategory || functionCategory == null )
.map( DbMetaRetriever::getFunctionMeta )
.toList();
.collect( Collectors.toList() );
return FunctionsResponse.newBuilder().addAllFunctions( functions ).build();
}

Original file line number Diff line number Diff line change
@@ -14,13 +14,13 @@
* limitations under the License.
*/

package org.polypheny.db.prisminterface;
package org.polypheny.db.prisminterface.metaRetrieval;

import java.util.Arrays;
import java.util.List;
import java.util.Properties;

class PIClientInfoProperties extends Properties {
public class PIClientInfoProperties extends Properties {

private static final int MAX_STRING_LENGTH = 2147483647;
static final List<ClientInfoPropertiesDefault> DEFAULTS = Arrays.asList(
@@ -51,7 +51,7 @@ class PIClientInfoProperties extends Properties {
);


PIClientInfoProperties() {
public PIClientInfoProperties() {
super();
DEFAULTS.forEach( p -> setProperty( p.key, p.default_value ) );
}
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.polypheny.db.prisminterface;
package org.polypheny.db.prisminterface.statementProcessing;

import java.util.ArrayList;
import java.util.List;
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@
import org.polypheny.db.PolyImplementation;
import org.polypheny.db.catalog.entity.logical.LogicalNamespace;
import org.polypheny.db.languages.QueryLanguage;
import org.polypheny.db.prisminterface.NamedValueProcessor;
import org.polypheny.db.prisminterface.statementProcessing.NamedValueProcessor;
import org.polypheny.db.prisminterface.PIClient;
import org.polypheny.db.prisminterface.statementProcessing.StatementProcessor;
import org.polypheny.db.transaction.Statement;
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@
import org.junit.jupiter.api.Test;
import org.polypheny.db.TestHelper;
import org.polypheny.db.catalog.exceptions.GenericRuntimeException;
import org.polypheny.db.prisminterface.statementProcessing.NamedValueProcessor;
import org.polypheny.db.type.entity.PolyString;
import org.polypheny.db.type.entity.PolyValue;