int fieldIndex = tables[0].getFieldIndexByName(fieldName);
if (fieldIndex == -1) throw new RuntimeException("we found the field name of the expression but could not find the field index?");
for (int i = 0; i < tables[0].getRowCount(); i++) {
Value v = tables[0].getFieldValue(i, fieldIndex);
if (v instanceof NumericValue){
res += ((NumericValue) v).doubleValue();
}else{
throw new ExecutionException("SUM only operates with numeric fields");
}