Search in sources :

Example 26 with FilterIllegalMemberException

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;
}
Also used : ExpressionResult(org.apache.carbondata.core.scan.expression.ExpressionResult) ArrayList(java.util.ArrayList) BinaryConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression) FilterIllegalMemberException(org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException)

Example 27 with FilterIllegalMemberException

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;
}
Also used : ExpressionResult(org.apache.carbondata.core.scan.expression.ExpressionResult) ArrayList(java.util.ArrayList) BinaryConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression) FilterIllegalMemberException(org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException)

Example 28 with FilterIllegalMemberException

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);
    }
}
Also used : DimColumnResolvedFilterInfo(org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo) ExpressionResult(org.apache.carbondata.core.scan.expression.ExpressionResult) ArrayList(java.util.ArrayList) ColumnFilterInfo(org.apache.carbondata.core.scan.filter.ColumnFilterInfo) FilterUnsupportedException(org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException) FilterIllegalMemberException(org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException)

Example 29 with FilterIllegalMemberException

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);
    }
}
Also used : DimColumnResolvedFilterInfo(org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo) ColumnFilterInfo(org.apache.carbondata.core.scan.filter.ColumnFilterInfo) FilterUnsupportedException(org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException) FilterIllegalMemberException(org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException)

Example 30 with FilterIllegalMemberException

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");
    }
}
Also used : ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) FilterIllegalMemberException(org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException) Date(java.util.Date)

Aggregations

FilterIllegalMemberException (org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException)30 ArrayList (java.util.ArrayList)14 FilterUnsupportedException (org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException)14 ExpressionResult (org.apache.carbondata.core.scan.expression.ExpressionResult)10 RowImpl (org.apache.carbondata.core.scan.filter.intf.RowImpl)7 RowIntf (org.apache.carbondata.core.scan.filter.intf.RowIntf)7 DataType (org.apache.carbondata.core.metadata.datatype.DataType)6 ColumnFilterInfo (org.apache.carbondata.core.scan.filter.ColumnFilterInfo)6 ParseException (java.text.ParseException)5 SimpleDateFormat (java.text.SimpleDateFormat)5 Date (java.util.Date)5 DimColumnFilterInfo (org.apache.carbondata.core.scan.filter.DimColumnFilterInfo)5 DimColumnResolvedFilterInfo (org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo)5 BitSet (java.util.BitSet)4 BinaryConditionalExpression (org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression)4 EqualToExpression (org.apache.carbondata.core.scan.expression.conditional.EqualToExpression)4 Timestamp (java.sql.Timestamp)3 BitSetGroup (org.apache.carbondata.core.util.BitSetGroup)3 DictionaryChunksWrapper (org.apache.carbondata.core.cache.dictionary.DictionaryChunksWrapper)2 MatchExpression (org.apache.carbondata.core.scan.expression.MatchExpression)2