Skip to content

Commit

Permalink
Fix table compression
Browse files Browse the repository at this point in the history
Currently setting table compression fails with
`Missing sub-option 'sstable_compression' for the 'compression' option.`.
This is due to Cassandra using now 'class' sub-option and Scylla using
'sstable_compression'. Resolved by calling with customized 'withOption'
instead of directly 'withCompression'.

Upgrades snappy to 1.1.10.5 . This technically also requires upping the
driver version to the one using snappy 1.1.10.5 .
  • Loading branch information
Bouncheck committed Oct 17, 2023
1 parent dc54792 commit c1adfdb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
<!-- should match version from drivers POM -->
<version>1.1.10.1</version>
<version>1.1.10.5</version>
</dependency>


Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/connect/scylladb/ScyllaDbSchemaBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.datastax.oss.driver.api.core.metadata.schema.SchemaChangeListenerBase;
import com.datastax.oss.driver.api.core.type.DataType;
import com.datastax.oss.driver.api.core.type.DataTypes;
import static com.datastax.oss.driver.api.querybuilder.QueryBuilder.*;
import static com.datastax.oss.driver.api.querybuilder.SchemaBuilder.*;

import com.datastax.oss.driver.api.querybuilder.schema.AlterTableAddColumnEnd;
Expand All @@ -21,6 +20,7 @@
import com.datastax.oss.driver.shaded.guava.common.cache.CacheBuilder;

import com.datastax.oss.driver.shaded.guava.common.collect.ComparisonChain;
import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap;
import io.connect.scylladb.topictotable.TopicConfigs;

import org.apache.kafka.connect.data.Date;
Expand Down Expand Up @@ -220,7 +220,7 @@ void alter(
alterTableWithOptionsEnd = alterTable.withNoCompression();
}
else {
alterTableWithOptionsEnd = alterTable.withCompression(config.tableCompressionAlgorithm);
alterTableWithOptionsEnd = alterTable.withOption("compression", ImmutableMap.of("sstable_compression", config.tableCompressionAlgorithm));
}
String query = alterTableWithOptionsEnd.asCql();
this.session.executeQuery(query);
Expand Down Expand Up @@ -376,7 +376,7 @@ void create(
createWithOptions = createWithOptions.withNoCompression();
}
else {
createWithOptions = createWithOptions.withCompression(config.tableCompressionAlgorithm);
createWithOptions = createWithOptions.withOption("compression", ImmutableMap.of("sstable_compression", config.tableCompressionAlgorithm));
}
log.info("create() - Adding table {}.{}\n{}", this.config.keyspace, tableName, Arrays.toString(createWithOptions.getOptions().entrySet().toArray()));
session.executeStatement(createWithOptions.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.util.Arrays;

public class ScyllaDbSessionFactory {

Expand Down

0 comments on commit c1adfdb

Please sign in to comment.