You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ch...@apache.org on 2016/06/30 17:42:30 UTC
[43/50] [abbrv] incubator-carbondata git commit: Merge
remote-tracking branch 'carbon_master/master' into apache/master
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/filter/resolver/ConditionalFilterResolverImpl.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/filter/resolver/ConditionalFilterResolverImpl.java
index 072d527,0000000..bbef2d5
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/filter/resolver/ConditionalFilterResolverImpl.java
+++ b/core/src/main/java/org/carbondata/scan/filter/resolver/ConditionalFilterResolverImpl.java
@@@ -1,242 -1,0 +1,237 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.carbondata.scan.filter.resolver;
+
+import java.util.List;
+import java.util.SortedMap;
+
+import org.carbondata.core.carbon.AbsoluteTableIdentifier;
+import org.carbondata.core.carbon.datastore.block.SegmentProperties;
+import org.carbondata.core.carbon.metadata.encoder.Encoding;
+import org.carbondata.core.carbon.metadata.schema.table.column.CarbonDimension;
+import org.carbondata.scan.executor.exception.QueryExecutionException;
+import org.carbondata.scan.expression.ColumnExpression;
+import org.carbondata.scan.expression.DataType;
+import org.carbondata.scan.expression.Expression;
+import org.carbondata.scan.expression.conditional.BinaryConditionalExpression;
+import org.carbondata.scan.expression.conditional.ConditionalExpression;
+import org.carbondata.scan.expression.exception.FilterUnsupportedException;
+import org.carbondata.scan.filter.FilterUtil;
+import org.carbondata.scan.filter.intf.FilterExecuterType;
+import org.carbondata.scan.filter.resolver.metadata.FilterResolverMetadata;
+import org.carbondata.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo;
+import org.carbondata.scan.filter.resolver.resolverinfo.visitor.FilterInfoTypeVisitorFactory;
+
+public class ConditionalFilterResolverImpl implements FilterResolverIntf {
+
+ private static final long serialVersionUID = 1838955268462201691L;
+ protected Expression exp;
+ protected boolean isExpressionResolve;
+ protected boolean isIncludeFilter;
+ private DimColumnResolvedFilterInfo dimColResolvedFilterInfo;
+
+ public ConditionalFilterResolverImpl(Expression exp, boolean isExpressionResolve,
+ boolean isIncludeFilter) {
+ this.exp = exp;
+ this.isExpressionResolve = isExpressionResolve;
+ this.isIncludeFilter = isIncludeFilter;
+ this.dimColResolvedFilterInfo = new DimColumnResolvedFilterInfo();
+ }
+
+ /**
+ * This API will resolve the filter expression and generates the
+ * dictionaries for executing/evaluating the filter expressions in the
+ * executer layer.
+ *
+ * @throws QueryExecutionException
+ * @throws FilterUnsupportedException
+ */
+ @Override public void resolve(AbsoluteTableIdentifier absoluteTableIdentifier)
+ throws FilterUnsupportedException {
+ FilterResolverMetadata metadata = new FilterResolverMetadata();
+ metadata.setTableIdentifier(absoluteTableIdentifier);
+ if ((!isExpressionResolve) && exp instanceof BinaryConditionalExpression) {
+ BinaryConditionalExpression binaryConditionalExpression = (BinaryConditionalExpression) exp;
+ Expression leftExp = binaryConditionalExpression.getLeft();
+ Expression rightExp = binaryConditionalExpression.getRight();
+ if (leftExp instanceof ColumnExpression) {
+ ColumnExpression columnExpression = (ColumnExpression) leftExp;
+ metadata.setColumnExpression(columnExpression);
+ metadata.setExpression(rightExp);
+ metadata.setIncludeFilter(isIncludeFilter);
+ // If imei=imei comes in filter condition then we need to
+ // skip processing of right expression.
+ // This flow has reached here assuming that this is a single
+ // column expression.
+ // we need to check if the other expression contains column
+ // expression or not in depth.
+ CarbonDimension dimension = columnExpression.getDimension();
+ if (FilterUtil.checkIfExpressionContainsColumn(rightExp)
+ || FilterUtil.isExpressionNeedsToResolved(rightExp, isIncludeFilter) &&
+ dimension.hasEncoding(Encoding.DICTIONARY) && !dimension
+ .hasEncoding(Encoding.DIRECT_DICTIONARY)) {
+ isExpressionResolve = true;
+ } else {
+ //Visitor pattern is been used in this scenario inorder to populate the
+ // dimColResolvedFilterInfo
+ //visitable object with filter member values based on the visitor type, currently there
+ //3 types of visitors custom,direct and no dictionary, all types of visitor populate
+ //the visitable instance as per its buisness logic which is different for all the
+ // visitors.
+ dimColResolvedFilterInfo.populateFilterInfoBasedOnColumnType(
+ FilterInfoTypeVisitorFactory.getResolvedFilterInfoVisitor(columnExpression),
+ metadata);
+ }
+ } else if (rightExp instanceof ColumnExpression) {
+ ColumnExpression columnExpression = (ColumnExpression) rightExp;
+ metadata.setColumnExpression(columnExpression);
+ metadata.setExpression(leftExp);
+ metadata.setIncludeFilter(isIncludeFilter);
+ if (columnExpression.getDataType().equals(DataType.TimestampType)) {
+ isExpressionResolve = true;
+ } else {
+ // if imei=imei comes in filter condition then we need to
+ // skip processing of right expression.
+ // This flow has reached here assuming that this is a single
+ // column expression.
+ // we need to check if the other expression contains column
+ // expression or not in depth.
+ if (FilterUtil.checkIfExpressionContainsColumn(leftExp)) {
+ isExpressionResolve = true;
+ } else {
+
+ dimColResolvedFilterInfo.populateFilterInfoBasedOnColumnType(
+ FilterInfoTypeVisitorFactory.getResolvedFilterInfoVisitor(columnExpression),
+ metadata);
+
+ }
+ }
+ } else {
+ isExpressionResolve = true;
+ }
+ }
+ if (isExpressionResolve && exp instanceof ConditionalExpression) {
+ ConditionalExpression conditionalExpression = (ConditionalExpression) exp;
+ List<ColumnExpression> columnList = conditionalExpression.getColumnList();
+ metadata.setColumnExpression(columnList.get(0));
+ metadata.setExpression(exp);
+ metadata.setIncludeFilter(isIncludeFilter);
- if (!columnList.get(0).getDimension().hasEncoding(Encoding.DICTIONARY) || columnList.get(0)
- .getDimension().hasEncoding(Encoding.DIRECT_DICTIONARY)) {
++ if (!columnList.get(0).getDimension().hasEncoding(Encoding.DICTIONARY)) {
+ dimColResolvedFilterInfo.populateFilterInfoBasedOnColumnType(
+ FilterInfoTypeVisitorFactory.getResolvedFilterInfoVisitor(columnList.get(0)), metadata);
+
+ } else if (columnList.get(0).getDimension().hasEncoding(Encoding.DICTIONARY) && !(
+ columnList.get(0).getDimension().getDataType()
+ == org.carbondata.core.carbon.metadata.datatype.DataType.STRUCT
+ || columnList.get(0).getDimension().getDataType()
+ == org.carbondata.core.carbon.metadata.datatype.DataType.ARRAY)) {
+ dimColResolvedFilterInfo.setFilterValues(FilterUtil
+ .getFilterListForAllValues(absoluteTableIdentifier, exp, columnList.get(0),
+ isIncludeFilter));
+
+ dimColResolvedFilterInfo.setColumnIndex(columnList.get(0).getDimension().getOrdinal());
+ dimColResolvedFilterInfo.setDimension(columnList.get(0).getDimension());
+ }
+ }
+
+ }
+
+ /**
+ * Left node will not be presentin this scenario
+ *
+ * @return left node of type FilterResolverIntf instance
+ */
+ public FilterResolverIntf getLeft() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * Right node will not be presentin this scenario
+ *
+ * @return left node of type FilterResolverIntf instance
+ */
+ @Override public FilterResolverIntf getRight() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * Method will return the DimColumnResolvedFilterInfo instance which consists
+ * the mapping of the respective dimension and its surrogates involved in
+ * filter expression.
+ *
+ * @return DimColumnResolvedFilterInfo
+ */
+ public DimColumnResolvedFilterInfo getDimColResolvedFilterInfo() {
+ return dimColResolvedFilterInfo;
+ }
+
+ /**
+ * method will calculates the start key based on the filter surrogates
+ */
+ public void getStartKey(SegmentProperties segmentProperties, long[] startKey,
+ SortedMap<Integer, byte[]> setOfStartKeyByteArray) {
+ if (null == dimColResolvedFilterInfo.getStarIndexKey()) {
+ FilterUtil.getStartKeyForNoDictionaryDimension(dimColResolvedFilterInfo, segmentProperties,
+ setOfStartKeyByteArray);
+ }
+ }
+
+ /**
+ * method will get the start key based on the filter surrogates
+ *
+ * @return end IndexKey
++ * @throws QueryExecutionException
+ */
+ @Override public void getEndKey(SegmentProperties segmentProperties,
+ AbsoluteTableIdentifier absoluteTableIdentifier, long[] endKeys,
- SortedMap<Integer, byte[]> setOfEndKeyByteArray) {
++ SortedMap<Integer, byte[]> setOfEndKeyByteArray) throws QueryExecutionException {
+ if (null == dimColResolvedFilterInfo.getEndIndexKey()) {
- try {
- FilterUtil.getEndKey(dimColResolvedFilterInfo.getDimensionResolvedFilterInstance(),
- absoluteTableIdentifier, endKeys, segmentProperties);
- FilterUtil.getEndKeyForNoDictionaryDimension(dimColResolvedFilterInfo, segmentProperties,
- setOfEndKeyByteArray);
- } catch (QueryExecutionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
++ FilterUtil.getEndKey(dimColResolvedFilterInfo.getDimensionResolvedFilterInstance(),
++ absoluteTableIdentifier, endKeys, segmentProperties);
++ FilterUtil.getEndKeyForNoDictionaryDimension(dimColResolvedFilterInfo, segmentProperties,
++ setOfEndKeyByteArray);
+ }
+ }
+
+ /**
+ * Method will return the executer type for particular conditional resolver
+ * basically two types of executers will be formed for the conditional query.
+ *
+ * @return the filter executer type
+ */
+ @Override public FilterExecuterType getFilterExecuterType() {
+ switch (exp.getFilterExpressionType()) {
+ case NOT_EQUALS:
+ case NOT_IN:
+ return FilterExecuterType.EXCLUDE;
+
+ default:
+ return FilterExecuterType.INCLUDE;
+ }
+
+ }
+
+ @Override public Expression getFilterExpression() {
+ // TODO Auto-generated method stub
+ return exp;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/filter/resolver/FilterResolverIntf.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/filter/resolver/FilterResolverIntf.java
index 620b1ba,0000000..4981126
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/filter/resolver/FilterResolverIntf.java
+++ b/core/src/main/java/org/carbondata/scan/filter/resolver/FilterResolverIntf.java
@@@ -1,98 -1,0 +1,101 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.carbondata.scan.filter.resolver;
+
+import java.io.Serializable;
+import java.util.SortedMap;
+
+import org.carbondata.core.carbon.AbsoluteTableIdentifier;
+import org.carbondata.core.carbon.datastore.block.SegmentProperties;
++import org.carbondata.scan.executor.exception.QueryExecutionException;
+import org.carbondata.scan.expression.Expression;
+import org.carbondata.scan.expression.exception.FilterUnsupportedException;
+import org.carbondata.scan.filter.intf.FilterExecuterType;
+import org.carbondata.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo;
+
+public interface FilterResolverIntf extends Serializable {
+
+ /**
+ * This API will resolve the filter expression and generates the
+ * dictionaries for executing/evaluating the filter expressions in the
+ * executer layer.
+ *
+ * @throws QueryExecutionException
+ * @throws FilterUnsupportedException
+ */
+ void resolve(AbsoluteTableIdentifier absoluteTableIdentifier) throws FilterUnsupportedException;
+
+ /**
+ * This API will provide the left column filter expression
+ * inorder to resolve the left expression filter.
+ *
+ * @return FilterResolverIntf
+ */
+ FilterResolverIntf getLeft();
+
+ /**
+ * API will provide the right column filter expression inorder to resolve
+ * the right expression filter.
+ *
+ * @return FilterResolverIntf
+ */
+ FilterResolverIntf getRight();
+
+ /**
+ * API will return the resolved filter instance, this instance will provide
+ * the resolved surrogates based on the applied filter
+ *
+ * @return DimColumnResolvedFilterInfo object
+ */
+ DimColumnResolvedFilterInfo getDimColResolvedFilterInfo();
+
+ /**
+ * API will get the start key based on the filter applied based on the key generator
+ *
+ * @param segmentProperties
+ * @param startKey
+ * @param setOfStartKeyByteArray
+ */
+ void getStartKey(SegmentProperties segmentProperties, long[] startKey,
+ SortedMap<Integer, byte[]> setOfStartKeyByteArray);
+
+ /**
+ * API will read the end key based on the max surrogate of
+ * particular dimension column
+ *
+ * @param setOfEndKeyByteArray
+ * @param endKeys
+ * @return
++ * @throws QueryExecutionException
+ */
+ void getEndKey(SegmentProperties segmentProperties, AbsoluteTableIdentifier tableIdentifier,
- long[] endKeys, SortedMap<Integer, byte[]> setOfEndKeyByteArray);
++ long[] endKeys, SortedMap<Integer, byte[]> setOfEndKeyByteArray)
++ throws QueryExecutionException;
+
+ /**
+ * API will return the filter executer type which will be used to evaluate
+ * the resolved filter while query execution
+ *
+ * @return FilterExecuterType.
+ */
+ FilterExecuterType getFilterExecuterType();
+
+ Expression getFilterExpression();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/filter/resolver/LogicalFilterResolverImpl.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/filter/resolver/LogicalFilterResolverImpl.java
index 48c43be,0000000..4fd9223
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/filter/resolver/LogicalFilterResolverImpl.java
+++ b/core/src/main/java/org/carbondata/scan/filter/resolver/LogicalFilterResolverImpl.java
@@@ -1,110 -1,0 +1,111 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.carbondata.scan.filter.resolver;
+
+import java.util.SortedMap;
+
+import org.carbondata.core.carbon.AbsoluteTableIdentifier;
+import org.carbondata.core.carbon.datastore.block.SegmentProperties;
++import org.carbondata.scan.executor.exception.QueryExecutionException;
+import org.carbondata.scan.expression.Expression;
+import org.carbondata.scan.filter.intf.ExpressionType;
+import org.carbondata.scan.filter.intf.FilterExecuterType;
+import org.carbondata.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo;
+
+public class LogicalFilterResolverImpl implements FilterResolverIntf {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5734382980564402914L;
+
+ protected FilterResolverIntf leftEvalutor;
+
+ protected FilterResolverIntf rightEvalutor;
+
+ protected ExpressionType filterExpressionType;
+
+ public LogicalFilterResolverImpl(FilterResolverIntf leftEvalutor,
+ FilterResolverIntf rightEvalutor, ExpressionType filterExpressionType) {
+ this.leftEvalutor = leftEvalutor;
+ this.rightEvalutor = rightEvalutor;
+ this.filterExpressionType = filterExpressionType;
+ }
+
+ /**
+ * Logical filter resolver will return the left and right filter expresison
+ * node for filter evaluation, so in this instance no implementation is required.
+ *
+ * @param absoluteTableIdentifier
+ */
+ @Override public void resolve(AbsoluteTableIdentifier absoluteTableIdentifier) {
+
+ }
+
+ /**
+ * Since its a binary condition expresion the getLeft method will get the left
+ * node of filter expression
+ *
+ * @return FilterResolverIntf.
+ */
+ public FilterResolverIntf getLeft() {
+ return leftEvalutor;
+ }
+
+ /**
+ * Since its a binary condition expresion the getRight method will get the left
+ * node of filter expression
+ *
+ * @return FilterResolverIntf.
+ */
+ public FilterResolverIntf getRight() {
+ return rightEvalutor;
+ }
+
+ @Override public DimColumnResolvedFilterInfo getDimColResolvedFilterInfo() {
+ return null;
+ }
+
+ @Override public void getStartKey(SegmentProperties segmentProperties, long[] startKey,
+ SortedMap<Integer, byte[]> setOfStartKeyByteArray) {
+
+ }
+
+ @Override public void getEndKey(SegmentProperties segmentProperties,
+ AbsoluteTableIdentifier tableIdentifier, long[] endKeys,
- SortedMap<Integer, byte[]> setOfEndKeyByteArray) {
++ SortedMap<Integer, byte[]> setOfEndKeyByteArray) throws QueryExecutionException {
+ }
+
+ @Override public FilterExecuterType getFilterExecuterType() {
+ switch (filterExpressionType) {
+ case OR:
+ return FilterExecuterType.OR;
+ case AND:
+ return FilterExecuterType.AND;
+
+ default:
+ return null;
+ }
+ }
+
+ @Override public Expression getFilterExpression() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/filter/resolver/RestructureFilterResolverImpl.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/filter/resolver/RestructureFilterResolverImpl.java
index def2725,0000000..a04e5b4
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/filter/resolver/RestructureFilterResolverImpl.java
+++ b/core/src/main/java/org/carbondata/scan/filter/resolver/RestructureFilterResolverImpl.java
@@@ -1,203 -1,0 +1,206 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.carbondata.scan.filter.resolver;
+
+import java.util.List;
+import java.util.SortedMap;
+
+import org.carbondata.core.carbon.AbsoluteTableIdentifier;
+import org.carbondata.core.carbon.datastore.block.SegmentProperties;
+import org.carbondata.scan.expression.ColumnExpression;
+import org.carbondata.scan.expression.DataType;
+import org.carbondata.scan.expression.Expression;
+import org.carbondata.scan.expression.conditional.BinaryConditionalExpression;
+import org.carbondata.scan.expression.conditional.ConditionalExpression;
++import org.carbondata.scan.expression.exception.FilterUnsupportedException;
+import org.carbondata.scan.filter.FilterUtil;
+import org.carbondata.scan.filter.intf.FilterExecuterType;
+import org.carbondata.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo;
+
+public class RestructureFilterResolverImpl implements FilterResolverIntf {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5399656036192814524L;
+
+ protected DimColumnResolvedFilterInfo dimColumnResolvedFilterInfo;
+
+ private Expression exp;
+
+ private String defaultValue;
+
+ private int surrogate;
+
+ private boolean isExpressionResolve;
+
+ private boolean isIncludeFilter;
+
+ public RestructureFilterResolverImpl(Expression exp, String defaultValue, int surrogate,
+ boolean isExpressionResolve, boolean isIncludeFilter) {
+ dimColumnResolvedFilterInfo = new DimColumnResolvedFilterInfo();
+ this.exp = exp;
+ this.defaultValue = defaultValue;
+ this.surrogate = surrogate;
+ this.isExpressionResolve = isExpressionResolve;
+ this.isIncludeFilter = isIncludeFilter;
+ }
+
+ /**
+ * Method will resolve the filters and it will replace the newly added dimension with default
+ * value
+ *
+ * @param absoluteTableIdentifier
++ * @throws FilterUnsupportedException
+ */
- @Override public void resolve(AbsoluteTableIdentifier absoluteTableIdentifier) {
++ @Override public void resolve(AbsoluteTableIdentifier absoluteTableIdentifier)
++ throws FilterUnsupportedException {
+
+ DimColumnResolvedFilterInfo dimColumnResolvedFilterInfo = new DimColumnResolvedFilterInfo();
+ if (!this.isExpressionResolve && exp instanceof BinaryConditionalExpression) {
+ BinaryConditionalExpression binaryConditionalExpression = (BinaryConditionalExpression) exp;
+ Expression left = binaryConditionalExpression.getLeft();
+ Expression right = binaryConditionalExpression.getRight();
+ if (left instanceof ColumnExpression) {
+ ColumnExpression columnExpression = (ColumnExpression) left;
+ if (columnExpression.getDataType().equals(DataType.TimestampType)) {
+ isExpressionResolve = true;
+ } else {
+ // If imei=imei comes in filter condition then we need to
+ // skip processing of right expression.
+ // This flow has reached here assuming that this is a single
+ // column expression.
+ // we need to check if the other expression contains column
+ // expression or not in depth.
+ if (FilterUtil.checkIfExpressionContainsColumn(right)) {
+ isExpressionResolve = true;
+ } else {
+ dimColumnResolvedFilterInfo
+ .setColumnIndex(columnExpression.getCarbonColumn().getOrdinal());
+ dimColumnResolvedFilterInfo.setFilterValues(
+ FilterUtil.getFilterListForRS(right, columnExpression, defaultValue, surrogate));
+ }
+ }
+ } else if (right instanceof ColumnExpression) {
+ ColumnExpression columnExpression = (ColumnExpression) right;
+ if (columnExpression.getDataType().equals(DataType.TimestampType)) {
+ isExpressionResolve = true;
+ } else {
+
+ // If imei=imei comes in filter condition then we need to
+ // skip processing of right expression.
+ // This flow has reached here assuming that this is a single
+ // column expression.
+ // we need to check if the other expression contains column
+ // expression or not in depth.
+ if (checkIfExpressionContainsColumn(left)) {
+ isExpressionResolve = true;
+ } else {
+ dimColumnResolvedFilterInfo
+ .setColumnIndex(columnExpression.getCarbonColumn().getOrdinal());
+ dimColumnResolvedFilterInfo.setFilterValues(
+ FilterUtil.getFilterListForRS(left, columnExpression, defaultValue, surrogate));
+ }
+ }
+ }
+ }
+ if (this.isExpressionResolve && exp instanceof ConditionalExpression) {
+ ConditionalExpression conditionalExpression = (ConditionalExpression) exp;
+ List<ColumnExpression> columnList = conditionalExpression.getColumnList();
+ dimColumnResolvedFilterInfo.setColumnIndex(columnList.get(0).getDimension().getOrdinal());
+ dimColumnResolvedFilterInfo.setFilterValues(FilterUtil
+ .getFilterListForAllMembersRS(exp, columnList.get(0), defaultValue, surrogate,
+ isIncludeFilter));
+ }
+
+ }
+
+ /**
+ * This method will check if a given expression contains a column expression recursively.
+ *
+ * @return boolean
+ */
+ private boolean checkIfExpressionContainsColumn(Expression expression) {
+ if (expression instanceof ColumnExpression) {
+ return true;
+ }
+ for (Expression child : expression.getChildren()) {
+ if (checkIfExpressionContainsColumn(child)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override public FilterResolverIntf getLeft() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override public FilterResolverIntf getRight() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * Method will return the DimColumnResolvedFilterInfo instance which consists
+ * the mapping of the respective dimension and its surrogates involved in
+ * filter expression.
+ *
+ * @return DimColumnResolvedFilterInfo
+ */
+ public DimColumnResolvedFilterInfo getDimColResolvedFilterInfo() {
+ return dimColumnResolvedFilterInfo;
+ }
+
+ /**
+ * For restructure resolver no implementation is required for getting
+ * the start key since it already has default values
+ */
+ @Override public void getStartKey(SegmentProperties segmentProperties, long[] startKeys,
+ SortedMap<Integer, byte[]> noDicStartKeys) {
+
+ }
+
+ /**
+ * For restructure resolver no implementation is required for getting
+ * the end key since it already has default values
+ *
+ * @return IndexKey.
+ */
+ @Override public void getEndKey(SegmentProperties segmentProperties,
+ AbsoluteTableIdentifier tableIdentifier, long[] endKeys,
+ SortedMap<Integer, byte[]> noDicEndKeys) {
+ }
+
+ /**
+ * Method will get the executer type inorder to create filter executer tree
+ *
+ * @return FilterExecuterType
+ */
+ @Override public FilterExecuterType getFilterExecuterType() {
+ return FilterExecuterType.RESTRUCTURE;
+ }
+
+ @Override public Expression getFilterExpression() {
+ // TODO Auto-generated method stub
+ return exp;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/filter/resolver/RowLevelRangeFilterResolverImpl.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/filter/resolver/RowLevelRangeFilterResolverImpl.java
index d09bab5,0000000..cf2a998
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/filter/resolver/RowLevelRangeFilterResolverImpl.java
+++ b/core/src/main/java/org/carbondata/scan/filter/resolver/RowLevelRangeFilterResolverImpl.java
@@@ -1,233 -1,0 +1,284 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.carbondata.scan.filter.resolver;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.SortedMap;
+
++import org.carbondata.common.logging.LogService;
++import org.carbondata.common.logging.LogServiceFactory;
+import org.carbondata.core.carbon.AbsoluteTableIdentifier;
+import org.carbondata.core.carbon.datastore.block.SegmentProperties;
++import org.carbondata.core.carbon.metadata.encoder.Encoding;
+import org.carbondata.core.carbon.metadata.schema.table.column.CarbonMeasure;
+import org.carbondata.core.constants.CarbonCommonConstants;
++import org.carbondata.core.keygenerator.directdictionary.DirectDictionaryGenerator;
++import org.carbondata.core.keygenerator.directdictionary.DirectDictionaryKeyGeneratorFactory;
+import org.carbondata.core.util.ByteUtil;
+import org.carbondata.scan.executor.exception.QueryExecutionException;
+import org.carbondata.scan.expression.ColumnExpression;
+import org.carbondata.scan.expression.Expression;
+import org.carbondata.scan.expression.ExpressionResult;
+import org.carbondata.scan.expression.conditional.BinaryConditionalExpression;
++import org.carbondata.scan.expression.exception.FilterIllegalMemberException;
++import org.carbondata.scan.expression.exception.FilterUnsupportedException;
+import org.carbondata.scan.expression.logical.BinaryLogicalExpression;
+import org.carbondata.scan.filter.DimColumnFilterInfo;
+import org.carbondata.scan.filter.FilterUtil;
+import org.carbondata.scan.filter.intf.FilterExecuterType;
+import org.carbondata.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo;
+import org.carbondata.scan.filter.resolver.resolverinfo.MeasureColumnResolvedFilterInfo;
+
+public class RowLevelRangeFilterResolverImpl extends ConditionalFilterResolverImpl {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 6629319265336666789L;
-
++ private static final LogService LOGGER =
++ LogServiceFactory.getLogService(RowLevelRangeFilterResolverImpl.class.getName());
+ private List<DimColumnResolvedFilterInfo> dimColEvaluatorInfoList;
+ private List<MeasureColumnResolvedFilterInfo> msrColEvalutorInfoList;
+ private AbsoluteTableIdentifier tableIdentifier;
+
+ public RowLevelRangeFilterResolverImpl(Expression exp, boolean isExpressionResolve,
+ boolean isIncludeFilter, AbsoluteTableIdentifier tableIdentifier) {
+ super(exp, isExpressionResolve, isIncludeFilter);
+ dimColEvaluatorInfoList =
+ new ArrayList<DimColumnResolvedFilterInfo>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
+ msrColEvalutorInfoList = new ArrayList<MeasureColumnResolvedFilterInfo>(
+ CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
+ this.tableIdentifier = tableIdentifier;
+ }
+
+ /**
- * This method will return the filter values which is present in the range leve
++ * This method will return the filter values which is present in the range level
+ * conditional expressions.
+ *
+ * @return
+ */
- public byte[][] getFilterRangeValues() {
- List<byte[]> filterValuesList = new ArrayList<byte[]>();
- if (null != dimColEvaluatorInfoList.get(0).getFilterValues()) {
- filterValuesList =
++ public byte[][] getFilterRangeValues(SegmentProperties segmentProperties) {
++
++ if (null != dimColEvaluatorInfoList.get(0).getFilterValues() && !dimColEvaluatorInfoList.get(0)
++ .getDimension().hasEncoding(Encoding.DICTIONARY)) {
++ List<byte[]> noDictFilterValuesList =
+ dimColEvaluatorInfoList.get(0).getFilterValues().getNoDictionaryFilterValuesList();
- return filterValuesList.toArray((new byte[filterValuesList.size()][]));
++ return noDictFilterValuesList.toArray((new byte[noDictFilterValuesList.size()][]));
++ } else if (null != dimColEvaluatorInfoList.get(0).getFilterValues() && dimColEvaluatorInfoList
++ .get(0).getDimension().hasEncoding(Encoding.DIRECT_DICTIONARY)) {
++ return FilterUtil.getKeyArray(this.dimColEvaluatorInfoList.get(0).getFilterValues(),
++ this.dimColEvaluatorInfoList.get(0).getDimension(),
++ segmentProperties.getDimensionKeyGenerator());
+ }
- return filterValuesList.toArray((new byte[filterValuesList.size()][]));
++ return null;
+
+ }
+
+ /**
+ * method will get the start key based on the filter surrogates
+ *
+ * @return start IndexKey
+ */
+ public void getStartKey(SegmentProperties segmentProperties, long[] startKey,
+ SortedMap<Integer, byte[]> noDictStartKeys) {
+ if (null == dimColEvaluatorInfoList.get(0).getStarIndexKey()) {
++ FilterUtil.getStartKey(dimColEvaluatorInfoList.get(0), segmentProperties, startKey);
+ FilterUtil
+ .getStartKeyForNoDictionaryDimension(dimColEvaluatorInfoList.get(0), segmentProperties,
+ noDictStartKeys);
+ }
+ }
+
+ /**
+ * method will get the start key based on the filter surrogates
+ *
+ * @return end IndexKey
+ */
+ @Override public void getEndKey(SegmentProperties segmentProperties,
+ AbsoluteTableIdentifier absoluteTableIdentifier, long[] endKeys,
+ SortedMap<Integer, byte[]> noDicEndKeys) {
+ if (null == dimColEvaluatorInfoList.get(0).getEndIndexKey()) {
+ try {
+ FilterUtil.getEndKey(dimColEvaluatorInfoList.get(0).getDimensionResolvedFilterInstance(),
+ absoluteTableIdentifier, endKeys, segmentProperties);
+ FilterUtil
+ .getEndKeyForNoDictionaryDimension(dimColEvaluatorInfoList.get(0), segmentProperties,
+ noDicEndKeys);
+ } catch (QueryExecutionException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ 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;
+ for (ExpressionResult result : listOfExpressionResults) {
- if (result.getString() == null) {
- filterValuesList.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL.getBytes());
- continue;
++ try {
++ if (result.getString() == null) {
++ filterValuesList.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL.getBytes());
++ continue;
++ }
++ filterValuesList.add(result.getString().getBytes());
++ } 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 inforation only once the log will be printed.
++ FilterUtil.logError(e, invalidRowsPresent);
+ }
- filterValuesList.add(result.getString().getBytes());
+ }
+ Comparator<byte[]> filterNoDictValueComaparator = new Comparator<byte[]>() {
+ @Override public int compare(byte[] filterMember1, byte[] filterMember2) {
+ return ByteUtil.UnsafeComparer.INSTANCE.compareTo(filterMember1, filterMember2);
+ }
+
+ };
+ Collections.sort(filterValuesList, filterNoDictValueComaparator);
+ return filterValuesList;
+ }
+
+ /**
+ * Method which will resolve the filter expression by converting the filter
+ * member to its assigned dictionary values.
+ */
+ public void resolve(AbsoluteTableIdentifier absoluteTableIdentifier) {
+ DimColumnResolvedFilterInfo dimColumnEvaluatorInfo = null;
+ MeasureColumnResolvedFilterInfo msrColumnEvalutorInfo = null;
+ int index = 0;
+ if (exp instanceof BinaryLogicalExpression) {
+ BinaryLogicalExpression conditionalExpression = (BinaryLogicalExpression) exp;
+ List<ColumnExpression> columnList = conditionalExpression.getColumnList();
+ for (ColumnExpression columnExpression : columnList) {
+ if (columnExpression.isDimension()) {
+ dimColumnEvaluatorInfo = new DimColumnResolvedFilterInfo();
+ DimColumnFilterInfo filterInfo = new DimColumnFilterInfo();
+ dimColumnEvaluatorInfo.setColumnIndex(columnExpression.getCarbonColumn().getOrdinal());
+ //dimColumnEvaluatorInfo.se
+ dimColumnEvaluatorInfo.setRowIndex(index++);
+ dimColumnEvaluatorInfo.setDimension(columnExpression.getDimension());
+ dimColumnEvaluatorInfo.setDimensionExistsInCurrentSilce(false);
- filterInfo.setFilterListForNoDictionaryCols(getNoDictionaryRangeValues());
++ if (columnExpression.getDimension().hasEncoding(Encoding.DIRECT_DICTIONARY)) {
++ filterInfo.setFilterList(getDirectSurrogateValues(columnExpression));
++ } else {
++ filterInfo.setFilterListForNoDictionaryCols(getNoDictionaryRangeValues());
++ }
+ filterInfo.setIncludeFilter(isIncludeFilter);
+ dimColumnEvaluatorInfo.setFilterValues(filterInfo);
+ dimColumnEvaluatorInfo
+ .addDimensionResolvedFilterInstance(columnExpression.getDimension(), filterInfo);
+ dimColEvaluatorInfoList.add(dimColumnEvaluatorInfo);
+ } else {
+ msrColumnEvalutorInfo = new MeasureColumnResolvedFilterInfo();
+ msrColumnEvalutorInfo.setRowIndex(index++);
+ msrColumnEvalutorInfo.setAggregator(
+ ((CarbonMeasure) columnExpression.getCarbonColumn()).getAggregateFunction());
+ msrColumnEvalutorInfo
+ .setColumnIndex(((CarbonMeasure) columnExpression.getCarbonColumn()).getOrdinal());
+ msrColumnEvalutorInfo.setType(columnExpression.getCarbonColumn().getDataType());
+ msrColEvalutorInfoList.add(msrColumnEvalutorInfo);
+ }
+ }
+ }
+ }
+
++ private List<Integer> getDirectSurrogateValues(ColumnExpression columnExpression) {
++ List<ExpressionResult> listOfExpressionResults = new ArrayList<ExpressionResult>(20);
++ DirectDictionaryGenerator directDictionaryGenerator = DirectDictionaryKeyGeneratorFactory
++ .getDirectDictionaryGenerator(columnExpression.getDimension().getDataType());
++
++ if (this.getFilterExpression() instanceof BinaryConditionalExpression) {
++ listOfExpressionResults =
++ ((BinaryConditionalExpression) this.getFilterExpression()).getLiterals();
++ }
++ List<Integer> filterValuesList = new ArrayList<Integer>(20);
++ try {
++ // if any filter member provided by user is invalid throw error else
++ // system can display inconsistent result.
++ for (ExpressionResult result : listOfExpressionResults) {
++ filterValuesList.add(directDictionaryGenerator
++ .generateDirectSurrogateKey(result.getString(),
++ CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT));
++ }
++ } catch (FilterIllegalMemberException e) {
++ new FilterUnsupportedException(e);
++ }
++ return filterValuesList;
++ }
++
+ /**
+ * Method will return the DimColumnResolvedFilterInfo instance which consists
+ * the mapping of the respective dimension and its surrogates involved in
+ * filter expression.
+ *
+ * @return DimColumnResolvedFilterInfo
+ */
+ public List<DimColumnResolvedFilterInfo> getDimColEvaluatorInfoList() {
+ return dimColEvaluatorInfoList;
+ }
+
+ /**
+ * Method will return the DimColumnResolvedFilterInfo instance which containts
+ * measure level details.
+ *
+ * @return MeasureColumnResolvedFilterInfo
+ */
+ public List<MeasureColumnResolvedFilterInfo> getMsrColEvalutorInfoList() {
+ return msrColEvalutorInfoList;
+ }
+
+ public AbsoluteTableIdentifier getTableIdentifier() {
+ return tableIdentifier;
+ }
+
+ public Expression getFilterExpression() {
+ return this.exp;
+ }
+
+ /**
+ * This method will provide the executer type to the callee inorder to identify
+ * the executer type for the filter resolution, Row level filter executer is a
+ * special executer since it get all the rows of the specified filter dimension
+ * and will be send to the spark for processing
+ */
+ public FilterExecuterType getFilterExecuterType() {
+ switch (exp.getFilterExpressionType()) {
+ case GREATERTHAN:
+ return FilterExecuterType.ROWLEVEL_GREATERTHAN;
+ case GREATERTHAN_EQUALTO:
+ return FilterExecuterType.ROWLEVEL_GREATERTHAN_EQUALTO;
+ case LESSTHAN:
+ return FilterExecuterType.ROWLEVEL_LESSTHAN;
+ case LESSTHAN_EQUALTO:
+ return FilterExecuterType.ROWLEVEL_LESSTHAN_EQUALTO;
+
+ default:
+ return FilterExecuterType.ROWLEVEL;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/filter/resolver/resolverinfo/visitor/CustomTypeDictionaryVisitor.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/filter/resolver/resolverinfo/visitor/CustomTypeDictionaryVisitor.java
index 273bdf1,0000000..5131cca
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/filter/resolver/resolverinfo/visitor/CustomTypeDictionaryVisitor.java
+++ b/core/src/main/java/org/carbondata/scan/filter/resolver/resolverinfo/visitor/CustomTypeDictionaryVisitor.java
@@@ -1,80 -1,0 +1,88 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.carbondata.scan.filter.resolver.resolverinfo.visitor;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.carbondata.common.logging.LogService;
+import org.carbondata.common.logging.LogServiceFactory;
+import org.carbondata.core.carbon.AbsoluteTableIdentifier;
++import org.carbondata.core.constants.CarbonCommonConstants;
+import org.carbondata.core.keygenerator.directdictionary.DirectDictionaryGenerator;
+import org.carbondata.core.keygenerator.directdictionary.DirectDictionaryKeyGeneratorFactory;
+import org.carbondata.scan.expression.ColumnExpression;
++import org.carbondata.scan.expression.exception.FilterIllegalMemberException;
+import org.carbondata.scan.expression.exception.FilterUnsupportedException;
+import org.carbondata.scan.filter.DimColumnFilterInfo;
+import org.carbondata.scan.filter.resolver.metadata.FilterResolverMetadata;
+import org.carbondata.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo;
+
+public class CustomTypeDictionaryVisitor implements ResolvedFilterInfoVisitorIntf {
+ private static final LogService LOGGER =
+ LogServiceFactory.getLogService(CustomTypeDictionaryVisitor.class.getName());
+
+ /**
+ * This Visitor method is been used to resolve or populate the filter details
+ * by using custom type dictionary value, the filter membrers will be resolved using
+ * custom type function which will generate dictionary for the direct column type filter members
+ *
+ * @param visitableObj
+ * @param metadata
- * @throws FilterUnsupportedException
++ * @throws FilterUnsupportedException,if exception occurs while evaluating
++ * filter models.
+ */
+ public void populateFilterResolvedInfo(DimColumnResolvedFilterInfo visitableObj,
+ FilterResolverMetadata metadata) throws FilterUnsupportedException {
+ DimColumnFilterInfo resolvedFilterObject = null;
+
- List<String> evaluateResultListFinal =
- metadata.getExpression().evaluate(null).getListAsString();
++ List<String> evaluateResultListFinal;
++ try {
++ evaluateResultListFinal = metadata.getExpression().evaluate(null).getListAsString();
++ } catch (FilterIllegalMemberException e) {
++ throw new FilterUnsupportedException(e);
++ }
+ resolvedFilterObject = getDirectDictionaryValKeyMemberForFilter(metadata.getTableIdentifier(),
+ metadata.getColumnExpression(), evaluateResultListFinal, metadata.isIncludeFilter());
+ visitableObj.setFilterValues(resolvedFilterObject);
+ }
+
+ private DimColumnFilterInfo getDirectDictionaryValKeyMemberForFilter(
+ AbsoluteTableIdentifier tableIdentifier, ColumnExpression columnExpression,
+ List<String> evaluateResultListFinal, boolean isIncludeFilter) {
+ List<Integer> surrogates = new ArrayList<Integer>(20);
+ DirectDictionaryGenerator directDictionaryGenerator = DirectDictionaryKeyGeneratorFactory
+ .getDirectDictionaryGenerator(columnExpression.getDimension().getDataType());
+ // Reading the dictionary value direct
+ for (String filterMember : evaluateResultListFinal) {
- surrogates.add(directDictionaryGenerator.generateDirectSurrogateKey(filterMember));
++ surrogates.add(directDictionaryGenerator.generateDirectSurrogateKey(filterMember,
++ CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT));
+ }
+ Collections.sort(surrogates);
+ DimColumnFilterInfo columnFilterInfo = null;
+ if (surrogates.size() > 0) {
+ columnFilterInfo = new DimColumnFilterInfo();
+ columnFilterInfo.setIncludeFilter(isIncludeFilter);
+ columnFilterInfo.setFilterList(surrogates);
+ }
+ return columnFilterInfo;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/filter/resolver/resolverinfo/visitor/DictionaryColumnVisitor.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/filter/resolver/resolverinfo/visitor/DictionaryColumnVisitor.java
index 7ec2751,0000000..f531474
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/filter/resolver/resolverinfo/visitor/DictionaryColumnVisitor.java
+++ b/core/src/main/java/org/carbondata/scan/filter/resolver/resolverinfo/visitor/DictionaryColumnVisitor.java
@@@ -1,58 -1,0 +1,65 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.carbondata.scan.filter.resolver.resolverinfo.visitor;
+
+import java.util.List;
+
+import org.carbondata.common.logging.LogService;
+import org.carbondata.common.logging.LogServiceFactory;
+import org.carbondata.scan.executor.exception.QueryExecutionException;
++import org.carbondata.scan.expression.exception.FilterIllegalMemberException;
+import org.carbondata.scan.expression.exception.FilterUnsupportedException;
+import org.carbondata.scan.filter.DimColumnFilterInfo;
+import org.carbondata.scan.filter.FilterUtil;
+import org.carbondata.scan.filter.resolver.metadata.FilterResolverMetadata;
+import org.carbondata.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo;
+
+public class DictionaryColumnVisitor implements ResolvedFilterInfoVisitorIntf {
+ private static final LogService LOGGER =
+ LogServiceFactory.getLogService(DictionaryColumnVisitor.class.getName());
+
+ /**
+ * 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 QueryExecutionException
+ */
+ public void populateFilterResolvedInfo(DimColumnResolvedFilterInfo visitableObj,
+ FilterResolverMetadata metadata) throws FilterUnsupportedException {
+ DimColumnFilterInfo resolvedFilterObject = null;
- List<String> evaluateResultListFinal =
- metadata.getExpression().evaluate(null).getListAsString();
++ List<String> evaluateResultListFinal;
++ try {
++ evaluateResultListFinal = metadata.getExpression().evaluate(null).getListAsString();
++ } catch (FilterIllegalMemberException e) {
++ throw new FilterUnsupportedException(e);
++ }
+ try {
+ resolvedFilterObject = FilterUtil
+ .getFilterValues(metadata.getTableIdentifier(), metadata.getColumnExpression(),
+ evaluateResultListFinal, metadata.isIncludeFilter());
+ } catch (QueryExecutionException e) {
+ throw new FilterUnsupportedException(e);
+ }
+ visitableObj.setFilterValues(resolvedFilterObject);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/filter/resolver/resolverinfo/visitor/NoDictionaryTypeVisitor.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/filter/resolver/resolverinfo/visitor/NoDictionaryTypeVisitor.java
index ee3d157,0000000..6958d61
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/filter/resolver/resolverinfo/visitor/NoDictionaryTypeVisitor.java
+++ b/core/src/main/java/org/carbondata/scan/filter/resolver/resolverinfo/visitor/NoDictionaryTypeVisitor.java
@@@ -1,56 -1,0 +1,62 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.carbondata.scan.filter.resolver.resolverinfo.visitor;
+
+import java.util.List;
+
+import org.carbondata.common.logging.LogService;
+import org.carbondata.common.logging.LogServiceFactory;
++import org.carbondata.scan.expression.exception.FilterIllegalMemberException;
+import org.carbondata.scan.expression.exception.FilterUnsupportedException;
+import org.carbondata.scan.filter.DimColumnFilterInfo;
+import org.carbondata.scan.filter.FilterUtil;
+import org.carbondata.scan.filter.resolver.metadata.FilterResolverMetadata;
+import org.carbondata.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo;
+
+public class NoDictionaryTypeVisitor implements ResolvedFilterInfoVisitorIntf {
+ private static final LogService LOGGER =
+ LogServiceFactory.getLogService(NoDictionaryTypeVisitor.class.getName());
+
+ /**
+ * 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
++ * @throws FilterUnsupportedException,if exception occurs while evaluating
++ * filter models.
+ */
+ public void populateFilterResolvedInfo(DimColumnResolvedFilterInfo visitableObj,
+ FilterResolverMetadata metadata) throws FilterUnsupportedException {
+ DimColumnFilterInfo resolvedFilterObject = null;
- List<String> evaluateResultListFinal =
- metadata.getExpression().evaluate(null).getListAsString();
++ List<String> evaluateResultListFinal;
++ try {
++ evaluateResultListFinal = metadata.getExpression().evaluate(null).getListAsString();
++ } catch (FilterIllegalMemberException e) {
++ throw new FilterUnsupportedException(e);
++ }
+ resolvedFilterObject = FilterUtil
+ .getNoDictionaryValKeyMemberForFilter(metadata.getTableIdentifier(),
+ metadata.getColumnExpression(), evaluateResultListFinal, metadata.isIncludeFilter());
+ visitableObj.setFilterValues(resolvedFilterObject);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/result/iterator/RawResultIterator.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/result/iterator/RawResultIterator.java
index 62849ee,0000000..0f9c339
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/result/iterator/RawResultIterator.java
+++ b/core/src/main/java/org/carbondata/scan/result/iterator/RawResultIterator.java
@@@ -1,167 -1,0 +1,169 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.carbondata.scan.result.iterator;
+
+import org.carbondata.common.CarbonIterator;
+import org.carbondata.common.logging.LogService;
+import org.carbondata.common.logging.LogServiceFactory;
+import org.carbondata.core.carbon.datastore.block.SegmentProperties;
+import org.carbondata.core.keygenerator.KeyGenException;
+import org.carbondata.scan.result.BatchRawResult;
+import org.carbondata.scan.wrappers.ByteArrayWrapper;
+
+/**
+ * This is a wrapper iterator over the detail raw query iterator.
+ * This iterator will handle the processing of the raw rows.
+ * This will handle the batch results and will iterate on the batches and give single row.
+ */
+public class RawResultIterator extends CarbonIterator<Object[]> {
+
+ private final SegmentProperties sourceSegProperties;
+
+ private final SegmentProperties destinationSegProperties;
+ /**
+ * Iterator of the Batch raw result.
+ */
+ private CarbonIterator<BatchRawResult> detailRawQueryResultIterator;
+
+ /**
+ * Counter to maintain the row counter.
+ */
+ private int counter = 0;
+
+ private Object[] currentConveretedRawRow = null;
+
+ /**
+ * LOGGER
+ */
+ private static final LogService LOGGER =
+ LogServiceFactory.getLogService(RawResultIterator.class.getName());
+
+ /**
+ * batch of the result.
+ */
+ private BatchRawResult batch;
+
+ public RawResultIterator(CarbonIterator<BatchRawResult> detailRawQueryResultIterator,
+ SegmentProperties sourceSegProperties, SegmentProperties destinationSegProperties) {
+ this.detailRawQueryResultIterator = detailRawQueryResultIterator;
+ this.sourceSegProperties = sourceSegProperties;
+ this.destinationSegProperties = destinationSegProperties;
+ }
+
+ @Override public boolean hasNext() {
+
+ if (null == batch || checkIfBatchIsProcessedCompletely(batch)) {
+ if (detailRawQueryResultIterator.hasNext()) {
++ batch = null;
+ batch = detailRawQueryResultIterator.next();
+ counter = 0; // batch changed so reset the counter.
+ } else {
+ return false;
+ }
+ }
+
+ if (!checkIfBatchIsProcessedCompletely(batch)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override public Object[] next() {
+ if (null == batch) { // for 1st time
+ batch = detailRawQueryResultIterator.next();
+ }
+ if (!checkIfBatchIsProcessedCompletely(batch)) {
+ try {
+ if(null != currentConveretedRawRow){
+ counter++;
+ Object[] currentConveretedRawRowTemp = this.currentConveretedRawRow;
+ currentConveretedRawRow = null;
+ return currentConveretedRawRowTemp;
+ }
+ return convertRow(batch.getRawRow(counter++));
+ } catch (KeyGenException e) {
+ LOGGER.error(e.getMessage());
+ return null;
+ }
+ } else { // completed one batch.
++ batch = null;
+ batch = detailRawQueryResultIterator.next();
+ counter = 0;
+ }
+ try {
+ if(null != currentConveretedRawRow){
+ counter++;
+ Object[] currentConveretedRawRowTemp = this.currentConveretedRawRow;
+ currentConveretedRawRow = null;
+ return currentConveretedRawRowTemp;
+ }
+
+ return convertRow(batch.getRawRow(counter++));
+ } catch (KeyGenException e) {
+ LOGGER.error(e.getMessage());
+ return null;
+ }
+
+ }
+
+ /**
+ * for fetching the row with out incrementing counter.
+ * @return
+ */
+ public Object[] fetchConverted() throws KeyGenException {
+ if(null != currentConveretedRawRow){
+ return currentConveretedRawRow;
+ }
+ if(hasNext())
+ {
+ Object[] rawRow = batch.getRawRow(counter);
+ currentConveretedRawRow = convertRow(rawRow);;
+ return currentConveretedRawRow;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ private Object[] convertRow(Object[] rawRow) throws KeyGenException {
+ byte[] dims = ((ByteArrayWrapper) rawRow[0]).getDictionaryKey();
+ long[] keyArray = sourceSegProperties.getDimensionKeyGenerator().getKeyArray(dims);
+ byte[] covertedBytes =
+ destinationSegProperties.getDimensionKeyGenerator().generateKey(keyArray);
+ ((ByteArrayWrapper) rawRow[0]).setDictionaryKey(covertedBytes);
+ return rawRow;
+ }
+
+ /**
+ * To check if the batch is processed completely
+ * @param batch
+ * @return
+ */
+ private boolean checkIfBatchIsProcessedCompletely(BatchRawResult batch){
+ if(counter < batch.getSize())
+ {
+ return false;
+ }
+ else{
+ return true;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/core/src/main/java/org/carbondata/scan/util/DataTypeUtil.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/carbondata/scan/util/DataTypeUtil.java
index 5654b1d,0000000..86828f0
mode 100644,000000..100644
--- a/core/src/main/java/org/carbondata/scan/util/DataTypeUtil.java
+++ b/core/src/main/java/org/carbondata/scan/util/DataTypeUtil.java
@@@ -1,127 -1,0 +1,127 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.carbondata.scan.util;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.carbondata.common.logging.LogService;
+import org.carbondata.common.logging.LogServiceFactory;
+import org.carbondata.core.carbon.metadata.datatype.DataType;
+import org.carbondata.core.constants.CarbonCommonConstants;
+import org.carbondata.core.util.CarbonProperties;
+
+import org.apache.spark.unsafe.types.UTF8String;
+
+/**
+ * Utility for data type
+ */
+public class DataTypeUtil {
+
+ /**
+ * LOGGER
+ */
+ private static final LogService LOGGER =
+ LogServiceFactory.getLogService(DataTypeUtil.class.getName());
+
+ /**
+ * Below method will be used to convert the data passed to its actual data
+ * type
+ *
+ * @param data data
+ * @param actualDataType actual data type
+ * @return actual data after conversion
+ */
+ public static Object getDataBasedOnDataType(String data, DataType actualDataType) {
+
- if (null == data || data.isEmpty()) {
++ if (null == data || data.isEmpty() || CarbonCommonConstants.MEMBER_DEFAULT_VAL.equals(data)) {
+ return null;
+ }
+ try {
+ switch (actualDataType) {
+ case INT:
+ return Integer.parseInt(data);
+ case SHORT:
+ return Short.parseShort(data);
+ case DOUBLE:
+ return Double.parseDouble(data);
+ case LONG:
+ return Long.parseLong(data);
+ case TIMESTAMP:
+ SimpleDateFormat parser = new SimpleDateFormat(CarbonProperties.getInstance()
+ .getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
+ CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT));
+ Date dateToStr = null;
+ try {
+ dateToStr = parser.parse(data);
+ return dateToStr.getTime() * 1000;
+ } catch (ParseException e) {
+ LOGGER.error("Cannot convert" + data + " to Time/Long type value" + e.getMessage());
+ return null;
+ }
+ case DECIMAL:
+ java.math.BigDecimal javaDecVal = new java.math.BigDecimal(data);
+ scala.math.BigDecimal scalaDecVal = new scala.math.BigDecimal(javaDecVal);
+ org.apache.spark.sql.types.Decimal decConverter =
+ new org.apache.spark.sql.types.Decimal();
+ return decConverter.set(scalaDecVal);
+ default:
+ return UTF8String.fromString(data);
+ }
+ } catch (NumberFormatException ex) {
+ LOGGER.error("Problem while converting data type" + data);
+ return null;
+ }
+
+ }
+
+ public static Object getMeasureDataBasedOnDataType(Object data, DataType dataType) {
+
+ if (null == data) {
+ return null;
+ }
+ try {
+ switch (dataType) {
+ case DOUBLE:
+
+ return (Double) data;
+ case LONG:
+
+ return (Long) data;
+
+ case DECIMAL:
+
+ java.math.BigDecimal javaDecVal = new java.math.BigDecimal(data.toString());
+ scala.math.BigDecimal scalaDecVal = new scala.math.BigDecimal(javaDecVal);
+ org.apache.spark.sql.types.Decimal decConverter =
+ new org.apache.spark.sql.types.Decimal();
+ return decConverter.set(scalaDecVal);
+ default:
+
+ return data;
+ }
+ } catch (NumberFormatException ex) {
+ LOGGER.error("Problem while converting data type" + data);
+ return null;
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/examples/src/main/scala/org/carbondata/examples/GenerateDictionaryExample.scala
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/format/src/main/thrift/schema.thrift
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/hadoop/src/test/java/org/carbondata/hadoop/test/util/StoreCreator.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/integration-testcases/src/test/scala/org/carbondata/spark/testsuite/allqueries/AllDataTypesTestCase1.scala
----------------------------------------------------------------------
diff --cc integration-testcases/src/test/scala/org/carbondata/spark/testsuite/allqueries/AllDataTypesTestCase1.scala
index bd7b596,2471e41..0c13a3a
--- a/integration-testcases/src/test/scala/org/carbondata/spark/testsuite/allqueries/AllDataTypesTestCase1.scala
+++ b/integration-testcases/src/test/scala/org/carbondata/spark/testsuite/allqueries/AllDataTypesTestCase1.scala
@@@ -40,83 -40,53 +40,83 @@@ class AllDataTypesTestCase1 extends Que
CarbonProperties.getInstance().addProperty("carbon.direct.surrogate", "false")
try {
sql(
- "create cube Carbon_automation_test dimensions(imei string,deviceInformationId integer," +
- "MAC string,deviceColor string,device_backColor string,modelId string,marketName " +
- "string,AMSize string,ROMSize string,CUPAudit string,CPIClocked string,series string," +
- "productionDate timestamp,bomCode string,internalModels string, deliveryTime string, " +
- "channelsId string, channelsName string , deliveryAreaId string, deliveryCountry " +
- "string, deliveryProvince string, deliveryCity string,deliveryDistrict string, " +
- "deliveryStreet string, oxSingleNumber string, ActiveCheckTime string, ActiveAreaId " +
- "string, ActiveCountry string, ActiveProvince string, Activecity string, ActiveDistrict" +
- " string, ActiveStreet string, ActiveOperatorId string, Active_releaseId string, " +
- "Active_EMUIVersion string, Active_operaSysVersion string, Active_BacVerNumber string, " +
- "Active_BacFlashVer string, Active_webUIVersion string, Active_webUITypeCarrVer string," +
- "Active_webTypeDataVerNumber string, Active_operatorsVersion string, " +
- "Active_phonePADPartitionedVersions string, Latest_YEAR integer, Latest_MONTH integer, " +
- "Latest_DAY integer, Latest_HOUR string, Latest_areaId string, Latest_country string, " +
- "Latest_province string, Latest_city string, Latest_district string, Latest_street " +
- "string, Latest_releaseId string, Latest_EMUIVersion string, Latest_operaSysVersion " +
- "string, Latest_BacVerNumber string, Latest_BacFlashVer string, Latest_webUIVersion " +
- "string, Latest_webUITypeCarrVer string, Latest_webTypeDataVerNumber string, " +
- "Latest_operatorsVersion string, Latest_phonePADPartitionedVersions string, " +
- "Latest_operatorId string, gamePointDescription string) measures(gamePointId numeric," +
- "contractNumber numeric) OPTIONS (PARTITIONER [CLASS = 'org.carbondata" +
- ".spark.partition.api.impl.SampleDataPartitionerImpl' ,COLUMNS= (imei) , " +
- "PARTITION_COUNT=2] )"
+ "create table Carbon_automation_test (imei string,deviceInformationId int,MAC string," +
+ "deviceColor string,device_backColor string,modelId string,marketName string,AMSize " +
+ "string,ROMSize string,CUPAudit string,CPIClocked string,series string,productionDate " +
+ "string,bomCode string,internalModels string, deliveryTime string, channelsId string, " +
+ "channelsName string , deliveryAreaId string, deliveryCountry string, deliveryProvince " +
+ "string, deliveryCity string,deliveryDistrict string, deliveryStreet string, " +
+ "oxSingleNumber string, ActiveCheckTime string, ActiveAreaId string, ActiveCountry " +
+ "string, ActiveProvince string, Activecity string, ActiveDistrict string, ActiveStreet " +
+ "string, ActiveOperatorId string, Active_releaseId string, Active_EMUIVersion string, " +
+ "Active_operaSysVersion string, Active_BacVerNumber string, Active_BacFlashVer string, " +
+ "Active_webUIVersion string, Active_webUITypeCarrVer string,Active_webTypeDataVerNumber " +
+ "string, Active_operatorsVersion string, Active_phonePADPartitionedVersions string, " +
+ "Latest_YEAR int, Latest_MONTH int, Latest_DAY int, Latest_HOUR string, Latest_areaId " +
+ "string, Latest_country string, Latest_province string, Latest_city string, " +
+ "Latest_district string, Latest_street string, Latest_releaseId string, " +
+ "Latest_EMUIVersion string, Latest_operaSysVersion string, Latest_BacVerNumber string, " +
+ "Latest_BacFlashVer string, Latest_webUIVersion string, Latest_webUITypeCarrVer string, " +
+ "Latest_webTypeDataVerNumber string, Latest_operatorsVersion string, " +
+ "Latest_phonePADPartitionedVersions string, Latest_operatorId string, " +
+ "gamePointDescription string, gamePointId int,contractNumber int) stored by 'org.apache" +
+ ".carbondata.format' TBLPROPERTIES('DICTIONARY_EXCLUDE'='Latest_DAY,deviceInformationId," +
+ "Latest_MONTH')")
+ sql("LOAD DATA LOCAL INPATH '" + currentDirectory +
+ "/src/test/resources/100_olap.csv' INTO table Carbon_automation_test OPTIONS" +
+ "('DELIMITER'= ',' ,'QUOTECHAR'= '\"', 'FILEHEADER'= 'imei,deviceInformationId,MAC," +
+ "deviceColor,device_backColor,modelId,marketName,AMSize,ROMSize,CUPAudit,CPIClocked," +
+ "series,productionDate,bomCode,internalModels,deliveryTime,channelsId,channelsName," +
+ "deliveryAreaId,deliveryCountry,deliveryProvince,deliveryCity,deliveryDistrict," +
+ "deliveryStreet,oxSingleNumber,contractNumber,ActiveCheckTime,ActiveAreaId," +
+ "ActiveCountry,ActiveProvince,Activecity,ActiveDistrict,ActiveStreet,ActiveOperatorId," +
+ "Active_releaseId,Active_EMUIVersion,Active_operaSysVersion,Active_BacVerNumber," +
+ "Active_BacFlashVer,Active_webUIVersion,Active_webUITypeCarrVer," +
+ "Active_webTypeDataVerNumber,Active_operatorsVersion," +
+ "Active_phonePADPartitionedVersions,Latest_YEAR,Latest_MONTH,Latest_DAY,Latest_HOUR," +
+ "Latest_areaId,Latest_country,Latest_province,Latest_city,Latest_district," +
+ "Latest_street,Latest_releaseId,Latest_EMUIVersion,Latest_operaSysVersion," +
+ "Latest_BacVerNumber,Latest_BacFlashVer,Latest_webUIVersion,Latest_webUITypeCarrVer," +
+ "Latest_webTypeDataVerNumber,Latest_operatorsVersion," +
+ "Latest_phonePADPartitionedVersions,Latest_operatorId,gamePointId,gamePointDescription')")
+ )
- sql("LOAD DATA FACT FROM '" + currentDirectory + "/src/test/resources/100_olap.csv' INTO " +
- "Cube Carbon_automation_test partitionData(DELIMITER ',' ,QUOTECHAR '\"', FILEHEADER " +
- "'imei,deviceInformationId,MAC,deviceColor,device_backColor,modelId,marketName,AMSize," +
- "ROMSize,CUPAudit,CPIClocked,series,productionDate,bomCode,internalModels,deliveryTime," +
- "channelsId,channelsName,deliveryAreaId,deliveryCountry,deliveryProvince,deliveryCity," +
- "deliveryDistrict,deliveryStreet,oxSingleNumber,contractNumber,ActiveCheckTime," +
- "ActiveAreaId,ActiveCountry,ActiveProvince,Activecity,ActiveDistrict,ActiveStreet," +
- "ActiveOperatorId,Active_releaseId,Active_EMUIVersion,Active_operaSysVersion," +
- "Active_BacVerNumber,Active_BacFlashVer,Active_webUIVersion,Active_webUITypeCarrVer," +
- "Active_webTypeDataVerNumber,Active_operatorsVersion,Active_phonePADPartitionedVersions," +
- "Latest_YEAR,Latest_MONTH,Latest_DAY,Latest_HOUR,Latest_areaId,Latest_country," +
- "Latest_province,Latest_city,Latest_district,Latest_street,Latest_releaseId," +
- "Latest_EMUIVersion,Latest_operaSysVersion,Latest_BacVerNumber,Latest_BacFlashVer," +
- "Latest_webUIVersion,Latest_webUITypeCarrVer,Latest_webTypeDataVerNumber," +
- "Latest_operatorsVersion,Latest_phonePADPartitionedVersions,Latest_operatorId," +
- "gamePointId,gamePointDescription')")
+
+ sql(
+ "create table if not exists Carbon_automation_hive (imei string,deviceInformationId int," +
+ "MAC string,deviceColor string,device_backColor string,modelId string,marketName " +
+ "string,AMSize string,ROMSize string,CUPAudit string,CPIClocked string,series string," +
+ "productionDate timestamp,bomCode string,internalModels string, deliveryTime string, " +
+ "channelsId string, channelsName string , deliveryAreaId string, deliveryCountry " +
+ "string, deliveryProvince string, deliveryCity string,deliveryDistrict string, " +
+ "deliveryStreet string, oxSingleNumber string,contractNumber int, ActiveCheckTime string, ActiveAreaId " +
+ "string, ActiveCountry string, ActiveProvince string, Activecity string, ActiveDistrict" +
+ " string, ActiveStreet string, ActiveOperatorId string, Active_releaseId string, " +
+ "Active_EMUIVersion string, Active_operaSysVersion string, Active_BacVerNumber string, " +
+ "Active_BacFlashVer string, Active_webUIVersion string, Active_webUITypeCarrVer string," +
+ "Active_webTypeDataVerNumber string, Active_operatorsVersion string, " +
+ "Active_phonePADPartitionedVersions string, Latest_YEAR int, Latest_MONTH int, " +
+ "Latest_DAY int, Latest_HOUR string, Latest_areaId string, Latest_country string, " +
+ "Latest_province string, Latest_city string, Latest_district string, Latest_street " +
+ "string, Latest_releaseId string, Latest_EMUIVersion string, Latest_operaSysVersion " +
+ "string, Latest_BacVerNumber string, Latest_BacFlashVer string, Latest_webUIVersion " +
+ "string, Latest_webUITypeCarrVer string, Latest_webTypeDataVerNumber string, " +
+ "Latest_operatorsVersion string, Latest_phonePADPartitionedVersions string, " +
+ "Latest_operatorId string, , gamePointId int, gamePointDescription string" +
+ ") row format delimited fields terminated by ','"
+ )
+
+ sql("LOAD DATA LOCAL INPATH '" + currentDirectory + "/src/test/resources/100_olap.csv' INTO " +
+ "table Carbon_automation_hive ")
+
} catch {
- case e: Exception => print("ERROR: DROP Carbon_automation_test ")
+ case e: Exception => print("ERROR : " + e.getMessage)
}
}
override def afterAll {
- sql("drop cube Carbon_automation_test")
+ sql("drop table Carbon_automation_test")
+ sql("drop table Carbon_automation_hive")
}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/integration-testcases/src/test/scala/org/carbondata/spark/testsuite/allqueries/AllDataTypesTestCase2.scala
----------------------------------------------------------------------
diff --cc integration-testcases/src/test/scala/org/carbondata/spark/testsuite/allqueries/AllDataTypesTestCase2.scala
index da328a1,1707e15..26453cb
--- a/integration-testcases/src/test/scala/org/carbondata/spark/testsuite/allqueries/AllDataTypesTestCase2.scala
+++ b/integration-testcases/src/test/scala/org/carbondata/spark/testsuite/allqueries/AllDataTypesTestCase2.scala
@@@ -71,60 -67,62 +67,89 @@@ class AllDataTypesTestCase2 extends Que
.addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT
)
- sql("LOAD DATA FACT FROM '" + currentDirectory + "/src/test/resources/100_olap.csv' INTO " +
- "Cube Carbon_automation_test2 partitionData(DELIMITER ',' ,QUOTECHAR '\"', FILEHEADER " +
- "'imei,deviceInformationId,MAC,deviceColor,device_backColor,modelId,marketName,AMSize," +
- "ROMSize,CUPAudit,CPIClocked,series,productionDate,bomCode,internalModels,deliveryTime," +
- "channelsId,channelsName,deliveryAreaId,deliveryCountry,deliveryProvince,deliveryCity," +
- "deliveryDistrict,deliveryStreet,oxSingleNumber,contractNumber,ActiveCheckTime," +
- "ActiveAreaId,ActiveCountry,ActiveProvince,Activecity,ActiveDistrict,ActiveStreet," +
- "ActiveOperatorId,Active_releaseId,Active_EMUIVersion,Active_operaSysVersion," +
- "Active_BacVerNumber,Active_BacFlashVer,Active_webUIVersion,Active_webUITypeCarrVer," +
- "Active_webTypeDataVerNumber,Active_operatorsVersion,Active_phonePADPartitionedVersions," +
- "Latest_YEAR,Latest_MONTH,Latest_DAY,Latest_HOUR,Latest_areaId,Latest_country," +
- "Latest_province,Latest_city,Latest_district,Latest_street,Latest_releaseId," +
- "Latest_EMUIVersion,Latest_operaSysVersion,Latest_BacVerNumber,Latest_BacFlashVer," +
- "Latest_webUIVersion,Latest_webUITypeCarrVer,Latest_webTypeDataVerNumber," +
- "Latest_operatorsVersion,Latest_phonePADPartitionedVersions,Latest_operatorId," +
- "gamePointId,gamePointDescription')")
+ sql("LOAD DATA LOCAL INPATH '" + currentDirectory +
+ "/src/test/resources/100_olap.csv' INTO table Carbon_automation_test2 OPTIONS" +
+ "('DELIMITER'= ',' ,'QUOTECHAR'= '\"', 'FILEHEADER'= 'imei,deviceInformationId,MAC," +
+ "deviceColor,device_backColor,modelId,marketName,AMSize,ROMSize,CUPAudit,CPIClocked," +
+ "series,productionDate,bomCode,internalModels,deliveryTime,channelsId,channelsName," +
+ "deliveryAreaId,deliveryCountry,deliveryProvince,deliveryCity,deliveryDistrict," +
+ "deliveryStreet,oxSingleNumber,contractNumber,ActiveCheckTime,ActiveAreaId," +
+ "ActiveCountry,ActiveProvince,Activecity,ActiveDistrict,ActiveStreet,ActiveOperatorId," +
+ "Active_releaseId,Active_EMUIVersion,Active_operaSysVersion,Active_BacVerNumber," +
+ "Active_BacFlashVer,Active_webUIVersion,Active_webUITypeCarrVer," +
+ "Active_webTypeDataVerNumber,Active_operatorsVersion," +
+ "Active_phonePADPartitionedVersions,Latest_YEAR,Latest_MONTH,Latest_DAY,Latest_HOUR," +
+ "Latest_areaId,Latest_country,Latest_province,Latest_city,Latest_district," +
+ "Latest_street,Latest_releaseId,Latest_EMUIVersion,Latest_operaSysVersion," +
+ "Latest_BacVerNumber,Latest_BacFlashVer,Latest_webUIVersion,Latest_webUITypeCarrVer," +
+ "Latest_webTypeDataVerNumber,Latest_operatorsVersion," +
+ "Latest_phonePADPartitionedVersions,Latest_operatorId,gamePointId,gamePointDescription')")
+
+ sql(
+ "create table Carbon_automation_hive (imei string,deviceInformationId int,MAC string," +
+ "deviceColor string,device_backColor string,modelId string,marketName string,AMSize " +
+ "string,ROMSize string,CUPAudit string,CPIClocked string,series string,productionDate " +
+ "string,bomCode string,internalModels string, deliveryTime string, channelsId string, " +
+ "channelsName string , deliveryAreaId string, deliveryCountry string, deliveryProvince " +
+ "string, deliveryCity string,deliveryDistrict string, deliveryStreet string, " +
+ "oxSingleNumber string, ActiveCheckTime string, ActiveAreaId string, ActiveCountry " +
+ "string, ActiveProvince string, Activecity string, ActiveDistrict string, ActiveStreet " +
+ "string, ActiveOperatorId string, Active_releaseId string, Active_EMUIVersion string, " +
+ "Active_operaSysVersion string, Active_BacVerNumber string, Active_BacFlashVer string, " +
+ "Active_webUIVersion string, Active_webUITypeCarrVer string,Active_webTypeDataVerNumber " +
+ "string, Active_operatorsVersion string, Active_phonePADPartitionedVersions string, " +
+ "Latest_YEAR int, Latest_MONTH int, Latest_DAY int, Latest_HOUR string, Latest_areaId " +
+ "string, Latest_country string, Latest_province string, Latest_city string, " +
+ "Latest_district string, Latest_street string, Latest_releaseId string, " +
+ "Latest_EMUIVersion string, Latest_operaSysVersion string, Latest_BacVerNumber string, " +
+ "Latest_BacFlashVer string, Latest_webUIVersion string, Latest_webUITypeCarrVer string, " +
+ "Latest_webTypeDataVerNumber string, Latest_operatorsVersion string, " +
+ "Latest_phonePADPartitionedVersions string, Latest_operatorId string, " +
+ "gamePointDescription string, gamePointId int,contractNumber int)" +
+ " row format delimited fields terminated by ','"
+ )
+
+ sql("LOAD DATA LOCAL INPATH '" + currentDirectory + "/src/test/resources/100_olap.csv' INTO " +
+ "table Carbon_automation_hive ")
+
+ sql(
+ "create table if not exists Carbon_automation_hive2(imei string,deviceInformationId int," +
+ "MAC string,deviceColor string,device_backColor string,modelId string,marketName " +
+ "string,AMSize string,ROMSize string,CUPAudit string,CPIClocked string,series string," +
+ "productionDate timestamp,bomCode string,internalModels string, deliveryTime string, " +
+ "channelsId string, channelsName string , deliveryAreaId string, deliveryCountry " +
+ "string, deliveryProvince string, deliveryCity string,deliveryDistrict string, " +
+ "deliveryStreet string, oxSingleNumber string,contractNumber int, ActiveCheckTime string, ActiveAreaId " +
+ "string, ActiveCountry string, ActiveProvince string, Activecity string, ActiveDistrict" +
+ " string, ActiveStreet string, ActiveOperatorId string, Active_releaseId string, " +
+ "Active_EMUIVersion string, Active_operaSysVersion string, Active_BacVerNumber string, " +
+ "Active_BacFlashVer string, Active_webUIVersion string, Active_webUITypeCarrVer string," +
+ "Active_webTypeDataVerNumber string, Active_operatorsVersion string, " +
+ "Active_phonePADPartitionedVersions string, Latest_YEAR int, Latest_MONTH int, " +
+ "Latest_DAY int, Latest_HOUR string, Latest_areaId string, Latest_country string, " +
+ "Latest_province string, Latest_city string, Latest_district string, Latest_street " +
+ "string, Latest_releaseId string, Latest_EMUIVersion string, Latest_operaSysVersion " +
+ "string, Latest_BacVerNumber string, Latest_BacFlashVer string, Latest_webUIVersion " +
+ "string, Latest_webUITypeCarrVer string, Latest_webTypeDataVerNumber string, " +
+ "Latest_operatorsVersion string, Latest_phonePADPartitionedVersions string, " +
+ "Latest_operatorId string, gamePointId int,gamePointDescription string" +
+ ") row format delimited fields terminated by ','"
+ )
+ sql("LOAD DATA LOCAL INPATH '" + currentDirectory + "/src/test/resources/100_olap.csv' INTO " +
+ "table Carbon_automation_hive2 ")
} catch {
- case e: Exception => print("ERROR: DROP Carbon_automation_test2 ")
+ case e: Exception => print("ERROR : " + e.getMessage)
}
}
override def afterAll {
//CarbonProperties.getInstance().addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT, "dd-MM-yyyy")
try {
- sql("drop cube Carbon_automation_test2")
+ sql("drop table Carbon_automation_test2")
+ sql("drop table Carbon_automation_hive")
+ sql("drop table Carbon_automation_hive2")
} catch {
- case e: Exception => print("ERROR: DROP Carbon_automation_test2 ")
+ case e: Exception => print("ERROR : " + e.getMessage)
}
}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/integration-testcases/src/test/scala/org/carbondata/spark/testsuite/allqueries/AllDataTypesTestCase6.scala
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/7f722186/integration/spark/src/main/java/org/carbondata/integration/spark/merger/RowResultMerger.java
----------------------------------------------------------------------