Skip to content

Commit

Permalink
Fix Cassandra incorrect query results when applyFilter repeated
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed Mar 11, 2022
1 parent fe16de1 commit a8f1d67
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ public ColumnMetadata getColumnMetadata(ConnectorSession session, ConnectorTable
public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(ConnectorSession session, ConnectorTableHandle tableHandle, Constraint constraint)
{
CassandraTableHandle handle = (CassandraTableHandle) tableHandle;
if (handle.getPartitions().isPresent() || !handle.getClusteringKeyPredicates().isEmpty()) {
// TODO support repeated applyFilter
return Optional.empty();
}

CassandraPartitionResult partitionResult = partitionManager.getPartitions(handle, constraint.getSummary());

Expand Down Expand Up @@ -232,6 +236,7 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C
handle.getSchemaName(),
handle.getTableName(),
Optional.of(partitionResult.getPartitions()),
// TODO this should probably be AND-ed with handle.getClusteringKeyPredicates()
clusteringKeyPredicates),
unenforcedConstraint,
false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.Set;
import java.util.stream.Stream;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Predicates.in;
import static com.google.common.base.Predicates.not;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
Expand All @@ -53,6 +54,9 @@ public CassandraPartitionManager(CassandraSession cassandraSession)

public CassandraPartitionResult getPartitions(CassandraTableHandle cassandraTableHandle, TupleDomain<ColumnHandle> tupleDomain)
{
// TODO support repeated applyFilter
checkArgument(cassandraTableHandle.getPartitions().isEmpty(), "getPartitions() currently does not take into account table handle's partitions");

CassandraTable table = cassandraSession.getTable(cassandraTableHandle.getSchemaTableName());

// fetch the partitions
Expand Down

0 comments on commit a8f1d67

Please sign in to comment.