Source:
<code>private CqlQuery constructQuery(TableReference tableRef, byte[] metadata) { StringBuilder queryBuilder = new StringBuilder(); TableMetadata tableMetadata = CassandraKeyValueServices.getMetadataOrDefaultToGeneric(metadata); boolean appendHeavyReadLight = tableMetadata.isAppendHeavyAndReadLight(); Map<String, String> settings = new HashMap<>(); settings.put("bloom_filter_fp_chance", falsePositive(tableMetadata.hasNegativeLookups(), appendHeavyReadLight)); settings.put("caching", "'KEYS_ONLY'"); settings.put("compaction", getCompaction(appendHeavyReadLight)); settings.put("compression", getCompression(tableMetadata.getExplicitCompressionBlockSizeKB())); settings.put("gc_grace_seconds", Integer.toString(config.gcGraceSeconds())); settings.put("id", "'%s'"); settings.put("populate_io_cache_on_flush", cachePriorityIsHottest(tableMetadata)); settings.put("speculative_retry", "'NONE'"); queryBuilder.append("CREATE TABLE IF NOT EXISTS \"%s\".\"%s\"" + " ( " + ROW + " blob, " + COLUMN + " blob, " + TIMESTAMP + " bigint, " + VALUE + " blob, " + "PRIMARY KEY (" + ROW + ", " + COLUMN + ", " + TIMESTAMP + ")) " + "WITH COMPACT STORAGE "); settings.forEach((option, value) -> queryBuilder.append("AND " + option + " = " + value + " ")); queryBuilder.append("AND CLUSTERING ORDER BY (" + COLUMN + " ASC, " + TIMESTAMP + " ASC) "); return CqlQuery.builder() .safeQueryFormat(queryBuilder.toString()) .addArgs( SafeArg.of("keyspace", config.getKeyspaceOrThrow()), <START> SafeArg.of("internalTableName", CassandraKeyValueServiceImpl.internalTableName(tableRef)), <END> SafeArg.of("cfId", getUuidForTable(tableRef))) .build(); }</code><technical_language>note: guarantee this is safe (it is arbitrary table name all) internal logging practices tempted consider allowing TRs context of Cassandra assumed safe - discuss tomorrow team is in</technical_language>

Target:
private CqlQuery constructQuery(TableReference tableRef, byte[] metadata) { TableMetadata tableMetadata = CassandraKeyValueServices.getMetadataOrDefaultToGeneric(metadata); boolean appendHeavyReadLight = tableMetadata.isAppendHeavyAndReadLight(); String keyspace = wrapInQuotes(config.getKeyspaceOrThrow()); String internalTableName = wrapInQuotes(CassandraKeyValueServiceImpl.internalTableName(tableRef)); String query = SchemaBuilder.createTable(keyspace, internalTableName) .ifNotExists() .addPartitionKey(ROW, DataType.blob()) .addClusteringColumn(COLUMN, DataType.blob()) .addClusteringColumn(TIMESTAMP, DataType.bigint()) .addColumn(VALUE, DataType.blob()) .withOptions() .bloomFilterFPChance(falsePositive(tableMetadata.hasNegativeLookups(), appendHeavyReadLight)) .caching(SchemaBuilder.Caching.KEYS_ONLY) .compactionOptions(getCompaction(appendHeavyReadLight)) .compactStorage() .compressionOptions(getCompression(tableMetadata.getExplicitCompressionBlockSizeKB())) .dcLocalReadRepairChance(0.1) .gcGraceSeconds(config.gcGraceSeconds()) .minIndexInterval(128) .maxIndexInterval(2048) .populateIOCacheOnFlush(tableMetadata.getCachePriority() == CachePriority.HOTTEST) .speculativeRetry(SchemaBuilder.noSpeculativeRetry()) .clusteringOrder(COLUMN, SchemaBuilder.Direction.ASC) .clusteringOrder(TIMESTAMP, SchemaBuilder.Direction.ASC) .buildInternal(); return CqlQuery.builder() .safeQueryFormat(query + " AND id = '%s'") .addArgs(SafeArg.of("cfId", getUuidForTable(tableRef))) .build(); }