diff --git a/core/src/main/java/org/polypheny/db/adapter/Adapter.java b/core/src/main/java/org/polypheny/db/adapter/Adapter.java index 2c52a7aa1e..45c780f767 100644 --- a/core/src/main/java/org/polypheny/db/adapter/Adapter.java +++ b/core/src/main/java/org/polypheny/db/adapter/Adapter.java @@ -59,8 +59,7 @@ public abstract class Adapter implements Scanna private final AdapterProperties properties; protected final DeployMode deployMode; protected String deploymentId; - @Getter - private final String adapterName; + public final String adapterName; public final ACatalog adapterCatalog; diff --git a/core/src/main/java/org/polypheny/db/adapter/AdapterManager.java b/core/src/main/java/org/polypheny/db/adapter/AdapterManager.java index 1385f29c9a..9de52a088f 100644 --- a/core/src/main/java/org/polypheny/db/adapter/AdapterManager.java +++ b/core/src/main/java/org/polypheny/db/adapter/AdapterManager.java @@ -170,10 +170,7 @@ public ImmutableMap> getSources() { } - - - - public Adapter addAdapter( String adapterName, String uniqueName, AdapterType adapterType, DeployMode mode, Map settings ) { + public Adapter addAdapter( String adapterName, String uniqueName, long defaultNamespace, AdapterType adapterType, DeployMode mode, Map settings ) { uniqueName = uniqueName.toLowerCase(); if ( getAdapters().containsKey( uniqueName ) ) { throw new GenericRuntimeException( "There is already an adapter with this unique name" ); @@ -184,7 +181,7 @@ public Adapter addAdapter( String adapterName, String uniqueName, AdapterType AdapterTemplate adapterTemplate = AdapterTemplate.fromString( adapterName, adapterType ); - long adapterId = Catalog.getInstance().createAdapter( uniqueName, adapterName, adapterType, settings, mode ); + long adapterId = Catalog.getInstance().createAdapter( uniqueName, adapterName, defaultNamespace, adapterType, settings, mode ); try { Adapter adapter = adapterTemplate.getDeployer().get( adapterId, uniqueName, settings ); adapterByName.put( adapter.getUniqueName(), adapter ); @@ -266,4 +263,12 @@ public interface Function4 { } + + @FunctionalInterface + public interface Function5 { + + R get( P1 p1, P2 p2, P3 p3, P4 p4 ); + + } + } diff --git a/core/src/main/java/org/polypheny/db/catalog/Catalog.java b/core/src/main/java/org/polypheny/db/catalog/Catalog.java index ce0dcc264a..f4772074c5 100644 --- a/core/src/main/java/org/polypheny/db/catalog/Catalog.java +++ b/core/src/main/java/org/polypheny/db/catalog/Catalog.java @@ -191,12 +191,13 @@ public void removeObserver( PropertyChangeListener listener ) { * * @param uniqueName The unique name of the adapter * @param clazz The class name of the adapter + * @param defaultNamespace The default namespace of the adapter * @param type The type of adapter * @param settings The configuration of the adapter - * @param mode + * @param mode The deploy mode of the adapter * @return The id of the newly added adapter */ - public abstract long createAdapter( String uniqueName, String clazz, AdapterType type, Map settings, DeployMode mode ); + public abstract long createAdapter( String uniqueName, String clazz, long defaultNamespace, AdapterType type, Map settings, DeployMode mode ); /** * Update settings of an adapter diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/LogicalAdapter.java b/core/src/main/java/org/polypheny/db/catalog/entity/LogicalAdapter.java index 98fdeb1f54..5c4627c877 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/LogicalAdapter.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/LogicalAdapter.java @@ -19,6 +19,7 @@ import io.activej.serializer.annotations.Deserialize; import io.activej.serializer.annotations.Serialize; +import java.io.Serial; import java.util.HashMap; import java.util.Map; import lombok.EqualsAndHashCode; @@ -35,6 +36,7 @@ @SuperBuilder(toBuilder = true) public class LogicalAdapter implements PolyObject { + @Serial private static final long serialVersionUID = -6140489767408917639L; @Serialize @@ -51,6 +53,8 @@ public class LogicalAdapter implements PolyObject { public String adapterTypeName; @Serialize public DeployMode mode; + @Serialize + public long defaultNamespace; public enum AdapterType {STORE, SOURCE} @@ -62,7 +66,8 @@ public LogicalAdapter( @Deserialize("adapterName") @NonNull final String adapterName, @Deserialize("type") @NonNull final AdapterType adapterType, @Deserialize("mode") @NotNull final DeployMode mode, - @Deserialize("settings") @NonNull final Map settings ) { + @Deserialize("settings") @NonNull final Map settings, + @Deserialize("defaultNamespace") final long defaultNamespace ) { this.id = id; this.uniqueName = uniqueName; this.adapterName = adapterName; @@ -70,6 +75,7 @@ public LogicalAdapter( this.settings = new HashMap<>( settings ); this.adapterTypeName = getAdapterName(); this.mode = mode; + this.defaultNamespace = defaultNamespace; } diff --git a/core/src/main/java/org/polypheny/db/catalog/impl/PolyCatalog.java b/core/src/main/java/org/polypheny/db/catalog/impl/PolyCatalog.java index b96d5dae61..44c05ab000 100644 --- a/core/src/main/java/org/polypheny/db/catalog/impl/PolyCatalog.java +++ b/core/src/main/java/org/polypheny/db/catalog/impl/PolyCatalog.java @@ -369,9 +369,9 @@ public void dropNamespace( long id ) { @Override - public long createAdapter( String uniqueName, String clazz, AdapterType type, Map settings, DeployMode mode ) { + public long createAdapter( String uniqueName, String clazz, long defaultNamespace, AdapterType type, Map settings, DeployMode mode ) { long id = idBuilder.getNewAdapterId(); - adapters.put( id, new LogicalAdapter( id, uniqueName, clazz, type, mode, settings ) ); + adapters.put( id, new LogicalAdapter( id, uniqueName, clazz, type, mode, settings, defaultNamespace ) ); change(); return id; } diff --git a/core/src/main/java/org/polypheny/db/ddl/DdlManager.java b/core/src/main/java/org/polypheny/db/ddl/DdlManager.java index d2faf1a821..a9edbf815a 100644 --- a/core/src/main/java/org/polypheny/db/ddl/DdlManager.java +++ b/core/src/main/java/org/polypheny/db/ddl/DdlManager.java @@ -106,11 +106,12 @@ public static DdlManager getInstance() { * * @param uniqueName unique name of the newly created adapter * @param adapterName name of adapter, which is used to create the adapter + * @param defaultNamespace the default namespace for the adapter * @param adapterType the specific {@link AdapterType} for the adapter to create * @param config configuration for the adapter * @param mode the deploy mode */ - public abstract void createAdapter( String uniqueName, String adapterName, AdapterType adapterType, Map config, DeployMode mode ); + public abstract void createAdapter( String uniqueName, String adapterName, long defaultNamespace, AdapterType adapterType, Map config, DeployMode mode ); /** * Drop an adapter diff --git a/core/src/test/java/org/polypheny/db/catalog/MockCatalog.java b/core/src/test/java/org/polypheny/db/catalog/MockCatalog.java index 0a69cbdaf3..0925fc4267 100644 --- a/core/src/test/java/org/polypheny/db/catalog/MockCatalog.java +++ b/core/src/test/java/org/polypheny/db/catalog/MockCatalog.java @@ -163,7 +163,7 @@ public void dropNamespace( long id ) { @Override - public long createAdapter( String uniqueName, String clazz, AdapterType type, Map settings, DeployMode mode ) { + public long createAdapter( String uniqueName, String clazz, long defaultNamespace, AdapterType type, Map settings, DeployMode mode ) { throw new NotImplementedException(); } diff --git a/dbms/src/main/java/org/polypheny/db/ddl/DdlManagerImpl.java b/dbms/src/main/java/org/polypheny/db/ddl/DdlManagerImpl.java index 94c2bb76c8..214553df27 100644 --- a/dbms/src/main/java/org/polypheny/db/ddl/DdlManagerImpl.java +++ b/dbms/src/main/java/org/polypheny/db/ddl/DdlManagerImpl.java @@ -206,17 +206,17 @@ public long createNamespace( String initialName, DataModel type, boolean ifNotEx @Override - public void createAdapter( String uniqueName, String adapterName, AdapterType adapterType, Map config, DeployMode mode ) { + public void createAdapter( String uniqueName, String adapterName, long defaultNamespace, AdapterType adapterType, Map config, DeployMode mode ) { uniqueName = uniqueName.toLowerCase(); - Adapter adapter = AdapterManager.getInstance().addAdapter( adapterName, uniqueName, adapterType, mode, config ); + Adapter adapter = AdapterManager.getInstance().addAdapter( adapterName, uniqueName, defaultNamespace, adapterType, mode, config ); if ( adapter instanceof DataSource ) { - handleSource( (DataSource) adapter ); + handleSource( (DataSource) adapter, defaultNamespace ); } } - private void handleSource( DataSource adapter ) { + private void handleSource( DataSource adapter, long defaultNamespace ) { Map> exportedColumns; try { exportedColumns = adapter.getExportedColumns(); @@ -228,26 +228,26 @@ private void handleSource( DataSource adapter ) { for ( Map.Entry> entry : exportedColumns.entrySet() ) { // Make sure the table name is unique String tableName = entry.getKey(); - if ( catalog.getSnapshot().rel().getTable( Catalog.defaultNamespaceId, tableName ).isPresent() ) { // apparently we put them all into 1? + if ( catalog.getSnapshot().rel().getTable( defaultNamespace, tableName ).isPresent() ) { // apparently we put them all into 1? int i = 0; - while ( catalog.getSnapshot().rel().getTable( Catalog.defaultNamespaceId, tableName + i ).isPresent() ) { + while ( catalog.getSnapshot().rel().getTable( defaultNamespace, tableName + i ).isPresent() ) { i++; } tableName += i; } - LogicalTable logical = catalog.getLogicalRel( Catalog.defaultNamespaceId ).addTable( tableName, EntityType.SOURCE, !(adapter).isDataReadOnly() ); + LogicalTable logical = catalog.getLogicalRel( defaultNamespace ).addTable( tableName, EntityType.SOURCE, !(adapter).isDataReadOnly() ); List columns = new ArrayList<>(); Pair partitionProperty = createSinglePartition( logical.namespaceId, logical ); - AllocationPlacement placement = catalog.getAllocRel( Catalog.defaultNamespaceId ).addPlacement( logical.id, Catalog.defaultNamespaceId, adapter.adapterId ); - AllocationEntity allocation = catalog.getAllocRel( Catalog.defaultNamespaceId ).addAllocation( adapter.getAdapterId(), placement.id, partitionProperty.left.id, logical.id ); + AllocationPlacement placement = catalog.getAllocRel( defaultNamespace ).addPlacement( logical.id, defaultNamespace, adapter.adapterId ); + AllocationEntity allocation = catalog.getAllocRel( defaultNamespace ).addAllocation( adapter.getAdapterId(), placement.id, partitionProperty.left.id, logical.id ); List aColumns = new ArrayList<>(); int colPos = 1; for ( ExportedColumn exportedColumn : entry.getValue() ) { - LogicalColumn column = catalog.getLogicalRel( Catalog.defaultNamespaceId ).addColumn( + LogicalColumn column = catalog.getLogicalRel( defaultNamespace ).addColumn( exportedColumn.name, logical.id, colPos++, @@ -260,7 +260,7 @@ private void handleSource( DataSource adapter ) { exportedColumn.nullable, Collation.getDefaultCollation() ); - AllocationColumn allocationColumn = catalog.getAllocRel( Catalog.defaultNamespaceId ).addColumn( + AllocationColumn allocationColumn = catalog.getAllocRel( defaultNamespace ).addColumn( placement.id, logical.id, column.id, @@ -284,7 +284,6 @@ private void handleSource( DataSource adapter ) { @Override public void dropAdapter( String name, Statement statement ) { - long defaultNamespaceId = Catalog.defaultNamespaceId; name = name.replace( "'", "" ); LogicalAdapter adapter = catalog.getSnapshot().getAdapter( name ).orElseThrow(); @@ -300,7 +299,7 @@ public void dropAdapter( String name, Statement statement ) { } else if ( allocation.unwrap( AllocationTable.class ).isPresent() ) { for ( LogicalForeignKey fk : catalog.getSnapshot().rel().getForeignKeys( allocation.logicalId ) ) { - catalog.getLogicalRel( defaultNamespaceId ).deleteForeignKey( fk.id ); + catalog.getLogicalRel( allocation.namespaceId ).deleteForeignKey( fk.id ); } LogicalTable table = catalog.getSnapshot().rel().getTable( allocation.logicalId ).orElseThrow(); @@ -316,22 +315,22 @@ public void dropAdapter( String name, Statement statement ) { } // Delete column placement in catalog for ( AllocationColumn column : allocation.unwrap( AllocationTable.class ).get().getColumns() ) { - catalog.getAllocRel( defaultNamespaceId ).deleteColumn( allocation.id, column.columnId ); + catalog.getAllocRel( allocation.namespaceId ).deleteColumn( allocation.id, column.columnId ); } // delete allocation - catalog.getAllocRel( defaultNamespaceId ).deleteAllocation( allocation.id ); + catalog.getAllocRel( allocation.namespaceId ).deleteAllocation( allocation.id ); // Remove primary keys - catalog.getLogicalRel( defaultNamespaceId ).deletePrimaryKey( table.id ); + catalog.getLogicalRel( allocation.namespaceId ).deletePrimaryKey( table.id ); // Delete columns for ( LogicalColumn column : catalog.getSnapshot().rel().getColumns( allocation.logicalId ) ) { - catalog.getLogicalRel( defaultNamespaceId ).deleteColumn( column.id ); + catalog.getLogicalRel( allocation.namespaceId ).deleteColumn( column.id ); } // Delete the table - catalog.getLogicalRel( defaultNamespaceId ).deleteTable( table.id ); + catalog.getLogicalRel( allocation.namespaceId ).deleteTable( table.id ); // Reset plan cache implementation cache & routing cache statement.getQueryProcessor().resetCaches(); } diff --git a/dbms/src/main/java/org/polypheny/db/ddl/DefaultInserter.java b/dbms/src/main/java/org/polypheny/db/ddl/DefaultInserter.java index b39f99ef6d..50a6dc7895 100644 --- a/dbms/src/main/java/org/polypheny/db/ddl/DefaultInserter.java +++ b/dbms/src/main/java/org/polypheny/db/ddl/DefaultInserter.java @@ -66,7 +66,7 @@ private static void restoreAdapters( DdlManager ddlManager, Catalog catalog, Run // Deploy default storeId Map defaultStore = Catalog.snapshot().getAdapterTemplate( Catalog.defaultStore.getAdapterName(), AdapterType.STORE ).orElseThrow().getDefaultSettings(); - ddlManager.createAdapter( "hsqldb", Catalog.defaultStore.getAdapterName(), AdapterType.STORE, defaultStore, DeployMode.EMBEDDED ); + ddlManager.createAdapter( "hsqldb", Catalog.defaultStore.getAdapterName(), Catalog.defaultNamespaceId, AdapterType.STORE, defaultStore, DeployMode.EMBEDDED ); if ( mode == RunMode.TEST ) { return; // source adapters create schema structure, which we do not want for testing @@ -74,7 +74,7 @@ private static void restoreAdapters( DdlManager ddlManager, Catalog catalog, Run // Deploy default CSV view Map defaultSource = Catalog.snapshot().getAdapterTemplate( Catalog.defaultSource.getAdapterName(), AdapterType.SOURCE ).orElseThrow().getDefaultSettings(); - ddlManager.createAdapter( "hr", Catalog.defaultSource.getAdapterName(), AdapterType.SOURCE, defaultSource, DeployMode.REMOTE ); + ddlManager.createAdapter( "hr", Catalog.defaultSource.getAdapterName(), Catalog.defaultNamespaceId, AdapterType.SOURCE, defaultSource, DeployMode.REMOTE ); } diff --git a/plugins/ethereum-adapter/src/main/java/org/polypheny/db/adapter/ethereum/EthereumPlugin.java b/plugins/ethereum-adapter/src/main/java/org/polypheny/db/adapter/ethereum/EthereumPlugin.java index 6d2314051f..39e1011dd2 100644 --- a/plugins/ethereum-adapter/src/main/java/org/polypheny/db/adapter/ethereum/EthereumPlugin.java +++ b/plugins/ethereum-adapter/src/main/java/org/polypheny/db/adapter/ethereum/EthereumPlugin.java @@ -294,10 +294,6 @@ public void renameLogicalColumn( long id, String newColumnName ) { } - - - - @SuppressWarnings("unused") private interface Excludes { diff --git a/plugins/excel-adapter/src/main/java/org/polypheny/db/adapter/excel/ExcelSource.java b/plugins/excel-adapter/src/main/java/org/polypheny/db/adapter/excel/ExcelSource.java index d228f8fffb..583d47a49d 100644 --- a/plugins/excel-adapter/src/main/java/org/polypheny/db/adapter/excel/ExcelSource.java +++ b/plugins/excel-adapter/src/main/java/org/polypheny/db/adapter/excel/ExcelSource.java @@ -89,7 +89,7 @@ public class ExcelSource extends DataSource { public String sheetName; - public ExcelSource( long storeId, String uniqueName, Map settings ) { + public ExcelSource( final long storeId, final String uniqueName, final Map settings ) { super( storeId, uniqueName, settings, true, new RelAdapterCatalog( storeId ) ); this.connectionMethod = settings.containsKey( "method" ) ? ConnectionMethod.from( settings.get( "method" ) ) : ConnectionMethod.UPLOAD; diff --git a/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/sources/AbstractJdbcSource.java b/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/sources/AbstractJdbcSource.java index f2532e1ab4..0da4dee864 100644 --- a/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/sources/AbstractJdbcSource.java +++ b/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/sources/AbstractJdbcSource.java @@ -65,12 +65,12 @@ public abstract class AbstractJdbcSource extends DataSource i public AbstractJdbcSource( - long storeId, - String uniqueName, - Map settings, - String diverClass, - SqlDialect dialect, - boolean readOnly ) { + final long storeId, + final String uniqueName, + final Map settings, + final String diverClass, + final SqlDialect dialect, + final boolean readOnly ) { super( storeId, uniqueName, settings, readOnly, new RelAdapterCatalog( storeId ) ); this.connectionFactory = createConnectionFactory( settings, dialect, diverClass ); this.dialect = dialect; diff --git a/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/stores/AbstractJdbcStore.java b/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/stores/AbstractJdbcStore.java index 1143a8f23a..2aa1890ad6 100644 --- a/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/stores/AbstractJdbcStore.java +++ b/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/stores/AbstractJdbcStore.java @@ -72,11 +72,11 @@ public abstract class AbstractJdbcStore extends DataStore imp public AbstractJdbcStore( - long storeId, - String uniqueName, - Map settings, - SqlDialect dialect, - boolean persistent ) { + final long storeId, + final String uniqueName, + final Map settings, + final SqlDialect dialect, + final boolean persistent ) { super( storeId, uniqueName, settings, persistent, new RelAdapterCatalog( storeId ) ); this.dialect = dialect; diff --git a/plugins/monetdb-adapter/src/main/java/org/polypheny/db/adapter/monetdb/sources/MonetdbSource.java b/plugins/monetdb-adapter/src/main/java/org/polypheny/db/adapter/monetdb/sources/MonetdbSource.java index 5d695c36cf..b156dc16b7 100644 --- a/plugins/monetdb-adapter/src/main/java/org/polypheny/db/adapter/monetdb/sources/MonetdbSource.java +++ b/plugins/monetdb-adapter/src/main/java/org/polypheny/db/adapter/monetdb/sources/MonetdbSource.java @@ -55,7 +55,7 @@ @AdapterSettingString(name = "table", defaultValue = "public.foo,public.bar", description = "Maximum number of concurrent JDBC connections.") public class MonetdbSource extends AbstractJdbcSource { - public MonetdbSource( long storeId, String uniqueName, final Map settings ) { + public MonetdbSource( final long storeId, final String uniqueName, final Map settings ) { super( storeId, uniqueName, settings, "nl.cwi.monetdb.jdbc.MonetDriver", MonetdbSqlDialect.DEFAULT, false ); } diff --git a/plugins/monetdb-adapter/src/main/java/org/polypheny/db/adapter/monetdb/stores/MonetdbStore.java b/plugins/monetdb-adapter/src/main/java/org/polypheny/db/adapter/monetdb/stores/MonetdbStore.java index faf8fcae6a..d3252b81d3 100644 --- a/plugins/monetdb-adapter/src/main/java/org/polypheny/db/adapter/monetdb/stores/MonetdbStore.java +++ b/plugins/monetdb-adapter/src/main/java/org/polypheny/db/adapter/monetdb/stores/MonetdbStore.java @@ -78,7 +78,7 @@ public class MonetdbStore extends AbstractJdbcStore { private DockerContainer container; - public MonetdbStore( long storeId, String uniqueName, final Map settings ) { + public MonetdbStore( final long storeId, final String uniqueName, final Map settings ) { super( storeId, uniqueName, settings, MonetdbSqlDialect.DEFAULT, true ); } diff --git a/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/MongoPlugin.java b/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/MongoPlugin.java index b7ad7197f0..4b71a0ae2b 100644 --- a/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/MongoPlugin.java +++ b/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/MongoPlugin.java @@ -139,7 +139,7 @@ public static class MongoStore extends DataStore { private final List unsupportedTypes = ImmutableList.of(); - public MongoStore( long adapterId, String uniqueName, Map settings ) { + public MongoStore( final long adapterId, final String uniqueName, final Map settings ) { super( adapterId, uniqueName, settings, true, new DocAdapterCatalog( adapterId ) ); if ( deployMode == DeployMode.DOCKER ) { diff --git a/plugins/mysql-adapter/src/main/java/org/polypheny/db/adapter/jdbc/MysqlSourcePlugin.java b/plugins/mysql-adapter/src/main/java/org/polypheny/db/adapter/jdbc/MysqlSourcePlugin.java index 2b55559c08..637967784b 100644 --- a/plugins/mysql-adapter/src/main/java/org/polypheny/db/adapter/jdbc/MysqlSourcePlugin.java +++ b/plugins/mysql-adapter/src/main/java/org/polypheny/db/adapter/jdbc/MysqlSourcePlugin.java @@ -38,6 +38,7 @@ import org.polypheny.db.prepare.Context; import org.polypheny.db.sql.language.dialect.MysqlSqlDialect; +@SuppressWarnings("unused") public class MysqlSourcePlugin extends PolyPlugin { @@ -90,7 +91,7 @@ public void stop() { description = "List of tables which should be imported. The names must to be separated by a comma.") public static class MysqlSource extends AbstractJdbcSource { - public MysqlSource( long storeId, String uniqueName, final Map settings ) { + public MysqlSource( final long storeId, final String uniqueName, final Map settings ) { super( storeId, uniqueName, settings, "org.mariadb.jdbc.Driver", MysqlSqlDialect.DEFAULT, false ); } diff --git a/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/Neo4jPlugin.java b/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/Neo4jPlugin.java index 6d7ab61af1..e999c599d5 100644 --- a/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/Neo4jPlugin.java +++ b/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/Neo4jPlugin.java @@ -158,7 +158,7 @@ public static class Neo4jStore extends DataStore { private String host; - public Neo4jStore( long adapterId, String uniqueName, Map adapterSettings ) { + public Neo4jStore( final long adapterId, final String uniqueName, final Map adapterSettings ) { super( adapterId, uniqueName, adapterSettings, true, new GraphAdapterCatalog( adapterId ) ); this.user = "neo4j"; diff --git a/plugins/postgres-adapter/src/main/java/org/polypheny/db/adapter/postgres/source/PostgresqlSource.java b/plugins/postgres-adapter/src/main/java/org/polypheny/db/adapter/postgres/source/PostgresqlSource.java index fe8f43ce45..6dbe369ad9 100644 --- a/plugins/postgres-adapter/src/main/java/org/polypheny/db/adapter/postgres/source/PostgresqlSource.java +++ b/plugins/postgres-adapter/src/main/java/org/polypheny/db/adapter/postgres/source/PostgresqlSource.java @@ -60,7 +60,7 @@ description = "List of tables which should be imported. The names must to be separated by a comma.") public class PostgresqlSource extends AbstractJdbcSource { - public PostgresqlSource( long storeId, String uniqueName, final Map settings ) { + public PostgresqlSource( final long storeId, final String uniqueName, final Map settings ) { super( storeId, uniqueName, diff --git a/plugins/postgres-adapter/src/main/java/org/polypheny/db/adapter/postgres/store/PostgresqlStore.java b/plugins/postgres-adapter/src/main/java/org/polypheny/db/adapter/postgres/store/PostgresqlStore.java index f6b652815a..f576e859dd 100644 --- a/plugins/postgres-adapter/src/main/java/org/polypheny/db/adapter/postgres/store/PostgresqlStore.java +++ b/plugins/postgres-adapter/src/main/java/org/polypheny/db/adapter/postgres/store/PostgresqlStore.java @@ -88,7 +88,7 @@ public class PostgresqlStore extends AbstractJdbcStore { private DockerContainer container; - public PostgresqlStore( long storeId, String uniqueName, final Map settings ) { + public PostgresqlStore( final long storeId, final String uniqueName, final Map settings ) { super( storeId, uniqueName, settings, PostgresqlSqlDialect.DEFAULT, true ); } @@ -292,7 +292,6 @@ public void dropIndex( Context context, LogicalIndex index, long allocId ) { } - @Override public List getAvailableIndexMethods() { return ImmutableList.of( diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/SqlDialect.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/SqlDialect.java index 151ec4b429..0487dda05a 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/SqlDialect.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/SqlDialect.java @@ -360,7 +360,7 @@ public void unparseSqlIntervalQualifier( SqlWriter writer, SqlIntervalQualifier public void unparseSqlIntervalLiteral( SqlWriter writer, SqlIntervalLiteral literal, int leftPrec, int rightPrec ) { SqlIntervalLiteral.IntervalValue interval = (SqlIntervalLiteral.IntervalValue) literal.getValue(); writer.keyword( "INTERVAL" ); - if ( interval.getSign() == -1 || interval.millis < 0 || interval.months < 0 ) { + if ( interval.isNegative() || interval.millis < 0 || interval.months < 0 ) { writer.print( "-" ); } String intervalStr = literal.getValue().toString(); diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/SqlIntervalLiteral.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/SqlIntervalLiteral.java index 09e648118b..4678e58d14 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/SqlIntervalLiteral.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/SqlIntervalLiteral.java @@ -80,13 +80,12 @@ public int signum() { /** * A Interval value. */ + @Getter public static class IntervalValue extends PolyInterval { - @Getter private final SqlIntervalQualifier intervalQualifier; private final String intervalStr; - @Getter - private final int sign; + private final boolean negative; /** @@ -97,24 +96,28 @@ public static class IntervalValue extends PolyInterval { IntervalValue( SqlIntervalQualifier intervalQualifier, PolyInterval interval ) { super( interval.millis, interval.months ); this.intervalQualifier = intervalQualifier; - this.sign = interval.millis < 0 ? -1 : 1; + this.negative = interval.millis < 0 || interval.months < 0; this.intervalStr = SqlIntervalQualifier.intervalString( interval, intervalQualifier ); } - public boolean equals( Object obj ) { if ( !(obj instanceof IntervalValue that) ) { return false; } return this.intervalStr.equals( that.intervalStr ) - && (this.sign == that.sign) + && (this.negative == that.negative) && this.intervalQualifier.equalsDeep( that.intervalQualifier, Litmus.IGNORE ); } + public int getSign() { + return negative ? -1 : 1; + } + + public int hashCode() { - return Objects.hash( sign, intervalStr, intervalQualifier ); + return Objects.hash( getSign(), intervalStr, intervalQualifier ); } diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/SqlIntervalQualifier.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/SqlIntervalQualifier.java index e043817574..51597dd2ef 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/SqlIntervalQualifier.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/SqlIntervalQualifier.java @@ -1200,7 +1200,7 @@ private PolyphenyDbContextException invalidValueException( ParserPos pos, String return CoreUtil.newContextException( pos, RESOURCE.unsupportedIntervalLiteral( - "'" + value + "'", "INTERVAL " + toString() ) ); + "'" + value + "'", "INTERVAL " + this ) ); } diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/ddl/SqlAlterAdaptersAdd.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/ddl/SqlAlterAdaptersAdd.java index 2e4c24c832..2edef87e97 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/ddl/SqlAlterAdaptersAdd.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/ddl/SqlAlterAdaptersAdd.java @@ -25,6 +25,7 @@ import org.apache.commons.lang3.StringUtils; import org.polypheny.db.adapter.DeployMode; import org.polypheny.db.algebra.constant.Kind; +import org.polypheny.db.catalog.Catalog; import org.polypheny.db.catalog.entity.LogicalAdapter.AdapterType; import org.polypheny.db.ddl.DdlManager; import org.polypheny.db.languages.ParserPos; @@ -99,6 +100,7 @@ public void execute( Context context, Statement statement, ParsedQueryContext pa DdlManager.getInstance().createAdapter( removeQuotationMarks( uniqueName.toString() ), removeQuotationMarks( adapterName.toString() ), + Catalog.defaultNamespaceId, AdapterType.valueOf( removeQuotationMarks( adapterType.toString().toUpperCase() ) ), configMap, configMap.containsKey( "mode" ) ? DeployMode.valueOf( configMap.get( "mode" ).toUpperCase() ) : DeployMode.EMBEDDED );