Skip to content

Commit

Permalink
Merge branch 'cassandra-5.0' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
smiklosovic committed Feb 25, 2025
2 parents 8892fac + 378c93d commit ffdc4b7
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
* Add the ability to disable bulk loading of SSTables (CASSANDRA-18781)
* Clean up obsolete functions and simplify cql_version handling in cqlsh (CASSANDRA-18787)
Merged from 5.0:
* Include materialized views to the output of DESCRIBE TABLE statements (CASSANDRA-20365)
* Heap and GC jvm flags improvements (CASSANDRA-20296)
* Fix unparseable YAML in default cassandra.yaml when uncommented for downstream tooling (CASSANDRA-20359)
* Avoid fetching entire partitions on unresolved static rows in RFP when no static column predicates exist (CASSANDRA-20243)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.function.BiFunction;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

import com.google.common.collect.ImmutableList;

Expand Down Expand Up @@ -472,9 +473,16 @@ public static DescribeStatement<SchemaElement> table(String keyspace, String nam
TableMetadata table = checkNotNull(ks.getTableNullable(t),
"Table '%s' not found in keyspace '%s'", t, ks.name);

return Stream.concat(Stream.of(table), table.indexes.stream()
.map(index -> toDescribable(table, index))
.sorted(SchemaElement.NAME_COMPARATOR));

Stream<SchemaElement> withIndexes = Stream.concat(Stream.of(table), table.indexes.stream()
.map(index -> toDescribable(table, index))
.sorted(SchemaElement.NAME_COMPARATOR));

Stream<SchemaElement> views = StreamSupport.stream(ks.views.forTable(table.id).spliterator(), false)
.map(viewMetadata -> toDescribable(table, viewMetadata))
.sorted(SchemaElement.NAME_COMPARATOR);

return Stream.concat(withIndexes, views);
});
}

Expand Down Expand Up @@ -580,6 +588,36 @@ public String toCqlString(boolean withWarnings, boolean withInternals, boolean i
};
}

private static SchemaElement toDescribable(TableMetadata table, ViewMetadata viewMetadata)
{
return new SchemaElement()
{
@Override
public SchemaElementType elementType()
{
return SchemaElementType.MATERIALIZED_VIEW;
}

@Override
public String elementKeyspace()
{
return table.keyspace;
}

@Override
public String elementName()
{
return viewMetadata.name();
}

@Override
public String toCqlString(boolean withWarnings, boolean withInternals, boolean ifNotExists)
{
return viewMetadata.toCqlString(withWarnings, withInternals, ifNotExists);
}
};
}

/**
* Creates a {@link DescribeStatement} for the generic {@code DESCRIBE ...}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,9 @@ public void testDescribeTableAndMaterializedViewWithClustringOrder() throws Thro

try
{

assertRowsNet(executeDescribeNet("DESCRIBE TABLE " + KEYSPACE_PER_TEST + "." + table),
row(KEYSPACE_PER_TEST, "table", table, tableCreateStatement));
row(KEYSPACE_PER_TEST, "table", table, tableCreateStatement),
row(KEYSPACE_PER_TEST, "materialized_view", "mv", mvCreateStatement));

assertRowsNet(executeDescribeNet("DESCRIBE MATERIALIZED VIEW " + KEYSPACE_PER_TEST + ".mv"),
row(KEYSPACE_PER_TEST, "materialized_view", "mv", mvCreateStatement));
Expand Down

0 comments on commit ffdc4b7

Please sign in to comment.