use of io.crate.sql.tree.ClusteredBy in project crate by crate.
the class CreateBlobTableAnalyzer method analyze.
public CreateBlobTableAnalyzedStatement analyze(CreateBlobTable node, ParameterContext parameterContext) {
CreateBlobTableAnalyzedStatement statement = new CreateBlobTableAnalyzedStatement();
TableIdent tableIdent = BlobTableAnalyzer.tableToIdent(node.name());
statement.table(tableIdent, schemas);
int numShards;
Optional<ClusteredBy> clusteredBy = node.clusteredBy();
if (clusteredBy.isPresent()) {
numShards = numberOfShards.fromClusteredByClause(clusteredBy.get(), parameterContext.parameters());
} else {
numShards = numberOfShards.defaultNumberOfShards();
}
statement.tableParameter().settingsBuilder().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numShards);
// apply default in case it is not specified in the genericProperties,
// if it is it will get overwritten afterwards.
TablePropertiesAnalyzer.analyze(statement.tableParameter(), new BlobTableParameterInfo(), node.genericProperties(), parameterContext.parameters(), true);
return statement;
}
use of io.crate.sql.tree.ClusteredBy in project crate by crate.
the class NumberOfShardsTest method testGetNumberOfShards.
@Test
public void testGetNumberOfShards() {
ClusteredBy clusteredBy = new ClusteredBy(Optional.of(QNAME_REF), Optional.of(LongLiteral.fromObject(7)));
assertThat(numberOfShards.fromClusteredByClause(clusteredBy, Row.EMPTY), is(7));
}
use of io.crate.sql.tree.ClusteredBy in project crate by crate.
the class NumberOfShardsTest method testGetNumberOfShardsLessThanOne.
@Test
public void testGetNumberOfShardsLessThanOne() {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("num_shards in CLUSTERED clause must be greater than 0");
numberOfShards.fromClusteredByClause(new ClusteredBy(Optional.of(QNAME_REF), Optional.of(LongLiteral.fromObject(0))), Row.EMPTY);
}
Aggregations