use of com.datastax.oss.driver.internal.core.metadata.schema.queries.SchemaRows in project java-driver by datastax.
the class SchemaParserTest method parse.
private MetadataRefresh parse(Consumer<CassandraSchemaRows.Builder> builderConfig) {
CassandraSchemaRows.Builder builder = new CassandraSchemaRows.Builder(NODE_3_0, keyspaceFilter, "test");
builderConfig.accept(builder);
SchemaRows rows = builder.build();
return new CassandraSchemaParser(rows, context).parse();
}
use of com.datastax.oss.driver.internal.core.metadata.schema.queries.SchemaRows in project java-driver by datastax.
the class ViewParserTest method should_parse_view.
@Test
public void should_parse_view() {
SchemaRows rows = rows(VIEW_ROW_3_0, COLUMN_ROWS_3_0);
ViewParser parser = new ViewParser(rows, context);
ViewMetadata view = parser.parseView(VIEW_ROW_3_0, KEYSPACE_ID, Collections.emptyMap());
assertThat(view.getKeyspace().asInternal()).isEqualTo("ks");
assertThat(view.getName().asInternal()).isEqualTo("alltimehigh");
assertThat(view.getBaseTable().asInternal()).isEqualTo("scores");
assertThat(view.getPartitionKey()).hasSize(1);
ColumnMetadata pk0 = view.getPartitionKey().get(0);
assertThat(pk0.getName().asInternal()).isEqualTo("game");
assertThat(pk0.getType()).isEqualTo(DataTypes.TEXT);
assertThat(view.getClusteringColumns().entrySet()).hasSize(5);
Iterator<ColumnMetadata> clusteringColumnsIterator = view.getClusteringColumns().keySet().iterator();
assertThat(clusteringColumnsIterator.next().getName().asInternal()).isEqualTo("score");
assertThat(clusteringColumnsIterator.next().getName().asInternal()).isEqualTo("user");
assertThat(clusteringColumnsIterator.next().getName().asInternal()).isEqualTo("year");
assertThat(clusteringColumnsIterator.next().getName().asInternal()).isEqualTo("month");
assertThat(clusteringColumnsIterator.next().getName().asInternal()).isEqualTo("day");
assertThat(view.getColumns()).containsOnlyKeys(CqlIdentifier.fromInternal("game"), CqlIdentifier.fromInternal("score"), CqlIdentifier.fromInternal("user"), CqlIdentifier.fromInternal("year"), CqlIdentifier.fromInternal("month"), CqlIdentifier.fromInternal("day"));
}
use of com.datastax.oss.driver.internal.core.metadata.schema.queries.SchemaRows in project java-driver by datastax.
the class TableParserTest method should_parse_legacy_tables.
@Test
public void should_parse_legacy_tables() {
SchemaRows rows = legacyRows(TABLE_ROW_2_2, COLUMN_ROWS_2_2);
TableParser parser = new TableParser(rows, context);
TableMetadata table = parser.parseTable(TABLE_ROW_2_2, KEYSPACE_ID, Collections.emptyMap());
checkTable(table);
assertThat(table.getOptions().get(CqlIdentifier.fromInternal("caching"))).isEqualTo("{\"keys\":\"ALL\", \"rows_per_partition\":\"NONE\"}");
}
use of com.datastax.oss.driver.internal.core.metadata.schema.queries.SchemaRows in project java-driver by datastax.
the class TableParserTest method should_skip_when_no_column_rows.
@Test
public void should_skip_when_no_column_rows() {
SchemaRows rows = legacyRows(TABLE_ROW_2_2, Collections.emptyList());
TableParser parser = new TableParser(rows, context);
TableMetadata table = parser.parseTable(TABLE_ROW_2_2, KEYSPACE_ID, Collections.emptyMap());
assertThat(table).isNull();
}
use of com.datastax.oss.driver.internal.core.metadata.schema.queries.SchemaRows in project java-driver by datastax.
the class TableParserTest method should_parse_read_repair_and_additional_write_policy.
/**
* Covers two additional Cassandra 4.0 options added in JAVA-2090.
*/
@Test
public void should_parse_read_repair_and_additional_write_policy() {
AdminRow tableRow40 = mockModernTableRow("ks", "foo");
when(tableRow40.get("read_repair", TypeCodecs.TEXT)).thenReturn("NONE");
when(tableRow40.get("additional_write_policy", TypeCodecs.TEXT)).thenReturn("40p");
SchemaRows rows = modernRows(tableRow40, COLUMN_ROWS_3_0, INDEX_ROWS_3_0);
TableParser parser = new TableParser(rows, context);
TableMetadata table = parser.parseTable(tableRow40, KEYSPACE_ID, Collections.emptyMap());
checkTable(table);
assertThat(table.getOptions()).containsEntry(CqlIdentifier.fromInternal("read_repair"), "NONE").containsEntry(CqlIdentifier.fromInternal("additional_write_policy"), "40p");
}
Aggregations