Skip to content

Commit

Permalink
Add time-related types to the storage and transactional interfaces. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Torch3333 authored Jan 8, 2025
1 parent 91681f5 commit f851464
Show file tree
Hide file tree
Showing 145 changed files with 8,362 additions and 1,125 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ subprojects {
commonsDbcp2Version = '2.13.0'
mysqlDriverVersion = '8.4.0'
postgresqlDriverVersion = '42.7.4'
oracleDriverVersion = '21.16.0.0'
sqlserverDriverVersion = '11.2.3.jre8'
oracleDriverVersion = '23.6.0.24.10'
sqlserverDriverVersion = '12.8.1.jre8'
sqliteDriverVersion = '3.47.1.0'
yugabyteDriverVersion = '42.7.3-yb-2'
mariadDbDriverVersion = '3.5.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ protected Properties getProperties(String testName) {
protected Map<String, String> getCreationOptions() {
return Collections.singletonMap(CassandraAdmin.REPLICATION_FACTOR, "1");
}

@Override
protected boolean isTimestampTypeSupported() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ protected boolean shouldMutate(
return super.shouldMutate(initialColumn, columnToCompare, operator);
}
}

@Override
protected boolean isTimestampTypeSupported() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ protected Map<String, String> getCreationOptions() {
@Override
@Disabled("Cross partition scan with ordering is not supported in Cassandra")
public void scan_WithOrderingForNonPrimaryColumns_ShouldReturnProperResult() {}

@Override
protected boolean isTimestampTypeSupported() {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.scalar.db.storage.cassandra;

import com.scalar.db.api.DistributedStorageMultipleClusteringKeyScanIntegrationTestBase;
import com.scalar.db.io.DataType;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;

public class CassandraMultipleClusteringKeyScanIntegrationTest
extends DistributedStorageMultipleClusteringKeyScanIntegrationTestBase {
Expand All @@ -17,4 +20,11 @@ protected Properties getProperties(String testName) {
protected Map<String, String> getCreationOptions() {
return Collections.singletonMap(CassandraAdmin.REPLICATION_FACTOR, "1");
}

@Override
protected List<DataType> getDataTypes() {
return super.getDataTypes().stream()
.filter(type -> type != DataType.TIMESTAMP)
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.scalar.db.storage.cassandra;

import com.scalar.db.api.DistributedStorageMultiplePartitionKeyIntegrationTestBase;
import com.scalar.db.io.DataType;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;

public class CassandraMultiplePartitionKeyIntegrationTest
extends DistributedStorageMultiplePartitionKeyIntegrationTestBase {
Expand All @@ -16,4 +19,11 @@ protected Properties getProperties(String testName) {
protected Map<String, String> getCreationOptions() {
return Collections.singletonMap(CassandraAdmin.REPLICATION_FACTOR, "1");
}

@Override
protected List<DataType> getDataTypes() {
return super.getDataTypes().stream()
.filter(type -> type != DataType.TIMESTAMP)
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.scalar.db.storage.cassandra;

import com.scalar.db.api.DistributedStorageSecondaryIndexIntegrationTestBase;
import com.scalar.db.io.DataType;
import java.util.Collections;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.stream.Collectors;

public class CassandraSecondaryIndexIntegrationTest
extends DistributedStorageSecondaryIndexIntegrationTestBase {
Expand All @@ -16,4 +19,11 @@ protected Properties getProperties(String testName) {
protected Map<String, String> getCreationOptions() {
return Collections.singletonMap(CassandraAdmin.REPLICATION_FACTOR, "1");
}

@Override
protected Set<DataType> getSecondaryIndexTypes() {
return super.getSecondaryIndexTypes().stream()
.filter(type -> type != DataType.TIMESTAMP)
.collect(Collectors.toSet());
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.scalar.db.storage.cassandra;

import com.scalar.db.api.DistributedStorageSingleClusteringKeyScanIntegrationTestBase;
import com.scalar.db.io.DataType;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;

public class CassandraSingleClusteringKeyScanIntegrationTest
extends DistributedStorageSingleClusteringKeyScanIntegrationTestBase {
Expand All @@ -16,4 +19,11 @@ protected Properties getProperties(String testName) {
protected Map<String, String> getCreationOptions() {
return Collections.singletonMap(CassandraAdmin.REPLICATION_FACTOR, "1");
}

@Override
protected List<DataType> getClusteringKeyTypes() {
return super.getClusteringKeyTypes().stream()
.filter(type -> type != DataType.TIMESTAMP)
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.scalar.db.storage.cassandra;

import com.scalar.db.api.DistributedStorageSinglePartitionKeyIntegrationTestBase;
import com.scalar.db.io.DataType;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;

public class CassandraSinglePartitionKeyIntegrationTest
extends DistributedStorageSinglePartitionKeyIntegrationTestBase {
Expand All @@ -16,4 +19,11 @@ protected Properties getProperties(String testName) {
protected Map<String, String> getCreationOptions() {
return Collections.singletonMap(CassandraAdmin.REPLICATION_FACTOR, "1");
}

@Override
protected List<DataType> getPartitionKeyTypes() {
return super.getPartitionKeyTypes().stream()
.filter(type -> type != DataType.TIMESTAMP)
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ protected Properties getProps(String testName) {
protected Map<String, String> getCreationOptions() {
return Collections.singletonMap(CassandraAdmin.REPLICATION_FACTOR, "1");
}

@Override
protected boolean isTimestampTypeSupported() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ protected Properties getProps(String testName) {
protected Map<String, String> getCreationOptions() {
return Collections.singletonMap(CassandraAdmin.REPLICATION_FACTOR, "1");
}

@Override
protected boolean isTimestampTypeSupported() {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.scalar.db.storage.cosmos;

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import com.scalar.db.api.DistributedStorageMultipleClusteringKeyScanIntegrationTestBase;
import com.scalar.db.io.DataType;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;

public class CosmosMultipleClusteringKeyScanIntegrationTest
extends DistributedStorageMultipleClusteringKeyScanIntegrationTestBase {
Expand All @@ -16,21 +16,11 @@ protected Properties getProperties(String testName) {
}

@Override
protected ListMultimap<DataType, DataType> getClusteringKeyTypes() {
protected List<DataType> getDataTypes() {
// Return types without BLOB because blob is not supported for clustering key for now
ListMultimap<DataType, DataType> clusteringKeyTypes = ArrayListMultimap.create();
for (DataType firstClusteringKeyType : DataType.valuesWithoutTimesRelatedTypes()) {
if (firstClusteringKeyType == DataType.BLOB) {
continue;
}
for (DataType secondClusteringKeyType : DataType.valuesWithoutTimesRelatedTypes()) {
if (secondClusteringKeyType == DataType.BLOB) {
continue;
}
clusteringKeyTypes.put(firstClusteringKeyType, secondClusteringKeyType);
}
}
return clusteringKeyTypes;
return super.getDataTypes().stream()
.filter(type -> type != DataType.BLOB)
.collect(Collectors.toList());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import com.scalar.db.api.DistributedStorageSingleClusteringKeyScanIntegrationTestBase;
import com.scalar.db.io.DataType;
import java.util.HashSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

public class CosmosSingleClusteringKeyScanIntegrationTest
extends DistributedStorageSingleClusteringKeyScanIntegrationTestBase {
Expand All @@ -15,10 +15,10 @@ protected Properties getProperties(String testName) {
}

@Override
protected Set<DataType> getClusteringKeyTypes() {
protected List<DataType> getClusteringKeyTypes() {
// Return types without BLOB because blob is not supported for clustering key for now
Set<DataType> clusteringKeyTypes = new HashSet<>();
for (DataType dataType : DataType.valuesWithoutTimesRelatedTypes()) {
List<DataType> clusteringKeyTypes = new ArrayList<>();
for (DataType dataType : DataType.values()) {
if (dataType == DataType.BLOB) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.scalar.db.storage.dynamo;

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import com.scalar.db.api.DistributedStorageMultipleClusteringKeyScanIntegrationTestBase;
import com.scalar.db.io.Column;
import com.scalar.db.io.DataType;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Random;
import java.util.stream.Collectors;

public class DynamoMultipleClusteringKeyScanIntegrationTest
extends DistributedStorageMultipleClusteringKeyScanIntegrationTestBase {
Expand All @@ -18,21 +18,11 @@ protected Properties getProperties(String testName) {
}

@Override
protected ListMultimap<DataType, DataType> getClusteringKeyTypes() {
protected List<DataType> getDataTypes() {
// Return types without BLOB because blob is not supported for clustering key for now
ListMultimap<DataType, DataType> clusteringKeyTypes = ArrayListMultimap.create();
for (DataType firstClusteringKeyType : DataType.valuesWithoutTimesRelatedTypes()) {
if (firstClusteringKeyType == DataType.BLOB) {
continue;
}
for (DataType secondClusteringKeyType : DataType.valuesWithoutTimesRelatedTypes()) {
if (secondClusteringKeyType == DataType.BLOB) {
continue;
}
clusteringKeyTypes.put(firstClusteringKeyType, secondClusteringKeyType);
}
}
return clusteringKeyTypes;
return super.getDataTypes().stream()
.filter(type -> type != DataType.BLOB)
.collect(Collectors.toList());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ protected Map<String, String> getCreationOptions() {
@Override
protected ListMultimap<DataType, DataType> getPartitionKeyTypes() {
ListMultimap<DataType, DataType> clusteringKeyTypes = ArrayListMultimap.create();
for (DataType firstClusteringKeyType : DataType.valuesWithoutTimesRelatedTypes()) {
for (DataType firstClusteringKeyType : DataType.values()) {
// BLOB type is supported only for the last value in partition key
if (firstClusteringKeyType == DataType.BLOB) {
continue;
}
for (DataType secondClusteringKeyType : DataType.valuesWithoutTimesRelatedTypes()) {
for (DataType secondClusteringKeyType : DataType.values()) {
clusteringKeyTypes.put(firstClusteringKeyType, secondClusteringKeyType);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected Properties getProperties(String testName) {
protected Set<DataType> getSecondaryIndexTypes() {
// Return types without BOOLEAN because boolean is not supported for secondary index for now
Set<DataType> clusteringKeyTypes = new HashSet<>();
for (DataType dataType : DataType.valuesWithoutTimesRelatedTypes()) {
for (DataType dataType : DataType.values()) {
if (dataType == DataType.BOOLEAN) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import com.scalar.db.api.DistributedStorageSingleClusteringKeyScanIntegrationTestBase;
import com.scalar.db.io.Column;
import com.scalar.db.io.DataType;
import java.util.HashSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Random;
import java.util.Set;

public class DynamoSingleClusteringKeyScanIntegrationTest
extends DistributedStorageSingleClusteringKeyScanIntegrationTestBase {
Expand All @@ -18,10 +18,10 @@ protected Properties getProperties(String testName) {
}

@Override
protected Set<DataType> getClusteringKeyTypes() {
protected List<DataType> getClusteringKeyTypes() {
// Return types without BLOB because blob is not supported for clustering key for now
Set<DataType> clusteringKeyTypes = new HashSet<>();
for (DataType dataType : DataType.valuesWithoutTimesRelatedTypes()) {
List<DataType> clusteringKeyTypes = new ArrayList<>();
for (DataType dataType : DataType.values()) {
if (dataType == DataType.BLOB) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public static DoubleColumn getRandomDynamoDoubleColumn(Random random, String col

public static double nextDynamoDouble(Random random) {
return random
.doubles(MIN_DYNAMO_DOUBLE_VALUE, MAX_DYNAMO_DOUBLE_VALUE)
.limit(1)
.doubles(1, MIN_DYNAMO_DOUBLE_VALUE, MAX_DYNAMO_DOUBLE_VALUE)
.findFirst()
.orElse(0.0d);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
import com.scalar.db.config.DatabaseConfig;
import com.scalar.db.io.Column;
import com.scalar.db.io.DataType;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import java.util.Random;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.jupiter.params.provider.Arguments;

public class JdbcDatabaseCrossPartitionScanIntegrationTest
extends DistributedStorageCrossPartitionScanIntegrationTestBase {
Expand Down Expand Up @@ -45,4 +50,25 @@ protected boolean isParallelDdlSupported() {
}
return super.isParallelDdlSupported();
}

@Override
protected Stream<Arguments> provideColumnsForCNFConditionsTest() {
List<String> allColumnNames =
prepareNonKeyColumns(0).stream().map(Column::getName).collect(Collectors.toList());

if ((JdbcTestUtils.isOracle(rdbEngine)
|| JdbcTestUtils.isSqlServer(rdbEngine)
|| JdbcTestUtils.isSqlite(rdbEngine))) {
// Oracle, SQLServer and SQLite do not support having too many conditions as CNF because it
// is converted internally to a query with conditions in DNF which can be too large for the
// storage to process.
// So we split the columns into two parts randomly to split the test into two executions
Collections.shuffle(allColumnNames, random.get());
return Stream.of(
Arguments.of(allColumnNames.subList(0, allColumnNames.size() / 2)),
Arguments.of(allColumnNames.subList(allColumnNames.size() / 2, allColumnNames.size())));
} else {
return Stream.of(Arguments.of(allColumnNames));
}
}
}
Loading

0 comments on commit f851464

Please sign in to comment.