Skip to content

Commit

Permalink
RUBY-326: Export also ascending clustering order on tables
Browse files Browse the repository at this point in the history
  • Loading branch information
mnin authored and stamhankar999 committed Aug 1, 2018
1 parent a0f1a51 commit ad3eaa7
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 52 deletions.
3 changes: 2 additions & 1 deletion integration/metadata_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ def test_skip_internal_columns_for_dense_table
"f3" int,
PRIMARY KEY \("f1", "f2"\)
\)
WITH COMPACT STORAGE/)
WITH CLUSTERING ORDER BY \("f2" ASC\)
AND COMPACT STORAGE/)

assert_equal 0, table_meta.to_cql =~ table_cql, "actual cql: #{table_meta.to_cql}"
assert_equal 3, table_meta.columns.size
Expand Down
2 changes: 1 addition & 1 deletion lib/cassandra/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def to_cql

cql << "\n)\nWITH "

if @clustering_order.any? {|o| o != :asc}
if !@clustering_order.empty? && !@clustering_columns.empty?
cql << 'CLUSTERING ORDER BY ('
first = true
@clustering_columns.zip(@clustering_order) do |column, order|
Expand Down
33 changes: 22 additions & 11 deletions spec/cassandra/cluster/schema/fetchers/1.2.19-schema.cql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ CREATE TABLE system."HintsColumnFamily" (
value blob,
PRIMARY KEY ("key", "column1")
)
WITH COMPACT STORAGE
WITH CLUSTERING ORDER BY ("column1" ASC)
AND COMPACT STORAGE
AND bloom_filter_fp_chance = 0.01
AND caching = 'KEYS_ONLY'
AND comment = 'unused'
Expand All @@ -23,7 +24,8 @@ CREATE TABLE system."IndexInfo" (
index_name text,
PRIMARY KEY (table_name, index_name)
)
WITH COMPACT STORAGE
WITH CLUSTERING ORDER BY (index_name ASC)
AND COMPACT STORAGE
AND bloom_filter_fp_chance = 0.01
AND caching = 'KEYS_ONLY'
AND comment = 'indexes that have been completed'
Expand All @@ -41,7 +43,8 @@ CREATE TABLE system."LocationInfo" (
value blob,
PRIMARY KEY ("key", "column1")
)
WITH COMPACT STORAGE
WITH CLUSTERING ORDER BY ("column1" ASC)
AND COMPACT STORAGE
AND bloom_filter_fp_chance = 0.01
AND caching = 'KEYS_ONLY'
AND comment = 'unused'
Expand All @@ -59,7 +62,8 @@ CREATE TABLE system."Migrations" (
value blob,
PRIMARY KEY ("key", "column1")
)
WITH COMPACT STORAGE
WITH CLUSTERING ORDER BY ("column1" ASC)
AND COMPACT STORAGE
AND bloom_filter_fp_chance = 0.01
AND caching = 'KEYS_ONLY'
AND comment = 'unused'
Expand All @@ -76,7 +80,8 @@ CREATE TABLE system."NodeIdInfo" (
id timeuuid,
PRIMARY KEY ("key", id)
)
WITH COMPACT STORAGE
WITH CLUSTERING ORDER BY (id ASC)
AND COMPACT STORAGE
AND bloom_filter_fp_chance = 0.01
AND caching = 'KEYS_ONLY'
AND comment = 'counter node IDs'
Expand All @@ -94,7 +99,8 @@ CREATE TABLE system."Schema" (
value blob,
PRIMARY KEY ("key", "column1")
)
WITH COMPACT STORAGE
WITH CLUSTERING ORDER BY ("column1" ASC)
AND COMPACT STORAGE
AND bloom_filter_fp_chance = 0.01
AND caching = 'KEYS_ONLY'
AND comment = 'unused'
Expand Down Expand Up @@ -129,7 +135,8 @@ CREATE TABLE system.hints (
mutation blob,
PRIMARY KEY (target_id, hint_id, message_version)
)
WITH COMPACT STORAGE
WITH CLUSTERING ORDER BY (hint_id ASC, message_version ASC)
AND COMPACT STORAGE
AND bloom_filter_fp_chance = 0.01
AND caching = 'KEYS_ONLY'
AND comment = 'hints awaiting delivery'
Expand Down Expand Up @@ -247,7 +254,8 @@ CREATE TABLE system.schema_columnfamilies (
value_alias text,
PRIMARY KEY (keyspace_name, columnfamily_name)
)
WITH bloom_filter_fp_chance = 0.01
WITH CLUSTERING ORDER BY (columnfamily_name ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = 'KEYS_ONLY'
AND comment = 'ColumnFamily definitions'
AND compaction = {'class': 'SizeTieredCompactionStrategy'}
Expand All @@ -269,7 +277,8 @@ CREATE TABLE system.schema_columns (
validator text,
PRIMARY KEY (keyspace_name, columnfamily_name, column_name)
)
WITH bloom_filter_fp_chance = 0.01
WITH CLUSTERING ORDER BY (columnfamily_name ASC, column_name ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = 'KEYS_ONLY'
AND comment = 'ColumnFamily column attributes'
AND compaction = {'class': 'SizeTieredCompactionStrategy'}
Expand Down Expand Up @@ -309,7 +318,8 @@ CREATE TABLE system_traces.events (
thread text,
PRIMARY KEY (session_id, event_id)
)
WITH bloom_filter_fp_chance = 0.01
WITH CLUSTERING ORDER BY (event_id ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = 'KEYS_ONLY'
AND comment = ''
AND compaction = {'class': 'SizeTieredCompactionStrategy'}
Expand Down Expand Up @@ -347,7 +357,8 @@ CREATE TABLE simplex."t1" (
"f3" int,
PRIMARY KEY ("f1", "f2")
)
WITH bloom_filter_fp_chance = 0.01
WITH CLUSTERING ORDER BY ("f2" ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = 'KEYS_ONLY'
AND comment = 'test table'
AND compaction = {'class': 'SizeTieredCompactionStrategy'}
Expand Down
27 changes: 18 additions & 9 deletions spec/cassandra/cluster/schema/fetchers/2.0.16-schema.cql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ CREATE TABLE system."IndexInfo" (
index_name text,
PRIMARY KEY (table_name, index_name)
)
WITH COMPACT STORAGE
WITH CLUSTERING ORDER BY (index_name ASC)
AND COMPACT STORAGE
AND bloom_filter_fp_chance = 0.01
AND caching = 'KEYS_ONLY'
AND comment = 'indexes that have been completed'
Expand All @@ -26,7 +27,8 @@ CREATE TABLE system."NodeIdInfo" (
id timeuuid,
PRIMARY KEY ("key", id)
)
WITH COMPACT STORAGE
WITH CLUSTERING ORDER BY (id ASC)
AND COMPACT STORAGE
AND bloom_filter_fp_chance = 0.01
AND caching = 'KEYS_ONLY'
AND comment = 'counter node IDs'
Expand Down Expand Up @@ -115,7 +117,8 @@ CREATE TABLE system.hints (
mutation blob,
PRIMARY KEY (target_id, hint_id, message_version)
)
WITH COMPACT STORAGE
WITH CLUSTERING ORDER BY (hint_id ASC, message_version ASC)
AND COMPACT STORAGE
AND bloom_filter_fp_chance = 0.01
AND caching = 'KEYS_ONLY'
AND comment = 'hints awaiting delivery'
Expand Down Expand Up @@ -175,7 +178,8 @@ CREATE TABLE system.paxos (
proposal_ballot timeuuid,
PRIMARY KEY (row_key, cf_id)
)
WITH bloom_filter_fp_chance = 0.1
WITH CLUSTERING ORDER BY (cf_id ASC)
AND bloom_filter_fp_chance = 0.1
AND caching = 'KEYS_ONLY'
AND comment = 'in-progress paxos proposals'
AND compaction = {'class': 'LeveledCompactionStrategy'}
Expand Down Expand Up @@ -286,7 +290,8 @@ CREATE TABLE system.schema_columnfamilies (
value_alias text,
PRIMARY KEY (keyspace_name, columnfamily_name)
)
WITH bloom_filter_fp_chance = 0.01
WITH CLUSTERING ORDER BY (columnfamily_name ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = 'KEYS_ONLY'
AND comment = 'ColumnFamily definitions'
AND compaction = {'class': 'SizeTieredCompactionStrategy'}
Expand All @@ -313,7 +318,8 @@ CREATE TABLE system.schema_columns (
validator text,
PRIMARY KEY (keyspace_name, columnfamily_name, column_name)
)
WITH bloom_filter_fp_chance = 0.01
WITH CLUSTERING ORDER BY (columnfamily_name ASC, column_name ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = 'KEYS_ONLY'
AND comment = 'ColumnFamily column attributes'
AND compaction = {'class': 'SizeTieredCompactionStrategy'}
Expand Down Expand Up @@ -357,7 +363,8 @@ CREATE TABLE system.schema_triggers (
trigger_options map<text, text>,
PRIMARY KEY (keyspace_name, columnfamily_name, trigger_name)
)
WITH bloom_filter_fp_chance = 0.01
WITH CLUSTERING ORDER BY (columnfamily_name ASC, trigger_name ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = 'KEYS_ONLY'
AND comment = 'triggers metadata table'
AND compaction = {'class': 'SizeTieredCompactionStrategy'}
Expand Down Expand Up @@ -406,7 +413,8 @@ CREATE TABLE system_traces.events (
thread text,
PRIMARY KEY (session_id, event_id)
)
WITH bloom_filter_fp_chance = 0.01
WITH CLUSTERING ORDER BY (event_id ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = 'KEYS_ONLY'
AND comment = ''
AND compaction = {'class': 'SizeTieredCompactionStrategy'}
Expand Down Expand Up @@ -452,7 +460,8 @@ CREATE TABLE simplex."t1" (
"f3" int,
PRIMARY KEY ("f1", "f2")
)
WITH bloom_filter_fp_chance = 0.01
WITH CLUSTERING ORDER BY ("f2" ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = 'KEYS_ONLY'
AND comment = 'test table'
AND compaction = {'class': 'SizeTieredCompactionStrategy'}
Expand Down
30 changes: 20 additions & 10 deletions spec/cassandra/cluster/schema/fetchers/2.1.9-schema.cql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ CREATE TABLE system."IndexInfo" (
index_name text,
PRIMARY KEY (table_name, index_name)
)
WITH COMPACT STORAGE
WITH CLUSTERING ORDER BY (index_name ASC)
AND COMPACT STORAGE
AND bloom_filter_fp_chance = 0.01
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND comment = 'indexes that have been completed'
Expand Down Expand Up @@ -90,7 +91,8 @@ CREATE TABLE system.hints (
mutation blob,
PRIMARY KEY (target_id, hint_id, message_version)
)
WITH COMPACT STORAGE
WITH CLUSTERING ORDER BY (hint_id ASC, message_version ASC)
AND COMPACT STORAGE
AND bloom_filter_fp_chance = 0.01
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND comment = 'hints awaiting delivery'
Expand Down Expand Up @@ -149,7 +151,8 @@ CREATE TABLE system.paxos (
proposal_ballot timeuuid,
PRIMARY KEY (row_key, cf_id)
)
WITH bloom_filter_fp_chance = 0.1
WITH CLUSTERING ORDER BY (cf_id ASC)
AND bloom_filter_fp_chance = 0.1
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND comment = 'in-progress paxos proposals'
AND compaction = {'class': 'LeveledCompactionStrategy'}
Expand Down Expand Up @@ -257,7 +260,8 @@ CREATE TABLE system.schema_columnfamilies (
value_alias text,
PRIMARY KEY (keyspace_name, columnfamily_name)
)
WITH bloom_filter_fp_chance = 0.01
WITH CLUSTERING ORDER BY (columnfamily_name ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND comment = 'ColumnFamily definitions'
AND compaction = {'class': 'SizeTieredCompactionStrategy'}
Expand All @@ -283,7 +287,8 @@ CREATE TABLE system.schema_columns (
validator text,
PRIMARY KEY (keyspace_name, columnfamily_name, column_name)
)
WITH bloom_filter_fp_chance = 0.01
WITH CLUSTERING ORDER BY (columnfamily_name ASC, column_name ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND comment = 'ColumnFamily column attributes'
AND compaction = {'class': 'SizeTieredCompactionStrategy'}
Expand Down Expand Up @@ -325,7 +330,8 @@ CREATE TABLE system.schema_triggers (
trigger_options map<text, text>,
PRIMARY KEY (keyspace_name, columnfamily_name, trigger_name)
)
WITH bloom_filter_fp_chance = 0.01
WITH CLUSTERING ORDER BY (columnfamily_name ASC, trigger_name ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND comment = 'triggers metadata table'
AND compaction = {'class': 'SizeTieredCompactionStrategy'}
Expand All @@ -346,7 +352,8 @@ CREATE TABLE system.schema_usertypes (
field_types list<text>,
PRIMARY KEY (keyspace_name, type_name)
)
WITH bloom_filter_fp_chance = 0.01
WITH CLUSTERING ORDER BY (type_name ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND comment = 'Defined user types'
AND compaction = {'class': 'SizeTieredCompactionStrategy'}
Expand All @@ -369,7 +376,8 @@ CREATE TABLE system.size_estimates (
partitions_count bigint,
PRIMARY KEY (keyspace_name, table_name, range_start, range_end)
)
WITH bloom_filter_fp_chance = 0.01
WITH CLUSTERING ORDER BY (table_name ASC, range_start ASC, range_end ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND comment = 'per-table primary range size estimates'
AND compaction = {'class': 'SizeTieredCompactionStrategy'}
Expand Down Expand Up @@ -416,7 +424,8 @@ CREATE TABLE system_traces.events (
thread text,
PRIMARY KEY (session_id, event_id)
)
WITH bloom_filter_fp_chance = 0.01
WITH CLUSTERING ORDER BY (event_id ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND comment = ''
AND compaction = {'class': 'SizeTieredCompactionStrategy'}
Expand Down Expand Up @@ -460,7 +469,8 @@ CREATE TABLE simplex."t1" (
"f3" int,
PRIMARY KEY ("f1", "f2")
)
WITH bloom_filter_fp_chance = 0.01
WITH CLUSTERING ORDER BY ("f2" ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND comment = 'test table'
AND compaction = {'class': 'SizeTieredCompactionStrategy'}
Expand Down
Loading

0 comments on commit ad3eaa7

Please sign in to comment.