use of io.crate.exceptions.ColumnUnknownException in project crate by crate.
the class NameFieldProvider method resolveField.
@Override
public Symbol resolveField(QualifiedName qualifiedName, @Nullable List<String> path, Operation operation, boolean errorOnUnknownObjectKey) {
List<String> parts = qualifiedName.getParts();
ColumnIdent columnIdent = new ColumnIdent(parts.get(parts.size() - 1), path);
if (parts.size() != 1) {
throw new IllegalArgumentException(String.format(Locale.ENGLISH, "Column reference \"%s\" has too many parts. " + "A column must not have a schema or a table here.", qualifiedName));
}
Symbol field = relation.getField(columnIdent, operation, errorOnUnknownObjectKey);
if (field == null) {
throw new ColumnUnknownException(columnIdent.sqlFqn(), relation.relationName());
}
return field;
}
use of io.crate.exceptions.ColumnUnknownException in project crate by crate.
the class DocTableInfo method getDynamic.
@Nullable
public DynamicReference getDynamic(ColumnIdent ident, boolean forWrite, boolean errorOnUnknownObjectKey) {
boolean parentIsIgnored = false;
ColumnPolicy parentPolicy = columnPolicy();
int position = 0;
if (!ident.isTopLevel()) {
// see if parent is strict object
ColumnIdent parentIdent = ident.getParent();
Reference parentInfo = null;
while (parentIdent != null) {
parentInfo = getReference(parentIdent);
if (parentInfo != null) {
break;
}
parentIdent = parentIdent.getParent();
}
if (parentInfo != null) {
parentPolicy = parentInfo.columnPolicy();
position = parentInfo.position();
}
}
switch(parentPolicy) {
case DYNAMIC:
if (!forWrite) {
if (!errorOnUnknownObjectKey) {
return new VoidReference(new ReferenceIdent(ident(), ident), rowGranularity(), position);
}
return null;
}
break;
case STRICT:
if (forWrite) {
throw new ColumnUnknownException(ident.sqlFqn(), ident());
}
return null;
case IGNORED:
parentIsIgnored = true;
break;
default:
break;
}
if (parentIsIgnored) {
return new DynamicReference(new ReferenceIdent(ident(), ident), rowGranularity(), ColumnPolicy.IGNORED, position);
}
return new DynamicReference(new ReferenceIdent(ident(), ident), rowGranularity(), position);
}
Aggregations