Search in sources :

Example 1 with PartitionedColumnExpression

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());
    }
}
Also used : DocTableInfo(io.crate.metadata.doc.DocTableInfo) PartitionedColumnExpression(io.crate.operation.reference.partitioned.PartitionedColumnExpression) UnhandledServerException(io.crate.exceptions.UnhandledServerException) ResourceUnknownException(io.crate.exceptions.ResourceUnknownException)

Aggregations

ResourceUnknownException (io.crate.exceptions.ResourceUnknownException)1 UnhandledServerException (io.crate.exceptions.UnhandledServerException)1 DocTableInfo (io.crate.metadata.doc.DocTableInfo)1 PartitionedColumnExpression (io.crate.operation.reference.partitioned.PartitionedColumnExpression)1