use of io.crate.operation.reference.partitioned.PartitionedColumnExpression in project crate by crate.
the class ShardReferenceResolver method addPartitions.
private void addPartitions(Index index, Schemas schemas, ImmutableMap.Builder<ReferenceIdent, ReferenceImplementation> builder) {
PartitionName partitionName;
try {
partitionName = PartitionName.fromIndexOrTemplate(index.name());
} catch (IllegalArgumentException e) {
throw new UnhandledServerException(String.format(Locale.ENGLISH, "Unable to load PARTITIONED BY columns from partition %s", index.name()), e);
}
TableIdent tableIdent = partitionName.tableIdent();
try {
DocTableInfo info = (DocTableInfo) schemas.getTableInfo(tableIdent);
if (!schemas.isOrphanedAlias(info)) {
assert info.isPartitioned() : "table must be partitioned";
int i = 0;
int numPartitionedColumns = info.partitionedByColumns().size();
assert partitionName.values().size() == numPartitionedColumns : "invalid number of partitioned columns";
for (Reference partitionedInfo : info.partitionedByColumns()) {
builder.put(partitionedInfo.ident(), new PartitionedColumnExpression(partitionedInfo, partitionName.values().get(i)));
i++;
}
} else {
LOGGER.error("Orphaned partition '{}' with missing table '{}' found", index, tableIdent.fqn());
}
} catch (ResourceUnknownException e) {
LOGGER.error("Orphaned partition '{}' with missing table '{}' found", index, tableIdent.fqn());
}
}
Aggregations