use of io.crate.exceptions.AlterTableAliasException in project crate by crate.
the class AlterTableOperation method executeAlterTable.
public CompletableFuture<Long> executeAlterTable(AlterTableAnalyzedStatement analysis) {
DocTableInfo table = analysis.table();
if (table.isAlias() && !table.isPartitioned()) {
return CompletableFutures.failedFuture(new AlterTableAliasException(table.ident().fqn()));
}
List<CompletableFuture<Long>> results = new ArrayList<>(3);
if (table.isPartitioned()) {
// create new filtered partition table settings
PartitionedTableParameterInfo tableSettingsInfo = (PartitionedTableParameterInfo) table.tableParameterInfo();
TableParameter parameterWithFilteredSettings = new TableParameter(analysis.tableParameter().settings(), tableSettingsInfo.partitionTableSettingsInfo().supportedInternalSettings());
Optional<PartitionName> partitionName = analysis.partitionName();
if (partitionName.isPresent()) {
String index = partitionName.get().asIndexName();
results.add(updateMapping(analysis.tableParameter().mappings(), index));
results.add(updateSettings(parameterWithFilteredSettings, index));
} else {
// template gets all changes unfiltered
results.add(updateTemplate(analysis.tableParameter(), table.ident()));
if (!analysis.excludePartitions()) {
String[] indices = table.concreteIndices();
results.add(updateMapping(analysis.tableParameter().mappings(), indices));
results.add(updateSettings(parameterWithFilteredSettings, indices));
}
}
} else {
results.add(updateMapping(analysis.tableParameter().mappings(), table.ident().indexName()));
results.add(updateSettings(analysis.tableParameter(), table.ident().indexName()));
}
final CompletableFuture<Long> result = new CompletableFuture<>();
applyMultiFutureCallback(result, results);
return result;
}
Aggregations