diff --git a/core/src/main/java/org/polypheny/db/catalog/catalogs/AllocationRelationalCatalog.java b/core/src/main/java/org/polypheny/db/catalog/catalogs/AllocationRelationalCatalog.java index fff975259c..4fbcf4ff3b 100644 --- a/core/src/main/java/org/polypheny/db/catalog/catalogs/AllocationRelationalCatalog.java +++ b/core/src/main/java/org/polypheny/db/catalog/catalogs/AllocationRelationalCatalog.java @@ -74,7 +74,7 @@ public interface AllocationRelationalCatalog extends AllocationCatalog { * @param partitionType partition Type of the added partition * @return The id of the created partitionGroup */ - AllocationPartitionGroup addPartitionGroup( long tableId, String partitionGroupName, long namespaceId, PartitionType partitionType, long numberOfInternalPartitions, List effectivePartitionGroupQualifier, boolean isUnbound ); + AllocationPartitionGroup addPartitionGroup( long tableId, String partitionGroupName, long namespaceId, PartitionType partitionType, long numberOfInternalPartitions, boolean isUnbound ); /** * Should only be called from mergePartitions(). Deletes a single partition and all references. @@ -89,13 +89,15 @@ public interface AllocationRelationalCatalog extends AllocationCatalog { * * @param tableId The unique id of the table * @param namespaceId The unique id of the table + * @param groupId * @param name * @param placementType * @param role + * @param qualifiers * @param partitionType * @return The id of the created partition */ - AllocationPartition addPartition( long tableId, long namespaceId, @Nullable String name, boolean isUnbound, PlacementType placementType, DataPlacementRole role, PartitionType partitionType ); + AllocationPartition addPartition( long tableId, long namespaceId, long groupId, @Nullable String name, boolean isUnbound, PlacementType placementType, DataPlacementRole role, List qualifiers, PartitionType partitionType ); /** * Deletes a single partition and all references. diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationPartition.java b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationPartition.java index 4f42ae67c4..ee5aa53511 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationPartition.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationPartition.java @@ -17,14 +17,16 @@ package org.polypheny.db.catalog.entity.allocation; +import com.google.common.collect.ImmutableList; import io.activej.serializer.annotations.Deserialize; import io.activej.serializer.annotations.Serialize; import io.activej.serializer.annotations.SerializeNullable; import java.io.Serializable; +import java.util.List; import javax.annotation.Nullable; import lombok.Getter; -import lombok.NonNull; import lombok.Value; +import org.jetbrains.annotations.NotNull; import org.polypheny.db.catalog.entity.CatalogObject; import org.polypheny.db.catalog.logistic.DataPlacementRole; import org.polypheny.db.catalog.logistic.PartitionType; @@ -45,6 +47,9 @@ public class AllocationPartition implements CatalogObject { @Serialize public long logicalEntityId; + @Serialize + public long groupId; + @Getter @Serialize @SerializeNullable @@ -75,24 +80,32 @@ public class AllocationPartition implements CatalogObject { public DataPlacementRole role; @Serialize public boolean isUnbound; + @Serialize + @NotNull + public List qualifiers; + public AllocationPartition( @Deserialize("id") final long id, @Deserialize("namespaceId") long namespaceId, @Deserialize("logicalEntityId") final long logicalEntityId, - @Deserialize("placementType") @NonNull final PlacementType placementType, + @Deserialize("groupId") final long groupId, + @Deserialize("placementType") @NotNull final PlacementType placementType, @Deserialize("name") @Nullable final String name, @Deserialize("role") DataPlacementRole role, @Deserialize("isUnbound") final boolean isUnbound, - @Deserialize("partitionType") PartitionType partitionType ) { + @Deserialize("qualifiers") @Nullable final List qualifiers, + @Deserialize("partitionType") final PartitionType partitionType ) { this.namespaceId = namespaceId; this.logicalEntityId = logicalEntityId; this.placementType = placementType; this.partitionType = partitionType; + this.groupId = groupId; this.id = id; this.role = role; this.isUnbound = isUnbound; this.name = name; + this.qualifiers = qualifiers == null ? List.of() : ImmutableList.copyOf( qualifiers ); } diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationPartitionGroup.java b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationPartitionGroup.java index 80cf0b1506..d064cb6cfd 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationPartitionGroup.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationPartitionGroup.java @@ -16,12 +16,10 @@ package org.polypheny.db.catalog.entity.allocation; -import com.google.common.collect.ImmutableList; import io.activej.serializer.annotations.Deserialize; import io.activej.serializer.annotations.Serialize; import io.activej.serializer.annotations.SerializeNullable; import java.io.Serializable; -import java.util.List; import lombok.EqualsAndHashCode; import lombok.Value; import org.jetbrains.annotations.Nullable; @@ -37,15 +35,13 @@ public class AllocationPartitionGroup implements CatalogObject { @Serialize public long id; @Serialize + @SerializeNullable public String name; @Serialize public long logicalEntityId; @Serialize public long namespaceId; @Serialize - @SerializeNullable - public ImmutableList partitionQualifiers; - @Serialize public boolean isUnbound; @Serialize public long partitionKey; @@ -53,20 +49,16 @@ public class AllocationPartitionGroup implements CatalogObject { public AllocationPartitionGroup( @Deserialize("id") final long id, - @Deserialize("name") final String name, + @Deserialize("name") @Nullable final String name, @Deserialize("logicalEntityId") final long logicalEntityId, @Deserialize("namespaceId") final long namespaceId, @Deserialize("partitionKey") final long partitionKey, - @Deserialize("partitionQualifiers") @Nullable final List partitionQualifiers, @Deserialize("isUnbound") final boolean isUnbound ) { this.id = id; this.name = name; this.logicalEntityId = logicalEntityId; this.namespaceId = namespaceId; this.partitionKey = partitionKey; - // TODO @HENNLO Although the qualifiers are now part of CatalogPartitions, it might be a good improvement to - // accumulate all qualifiers of all internal partitions here to speed up query time. - this.partitionQualifiers = partitionQualifiers == null ? null : ImmutableList.copyOf( partitionQualifiers ); this.isUnbound = isUnbound; } diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalForeignKey.java b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalForeignKey.java index d14bddbd16..aba1ffabe0 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalForeignKey.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalForeignKey.java @@ -105,7 +105,7 @@ public List getReferencedKeyColumnNames() { // Used for creating ResultSets public List getCatalogForeignKeyColumns() { int i = 1; - LinkedList list = new LinkedList<>(); + List list = new LinkedList<>(); List referencedKeyColumnNames = getReferencedKeyColumnNames(); for ( String columnName : getColumnNames() ) { list.add( new CatalogForeignKeyColumn( tableId, name, i, referencedKeyColumnNames.get( i - 1 ), columnName ) ); diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalPrimaryKey.java b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalPrimaryKey.java index 2a1f90e774..e236cc4035 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalPrimaryKey.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalPrimaryKey.java @@ -53,7 +53,7 @@ public LogicalPrimaryKey( @Deserialize("key") @NonNull final LogicalKey key ) { // Used for creating ResultSets public List getCatalogPrimaryKeyColumns() { int i = 1; - LinkedList list = new LinkedList<>(); + List list = new LinkedList<>(); for ( String columnName : getColumnNames() ) { list.add( new CatalogPrimaryKeyColumn( id, i++, columnName ) ); } diff --git a/core/src/main/java/org/polypheny/db/catalog/impl/allocation/PolyAllocDocCatalog.java b/core/src/main/java/org/polypheny/db/catalog/impl/allocation/PolyAllocDocCatalog.java index e85ff74144..bfb006ee1d 100644 --- a/core/src/main/java/org/polypheny/db/catalog/impl/allocation/PolyAllocDocCatalog.java +++ b/core/src/main/java/org/polypheny/db/catalog/impl/allocation/PolyAllocDocCatalog.java @@ -133,7 +133,7 @@ public void removePlacement( long placementId ) { @Override public AllocationPartition addPartition( LogicalCollection collection, PartitionType partitionType, String name ) { long id = idBuilder.getNewPartitionId(); - AllocationPartition partition = new AllocationPartition( id, namespace.id, collection.id, PlacementType.MANUAL, name, DataPlacementRole.UP_TO_DATE, false, partitionType ); + AllocationPartition partition = new AllocationPartition( id, namespace.id, collection.id, -1, PlacementType.MANUAL, name, DataPlacementRole.UP_TO_DATE, false, null, partitionType ); partitions.put( id, partition ); change(); return partition; diff --git a/core/src/main/java/org/polypheny/db/catalog/impl/allocation/PolyAllocGraphCatalog.java b/core/src/main/java/org/polypheny/db/catalog/impl/allocation/PolyAllocGraphCatalog.java index d344431a7c..e8c581a2a5 100644 --- a/core/src/main/java/org/polypheny/db/catalog/impl/allocation/PolyAllocGraphCatalog.java +++ b/core/src/main/java/org/polypheny/db/catalog/impl/allocation/PolyAllocGraphCatalog.java @@ -125,7 +125,7 @@ public void removePlacement( long id ) { @Override public AllocationPartition addPartition( LogicalGraph graph, PartitionType partitionType, String name ) { long id = idBuilder.getNewPartitionId(); - AllocationPartition partition = new AllocationPartition( id, namespace.id, graph.id, PlacementType.MANUAL, name, DataPlacementRole.UP_TO_DATE, false, partitionType ); + AllocationPartition partition = new AllocationPartition( id, namespace.id, graph.id, -1, PlacementType.MANUAL, name, DataPlacementRole.UP_TO_DATE, false, null, partitionType ); partitions.put( id, partition ); change(); return partition; diff --git a/core/src/main/java/org/polypheny/db/catalog/impl/allocation/PolyAllocRelCatalog.java b/core/src/main/java/org/polypheny/db/catalog/impl/allocation/PolyAllocRelCatalog.java index ed720a50ac..9440d8c343 100644 --- a/core/src/main/java/org/polypheny/db/catalog/impl/allocation/PolyAllocRelCatalog.java +++ b/core/src/main/java/org/polypheny/db/catalog/impl/allocation/PolyAllocRelCatalog.java @@ -161,7 +161,7 @@ public void updateColumnPlacementType( long placementId, long columnId, Placemen @Override - public AllocationPartitionGroup addPartitionGroup( long tableId, String partitionGroupName, long namespaceId, PartitionType partitionType, long numberOfInternalPartitions, List effectivePartitionGroupQualifier, boolean isUnbound ) { + public AllocationPartitionGroup addPartitionGroup( long tableId, String partitionGroupName, long namespaceId, PartitionType partitionType, long numberOfInternalPartitions, boolean isUnbound ) { long id = idBuilder.getNewGroupId(); if ( log.isDebugEnabled() ) { log.debug( "Creating partitionGroup of type '{}' with id '{}'", partitionType, id ); @@ -173,7 +173,6 @@ public AllocationPartitionGroup addPartitionGroup( long tableId, String partitio tableId, namespaceId, 0, - null, isUnbound ); partitionGroups.put( id, partitionGroup ); @@ -188,7 +187,7 @@ public void deletePartitionGroup( long groupId ) { @Override - public AllocationPartition addPartition( long tableId, long namespaceId, @Nullable String name, boolean isUnbound, PlacementType placementType, DataPlacementRole role, PartitionType partitionType ) { + public AllocationPartition addPartition( long tableId, long namespaceId, long groupId, @Nullable String name, boolean isUnbound, PlacementType placementType, DataPlacementRole role, List qualifiers, PartitionType partitionType ) { long id = idBuilder.getNewPartitionId(); if ( log.isDebugEnabled() ) { log.debug( "Creating partition with id '{}'", id ); @@ -198,10 +197,12 @@ public AllocationPartition addPartition( long tableId, long namespaceId, @Nullab id, namespaceId, tableId, + groupId, placementType, name, role, isUnbound, + qualifiers, partitionType ); partitions.put( id, partition ); diff --git a/core/src/main/java/org/polypheny/db/catalog/logistic/PartitionType.java b/core/src/main/java/org/polypheny/db/catalog/logistic/PartitionType.java index d6618d8224..ca1a9cc213 100644 --- a/core/src/main/java/org/polypheny/db/catalog/logistic/PartitionType.java +++ b/core/src/main/java/org/polypheny/db/catalog/logistic/PartitionType.java @@ -16,6 +16,9 @@ package org.polypheny.db.catalog.logistic; +import lombok.Getter; + +@Getter public enum PartitionType { NONE( 0 ), RANGE( 1 ), @@ -32,11 +35,6 @@ public enum PartitionType { } - public int getId() { - return id; - } - - public static PartitionType getById( final int id ) { for ( PartitionType t : values() ) { if ( t.id == id ) { diff --git a/core/src/main/java/org/polypheny/db/catalog/snapshot/AllocSnapshot.java b/core/src/main/java/org/polypheny/db/catalog/snapshot/AllocSnapshot.java index b0d91589d0..4e1d596a3a 100644 --- a/core/src/main/java/org/polypheny/db/catalog/snapshot/AllocSnapshot.java +++ b/core/src/main/java/org/polypheny/db/catalog/snapshot/AllocSnapshot.java @@ -226,4 +226,7 @@ public interface AllocSnapshot { @NotNull List getPartitions(); + @NotNull + List getPartitionsFromGroup( long groupId ); + } diff --git a/core/src/main/java/org/polypheny/db/catalog/snapshot/impl/AllocSnapshotImpl.java b/core/src/main/java/org/polypheny/db/catalog/snapshot/impl/AllocSnapshotImpl.java index 03d6ca2e50..59cd48a1e6 100644 --- a/core/src/main/java/org/polypheny/db/catalog/snapshot/impl/AllocSnapshotImpl.java +++ b/core/src/main/java/org/polypheny/db/catalog/snapshot/impl/AllocSnapshotImpl.java @@ -79,6 +79,7 @@ public class AllocSnapshotImpl implements AllocSnapshot { ImmutableMap, AllocationPlacement> adapterLogicalToPlacement; ImmutableMap> placementToPartitions; ImmutableMap> placementsOfColumn; + ImmutableMap> partitionsOfGroup; ImmutableMap, AllocationPartition> entityPartitionNameToPartition; @@ -146,6 +147,18 @@ public AllocSnapshotImpl( Map allocationCatalogs, Map> buildPartitionsOfGroups() { + Map> map = new HashMap<>(); + for ( AllocationPartitionGroup group : groups.values() ) { + map.put( group.id, partitions.values().stream().filter( p -> p.groupId == group.id ).collect( Collectors.toList() ) ); + } + + return ImmutableMap.copyOf( map ); } @@ -403,6 +416,7 @@ private ImmutableMap buildTables( List> getEntitiesOnAdapter( long id ) { return Optional.ofNullable( allocsOnAdapters.get( id ) ); @@ -596,4 +610,10 @@ public Optional getPartitionFromName( long logicalId, Strin } + @Override + public @NotNull List getPartitionsFromGroup( long groupId ) { + return Optional.ofNullable( partitionsOfGroup.get( groupId ) ).orElse( List.of() ); + } + + } diff --git a/core/src/main/java/org/polypheny/db/processing/WhereClauseVisitor.java b/core/src/main/java/org/polypheny/db/processing/WhereClauseVisitor.java index 6d4e7dabfd..1ea8d74f6f 100644 --- a/core/src/main/java/org/polypheny/db/processing/WhereClauseVisitor.java +++ b/core/src/main/java/org/polypheny/db/processing/WhereClauseVisitor.java @@ -27,6 +27,7 @@ import org.polypheny.db.rex.RexNode; import org.polypheny.db.rex.RexShuttle; import org.polypheny.db.transaction.Statement; +import org.polypheny.db.type.entity.PolyValue; /** @@ -36,7 +37,7 @@ public class WhereClauseVisitor extends RexShuttle { private final Statement statement; @Getter - private final List values = new ArrayList<>(); + private final List values = new ArrayList<>(); private final long partitionColumnIndex; @Getter protected boolean valueIdentified = false; @@ -57,11 +58,11 @@ public RexNode visitCall( final RexCall call ) { if ( call.operands.size() == 2 ) { if ( call.op.getKind() == Kind.EQUALS ) { - Object value; + PolyValue value; if ( call.operands.get( 0 ) instanceof RexIndexRef ) { if ( ((RexIndexRef) call.operands.get( 0 )).getIndex() == partitionColumnIndex ) { if ( call.operands.get( 1 ) instanceof RexLiteral ) { - value = ((RexLiteral) call.operands.get( 1 )).getValueForQueryParameterizer(); + value = ((RexLiteral) call.operands.get( 1 )).value; values.add( value ); valueIdentified = true; } else if ( call.operands.get( 1 ) instanceof RexDynamicParam ) { diff --git a/core/src/main/java/org/polypheny/db/type/PolyTypeFactoryImpl.java b/core/src/main/java/org/polypheny/db/type/PolyTypeFactoryImpl.java index 6bab1308d5..39192419b1 100644 --- a/core/src/main/java/org/polypheny/db/type/PolyTypeFactoryImpl.java +++ b/core/src/main/java/org/polypheny/db/type/PolyTypeFactoryImpl.java @@ -169,7 +169,7 @@ public AlgDataType createTypeWithCharsetAndCollation( AlgDataType type, Charset @Override public AlgDataType leastRestrictive( List types ) { assert types != null; - assert types.size() >= 1; + assert !types.isEmpty(); AlgDataType type0 = types.get( 0 ); if ( type0.getPolyType() != null ) { 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 9395ff1535..a105ae08e6 100644 --- a/dbms/src/main/java/org/polypheny/db/ddl/DdlManagerImpl.java +++ b/dbms/src/main/java/org/polypheny/db/ddl/DdlManagerImpl.java @@ -226,7 +226,8 @@ private void handleSource( DataSource adapter ) { LogicalTable logical = catalog.getLogicalRel( Catalog.defaultNamespaceId ).addTable( tableName, EntityType.SOURCE, !(adapter).isDataReadOnly() ); List columns = new ArrayList<>(); - AllocationPartition partition = catalog.getAllocRel( Catalog.defaultNamespaceId ).addPartition( logical.id, Catalog.defaultNamespaceId, UNPARTITIONED, false, PlacementType.AUTOMATIC, DataPlacementRole.UP_TO_DATE, PartitionType.NONE ); + AllocationPartitionGroup group = catalog.getAllocRel( Catalog.defaultNamespaceId ).addPartitionGroup( logical.id, null, Catalog.defaultNamespaceId, PartitionType.NONE, 1, true ); + AllocationPartition partition = catalog.getAllocRel( Catalog.defaultNamespaceId ).addPartition( logical.id, Catalog.defaultNamespaceId, group.id, UNPARTITIONED, false, PlacementType.AUTOMATIC, DataPlacementRole.UP_TO_DATE, null, PartitionType.NONE ); AllocationPlacement placement = catalog.getAllocRel( Catalog.defaultNamespaceId ).addPlacement( logical.id, Catalog.defaultNamespaceId, adapter.adapterId ); AllocationEntity allocation = catalog.getAllocRel( Catalog.defaultNamespaceId ).addAllocation( adapter.getAdapterId(), placement.id, partition.id, logical.id ); @@ -1811,8 +1812,8 @@ public void createMaterializedView( String viewName, long namespaceId, AlgRoot a // Sets previously created primary key //catalog.getLogicalRel( namespaceId ).createPrimaryKey( view.id, columnIds ); - AllocationPartitionGroup group = catalog.getAllocRel( namespaceId ).addPartitionGroup( view.id, UNPARTITIONED, namespaceId, PartitionType.NONE, 1, List.of(), false ); - AllocationPartition partition = catalog.getAllocRel( namespaceId ).addPartition( view.id, namespaceId, null, false, PlacementType.AUTOMATIC, DataPlacementRole.UP_TO_DATE, PartitionType.NONE ); + AllocationPartitionGroup group = catalog.getAllocRel( namespaceId ).addPartitionGroup( view.id, UNPARTITIONED, namespaceId, PartitionType.NONE, 1, false ); + AllocationPartition partition = catalog.getAllocRel( namespaceId ).addPartition( view.id, namespaceId, group.id, null, false, PlacementType.AUTOMATIC, DataPlacementRole.UP_TO_DATE, null, PartitionType.NONE ); for ( DataStore store : stores ) { AllocationPlacement placement = catalog.getAllocRel( namespaceId ).addPlacement( view.id, namespaceId, store.adapterId ); @@ -2124,8 +2125,8 @@ public void createTable( long namespaceId, String name, List f @NotNull private Pair createSinglePartition( long namespaceId, LogicalTable logical ) { - AllocationPartitionGroup group = catalog.getAllocRel( namespaceId ).addPartitionGroup( logical.id, UNPARTITIONED, namespaceId, PartitionType.NONE, 1, List.of(), false ); - AllocationPartition partition = catalog.getAllocRel( namespaceId ).addPartition( logical.id, namespaceId, null, false, PlacementType.AUTOMATIC, DataPlacementRole.REFRESHABLE, PartitionType.NONE ); + AllocationPartitionGroup group = catalog.getAllocRel( namespaceId ).addPartitionGroup( logical.id, UNPARTITIONED, namespaceId, PartitionType.NONE, 1, false ); + AllocationPartition partition = catalog.getAllocRel( namespaceId ).addPartition( logical.id, namespaceId, group.id, null, false, PlacementType.AUTOMATIC, DataPlacementRole.REFRESHABLE, null, PartitionType.NONE ); PartitionProperty property = addBlankPartition( namespaceId, logical.id, List.of( group.id ), List.of( partition.id ) ); return Pair.of( partition, property ); } @@ -2534,7 +2535,6 @@ private Pair, PartitionProperty> addGroupsAndPartition partitionInfo.table.namespaceId, actualPartitionType, numberOfPartitionsPerGroup, - new ArrayList<>(), true ); } else { // If no names have been explicitly defined @@ -2551,7 +2551,6 @@ private Pair, PartitionProperty> addGroupsAndPartition partitionInfo.table.namespaceId, actualPartitionType, numberOfPartitionsPerGroup, - new ArrayList<>(), false ); } else { group = catalog.getAllocRel( partitionInfo.table.namespaceId ).addPartitionGroup( @@ -2560,7 +2559,6 @@ private Pair, PartitionProperty> addGroupsAndPartition partitionInfo.table.namespaceId, actualPartitionType, numberOfPartitionsPerGroup, - partitionInfo.qualifiers.get( i ), false ); } } @@ -2568,14 +2566,19 @@ private Pair, PartitionProperty> addGroupsAndPartition partitionGroups.put( group, partitions ); } + int j = 0; for ( AllocationPartitionGroup group : partitionGroups.keySet() ) { + List qualifiers = group.isUnbound ? null : (j < partitionInfo.qualifiers.size() ? partitionInfo.qualifiers.get( j++ ) : null); partitionGroups.put( group, List.of( catalog.getAllocRel( partitionInfo.table.namespaceId ).addPartition( partitionInfo.table.id, partitionInfo.table.namespaceId, + group.id, group.name, group.isUnbound, PlacementType.AUTOMATIC, - DataPlacementRole.REFRESHABLE, PartitionType.NONE ) ) ); + DataPlacementRole.REFRESHABLE, + qualifiers, + PartitionType.NONE ) ) ); } //get All PartitionGroups and then get all partitionIds for each PG and add them to completeList of partitionIds @@ -2583,77 +2586,7 @@ private Pair, PartitionProperty> addGroupsAndPartition PartitionProperty partitionProperty; if ( actualPartitionType == PartitionType.TEMPERATURE ) { - long frequencyInterval = ((RawTemperaturePartitionInformation) partitionInfo.rawPartitionInformation).getInterval(); - switch ( ((RawTemperaturePartitionInformation) partitionInfo.rawPartitionInformation).getIntervalUnit().toString() ) { - case "days": - frequencyInterval = frequencyInterval * 60 * 60 * 24; - break; - - case "hours": - frequencyInterval = frequencyInterval * 60 * 60; - break; - - case "minutes": - frequencyInterval = frequencyInterval * 60; - break; - } - - int hotPercentageIn = Integer.parseInt( ((RawTemperaturePartitionInformation) partitionInfo.rawPartitionInformation).getHotAccessPercentageIn().toString() ); - int hotPercentageOut = Integer.parseInt( ((RawTemperaturePartitionInformation) partitionInfo.rawPartitionInformation).getHotAccessPercentageOut().toString() ); - - //Initially distribute partitions as intended in a running system - long numberOfPartitionsInHot = (long) numberOfPartitions * hotPercentageIn / 100; - if ( numberOfPartitionsInHot == 0 ) { - numberOfPartitionsInHot = 1; - } - - long numberOfPartitionsInCold = numberOfPartitions - numberOfPartitionsInHot; - - // -1 because one partition is already created in COLD - AllocationPartitionGroup firstGroup = partitionGroups.keySet().stream().findFirst().orElseThrow(); - - // -1 because one partition is already created in HOT - for ( int i = 0; i < numberOfPartitionsInHot - 1; i++ ) { - partitions.add( catalog.getAllocRel( partitionInfo.table.namespaceId ).addPartition( - partitionInfo.table.id, - partitionInfo.table.namespaceId, - null, - false, - PlacementType.AUTOMATIC, - DataPlacementRole.UP_TO_DATE, PartitionType.NONE ) ); - } - - // -1 because one partition is already created in COLD - AllocationPartitionGroup secondGroup = new ArrayList<>( partitionGroups.keySet() ).get( 0 ); - - for ( int i = 0; i < numberOfPartitionsInCold - 1; i++ ) { - partitions.add( catalog.getAllocRel( partitionInfo.table.namespaceId ).addPartition( - partitionInfo.table.id, - partitionInfo.table.namespaceId, - null, - false, - PlacementType.AUTOMATIC, - DataPlacementRole.UP_TO_DATE, PartitionType.NONE ) ); - } - - partitionProperty = TemperaturePartitionProperty.builder() - .entityId( logicalColumn.tableId ) - .partitionType( actualPartitionType ) - .isPartitioned( true ) - .internalPartitionFunction( PartitionType.valueOf( ((RawTemperaturePartitionInformation) partitionInfo.rawPartitionInformation).getInternalPartitionFunction().toString().toUpperCase() ) ) - .partitionColumnId( logicalColumn.id ) - .partitionGroupIds( ImmutableList.copyOf( partitionGroups.keySet().stream().map( g -> g.id ).collect( Collectors.toList() ) ) ) - .partitionIds( ImmutableList.copyOf( partitions.stream().map( p -> p.id ).collect( Collectors.toList() ) ) ) - .partitionCostIndication( PartitionCostIndication.valueOf( ((RawTemperaturePartitionInformation) partitionInfo.rawPartitionInformation).getAccessPattern().toString().toUpperCase() ) ) - .frequencyInterval( frequencyInterval ) - .hotAccessPercentageIn( hotPercentageIn ) - .hotAccessPercentageOut( hotPercentageOut ) - .reliesOnPeriodicChecks( true ) - .hotPartitionGroupId( firstGroup.id ) - .coldPartitionGroupId( secondGroup.id ) - .numPartitions( partitions.size() ) - .numPartitionGroups( partitionGroups.size() ) - .build(); + partitionProperty = handleTemperaturePartitioning( partitionInfo, numberOfPartitions, partitionGroups, partitions, logicalColumn, actualPartitionType ); } else { partitionProperty = PartitionProperty.builder() .entityId( logicalColumn.tableId ) @@ -2669,6 +2602,87 @@ private Pair, PartitionProperty> addGroupsAndPartition } + private PartitionProperty handleTemperaturePartitioning( PartitionInformation partitionInfo, int numberOfPartitions, Map> partitionGroups, List partitions, LogicalColumn logicalColumn, PartitionType actualPartitionType ) { + PartitionProperty partitionProperty; + long frequencyInterval = ((RawTemperaturePartitionInformation) partitionInfo.rawPartitionInformation).getInterval(); + switch ( ((RawTemperaturePartitionInformation) partitionInfo.rawPartitionInformation).getIntervalUnit().toString() ) { + case "days": + frequencyInterval = frequencyInterval * 60 * 60 * 24; + break; + + case "hours": + frequencyInterval = frequencyInterval * 60 * 60; + break; + + case "minutes": + frequencyInterval = frequencyInterval * 60; + break; + } + + int hotPercentageIn = Integer.parseInt( ((RawTemperaturePartitionInformation) partitionInfo.rawPartitionInformation).getHotAccessPercentageIn().toString() ); + int hotPercentageOut = Integer.parseInt( ((RawTemperaturePartitionInformation) partitionInfo.rawPartitionInformation).getHotAccessPercentageOut().toString() ); + + //Initially distribute partitions as intended in a running system + long numberOfPartitionsInHot = (long) numberOfPartitions * hotPercentageIn / 100; + if ( numberOfPartitionsInHot == 0 ) { + numberOfPartitionsInHot = 1; + } + + long numberOfPartitionsInCold = numberOfPartitions - numberOfPartitionsInHot; + + // -1 because one partition is already created in HOT + AllocationPartitionGroup firstGroup = partitionGroups.keySet().stream().findFirst().orElseThrow(); + + // -1 because one partition is already created in HOT + for ( int i = 0; i < numberOfPartitionsInHot - 1; i++ ) { + partitions.add( catalog.getAllocRel( partitionInfo.table.namespaceId ).addPartition( + partitionInfo.table.id, + partitionInfo.table.namespaceId, + firstGroup.id, + null, + false, + PlacementType.AUTOMATIC, + DataPlacementRole.UP_TO_DATE, + null, PartitionType.NONE ) ); + } + + // -1 because one partition is already created in COLD + AllocationPartitionGroup secondGroup = new ArrayList<>( partitionGroups.keySet() ).get( 1 ); + + for ( int i = 0; i < numberOfPartitionsInCold - 1; i++ ) { + partitions.add( catalog.getAllocRel( partitionInfo.table.namespaceId ).addPartition( + partitionInfo.table.id, + partitionInfo.table.namespaceId, + secondGroup.id, + null, + false, + PlacementType.AUTOMATIC, + DataPlacementRole.UP_TO_DATE, + null, PartitionType.NONE ) ); + } + + partitionProperty = TemperaturePartitionProperty.builder() + .entityId( logicalColumn.tableId ) + .partitionType( actualPartitionType ) + .isPartitioned( true ) + .internalPartitionFunction( PartitionType.valueOf( ((RawTemperaturePartitionInformation) partitionInfo.rawPartitionInformation).getInternalPartitionFunction().toString().toUpperCase() ) ) + .partitionColumnId( logicalColumn.id ) + .partitionGroupIds( ImmutableList.copyOf( partitionGroups.keySet().stream().map( g -> g.id ).collect( Collectors.toList() ) ) ) + .partitionIds( ImmutableList.copyOf( partitions.stream().map( p -> p.id ).collect( Collectors.toList() ) ) ) + .partitionCostIndication( PartitionCostIndication.valueOf( ((RawTemperaturePartitionInformation) partitionInfo.rawPartitionInformation).getAccessPattern().toString().toUpperCase() ) ) + .frequencyInterval( frequencyInterval ) + .hotAccessPercentageIn( hotPercentageIn ) + .hotAccessPercentageOut( hotPercentageOut ) + .reliesOnPeriodicChecks( true ) + .hotPartitionGroupId( firstGroup.id ) + .coldPartitionGroupId( secondGroup.id ) + .numPartitions( partitions.size() ) + .numPartitionGroups( partitionGroups.size() ) + .build(); + return partitionProperty; + } + + @Override public void dropTablePartition( LogicalTable table, Statement statement ) throws TransactionException { long tableId = table.id; diff --git a/dbms/src/main/java/org/polypheny/db/partition/ListPartitionManager.java b/dbms/src/main/java/org/polypheny/db/partition/ListPartitionManager.java index dda395b716..90b152c400 100644 --- a/dbms/src/main/java/org/polypheny/db/partition/ListPartitionManager.java +++ b/dbms/src/main/java/org/polypheny/db/partition/ListPartitionManager.java @@ -23,6 +23,7 @@ import lombok.extern.slf4j.Slf4j; import org.polypheny.db.catalog.entity.logical.LogicalColumn; import org.polypheny.db.catalog.entity.logical.LogicalTable; +import org.polypheny.db.catalog.exceptions.GenericRuntimeException; import org.polypheny.db.partition.PartitionFunctionInfo.PartitionFunctionInfoColumn; import org.polypheny.db.partition.PartitionFunctionInfo.PartitionFunctionInfoColumnType; import org.polypheny.db.partition.properties.PartitionProperty; @@ -91,12 +92,12 @@ public boolean validatePartitionGroupSetup( List> partitionGroupQua } if ( partitionGroupQualifiers.isEmpty() ) { - throw new RuntimeException( "LIST Partitioning doesn't support empty Partition Qualifiers: '" + partitionGroupQualifiers + + throw new GenericRuntimeException( "LIST Partitioning doesn't support empty Partition Qualifiers: '" + partitionGroupQualifiers + "'. USE (PARTITION name1 VALUES(value1)[(,PARTITION name1 VALUES(value1))*])" ); } if ( partitionGroupQualifiers.size() + 1 != numPartitionGroups ) { - throw new RuntimeException( "Number of partitionQualifiers '" + partitionGroupQualifiers + + throw new GenericRuntimeException( "Number of partitionQualifiers '" + partitionGroupQualifiers + "' + (mandatory 'Unbound' partition) is not equal to number of specified partitions '" + numPartitionGroups + "'" ); } diff --git a/dbms/src/main/java/org/polypheny/db/partition/RangePartitionManager.java b/dbms/src/main/java/org/polypheny/db/partition/RangePartitionManager.java index c58df8c14e..9641bf694f 100644 --- a/dbms/src/main/java/org/polypheny/db/partition/RangePartitionManager.java +++ b/dbms/src/main/java/org/polypheny/db/partition/RangePartitionManager.java @@ -23,9 +23,11 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import lombok.extern.slf4j.Slf4j; +import org.polypheny.db.catalog.Catalog; import org.polypheny.db.catalog.entity.allocation.AllocationPartition; import org.polypheny.db.catalog.entity.logical.LogicalColumn; import org.polypheny.db.catalog.entity.logical.LogicalTable; +import org.polypheny.db.catalog.exceptions.GenericRuntimeException; import org.polypheny.db.partition.PartitionFunctionInfo.PartitionFunctionInfoColumn; import org.polypheny.db.partition.PartitionFunctionInfo.PartitionFunctionInfoColumnType; import org.polypheny.db.partition.properties.PartitionProperty; @@ -47,24 +49,24 @@ public long getTargetPartitionId( LogicalTable table, PartitionProperty property long selectedPartitionId = -1; // Process all accumulated CatalogPartitions - /*for ( AllocationEntity entity : Catalog.getInstance().getSnapshot().alloc().getFromLogical( catalogTable.id ) ) { - if ( unboundPartitionId == -1 && catalogPartition.isUnbound ) { - unboundPartitionId = catalogPartition.id; + for ( AllocationPartition partition : Catalog.snapshot().alloc().getPartitionsFromLogical( table.id ) ) { + if ( partition.isUnbound ) { + unboundPartitionId = partition.id; break; } - if ( isValueInRange( columnValue, catalogPartition ) ) { + if ( isValueInRange( columnValue, partition ) ) { if ( log.isDebugEnabled() ) { log.debug( "Found column value: {} on partitionID {} in range: [{} - {}]", columnValue, - catalogPartition.id, - catalogPartition.partitionQualifiers.get( 0 ), - catalogPartition.partitionQualifiers.get( 1 ) ); + partition.id, + partition.qualifiers.get( 0 ), + partition.qualifiers.get( 1 ) ); } - selectedPartitionId = catalogPartition.id; + selectedPartitionId = partition.id; break; } - }*/ + } // If no concrete partition could be identified, report back the unbound/default partition if ( selectedPartitionId == -1 ) { @@ -100,11 +102,11 @@ public boolean validatePartitionGroupSetup( List> partitionGroupQua } if ( partitionGroupQualifiers.size() + 1 != numPartitionGroups ) { - throw new RuntimeException( "Number of partitionQualifiers '" + partitionGroupQualifiers + "' + (mandatory 'Unbound' partition) is not equal to number of specified partitions '" + numPartitionGroups + "'" ); + throw new GenericRuntimeException( "Number of partitionQualifiers '" + partitionGroupQualifiers + "' + (mandatory 'Unbound' partition) is not equal to number of specified partitions '" + numPartitionGroups + "'" ); } if ( partitionGroupQualifiers.isEmpty() ) { - throw new RuntimeException( "Partition Qualifiers are empty '" + partitionGroupQualifiers + "'" ); + throw new GenericRuntimeException( "Partition Qualifiers are empty '" + partitionGroupQualifiers + "'" ); } // Check if range is overlapping @@ -253,14 +255,13 @@ public boolean supportsColumnOfType( PolyType type ) { } - private boolean isValueInRange( String columnValue, AllocationPartition logicalPartition ) { - //int lowerBound = Integer.parseInt( logicalPartition.partitionQualifiers.get( 0 ) ); - //int upperBound = Integer.parseInt( logicalPartition.partitionQualifiers.get( 1 ) ); + private boolean isValueInRange( String columnValue, AllocationPartition partition ) { + int lowerBound = Integer.parseInt( partition.qualifiers.get( 0 ) ); + int upperBound = Integer.parseInt( partition.qualifiers.get( 1 ) ); double numericValue = Double.parseDouble( columnValue ); - //return numericValue >= lowerBound && numericValue <= upperBound; - return false;// todo dl; + return numericValue >= lowerBound && numericValue <= upperBound; } } diff --git a/dbms/src/main/java/org/polypheny/db/processing/DataMigratorImpl.java b/dbms/src/main/java/org/polypheny/db/processing/DataMigratorImpl.java index 9c5bc13261..54a3a66736 100644 --- a/dbms/src/main/java/org/polypheny/db/processing/DataMigratorImpl.java +++ b/dbms/src/main/java/org/polypheny/db/processing/DataMigratorImpl.java @@ -740,7 +740,12 @@ public void copyAllocationData( Transaction transaction, LogicalAdapter store, L i++; } }*/ - int columIndex = 0; // todo dl //snapshot.alloc().getC sourcePlacement.indexOf( targetProperty.partitionColumnId ); + int columIndex = 0; + if ( partitionColumn.tableId == table.id ) { + columIndex = source.sourceAlg.alg.getRowType().getField( partitionColumn.name, true, false ).getIndex(); + } + + //int partitionColumnIndex = -1; String parsedValue = null; diff --git a/dbms/src/main/java/org/polypheny/db/routing/routers/DmlRouterImpl.java b/dbms/src/main/java/org/polypheny/db/routing/routers/DmlRouterImpl.java index 53dcd916bf..fd8813c2d0 100644 --- a/dbms/src/main/java/org/polypheny/db/routing/routers/DmlRouterImpl.java +++ b/dbms/src/main/java/org/polypheny/db/routing/routers/DmlRouterImpl.java @@ -211,7 +211,7 @@ public AlgNode visit( LogicalFilter filter ) { if ( !whereClauseVisitor.getValues().isEmpty() ) { whereClauseValues = whereClauseVisitor.getValues().stream() - .map( Object::toString ) + .map( PolyValue::toJson ) .collect( Collectors.toList() ); if ( log.isDebugEnabled() ) { log.debug( "Found Where Clause Values: {}", whereClauseValues ); @@ -293,7 +293,7 @@ public AlgNode visit( LogicalFilter filter ) { if ( !operationWasRewritten ) { for ( long partitionId : accessedPartitions ) { - if ( catalog.getSnapshot().alloc().getPartitionsFromLogical( table.id ).stream().noneMatch( p -> p.id == partitionId ) ) { + if ( catalog.getSnapshot().alloc().getAlloc( pkPlacement.id, partitionId ).isEmpty() ) { continue; } @@ -367,7 +367,7 @@ private Triple handleDmlInsert( List updateColumn if ( partitionColumnIndex == -1 || currentTuple.get( partitionColumnIndex ).getValue() == null ) { partitionValue = PartitionManager.NULL_STRING; } else { - partitionValue = currentTuple.get( partitionColumnIndex ).toString().replace( "'", "" ); + partitionValue = currentTuple.get( partitionColumnIndex ).value.toJson().replace( "'", "" ); } identPart = (int) partitionManager.getTargetPartitionId( table, property, partitionValue ); accessedPartitionList.add( identPart ); @@ -453,8 +453,7 @@ private Triple handleDmlInsert( List updateColumn tempPartitionId = partitionManager.getTargetPartitionId( table, property, currentRow.get( partitionValueIndex ).toString() ); - long finalTempPartitionId = tempPartitionId; - if ( catalog.getSnapshot().alloc().getPartitionsFromLogical( table.id ).stream().noneMatch( p -> p.id == finalTempPartitionId ) ) { + if ( catalog.getSnapshot().alloc().getAlloc( pkPlacement.id, tempPartitionId ).isEmpty() ) { continue; } @@ -541,7 +540,7 @@ private Pair, String> handleDmlUpdate( List updateColumns, Log log.debug( " UPDATE: Found PartitionColumnID Match: '{}' at index: {}", property.partitionColumnId, index ); } // Routing/Locking can now be executed on certain partitions - partitionValue = sourceExpressionList.get( index ).toString().replace( "'", "" ); + partitionValue = ((RexLiteral) sourceExpressionList.get( index )).value.toJson().replace( "'", "" ); if ( log.isDebugEnabled() ) { log.debug( "UPDATE: partitionColumn-value: '{}' should be put on partition: {}", @@ -776,13 +775,13 @@ private AlgBuilder buildDml( RoutedAlgBuilder builder, LogicalTable table, List placements, - AllocationEntity allocationTable, + AllocationEntity allocEntity, Statement statement, AlgOptCluster cluster, boolean remapParameterValues, List> parameterValues ) { for ( int i = 0; i < node.getInputs().size(); i++ ) { - buildDml( node.getInput( i ), builder, table, placements, allocationTable, statement, cluster, remapParameterValues, parameterValues ); + buildDml( node.getInput( i ), builder, table, placements, allocEntity, statement, cluster, remapParameterValues, parameterValues ); } if ( log.isDebugEnabled() ) { @@ -795,7 +794,7 @@ private AlgBuilder buildDml( if ( node instanceof LogicalDocumentScan ) { return handleLogicalDocumentScan( builder, statement ); } else if ( node instanceof LogicalRelScan && node.getEntity() != null ) { - return handleRelScan( builder, statement, ((LogicalRelScan) node).entity ); + return handleRelScan( builder, statement, allocEntity != null ? allocEntity : ((LogicalRelScan) node).entity ); } else if ( node instanceof LogicalDocumentValues ) { return handleDocuments( (LogicalDocumentValues) node, builder ); } else if ( node instanceof Values ) { @@ -850,13 +849,13 @@ private AlgBuilder handleLogicalProject( AlgNode node, RoutedAlgBuilder builder, builder = remapParameterizedDml( node, builder, statement, parameterValues ); } builder.push( node.copy( node.getTraitSet(), ImmutableList.of( builder.peek( 0 ) ) ) ); - ArrayList rexNodes = new ArrayList<>(); + List rexNodes = new ArrayList<>(); for ( AllocationColumn ccp : placements ) { rexNodes.add( builder.field( ccp.getLogicalColumnName() ) ); } return builder.project( rexNodes ); } else { - ArrayList rexNodes = new ArrayList<>(); + List rexNodes = new ArrayList<>(); for ( AllocationColumn ccp : placements ) { rexNodes.add( builder.field( ccp.getLogicalColumnName() ) ); } diff --git a/dbms/src/test/java/org/polypheny/db/misc/HorizontalPartitioningTest.java b/dbms/src/test/java/org/polypheny/db/misc/HorizontalPartitioningTest.java index 6ef2ad956d..6a726c889f 100644 --- a/dbms/src/test/java/org/polypheny/db/misc/HorizontalPartitioningTest.java +++ b/dbms/src/test/java/org/polypheny/db/misc/HorizontalPartitioningTest.java @@ -727,7 +727,7 @@ public void temperaturePartitionTest() throws SQLException { Assert.assertEquals( 20, partitionProperty.getPartitionIds().size() ); // Check if initially as many partitionPlacements are created as requested and stored in the partition property - Assert.assertEquals( partitionProperty.getPartitionIds().size(), Catalog.snapshot().alloc().getAllPartitionPlacementsByTable( table.id ).size() ); + Assert.assertEquals( partitionProperty.getPartitionIds().size(), Catalog.snapshot().alloc().getPartitionsFromLogical( table.id ).size() ); // Retrieve partition distribution // Get percentage of tables which can remain in HOT @@ -742,8 +742,8 @@ public void temperaturePartitionTest() throws SQLException { } long numberOfPartitionsInCold = partitionProperty.partitionIds.size() - numberOfPartitionsInHot; - List hotPartitions = Catalog.snapshot().alloc().getPartitions( ((TemperaturePartitionProperty) partitionProperty).getHotPartitionGroupId() ); - List coldPartitions = Catalog.snapshot().alloc().getPartitions( ((TemperaturePartitionProperty) partitionProperty).getColdPartitionGroupId() ); + List hotPartitions = Catalog.snapshot().alloc().getPartitionsFromGroup( ((TemperaturePartitionProperty) partitionProperty).getHotPartitionGroupId() ); + List coldPartitions = Catalog.snapshot().alloc().getPartitionsFromGroup( ((TemperaturePartitionProperty) partitionProperty).getColdPartitionGroupId() ); Assert.assertTrue( (numberOfPartitionsInHot == hotPartitions.size()) || (numberOfPartitionsInHot == allowedTablesInHot) ); @@ -782,8 +782,8 @@ public void temperaturePartitionTest() throws SQLException { PartitionManager partitionManager = partitionManagerFactory.getPartitionManager( partitionProperty.partitionType ); long targetId = partitionManager.getTargetPartitionId( table, partitionProperty, partitionValue ); - List hotPartitionsAfterChange = Catalog.snapshot().alloc().getPartitions( ((TemperaturePartitionProperty) updatedProperty).getHotPartitionGroupId() ); - Assert.assertTrue( hotPartitionsAfterChange.stream().map( p -> p.id ).collect( Collectors.toList() ).contains( Catalog.snapshot().alloc().getEntity( targetId ).orElseThrow().partitionId ) ); + List hotPartitionsAfterChange = Catalog.snapshot().alloc().getPartitionsFromGroup( ((TemperaturePartitionProperty) updatedProperty).getHotPartitionGroupId() ); + Assert.assertTrue( hotPartitionsAfterChange.stream().map( p -> p.id ).collect( Collectors.toList() ).contains( targetId ) ); //Todo @Hennlo check number of access } finally { @@ -1077,7 +1077,7 @@ public void hybridPartitioningTest() throws SQLException { new Object[]{ 407, "BarFoo", 67 } ) ); // Remove data - statement.executeUpdate( "DELETE FROM \"hybridpartitioningtest\" where tvarchar = 'Foo' " ); + statement.executeUpdate( "DELETE FROM \"hybridpartitioningtest\" where tvarchar = 'Foo'" ); // Assert and Check if Table has the desired entries TestHelper.checkResultSet( diff --git a/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/JdbcTable.java b/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/JdbcTable.java index bcd447834d..ca9cd9d094 100644 --- a/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/JdbcTable.java +++ b/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/JdbcTable.java @@ -167,7 +167,7 @@ public SqlNodeList getNodeList() { for ( PhysicalColumn column : columns ) { SqlNode[] operands = new SqlNode[]{ new SqlIdentifier( Arrays.asList( namespaceName, name, column.name ), ParserPos.ZERO ), - new SqlIdentifier( Collections.singletonList( column.name ), ParserPos.ZERO ) + new SqlIdentifier( Collections.singletonList( column.logicalName ), ParserPos.ZERO ) }; pcnl.add( new SqlBasicCall( (SqlOperator) OperatorRegistry.get( OperatorName.AS ), operands, ParserPos.ZERO ) ); } diff --git a/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/rel2sql/SqlImplementor.java b/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/rel2sql/SqlImplementor.java index 6b2fe034bc..b4908369a6 100644 --- a/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/rel2sql/SqlImplementor.java +++ b/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/rel2sql/SqlImplementor.java @@ -38,7 +38,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; -import java.util.AbstractList; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; @@ -161,17 +160,6 @@ public void addSelect( List selectList, SqlNode node, AlgDataType rowTy */ public static boolean isStar( List exps, AlgDataType inputRowType, AlgDataType projectRowType ) { return false; - /*assert exps.size() == projectRowType.getFieldCount(); - int i = 0; - for ( RexNode ref : exps ) { - if ( !(ref instanceof RexInputRef) ) { - return false; - } else if ( ((RexInputRef) ref).getIndex() != i++ ) { - return false; - } - } - return i == inputRowType.getFieldCount() - && inputRowType.getFieldNames().equals( projectRowType.getFieldNames() );*/ } @@ -845,21 +833,6 @@ private List toSql( RexProgram program, List operandList ) { } - public List fieldList() { - return new AbstractList<>() { - @Override - public SqlNode get( int index ) { - return field( index ); - } - - - @Override - public int size() { - return fieldCount; - } - }; - } - void addOrderItem( List orderByList, AlgFieldCollation field ) { if ( field.nullDirection != AlgFieldCollation.NullDirection.UNSPECIFIED ) { diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/SqlOrderBy.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/SqlOrderBy.java index dbf4dcadfc..2c6378bec5 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/SqlOrderBy.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/SqlOrderBy.java @@ -63,7 +63,7 @@ public Kind getKind() { @Override public org.polypheny.db.nodes.Operator getOperator() { - return (Operator) OPERATOR; + return OPERATOR; }