use of org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException in project carbondata by apache.
the class RowLevelRangeFilterResolverImpl method getMeasureRangeValues.
private List<Object> getMeasureRangeValues(CarbonMeasure carbonMeasure) {
List<ExpressionResult> listOfExpressionResults = new ArrayList<ExpressionResult>(20);
if (this.getFilterExpression() instanceof BinaryConditionalExpression) {
listOfExpressionResults = ((BinaryConditionalExpression) this.getFilterExpression()).getLiterals();
}
List<Object> filterValuesList = new ArrayList<>(20);
boolean invalidRowsPresent = false;
for (ExpressionResult result : listOfExpressionResults) {
try {
if (result.getString() == null) {
filterValuesList.add(null);
continue;
}
filterValuesList.add(DataTypeUtil.getMeasureValueBasedOnDataType(result.getString(), result.getDataType(), carbonMeasure.getScale(), carbonMeasure.getPrecision()));
} catch (FilterIllegalMemberException e) {
// Any invalid member while evaluation shall be ignored, system will log the
// error only once since all rows the evaluation happens so inorder to avoid
// too much log information only once the log will be printed.
FilterUtil.logError(e, invalidRowsPresent);
}
}
filterValuesList.sort(org.apache.carbondata.core.util.comparator.Comparator.getComparatorByDataTypeForMeasure(carbonMeasure.getDataType()));
return filterValuesList;
}
use of org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException in project carbondata by apache.
the class RowLevelRangeFilterResolverImpl method getNoDictionaryRangeValues.
private List<byte[]> getNoDictionaryRangeValues() {
List<ExpressionResult> listOfExpressionResults = new ArrayList<ExpressionResult>(20);
if (this.getFilterExpression() instanceof BinaryConditionalExpression) {
listOfExpressionResults = ((BinaryConditionalExpression) this.getFilterExpression()).getLiterals();
}
List<byte[]> filterValuesList = new ArrayList<byte[]>(20);
boolean invalidRowsPresent = false;
String timeFormat = CarbonProperties.getInstance().getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT, CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT);
for (ExpressionResult result : listOfExpressionResults) {
try {
if (result.getString() == null) {
if (result.getDataType() == DataTypes.STRING) {
filterValuesList.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL_ARRAY);
} else {
filterValuesList.add(CarbonCommonConstants.EMPTY_BYTE_ARRAY);
}
continue;
}
filterValuesList.add(DataTypeUtil.getBytesBasedOnDataTypeForNoDictionaryColumn(result.getString(), result.getDataType(), timeFormat));
} catch (FilterIllegalMemberException e) {
// Any invalid member while evaluation shall be ignored, system will log the
// error only once since all rows the evaluation happens so inorder to avoid
// too much log information only once the log will be printed.
FilterUtil.logError(e, invalidRowsPresent);
}
}
Comparator<byte[]> filterNoDictValueComparator = ByteUtil.UnsafeComparer.INSTANCE::compareTo;
filterValuesList.sort(filterNoDictValueComparator);
return filterValuesList;
}
use of org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException in project carbondata by apache.
the class RangeDirectDictionaryVisitor 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 FilterUnsupportedException
*/
public void populateFilterResolvedInfo(ColumnResolvedFilterInfo visitableObj, FilterResolverMetadata metadata) throws FilterUnsupportedException {
if (visitableObj instanceof DimColumnResolvedFilterInfo) {
DimColumnResolvedFilterInfo resolveDimension = (DimColumnResolvedFilterInfo) visitableObj;
ColumnFilterInfo resolvedFilterObject = null;
List<ExpressionResult> listOfExpressionResults = null;
List<String> evaluateResultListFinal = new ArrayList<String>();
try {
listOfExpressionResults = ((RangeExpression) metadata.getExpression()).getLiterals();
for (ExpressionResult result : listOfExpressionResults) {
if (result.getString() == null) {
evaluateResultListFinal.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL);
continue;
}
evaluateResultListFinal.add(result.getString());
}
} catch (FilterIllegalMemberException e) {
throw new FilterUnsupportedException(e);
}
resolvedFilterObject = getDirectDictionaryValKeyMemberForFilter(metadata.getColumnExpression(), evaluateResultListFinal, metadata.isIncludeFilter(), metadata.getColumnExpression().getDimension().getDataType());
if (!metadata.isIncludeFilter() && null != resolvedFilterObject && !resolvedFilterObject.getExcludeFilterList().contains(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY)) {
// Adding default surrogate key of null member inorder to not display the same while
// displaying the report as per hive compatibility.
resolvedFilterObject.getExcludeFilterList().add(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY);
Collections.sort(resolvedFilterObject.getExcludeFilterList());
}
resolveDimension.setFilterValues(resolvedFilterObject);
}
}
use of org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException in project carbondata by apache.
the class CustomTypeDictionaryVisitor method populateFilterResolvedInfo.
/**
* This Visitor method is been used to resolve or populate the filter details
* by using custom type dictionary value, the filter members will be resolved using
* custom type function which will generate dictionary for the direct column type filter members
*
* @param visitableObj
* @param metadata
* @throws FilterUnsupportedException,if exception occurs while evaluating
* filter models.
*/
public void populateFilterResolvedInfo(ColumnResolvedFilterInfo visitableObj, FilterResolverMetadata metadata) throws FilterUnsupportedException {
ColumnFilterInfo resolvedFilterObject = null;
if (visitableObj instanceof DimColumnResolvedFilterInfo) {
DimColumnResolvedFilterInfo resolveDimension = (DimColumnResolvedFilterInfo) visitableObj;
List<String> evaluateResultListFinal;
try {
evaluateResultListFinal = metadata.getExpression().evaluate(null).getListAsString();
} catch (FilterIllegalMemberException e) {
throw new FilterUnsupportedException(e);
}
resolvedFilterObject = getDirectDictionaryValKeyMemberForFilter(metadata.getColumnExpression(), evaluateResultListFinal, metadata.isIncludeFilter(), metadata.getColumnExpression().getDimension().getDataType());
if (!metadata.isIncludeFilter() && null != resolvedFilterObject && !resolvedFilterObject.getExcludeFilterList().contains(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY)) {
// Adding default surrogate key of null member inorder to not display the same while
// displaying the report as per hive compatibility.
resolvedFilterObject.getExcludeFilterList().add(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY);
Collections.sort(resolvedFilterObject.getExcludeFilterList());
}
resolveDimension.setFilterValues(resolvedFilterObject);
}
}
use of org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException in project carbondata by apache.
the class ExpressionResultTest method getTime.
public Long getTime(String value) throws FilterIllegalMemberException {
if (value == null) {
return null;
}
SimpleDateFormat parser = new SimpleDateFormat(CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT);
Date dateToStr;
try {
dateToStr = parser.parse(value.toString());
return dateToStr.getTime();
} catch (ParseException e) {
throw new FilterIllegalMemberException("Cannot convert value to Time/Long type value");
}
}
Aggregations