use of org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException in project carbondata by apache.
the class AndExpression method evaluate.
@Override
public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException, FilterIllegalMemberException {
ExpressionResult resultLeft = left.evaluate(value);
ExpressionResult resultRight = right.evaluate(value);
switch(resultLeft.getDataType()) {
case BOOLEAN:
resultLeft.set(DataType.BOOLEAN, (resultLeft.getBoolean() && resultRight.getBoolean()));
break;
default:
throw new FilterUnsupportedException("Incompatible datatype for applying AND Expression Filter");
}
return resultLeft;
}
use of org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException in project carbondata by apache.
the class DictionaryColumnVisitor method populateFilterResolvedInfo.
/**
* This Visitor method is used to populate the visitableObj with direct dictionary filter details
* where the filters values will be resolve using dictionary cache.
*
* @param visitableObj
* @param metadata
* @throws FilterUnsupportedException,if exception occurs while evaluating
* filter models.
* @throws IOException
* @throws FilterUnsupportedException
*/
public void populateFilterResolvedInfo(DimColumnResolvedFilterInfo visitableObj, FilterResolverMetadata metadata) throws FilterUnsupportedException, IOException {
DimColumnFilterInfo resolvedFilterObject = null;
List<String> evaluateResultListFinal;
try {
evaluateResultListFinal = metadata.getExpression().evaluate(null).getListAsString();
} catch (FilterIllegalMemberException e) {
throw new FilterUnsupportedException(e);
}
resolvedFilterObject = FilterUtil.getFilterValues(metadata.getTableIdentifier(), metadata.getColumnExpression(), evaluateResultListFinal, metadata.isIncludeFilter());
if (!metadata.isIncludeFilter() && null != resolvedFilterObject) {
// this is because two times it will flip the same bit
if (!resolvedFilterObject.getFilterList().contains(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY)) {
resolvedFilterObject.getFilterList().add(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY);
}
Collections.sort(resolvedFilterObject.getFilterList());
}
visitableObj.setFilterValues(resolvedFilterObject);
}
use of org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException in project carbondata by apache.
the class NoDictionaryTypeVisitor method populateFilterResolvedInfo.
/**
* Visitor Method will update the filter related details in visitableObj, For no dictionary
* type columns the filter members will resolved directly, no need to look up in dictionary
* since it will not be part of dictionary, directly the actual data can be converted as
* byte[] and can be set. this type of encoding is effective when the particular column
* is having very high cardinality.
*
* @param visitableObj
* @param metadata
* @throws FilterUnsupportedException,if exception occurs while evaluating
* filter models.
*/
public void populateFilterResolvedInfo(DimColumnResolvedFilterInfo visitableObj, FilterResolverMetadata metadata) throws FilterUnsupportedException {
DimColumnFilterInfo resolvedFilterObject = null;
List<String> evaluateResultListFinal = null;
try {
// handling for is null case scenarios
if (metadata.getExpression() instanceof EqualToExpression) {
EqualToExpression expression = (EqualToExpression) metadata.getExpression();
if (expression.isNull) {
evaluateResultListFinal = new ArrayList<>(1);
evaluateResultListFinal.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL);
}
} else {
evaluateResultListFinal = metadata.getExpression().evaluate(null).getListAsString();
}
// displaying the report as per hive compatibility.
if (!metadata.isIncludeFilter() && !evaluateResultListFinal.contains(CarbonCommonConstants.MEMBER_DEFAULT_VAL)) {
evaluateResultListFinal.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL);
}
} catch (FilterIllegalMemberException e) {
throw new FilterUnsupportedException(e);
}
resolvedFilterObject = FilterUtil.getNoDictionaryValKeyMemberForFilter(evaluateResultListFinal, metadata.isIncludeFilter(), metadata.getColumnExpression().getDataType());
visitableObj.setFilterValues(resolvedFilterObject);
}
Aggregations