use of org.apache.asterix.om.exceptions.UnsupportedTypeException in project asterixdb by apache.
the class RecordRemoveFieldsTypeComputer method getPathFromConstantExpression.
private void getPathFromConstantExpression(String funcName, ILogicalExpression expression, Set<String> fieldNameSet, List<List<String>> pathList) throws AlgebricksException {
ConstantExpression ce = (ConstantExpression) expression;
if (!(ce.getValue() instanceof AsterixConstantValue)) {
throw new InvalidExpressionException(funcName, 1, ce, LogicalExpressionTag.CONSTANT);
}
IAObject item = ((AsterixConstantValue) ce.getValue()).getObject();
ATypeTag type = item.getType().getTypeTag();
switch(type) {
case STRING:
String fn = ((AString) item).getStringValue();
fieldNameSet.add(fn);
break;
case ARRAY:
AOrderedList pathOrdereList = (AOrderedList) item;
String fieldName = ((AString) pathOrdereList.getItem(0)).getStringValue();
fieldNameSet.add(fieldName);
List<String> path = new ArrayList<>();
for (int i = 0; i < pathOrdereList.size(); i++) {
path.add(((AString) pathOrdereList.getItem(i)).getStringValue());
}
pathList.add(path);
break;
default:
throw new UnsupportedTypeException(funcName, type);
}
}
use of org.apache.asterix.om.exceptions.UnsupportedTypeException in project asterixdb by apache.
the class RecordRemoveFieldsTypeComputer method getListFromExpression.
private List<String> getListFromExpression(String funcName, ILogicalExpression expression) throws AlgebricksException {
AbstractFunctionCallExpression funcExp = (AbstractFunctionCallExpression) expression;
List<Mutable<ILogicalExpression>> args = funcExp.getArguments();
List<String> list = new ArrayList<>();
for (Mutable<ILogicalExpression> arg : args) {
// At this point all elements has to be a constant
// Input list has only one level of nesting (list of list or list of strings)
ConstantExpression ce = (ConstantExpression) arg.getValue();
if (!(ce.getValue() instanceof AsterixConstantValue)) {
throw new InvalidExpressionException(funcName, 1, ce, LogicalExpressionTag.CONSTANT);
}
IAObject item = ((AsterixConstantValue) ce.getValue()).getObject();
ATypeTag type = item.getType().getTypeTag();
if (type == ATypeTag.STRING) {
list.add(((AString) item).getStringValue());
} else {
throw new UnsupportedTypeException(funcName, type);
}
}
return list;
}
Aggregations