[GitHub] [carbondata] akkio-97 opened a new pull request #3773: [CARBONDATA-3830]Presto complex columns read support

classic Classic list List threaded Threaded
112 messages Options
123456
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3773: [CARBONDATA-3830]Presto complex columns read support

GitBox

CarbonDataQA1 commented on pull request #3773:
URL: https://github.com/apache/carbondata/pull/3773#issuecomment-652346179


   Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/3285/
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3773: [CARBONDATA-3830]Presto complex columns read support

GitBox
In reply to this post by GitBox

CarbonDataQA1 commented on pull request #3773:
URL: https://github.com/apache/carbondata/pull/3773#issuecomment-652346497


   Build Success with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/1548/
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] akkio-97 commented on a change in pull request #3773: [CARBONDATA-3830]Presto complex columns read support

GitBox
In reply to this post by GitBox

akkio-97 commented on a change in pull request #3773:
URL: https://github.com/apache/carbondata/pull/3773#discussion_r448303815



##########
File path: core/src/main/java/org/apache/carbondata/core/scan/collector/impl/DictionaryBasedVectorResultCollector.java
##########
@@ -98,6 +98,14 @@ void prepareDimensionAndMeasureColumnVectors() {
         columnVectorInfo.dimension = queryDimensions[i];
         columnVectorInfo.ordinal = queryDimensions[i].getDimension().getOrdinal();
         allColumnInfo[queryDimensions[i].getOrdinal()] = columnVectorInfo;
+      } else if (queryDimensions[i].getDimension().isComplex()) {
+        ColumnVectorInfo columnVectorInfo = new ColumnVectorInfo();
+        complexList.add(columnVectorInfo);
+        columnVectorInfo.dimension = queryDimensions[i];
+        columnVectorInfo.ordinal = queryDimensions[i].getDimension().getOrdinal();
+        columnVectorInfo.genericQueryType =
+            executionInfo.getComlexDimensionInfoMap().get(columnVectorInfo.ordinal);
+        allColumnInfo[queryDimensions[i].getOrdinal()] = columnVectorInfo;

Review comment:
       done




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3773: [CARBONDATA-3830]Presto complex columns read support

GitBox
In reply to this post by GitBox

CarbonDataQA1 commented on pull request #3773:
URL: https://github.com/apache/carbondata/pull/3773#issuecomment-652375948


   Build Failed  with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/3287/
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3773: [CARBONDATA-3830]Presto complex columns read support

GitBox
In reply to this post by GitBox

CarbonDataQA1 commented on pull request #3773:
URL: https://github.com/apache/carbondata/pull/3773#issuecomment-652377422


   Build Failed  with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/1550/
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] akkio-97 commented on a change in pull request #3773: [CARBONDATA-3830]Presto complex columns read support

GitBox
In reply to this post by GitBox

akkio-97 commented on a change in pull request #3773:
URL: https://github.com/apache/carbondata/pull/3773#discussion_r448303815



##########
File path: core/src/main/java/org/apache/carbondata/core/scan/collector/impl/DictionaryBasedVectorResultCollector.java
##########
@@ -98,6 +98,14 @@ void prepareDimensionAndMeasureColumnVectors() {
         columnVectorInfo.dimension = queryDimensions[i];
         columnVectorInfo.ordinal = queryDimensions[i].getDimension().getOrdinal();
         allColumnInfo[queryDimensions[i].getOrdinal()] = columnVectorInfo;
+      } else if (queryDimensions[i].getDimension().isComplex()) {
+        ColumnVectorInfo columnVectorInfo = new ColumnVectorInfo();
+        complexList.add(columnVectorInfo);
+        columnVectorInfo.dimension = queryDimensions[i];
+        columnVectorInfo.ordinal = queryDimensions[i].getDimension().getOrdinal();
+        columnVectorInfo.genericQueryType =
+            executionInfo.getComlexDimensionInfoMap().get(columnVectorInfo.ordinal);
+        allColumnInfo[queryDimensions[i].getOrdinal()] = columnVectorInfo;

Review comment:
       Why should that block be removed?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] akkio-97 commented on pull request #3773: [CARBONDATA-3830]Presto complex columns read support

GitBox
In reply to this post by GitBox

akkio-97 commented on pull request #3773:
URL: https://github.com/apache/carbondata/pull/3773#issuecomment-652417278


   retest this please


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3773: [CARBONDATA-3830]Presto complex columns read support

GitBox
In reply to this post by GitBox

CarbonDataQA1 commented on pull request #3773:
URL: https://github.com/apache/carbondata/pull/3773#issuecomment-652497582


   Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/3288/
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3773: [CARBONDATA-3830]Presto complex columns read support

GitBox
In reply to this post by GitBox

CarbonDataQA1 commented on pull request #3773:
URL: https://github.com/apache/carbondata/pull/3773#issuecomment-653065406


   Build Failed  with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/1555/
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3773: [CARBONDATA-3830]Presto complex columns read support

GitBox
In reply to this post by GitBox

CarbonDataQA1 commented on pull request #3773:
URL: https://github.com/apache/carbondata/pull/3773#issuecomment-653085499


   Build Failed  with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/3292/
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] akkio-97 commented on pull request #3773: [CARBONDATA-3830]Presto complex columns read support

GitBox
In reply to this post by GitBox

akkio-97 commented on pull request #3773:
URL: https://github.com/apache/carbondata/pull/3773#issuecomment-653212349


   retest this please


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3773: [CARBONDATA-3830]Presto complex columns read support

GitBox
In reply to this post by GitBox

CarbonDataQA1 commented on pull request #3773:
URL: https://github.com/apache/carbondata/pull/3773#issuecomment-653254442


   Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/3295/
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3773: [CARBONDATA-3830]Presto complex columns read support

GitBox
In reply to this post by GitBox

CarbonDataQA1 commented on pull request #3773:
URL: https://github.com/apache/carbondata/pull/3773#issuecomment-653254762


   Build Success with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/1558/
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] ajantha-bhat commented on a change in pull request #3773: [CARBONDATA-3830]Presto complex columns read support

GitBox
In reply to this post by GitBox

ajantha-bhat commented on a change in pull request #3773:
URL: https://github.com/apache/carbondata/pull/3773#discussion_r461597459



##########
File path: core/src/main/java/org/apache/carbondata/core/datastore/page/encoding/FillVector.java
##########
@@ -0,0 +1,345 @@
+/*
+ * 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.apache.carbondata.core.datastore.page.encoding;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.BitSet;
+
+import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
+import org.apache.carbondata.core.metadata.datatype.DecimalConverterFactory;
+import org.apache.carbondata.core.scan.result.vector.CarbonColumnVector;
+import org.apache.carbondata.core.scan.result.vector.ColumnVectorInfo;
+import org.apache.carbondata.core.scan.result.vector.impl.CarbonColumnVectorImpl;
+import org.apache.carbondata.core.util.ByteUtil;
+
+public class FillVector {

Review comment:
       check if it can be a static class

##########
File path: core/src/main/java/org/apache/carbondata/core/datastore/page/encoding/FillVector.java
##########
@@ -0,0 +1,345 @@
+/*
+ * 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.apache.carbondata.core.datastore.page.encoding;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.BitSet;
+
+import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
+import org.apache.carbondata.core.metadata.datatype.DecimalConverterFactory;
+import org.apache.carbondata.core.scan.result.vector.CarbonColumnVector;
+import org.apache.carbondata.core.scan.result.vector.ColumnVectorInfo;
+import org.apache.carbondata.core.scan.result.vector.impl.CarbonColumnVectorImpl;
+import org.apache.carbondata.core.util.ByteUtil;
+
+public class FillVector {
+  private byte[] pageData;
+  private float floatFactor = 0;
+  private double factor = 0;
+  private ColumnVectorInfo vectorInfo;
+  private BitSet nullBits;
+
+  public FillVector(byte[] pageData, ColumnVectorInfo vectorInfo, BitSet nullBits) {
+    this.pageData = pageData;
+    this.vectorInfo = vectorInfo;
+    this.nullBits = nullBits;
+  }
+
+  public void setFactor(double factor) {
+    this.factor = factor;
+  }
+
+  public void setFloatFactor(float floatFactor) {
+    this.floatFactor = floatFactor;
+  }
+
+  public void basedOnType(CarbonColumnVector vector, DataType vectorDataType, int pageSize,
+      DataType pageDataType) {
+    if (vectorInfo.vector.getColumnVector() != null && ((CarbonColumnVectorImpl) vectorInfo.vector
+        .getColumnVector()).isComplex()) {
+      fillComplexType(vector.getColumnVector(), pageDataType);
+    } else {
+      fillPrimitiveType(vector, vectorDataType, pageSize, pageDataType);
+      vector.setIndex(0);
+    }
+  }
+
+  private void fillComplexType(CarbonColumnVector vector, DataType pageDataType) {
+    CarbonColumnVectorImpl vectorImpl = (CarbonColumnVectorImpl) vector;
+    if (vector != null && vector.getChildrenVector() != null) {
+      ArrayList<Integer> childElements = ((CarbonColumnVectorImpl) vector).getChildrenElements();
+      for (int i = 0; i < childElements.size(); i++) {
+        int count = childElements.get(i);
+        typeComplexObject(vectorImpl.getChildrenVector(), count, pageDataType);
+        vector.putArrayObject();
+      }
+    }
+  }
+
+  private void fillPrimitiveType(CarbonColumnVector vector, DataType vectorDataType, int pageSize,

Review comment:
       too big method, check if can be modularized.

##########
File path: core/src/main/java/org/apache/carbondata/core/datastore/page/encoding/compress/DirectCompressCodec.java
##########
@@ -32,29 +29,27 @@
 import org.apache.carbondata.core.datastore.page.ColumnPageValueConverter;
 import org.apache.carbondata.core.datastore.page.LazyColumnPage;
 import org.apache.carbondata.core.datastore.page.VarLengthColumnPageBase;
-import org.apache.carbondata.core.datastore.page.encoding.ColumnPageCodec;
-import org.apache.carbondata.core.datastore.page.encoding.ColumnPageDecoder;
-import org.apache.carbondata.core.datastore.page.encoding.ColumnPageEncoder;
-import org.apache.carbondata.core.datastore.page.encoding.ColumnPageEncoderMeta;
+import org.apache.carbondata.core.datastore.page.encoding.*;
 import org.apache.carbondata.core.metadata.datatype.DataType;
 import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.datatype.DecimalConverterFactory;
 import org.apache.carbondata.core.scan.result.vector.CarbonColumnVector;
 import org.apache.carbondata.core.scan.result.vector.ColumnVectorInfo;
+import org.apache.carbondata.core.scan.result.vector.impl.CarbonColumnVectorImpl;
 import org.apache.carbondata.core.scan.result.vector.impl.directread.ColumnarVectorWrapperDirectFactory;
 import org.apache.carbondata.core.scan.result.vector.impl.directread.ConvertibleVector;
 import org.apache.carbondata.core.scan.result.vector.impl.directread.SequentialFill;
-import org.apache.carbondata.core.util.ByteUtil;
 import org.apache.carbondata.format.Encoding;
 
 /**
  * This codec directly apply compression on the input data
  */
+//public class DirectCompressCodec extends SerializeComplexTypes implements ColumnPageCodec {

Review comment:
       revert it and below super() also

##########
File path: core/src/main/java/org/apache/carbondata/core/datastore/page/encoding/compress/DirectCompressCodec.java
##########
@@ -246,7 +241,28 @@ public void decodeAndFillVector(byte[] pageData, ColumnVectorInfo vectorInfo, Bi
       vector = ColumnarVectorWrapperDirectFactory
           .getDirectVectorWrapperFactory(vector, vectorInfo.invertedIndex, nullBits, deletedRows,
               true, false);
-      fillVector(pageData, vector, vectorDataType, pageDataType, pageSize, vectorInfo, nullBits);
+      Deque<CarbonColumnVectorImpl> vectorStack = vectorInfo.getVectorStack();
+      // initialize vectorStack if null
+      if (vectorStack == null && vectorInfo.vector.getColumnVector() != null) {
+        vectorStack = new ArrayDeque<CarbonColumnVectorImpl>();
+        vectorStack.push((CarbonColumnVectorImpl) vectorInfo.vector.getColumnVector());
+        vectorInfo.setVectorStack(vectorStack);

Review comment:
       please add comments and how do we make sure this is only for parent vector ?

##########
File path: core/src/main/java/org/apache/carbondata/core/metadata/schema/table/column/CarbonDimension.java
##########
@@ -39,6 +39,16 @@
    */
   private int keyOrdinal;
 
+  private byte[] childElements;

Review comment:
       This looks to be row level info. schema should not care about row level children.
   
   please remove it

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/executor/impl/AbstractQueryExecutor.java
##########
@@ -508,7 +508,8 @@ private BlockExecutionInfo getBlockExecutionInfoForBlock(QueryModel queryModel,
     int[] dimensionChunkIndexes = QueryUtil.getDimensionChunkIndexes(projectDimensions,
         segmentProperties.getDimensionOrdinalToChunkMapping(),
         currentBlockFilterDimensions, allProjectionListDimensionIndexes);
-    ReusableDataBuffer[] dimensionBuffer = new ReusableDataBuffer[projectDimensions.size()];
+    // 4 because each column(including itself) can have a maximum of 3 nested complex levels
+    ReusableDataBuffer[] dimensionBuffer = new ReusableDataBuffer[projectDimensions.size() * 4];

Review comment:
       Should calculate the total dimensions when flattened and use it.
   always hardcoding to 4 is bad as if I have 100 primitive column, I waste 300 more.
   
   calculate in init method and keep a class variable.

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/BlockletScannedResult.java
##########
@@ -153,6 +154,8 @@
 
   private ReusableDataBuffer[] measureReusableBuffer;
 
+  int startIndex = 0;

Review comment:
       add a comment what is it and why it is required

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/vector/CarbonColumnVector.java
##########
@@ -114,4 +114,14 @@
 
   void setLazyPage(LazyPageLoader lazyPage);
 
+  CarbonColumnVector getColumnVector();
+
+  CarbonColumnVector getChildrenVector();

Review comment:
       Make this interface a **list** of CarbonColumnVector considering other complex type

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/vector/CarbonColumnVector.java
##########
@@ -114,4 +114,14 @@
 
   void setLazyPage(LazyPageLoader lazyPage);
 
+  CarbonColumnVector getColumnVector();
+
+  CarbonColumnVector getChildrenVector();
+
+  void putArrayObject();
+
+  int getIndex();

Review comment:
       please add comments for interfaces, so the new person who implements will know the usage

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/vector/CarbonColumnVector.java
##########
@@ -114,4 +114,14 @@
 
   void setLazyPage(LazyPageLoader lazyPage);
 
+  CarbonColumnVector getColumnVector();

Review comment:
       to get the original vector from wrapper ?

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/vector/impl/CarbonColumnVectorImpl.java
##########
@@ -70,10 +72,31 @@
 
   private CarbonColumnVector dictionaryVector;
 
+  private CarbonColumnVectorImpl childrenVector;
+
   private LazyPageLoader lazyPage;
 
   private boolean loaded;
 
+  public boolean isComplex() {
+    return false;

Review comment:
       please check if can add
   
   public DataType getDataType() {
       return dataType;
     }
   
   and check it is complex or not

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/vector/impl/CarbonColumnVectorImpl.java
##########
@@ -334,6 +409,10 @@ public DataType getType() {
     return dataType;
   }
 
+  public String getDataTypeName() {
+    return "";

Review comment:
       getDataType itself

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/vector/impl/directread/ColumnarVectorWrapperDirectWithDeleteDelta.java
##########
@@ -41,6 +41,31 @@ public ColumnarVectorWrapperDirectWithDeleteDelta(CarbonColumnVector vectorWrapp
     this.nullBits = nullBits;
   }
 
+  @Override
+  public CarbonColumnVector getColumnVector() {
+    return null;

Review comment:
       Throw unsupported exception for all these

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/vector/impl/directread/ColumnarVectorWrapperDirectWithInvertedIndex.java
##########
@@ -40,6 +40,31 @@ public ColumnarVectorWrapperDirectWithInvertedIndex(CarbonColumnVector columnVec
     this.isnullBitsExists = isnullBitsExists;
   }
 
+  @Override
+  public CarbonColumnVector getColumnVector() {
+    return null;
+  }

Review comment:
       same as above

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/vector/impl/directread/ColumnarVectorWrapperDirectWithDeleteDelta.java
##########
@@ -41,6 +41,31 @@ public ColumnarVectorWrapperDirectWithDeleteDelta(CarbonColumnVector vectorWrapp
     this.nullBits = nullBits;
   }
 
+  @Override
+  public CarbonColumnVector getColumnVector() {
+    return null;

Review comment:
       And all the below files where it is not applicable

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/vector/impl/directread/ColumnarVectorWrapperDirectWithDeleteDelta.java
##########
@@ -41,6 +41,31 @@ public ColumnarVectorWrapperDirectWithDeleteDelta(CarbonColumnVector vectorWrapp
     this.nullBits = nullBits;
   }
 
+  @Override
+  public CarbonColumnVector getColumnVector() {
+    return null;

Review comment:
       Also check if it is required by the majority, if not. just modify in implementation not the interface.

##########
File path: integration/presto/src/main/java/org/apache/carbondata/presto/PrestoCarbonVectorizedRecordReader.java
##########
@@ -176,8 +191,16 @@ private void initBatch() {
     for (int i = 0; i < queryDimension.size(); i++) {
       ProjectionDimension dim = queryDimension.get(i);
       if (dim.getDimension().isComplex()) {
+        List<CarbonDimension> childDimensions =
+                dim.getDimension().getListOfChildDimensions();
+        ArrayList<StructField> childFields = new ArrayList<StructField>();
+        for (int ind = 0; ind < childDimensions.size(); ind++) {

Review comment:
       *index

##########
File path: integration/presto/src/main/prestosql/org/apache/carbondata/presto/readers/ArrayStreamReader.java
##########
@@ -0,0 +1,145 @@
+/*
+ * 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.apache.carbondata.presto.readers;
+
+import io.prestosql.spi.type.*;
+
+import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
+import org.apache.carbondata.core.metadata.datatype.StructField;
+import org.apache.carbondata.core.scan.result.vector.impl.CarbonColumnVectorImpl;
+
+import io.prestosql.spi.block.Block;
+import io.prestosql.spi.block.BlockBuilder;
+
+import org.apache.carbondata.presto.CarbonVectorBatch;
+
+/**
+ * Class to read the Array Stream
+ */
+
+public class ArrayStreamReader extends CarbonColumnVectorImpl implements PrestoVectorBlockBuilder {
+
+  protected int batchSize;
+
+  protected Type type;
+  protected BlockBuilder builder;
+  Block childBlock = null;
+  private int index = 0;
+
+  public ArrayStreamReader(int batchSize, DataType dataType, StructField field) {
+    super(batchSize, dataType);
+    this.batchSize = batchSize;
+    this.type = getArrayOfType(field, dataType);
+    setChildrenVector(
+        CarbonVectorBatch.createDirectStreamReader(this.batchSize, field.getDataType(), field));
+    this.builder = type.createBlockBuilder(null, batchSize);
+  }
+
+  public int getIndex() {
+    return index;
+  }
+
+  public void setIndex(int index) {
+    this.index = index;
+  }
+
+  public String getDataTypeName() {
+    return "ARRAY";
+  }
+
+  Type getArrayOfType(StructField field, DataType dataType) {
+    if (dataType == DataTypes.STRING) {
+      return new ArrayType(VarcharType.VARCHAR);
+    } else if (dataType == DataTypes.INT) {
+      return new ArrayType(IntegerType.INTEGER);
+    } else if (dataType == DataTypes.LONG) {
+      return new ArrayType(BigintType.BIGINT);
+    } else if (dataType == DataTypes.DOUBLE) {
+      return new ArrayType(DoubleType.DOUBLE);
+    } else if (dataType == DataTypes.FLOAT) {
+      return new ArrayType(RealType.REAL);
+    } else if (dataType == DataTypes.BOOLEAN) {
+      return new ArrayType(BooleanType.BOOLEAN);
+    } else {

Review comment:
       * byte us missing ?

##########
File path: integration/presto/src/main/prestosql/org/apache/carbondata/presto/readers/ArrayStreamReader.java
##########
@@ -0,0 +1,145 @@
+/*
+ * 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.apache.carbondata.presto.readers;
+
+import io.prestosql.spi.type.*;
+
+import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
+import org.apache.carbondata.core.metadata.datatype.StructField;
+import org.apache.carbondata.core.scan.result.vector.impl.CarbonColumnVectorImpl;
+
+import io.prestosql.spi.block.Block;
+import io.prestosql.spi.block.BlockBuilder;
+
+import org.apache.carbondata.presto.CarbonVectorBatch;
+
+/**
+ * Class to read the Array Stream
+ */
+
+public class ArrayStreamReader extends CarbonColumnVectorImpl implements PrestoVectorBlockBuilder {
+
+  protected int batchSize;
+
+  protected Type type;
+  protected BlockBuilder builder;
+  Block childBlock = null;
+  private int index = 0;
+
+  public ArrayStreamReader(int batchSize, DataType dataType, StructField field) {
+    super(batchSize, dataType);
+    this.batchSize = batchSize;
+    this.type = getArrayOfType(field, dataType);
+    setChildrenVector(
+        CarbonVectorBatch.createDirectStreamReader(this.batchSize, field.getDataType(), field));
+    this.builder = type.createBlockBuilder(null, batchSize);
+  }
+
+  public int getIndex() {
+    return index;
+  }
+
+  public void setIndex(int index) {
+    this.index = index;
+  }
+
+  public String getDataTypeName() {
+    return "ARRAY";
+  }
+
+  Type getArrayOfType(StructField field, DataType dataType) {
+    if (dataType == DataTypes.STRING) {
+      return new ArrayType(VarcharType.VARCHAR);
+    } else if (dataType == DataTypes.INT) {
+      return new ArrayType(IntegerType.INTEGER);
+    } else if (dataType == DataTypes.LONG) {
+      return new ArrayType(BigintType.BIGINT);
+    } else if (dataType == DataTypes.DOUBLE) {
+      return new ArrayType(DoubleType.DOUBLE);
+    } else if (dataType == DataTypes.FLOAT) {
+      return new ArrayType(RealType.REAL);
+    } else if (dataType == DataTypes.BOOLEAN) {
+      return new ArrayType(BooleanType.BOOLEAN);
+    } else {

Review comment:
       * byte us missing ? *tiny int

##########
File path: integration/presto/src/main/prestosql/org/apache/carbondata/presto/readers/ArrayStreamReader.java
##########
@@ -0,0 +1,145 @@
+/*
+ * 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.apache.carbondata.presto.readers;
+
+import io.prestosql.spi.type.*;
+
+import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
+import org.apache.carbondata.core.metadata.datatype.StructField;
+import org.apache.carbondata.core.scan.result.vector.impl.CarbonColumnVectorImpl;
+
+import io.prestosql.spi.block.Block;
+import io.prestosql.spi.block.BlockBuilder;
+
+import org.apache.carbondata.presto.CarbonVectorBatch;
+
+/**
+ * Class to read the Array Stream
+ */
+
+public class ArrayStreamReader extends CarbonColumnVectorImpl implements PrestoVectorBlockBuilder {
+
+  protected int batchSize;
+
+  protected Type type;
+  protected BlockBuilder builder;
+  Block childBlock = null;
+  private int index = 0;
+
+  public ArrayStreamReader(int batchSize, DataType dataType, StructField field) {
+    super(batchSize, dataType);
+    this.batchSize = batchSize;
+    this.type = getArrayOfType(field, dataType);
+    setChildrenVector(
+        CarbonVectorBatch.createDirectStreamReader(this.batchSize, field.getDataType(), field));
+    this.builder = type.createBlockBuilder(null, batchSize);
+  }
+
+  public int getIndex() {
+    return index;
+  }
+
+  public void setIndex(int index) {
+    this.index = index;
+  }
+
+  public String getDataTypeName() {
+    return "ARRAY";
+  }
+
+  Type getArrayOfType(StructField field, DataType dataType) {
+    if (dataType == DataTypes.STRING) {
+      return new ArrayType(VarcharType.VARCHAR);
+    } else if (dataType == DataTypes.INT) {
+      return new ArrayType(IntegerType.INTEGER);
+    } else if (dataType == DataTypes.LONG) {
+      return new ArrayType(BigintType.BIGINT);
+    } else if (dataType == DataTypes.DOUBLE) {
+      return new ArrayType(DoubleType.DOUBLE);
+    } else if (dataType == DataTypes.FLOAT) {
+      return new ArrayType(RealType.REAL);
+    } else if (dataType == DataTypes.BOOLEAN) {
+      return new ArrayType(BooleanType.BOOLEAN);
+    } else {
+      StructField childField = field.getChildren().get(0);
+      return new ArrayType(getArrayOfType(childField, childField.getDataType()));
+    }
+  }
+
+  @Override
+  public Block buildBlock() {
+    return builder.build();
+  }
+
+  public boolean isComplex() {
+    return true;
+  }
+
+  @Override
+  public void setBatchSize(int batchSize) {
+    this.batchSize = batchSize;
+  }
+
+  @Override
+  public void putObject(int rowId, Object value) {
+    if (value == null) {
+      putNull(rowId);
+    } else {
+      getChildrenVector().putObject(rowId, value);
+    }
+  }
+
+  public void putArrayObject() {
+    if (this.getType().getName() == "ARRAY") {
+      childBlock = ((ArrayStreamReader) getChildrenVector()).buildBlock();
+    } else if (this.getType().getName() == "STRING") {

Review comment:
       handle for tiny int / byte

##########
File path: integration/presto/src/test/scala/org/apache/carbondata/presto/integrationtest/PrestoReadTableFilesTest.scala
##########
@@ -0,0 +1,443 @@
+package org.apache.carbondata.presto.integrationtest
+
+import java.io.File
+import java.sql.{SQLException, Timestamp}
+import java.util
+import java.util.Arrays.asList
+
+import io.prestosql.jdbc.PrestoArray
+import org.apache.carbondata.common.logging.LogServiceFactory
+import org.apache.carbondata.core.constants.CarbonCommonConstants
+import org.apache.carbondata.core.datastore.filesystem.CarbonFile
+import org.apache.carbondata.core.datastore.impl.FileFactory
+import org.apache.carbondata.core.metadata.datatype.{DataTypes, Field}
+import org.apache.carbondata.core.util.{CarbonProperties, CarbonUtil}
+import org.apache.carbondata.presto.server.PrestoServer
+import org.apache.carbondata.sdk.file.{CarbonWriter, Schema}
+import org.apache.commons.io.FileUtils
+import org.apache.commons.lang.RandomStringUtils
+import org.apache.spark.sql.Row
+import org.scalatest.{BeforeAndAfterAll, FunSuiteLike, BeforeAndAfterEach}
+
+import scala.collection.mutable
+import scala.collection.JavaConverters._
+class PrestoReadTableFilesTest extends FunSuiteLike with BeforeAndAfterAll with BeforeAndAfterEach{
+  private val logger = LogServiceFactory
+    .getLogService(classOf[PrestoTestNonTransactionalTableFiles].getCanonicalName)
+
+  private val rootPath = new File(this.getClass.getResource("/").getPath
+    + "../../../..").getCanonicalPath
+  private val storePath = s"$rootPath/integration/presto/target/store"
+  private val systemPath = s"$rootPath/integration/presto/target/system"
+  private var writerPath = storePath + "/sdk_output/files"
+  private val prestoServer = new PrestoServer
+  private var varcharString = new String
+
+  override def beforeAll: Unit = {
+    CarbonProperties.getInstance().addProperty(CarbonCommonConstants.CARBON_WRITTEN_BY_APPNAME,
+      "Presto")
+    CarbonProperties.getInstance().addProperty(CarbonCommonConstants.CARBON_WRITTEN_BY_APPNAME,
+      "Presto")
+    val map = new util.HashMap[String, String]()
+    map.put("hive.metastore", "file")
+    map.put("hive.metastore.catalog.dir", s"file://$storePath")
+
+    prestoServer.startServer("sdk_output", map)
+  }
+
+  override def afterAll(): Unit = {
+    prestoServer.stopServer()
+    CarbonUtil.deleteFoldersAndFiles(FileFactory.getCarbonFile(storePath))
+  }
+
+  private def createComplexTableForSingleLevelArray = {
+    prestoServer.execute("drop table if exists sdk_output.files")
+    prestoServer.execute("drop schema if exists sdk_output")
+    prestoServer.execute("create schema sdk_output")
+    prestoServer
+      .execute(
+        "create table sdk_output.files(stringCol varchar, intCol int, doubleCol double, realCol real, boolCol boolean, arrayStringCol1 array(varchar), arrayStringcol2 array(varchar), arrayIntCol array(int), arrayBigIntCol array(bigint), arrayRealCol array(real), arrayDoubleCol array(double), arrayBooleanCol array(boolean)) with(format='CARBON') ")
+  }
+
+  private def createComplexTableFor2LevelArray = {
+    prestoServer.execute("drop table if exists sdk_output.files2")
+    prestoServer.execute("drop schema if exists sdk_output")
+    prestoServer.execute("create schema sdk_output")
+        prestoServer
+      .execute(
+        "create table sdk_output.files2(arrayArrayInt array(array(int)), arrayArrayBigInt array(array(bigint)), arrayArrayReal array(array(real)), arrayArrayDouble array(array(double)), arrayArrayString array(array(varchar)), arrayArrayBoolean array(array(boolean))) with(format='CARBON') ")
+  }
+
+  private def createComplexTableFor3LevelArray = {
+    prestoServer.execute("drop table if exists sdk_output.files3")
+    prestoServer.execute("drop schema if exists sdk_output")
+    prestoServer.execute("create schema sdk_output")
+    prestoServer
+        .execute(
+          "create table sdk_output.files3(array3_Int array(array(array(int))), array3_BigInt array(array(array(bigint))), array3_Real array(array(array(real))), array3_Double array(array(array(double))), array3_String array(array(array(varchar))), array3_Boolean array(array(array(boolean))) ) with(format='CARBON') ")
+    }
+
+  def buildComplexTestForSingleLevelArray(): Any = {
+    FileUtils.deleteDirectory(new File(writerPath))
+    createComplexTableForSingleLevelArray
+    import java.io.IOException
+    val source = new File(this.getClass.getResource("/").getPath + "../../" + "/temp/table1").getCanonicalPath
+    val srcDir = new File(source)
+    val destination = new File(this.getClass.getResource("/").getPath + "../../" + "/target/store/sdk_output/files/").getCanonicalPath
+    val destDir = new File(destination)
+    try FileUtils.copyDirectory(srcDir, destDir)
+    catch {
+      case e: IOException =>
+        e.printStackTrace()
+    }
+  }
+
+  def buildComplexTestFor2LevelArray(): Any = {
+    writerPath = storePath + "/sdk_output/files2"
+    FileUtils.deleteDirectory(new File(writerPath))
+    createComplexTableFor2LevelArray
+    import java.io.IOException
+    val source = new File(this.getClass.getResource("/").getPath + "../../" + "/temp/table2").getCanonicalPath
+    val srcDir = new File(source)
+    val destination = new File(this.getClass.getResource("/").getPath + "../../" + "/target/store/sdk_output/files2/").getCanonicalPath
+    val destDir = new File(destination)
+    try FileUtils.copyDirectory(srcDir, destDir)
+    catch {
+      case e: IOException =>
+        e.printStackTrace()

Review comment:
       no use of printing trace in automation. throw an exception or fail test case

##########
File path: integration/presto/src/test/scala/org/apache/carbondata/presto/integrationtest/PrestoReadTableFilesTest.scala
##########
@@ -0,0 +1,443 @@
+package org.apache.carbondata.presto.integrationtest
+
+import java.io.File
+import java.sql.{SQLException, Timestamp}
+import java.util
+import java.util.Arrays.asList
+
+import io.prestosql.jdbc.PrestoArray
+import org.apache.carbondata.common.logging.LogServiceFactory
+import org.apache.carbondata.core.constants.CarbonCommonConstants
+import org.apache.carbondata.core.datastore.filesystem.CarbonFile
+import org.apache.carbondata.core.datastore.impl.FileFactory
+import org.apache.carbondata.core.metadata.datatype.{DataTypes, Field}
+import org.apache.carbondata.core.util.{CarbonProperties, CarbonUtil}
+import org.apache.carbondata.presto.server.PrestoServer
+import org.apache.carbondata.sdk.file.{CarbonWriter, Schema}
+import org.apache.commons.io.FileUtils
+import org.apache.commons.lang.RandomStringUtils
+import org.apache.spark.sql.Row
+import org.scalatest.{BeforeAndAfterAll, FunSuiteLike, BeforeAndAfterEach}
+
+import scala.collection.mutable
+import scala.collection.JavaConverters._
+class PrestoReadTableFilesTest extends FunSuiteLike with BeforeAndAfterAll with BeforeAndAfterEach{
+  private val logger = LogServiceFactory
+    .getLogService(classOf[PrestoTestNonTransactionalTableFiles].getCanonicalName)
+
+  private val rootPath = new File(this.getClass.getResource("/").getPath
+    + "../../../..").getCanonicalPath
+  private val storePath = s"$rootPath/integration/presto/target/store"
+  private val systemPath = s"$rootPath/integration/presto/target/system"
+  private var writerPath = storePath + "/sdk_output/files"
+  private val prestoServer = new PrestoServer
+  private var varcharString = new String
+
+  override def beforeAll: Unit = {
+    CarbonProperties.getInstance().addProperty(CarbonCommonConstants.CARBON_WRITTEN_BY_APPNAME,
+      "Presto")
+    CarbonProperties.getInstance().addProperty(CarbonCommonConstants.CARBON_WRITTEN_BY_APPNAME,
+      "Presto")
+    val map = new util.HashMap[String, String]()
+    map.put("hive.metastore", "file")
+    map.put("hive.metastore.catalog.dir", s"file://$storePath")
+
+    prestoServer.startServer("sdk_output", map)
+  }
+
+  override def afterAll(): Unit = {
+    prestoServer.stopServer()
+    CarbonUtil.deleteFoldersAndFiles(FileFactory.getCarbonFile(storePath))
+  }
+
+  private def createComplexTableForSingleLevelArray = {
+    prestoServer.execute("drop table if exists sdk_output.files")
+    prestoServer.execute("drop schema if exists sdk_output")
+    prestoServer.execute("create schema sdk_output")
+    prestoServer
+      .execute(
+        "create table sdk_output.files(stringCol varchar, intCol int, doubleCol double, realCol real, boolCol boolean, arrayStringCol1 array(varchar), arrayStringcol2 array(varchar), arrayIntCol array(int), arrayBigIntCol array(bigint), arrayRealCol array(real), arrayDoubleCol array(double), arrayBooleanCol array(boolean)) with(format='CARBON') ")
+  }
+
+  private def createComplexTableFor2LevelArray = {
+    prestoServer.execute("drop table if exists sdk_output.files2")
+    prestoServer.execute("drop schema if exists sdk_output")
+    prestoServer.execute("create schema sdk_output")
+        prestoServer
+      .execute(
+        "create table sdk_output.files2(arrayArrayInt array(array(int)), arrayArrayBigInt array(array(bigint)), arrayArrayReal array(array(real)), arrayArrayDouble array(array(double)), arrayArrayString array(array(varchar)), arrayArrayBoolean array(array(boolean))) with(format='CARBON') ")
+  }
+
+  private def createComplexTableFor3LevelArray = {
+    prestoServer.execute("drop table if exists sdk_output.files3")
+    prestoServer.execute("drop schema if exists sdk_output")
+    prestoServer.execute("create schema sdk_output")
+    prestoServer
+        .execute(
+          "create table sdk_output.files3(array3_Int array(array(array(int))), array3_BigInt array(array(array(bigint))), array3_Real array(array(array(real))), array3_Double array(array(array(double))), array3_String array(array(array(varchar))), array3_Boolean array(array(array(boolean))) ) with(format='CARBON') ")
+    }
+
+  def buildComplexTestForSingleLevelArray(): Any = {
+    FileUtils.deleteDirectory(new File(writerPath))
+    createComplexTableForSingleLevelArray
+    import java.io.IOException
+    val source = new File(this.getClass.getResource("/").getPath + "../../" + "/temp/table1").getCanonicalPath
+    val srcDir = new File(source)
+    val destination = new File(this.getClass.getResource("/").getPath + "../../" + "/target/store/sdk_output/files/").getCanonicalPath
+    val destDir = new File(destination)
+    try FileUtils.copyDirectory(srcDir, destDir)
+    catch {
+      case e: IOException =>
+        e.printStackTrace()
+    }
+  }
+
+  def buildComplexTestFor2LevelArray(): Any = {
+    writerPath = storePath + "/sdk_output/files2"
+    FileUtils.deleteDirectory(new File(writerPath))
+    createComplexTableFor2LevelArray
+    import java.io.IOException
+    val source = new File(this.getClass.getResource("/").getPath + "../../" + "/temp/table2").getCanonicalPath
+    val srcDir = new File(source)
+    val destination = new File(this.getClass.getResource("/").getPath + "../../" + "/target/store/sdk_output/files2/").getCanonicalPath
+    val destDir = new File(destination)
+    try FileUtils.copyDirectory(srcDir, destDir)
+    catch {
+      case e: IOException =>
+        e.printStackTrace()
+    }
+  }
+
+  def buildComplexTestFor3LevelArray(): Any = {
+    writerPath = storePath + "/sdk_output/files3"
+    FileUtils.deleteDirectory(new File(writerPath))
+    createComplexTableFor3LevelArray
+    import java.io.IOException
+    val source = new File(this.getClass.getResource("/").getPath + "../../" + "/temp/table3").getCanonicalPath
+    val srcDir = new File(source)
+    val destination = new File(this.getClass.getResource("/").getPath + "../../" + "/target/store/sdk_output/files3/").getCanonicalPath
+    val destDir = new File(destination)
+    try FileUtils.copyDirectory(srcDir, destDir)
+    catch {
+      case e: IOException =>
+        e.printStackTrace()
+    }
+  }
+
+  def cleanTestData(): Unit = {
+    FileUtils.deleteDirectory(new File(writerPath))
+  }
+
+  test("test single-array complex columns") {
+    buildComplexTestForSingleLevelArray()
+    val actualResult: List[Map[String, Any]] = prestoServer
+      .executeQuery("SELECT arrayStringCol2, arrayIntCol, arrayBigIntCol, arrayDoubleCol, arrayRealCol, arrayBooleanCol FROM files")
+
+    // check number of rows
+    assert(actualResult.size == 5)
+
+    // check number of columns in each row
+    assert(actualResult(0).size == 6)
+    assert(actualResult(1).size == 6)
+    assert(actualResult(2).size == 6)
+    assert(actualResult(3).size == 6)
+    assert(actualResult(4).size == 6)
+
+    for( row <- 0 to actualResult.size - 1){
+      var actual1 = (actualResult(row)("arrayStringCol2").asInstanceOf[PrestoArray].getArray()).asInstanceOf[Array[Object]]
+      var actual2 = (actualResult(row)("arrayIntCol").asInstanceOf[PrestoArray].getArray()).asInstanceOf[Array[Object]]
+      var actual3 = (actualResult(row)("arrayBigIntCol").asInstanceOf[PrestoArray].getArray()).asInstanceOf[Array[Object]]
+      var actual4 = (actualResult(row)("arrayDoubleCol").asInstanceOf[PrestoArray].getArray()).asInstanceOf[Array[Object]]
+      var actual5 = (actualResult(row)("arrayRealCol").asInstanceOf[PrestoArray].getArray()).asInstanceOf[Array[Object]]
+      var actual6 = (actualResult(row)("arrayBooleanCol").asInstanceOf[PrestoArray].getArray()).asInstanceOf[Array[Object]]
+
+      if(row == 0){
+        assert(actual1.sameElements(Array("India", "Egypt")))
+        assert(actual2.sameElements(Array(1,2,3)))
+        assert(actual3.sameElements(Array(70000L, 600000000L)))
+        assert(actual4.sameElements(Array(1.1,2.2,3.3)))
+        assert(actual5.sameElements(Array(1.111F,2.2F)))
+        assert(actual6.sameElements(Array(true, false, true)))
+      } else if(row == 1) {
+        assert(actual1.sameElements(Array("Japan", "China", "India")))
+        assert(actual2.sameElements(Array(1,2,3,4)))
+        assert(actual3.sameElements(Array(70000L, 600000000L,8000L)))
+        assert(actual4.sameElements(Array(1.1, 2.2, 4.45, 3.3)))
+        assert(actual5.sameElements(Array(1.1F,2.2F,3.3f)))
+        assert(actual6.sameElements(Array(true, true, true)))
+      } else if(row == 2) {
+        assert(actual1.sameElements(Array("China", "Brazil", "Paris", "France")))
+        assert(actual2.sameElements(Array(1,2,3,4,5)))
+        assert(actual3.sameElements(Array(70000L, 600000000L, 8000L, 9111111111L)))
+        assert(actual4.sameElements(Array(1.1, 2.2, 4.45, 5.5, 3.3)))
+        assert(actual5.sameElements(Array(1.1F, 2.2F, 3.3F, 4.45F)))
+        assert(actual6.sameElements(Array(true, false, true)))
+      } else if(row == 3) {
+        assert(actual1.sameElements(Array("India", "Egypt")))
+        assert(actual2.sameElements(Array(1,2,3)))
+        assert(actual3.sameElements(Array(70000L, 600000000L)))
+        assert(actual4.sameElements(Array(1.1, 2.2, 3.3)))
+        assert(actual5.sameElements(Array(1.1F,2.2F)))
+        assert(actual6.sameElements(Array(true, false, true)))
+      } else if(row == 4) {
+        assert(actual1.sameElements(Array("Japan", "China", "India")))
+        assert(actual2.sameElements(Array(1,2,3,4)))
+        assert(actual3.sameElements(Array(70000L, 600000000L,8000L)))
+        assert(actual4.sameElements(Array(4.0, 1.0, 21.222, 15.231)))
+        assert(actual5.sameElements(Array(1.1F,2.2F,3.3F)))
+        assert(actual6.sameElements(Array(false, false, false)))
+      }
+
+    }
+
+    cleanTestData()
+  }
+
+
+  /*
+  +--------------------------------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------+--------------------------------------------+----------------------------------+--------------------------+
+  |arrayarrayint                               |arrayarraybigint                                                                 |arrayarrayreal                                                 |arrayarraydouble                            |arrayarraystring                  |arrayarrayboolean         |
+  +--------------------------------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------+--------------------------------------------+----------------------------------+--------------------------+
+  |[[1, 2, 3], [4, 5]]                         |[[90000, 600000000], [8000], [911111111]]                                        |[[1.111, 2.2], [9.139, 2.98]]                                  |[[1.111, 2.2], [9.139, 2.98989898]]         |[[Japan, China], [India]]         |[[false, false], [false]] |
+  |[[1, 2, 3], [0, 5], [1, 2, 3, 4, 5], [4, 5]]|[[40000, 600000000, 8000], [9111111111]]                                         |[[1.111, 2.2], [9.139, 2.98], [9.99]]                          |[[1.111, 2.2], [9.139777, 2.98], [9.99888]] |[[China, Brazil], [Paris, France]]|[[false], [true, false]]  |
+  |[[1], [0], [3], [4, 5]]                     |[[5000], [600000000], [8000, 9111111111], [20000], [600000000, 8000, 9111111111]]|[[9.198]]                                                      |[[0.1987979]]                               |[[Japan, China, India]]           |[[false, true, false]]    |
+  |[[0, 9, 0, 1, 3, 2, 3, 4, 7]]               |[[5000, 600087000, 8000, 9111111111, 20000, 600000000, 8000, 977777]]            |[[1.111, 2.2], [9.139, 2.98, 4.67], [2.91, 2.2], [9.139, 2.98]]|[[1.111, 2.0, 4.67, 2.91, 2.2, 9.139, 2.98]]|[[Japan], [China], [India]]       |[[false], [true], [false]]|
+  +--------------------------------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------+--------------------------------------------+----------------------------------+--------------------------+
+  */
+
+
+  test("test 2-level for array of int, bigInt") {

Review comment:
       add test case for null values also in nested array

##########
File path: integration/presto/src/test/scala/org/apache/carbondata/presto/integrationtest/PrestoReadTableFilesTest.scala
##########
@@ -0,0 +1,443 @@
+package org.apache.carbondata.presto.integrationtest
+
+import java.io.File
+import java.sql.{SQLException, Timestamp}
+import java.util
+import java.util.Arrays.asList
+
+import io.prestosql.jdbc.PrestoArray
+import org.apache.carbondata.common.logging.LogServiceFactory
+import org.apache.carbondata.core.constants.CarbonCommonConstants
+import org.apache.carbondata.core.datastore.filesystem.CarbonFile
+import org.apache.carbondata.core.datastore.impl.FileFactory
+import org.apache.carbondata.core.metadata.datatype.{DataTypes, Field}
+import org.apache.carbondata.core.util.{CarbonProperties, CarbonUtil}
+import org.apache.carbondata.presto.server.PrestoServer
+import org.apache.carbondata.sdk.file.{CarbonWriter, Schema}
+import org.apache.commons.io.FileUtils
+import org.apache.commons.lang.RandomStringUtils
+import org.apache.spark.sql.Row
+import org.scalatest.{BeforeAndAfterAll, FunSuiteLike, BeforeAndAfterEach}
+
+import scala.collection.mutable
+import scala.collection.JavaConverters._
+class PrestoReadTableFilesTest extends FunSuiteLike with BeforeAndAfterAll with BeforeAndAfterEach{
+  private val logger = LogServiceFactory
+    .getLogService(classOf[PrestoTestNonTransactionalTableFiles].getCanonicalName)
+
+  private val rootPath = new File(this.getClass.getResource("/").getPath
+    + "../../../..").getCanonicalPath
+  private val storePath = s"$rootPath/integration/presto/target/store"
+  private val systemPath = s"$rootPath/integration/presto/target/system"
+  private var writerPath = storePath + "/sdk_output/files"
+  private val prestoServer = new PrestoServer
+  private var varcharString = new String
+
+  override def beforeAll: Unit = {
+    CarbonProperties.getInstance().addProperty(CarbonCommonConstants.CARBON_WRITTEN_BY_APPNAME,
+      "Presto")
+    CarbonProperties.getInstance().addProperty(CarbonCommonConstants.CARBON_WRITTEN_BY_APPNAME,
+      "Presto")
+    val map = new util.HashMap[String, String]()
+    map.put("hive.metastore", "file")
+    map.put("hive.metastore.catalog.dir", s"file://$storePath")
+
+    prestoServer.startServer("sdk_output", map)
+  }
+
+  override def afterAll(): Unit = {
+    prestoServer.stopServer()
+    CarbonUtil.deleteFoldersAndFiles(FileFactory.getCarbonFile(storePath))
+  }
+
+  private def createComplexTableForSingleLevelArray = {
+    prestoServer.execute("drop table if exists sdk_output.files")
+    prestoServer.execute("drop schema if exists sdk_output")
+    prestoServer.execute("create schema sdk_output")
+    prestoServer
+      .execute(
+        "create table sdk_output.files(stringCol varchar, intCol int, doubleCol double, realCol real, boolCol boolean, arrayStringCol1 array(varchar), arrayStringcol2 array(varchar), arrayIntCol array(int), arrayBigIntCol array(bigint), arrayRealCol array(real), arrayDoubleCol array(double), arrayBooleanCol array(boolean)) with(format='CARBON') ")
+  }
+
+  private def createComplexTableFor2LevelArray = {
+    prestoServer.execute("drop table if exists sdk_output.files2")
+    prestoServer.execute("drop schema if exists sdk_output")
+    prestoServer.execute("create schema sdk_output")
+        prestoServer
+      .execute(
+        "create table sdk_output.files2(arrayArrayInt array(array(int)), arrayArrayBigInt array(array(bigint)), arrayArrayReal array(array(real)), arrayArrayDouble array(array(double)), arrayArrayString array(array(varchar)), arrayArrayBoolean array(array(boolean))) with(format='CARBON') ")
+  }
+
+  private def createComplexTableFor3LevelArray = {
+    prestoServer.execute("drop table if exists sdk_output.files3")
+    prestoServer.execute("drop schema if exists sdk_output")
+    prestoServer.execute("create schema sdk_output")
+    prestoServer
+        .execute(
+          "create table sdk_output.files3(array3_Int array(array(array(int))), array3_BigInt array(array(array(bigint))), array3_Real array(array(array(real))), array3_Double array(array(array(double))), array3_String array(array(array(varchar))), array3_Boolean array(array(array(boolean))) ) with(format='CARBON') ")
+    }
+
+  def buildComplexTestForSingleLevelArray(): Any = {
+    FileUtils.deleteDirectory(new File(writerPath))
+    createComplexTableForSingleLevelArray
+    import java.io.IOException
+    val source = new File(this.getClass.getResource("/").getPath + "../../" + "/temp/table1").getCanonicalPath
+    val srcDir = new File(source)
+    val destination = new File(this.getClass.getResource("/").getPath + "../../" + "/target/store/sdk_output/files/").getCanonicalPath
+    val destDir = new File(destination)
+    try FileUtils.copyDirectory(srcDir, destDir)
+    catch {
+      case e: IOException =>
+        e.printStackTrace()
+    }
+  }
+
+  def buildComplexTestFor2LevelArray(): Any = {
+    writerPath = storePath + "/sdk_output/files2"

Review comment:
       please generate files on the fly while running test case. should not commit binary file. revert all the binary files in the commit.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3773: [CARBONDATA-3830]Presto complex columns read support

GitBox
In reply to this post by GitBox

CarbonDataQA1 commented on pull request #3773:
URL: https://github.com/apache/carbondata/pull/3773#issuecomment-665065271






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] Indhumathi27 commented on a change in pull request #3773: [CARBONDATA-3830]Presto complex columns read support

GitBox
In reply to this post by GitBox

Indhumathi27 commented on a change in pull request #3773:
URL: https://github.com/apache/carbondata/pull/3773#discussion_r461655861



##########
File path: core/src/main/java/org/apache/carbondata/core/scan/collector/impl/DictionaryBasedVectorResultCollector.java
##########
@@ -98,6 +98,14 @@ void prepareDimensionAndMeasureColumnVectors() {
         columnVectorInfo.dimension = queryDimensions[i];
         columnVectorInfo.ordinal = queryDimensions[i].getDimension().getOrdinal();
         allColumnInfo[queryDimensions[i].getOrdinal()] = columnVectorInfo;
+      } else if (queryDimensions[i].getDimension().isComplex()) {
+        ColumnVectorInfo columnVectorInfo = new ColumnVectorInfo();
+        complexList.add(columnVectorInfo);
+        columnVectorInfo.dimension = queryDimensions[i];
+        columnVectorInfo.ordinal = queryDimensions[i].getDimension().getOrdinal();
+        columnVectorInfo.genericQueryType =
+            executionInfo.getComlexDimensionInfoMap().get(columnVectorInfo.ordinal);
+        allColumnInfo[queryDimensions[i].getOrdinal()] = columnVectorInfo;

Review comment:
        can add a check in line No.109 `  } else if (queryDimensions[i].getDimension().getDataType() != DataTypes.DATE &&
   !queryDimensions[i].getDimension().isComplex()) {` to avoid moving this method Up.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] ajantha-bhat commented on pull request #3773: [CARBONDATA-3830]Presto complex columns read support

GitBox
In reply to this post by GitBox

ajantha-bhat commented on pull request #3773:
URL: https://github.com/apache/carbondata/pull/3773#issuecomment-665473589


   @akkio-97 : Also change description to presto supporting array columns reading


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] ajantha-bhat commented on a change in pull request #3773: [CARBONDATA-3830]Presto complex columns read support

GitBox
In reply to this post by GitBox

ajantha-bhat commented on a change in pull request #3773:
URL: https://github.com/apache/carbondata/pull/3773#discussion_r462270452



##########
File path: integration/presto/src/main/java/org/apache/carbondata/presto/PrestoCarbonVectorizedRecordReader.java
##########
@@ -176,8 +191,16 @@ private void initBatch() {
     for (int i = 0; i < queryDimension.size(); i++) {
       ProjectionDimension dim = queryDimension.get(i);
       if (dim.getDimension().isComplex()) {
+        List<CarbonDimension> childDimensions =
+                dim.getDimension().getListOfChildDimensions();
+        ArrayList<StructField> childFields = new ArrayList<StructField>();
+        for (int ind = 0; ind < childDimensions.size(); ind++) {
+          ColumnSchema childSchema = childDimensions.get(ind).getColumnSchema();

Review comment:
       go to each file where new code is added and look for unused variable/function added (IDE can show in grey) and remove it.
   
   Here childSchema is not used.

##########
File path: integration/presto/src/main/prestosql/org/apache/carbondata/presto/readers/ArrayStreamReader.java
##########
@@ -0,0 +1,145 @@
+/*
+ * 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.apache.carbondata.presto.readers;
+
+import io.prestosql.spi.type.*;
+
+import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
+import org.apache.carbondata.core.metadata.datatype.StructField;
+import org.apache.carbondata.core.scan.result.vector.impl.CarbonColumnVectorImpl;
+
+import io.prestosql.spi.block.Block;
+import io.prestosql.spi.block.BlockBuilder;
+
+import org.apache.carbondata.presto.CarbonVectorBatch;
+
+/**
+ * Class to read the Array Stream
+ */
+
+public class ArrayStreamReader extends CarbonColumnVectorImpl implements PrestoVectorBlockBuilder {
+
+  protected int batchSize;
+
+  protected Type type;
+  protected BlockBuilder builder;
+  Block childBlock = null;
+  private int index = 0;
+
+  public ArrayStreamReader(int batchSize, DataType dataType, StructField field) {
+    super(batchSize, dataType);
+    this.batchSize = batchSize;
+    this.type = getArrayOfType(field, dataType);
+    setChildrenVector(
+        CarbonVectorBatch.createDirectStreamReader(this.batchSize, field.getDataType(), field));
+    this.builder = type.createBlockBuilder(null, batchSize);
+  }
+
+  public int getIndex() {
+    return index;
+  }
+
+  public void setIndex(int index) {
+    this.index = index;
+  }
+
+  public String getDataTypeName() {
+    return "ARRAY";
+  }
+
+  Type getArrayOfType(StructField field, DataType dataType) {
+    if (dataType == DataTypes.STRING) {
+      return new ArrayType(VarcharType.VARCHAR);

Review comment:
       use equals, it is string

##########
File path: integration/presto/src/main/prestosql/org/apache/carbondata/presto/readers/ArrayStreamReader.java
##########
@@ -0,0 +1,145 @@
+/*
+ * 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.apache.carbondata.presto.readers;
+
+import io.prestosql.spi.type.*;
+
+import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
+import org.apache.carbondata.core.metadata.datatype.StructField;
+import org.apache.carbondata.core.scan.result.vector.impl.CarbonColumnVectorImpl;
+
+import io.prestosql.spi.block.Block;
+import io.prestosql.spi.block.BlockBuilder;
+
+import org.apache.carbondata.presto.CarbonVectorBatch;
+
+/**
+ * Class to read the Array Stream
+ */
+
+public class ArrayStreamReader extends CarbonColumnVectorImpl implements PrestoVectorBlockBuilder {
+
+  protected int batchSize;
+
+  protected Type type;
+  protected BlockBuilder builder;
+  Block childBlock = null;
+  private int index = 0;
+
+  public ArrayStreamReader(int batchSize, DataType dataType, StructField field) {
+    super(batchSize, dataType);
+    this.batchSize = batchSize;
+    this.type = getArrayOfType(field, dataType);
+    setChildrenVector(
+        CarbonVectorBatch.createDirectStreamReader(this.batchSize, field.getDataType(), field));
+    this.builder = type.createBlockBuilder(null, batchSize);
+  }
+
+  public int getIndex() {
+    return index;
+  }
+
+  public void setIndex(int index) {
+    this.index = index;
+  }
+
+  public String getDataTypeName() {
+    return "ARRAY";
+  }
+
+  Type getArrayOfType(StructField field, DataType dataType) {
+    if (dataType == DataTypes.STRING) {
+      return new ArrayType(VarcharType.VARCHAR);

Review comment:
       use equals instead of == , it is string

##########
File path: core/src/main/java/org/apache/carbondata/core/datastore/page/encoding/compress/DirectCompressCodec.java
##########
@@ -246,7 +241,28 @@ public void decodeAndFillVector(byte[] pageData, ColumnVectorInfo vectorInfo, Bi
       vector = ColumnarVectorWrapperDirectFactory
           .getDirectVectorWrapperFactory(vector, vectorInfo.invertedIndex, nullBits, deletedRows,
               true, false);
-      fillVector(pageData, vector, vectorDataType, pageDataType, pageSize, vectorInfo, nullBits);
+      Deque<CarbonColumnVectorImpl> vectorStack = vectorInfo.getVectorStack();
+      // initialize vectorStack if null
+      if (vectorStack == null && vectorInfo.vector.getColumnVector() != null) {
+        vectorStack = new ArrayDeque<CarbonColumnVectorImpl>();
+        vectorStack.push((CarbonColumnVectorImpl) vectorInfo.vector.getColumnVector());
+        vectorInfo.setVectorStack(vectorStack);
+      }
+      /**

Review comment:
       can't use this style of comment, please observe IDE warnings while coding

##########
File path: core/src/main/java/org/apache/carbondata/core/datastore/page/encoding/compress/DirectCompressCodec.java
##########
@@ -246,7 +241,28 @@ public void decodeAndFillVector(byte[] pageData, ColumnVectorInfo vectorInfo, Bi
       vector = ColumnarVectorWrapperDirectFactory
           .getDirectVectorWrapperFactory(vector, vectorInfo.invertedIndex, nullBits, deletedRows,
               true, false);
-      fillVector(pageData, vector, vectorDataType, pageDataType, pageSize, vectorInfo, nullBits);
+      Deque<CarbonColumnVectorImpl> vectorStack = vectorInfo.getVectorStack();
+      // initialize vectorStack if null
+      if (vectorStack == null && vectorInfo.vector.getColumnVector() != null) {
+        vectorStack = new ArrayDeque<CarbonColumnVectorImpl>();
+        vectorStack.push((CarbonColumnVectorImpl) vectorInfo.vector.getColumnVector());
+        vectorInfo.setVectorStack(vectorStack);
+      }
+      /**
+       * if top of vector stack is a complex vector then
+       * add their children into the stack and load them too.
+       * TODO: If there are multiple children push them into stack and load them iteratively
+       */
+      if (vectorStack != null && vectorStack.peek().isComplex()) {

Review comment:
       should add !vectorStack.isEmpty() also !

##########
File path: core/src/main/java/org/apache/carbondata/core/datastore/page/encoding/compress/DirectCompressCodec.java
##########
@@ -246,7 +241,28 @@ public void decodeAndFillVector(byte[] pageData, ColumnVectorInfo vectorInfo, Bi
       vector = ColumnarVectorWrapperDirectFactory
           .getDirectVectorWrapperFactory(vector, vectorInfo.invertedIndex, nullBits, deletedRows,
               true, false);
-      fillVector(pageData, vector, vectorDataType, pageDataType, pageSize, vectorInfo, nullBits);
+      Deque<CarbonColumnVectorImpl> vectorStack = vectorInfo.getVectorStack();
+      // initialize vectorStack if null
+      if (vectorStack == null && vectorInfo.vector.getColumnVector() != null) {
+        vectorStack = new ArrayDeque<CarbonColumnVectorImpl>();
+        vectorStack.push((CarbonColumnVectorImpl) vectorInfo.vector.getColumnVector());
+        vectorInfo.setVectorStack(vectorStack);
+      }
+      /**
+       * if top of vector stack is a complex vector then
+       * add their children into the stack and load them too.
+       * TODO: If there are multiple children push them into stack and load them iteratively
+       */
+      if (vectorStack != null && vectorStack.peek().isComplex()) {

Review comment:
       should add !vectorStack.isEmpty() or vectorStack.peek() != null is better

##########
File path: integration/presto/src/main/prestosql/org/apache/carbondata/presto/readers/ArrayStreamReader.java
##########
@@ -0,0 +1,145 @@
+/*
+ * 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.apache.carbondata.presto.readers;
+
+import io.prestosql.spi.type.*;
+
+import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
+import org.apache.carbondata.core.metadata.datatype.StructField;
+import org.apache.carbondata.core.scan.result.vector.impl.CarbonColumnVectorImpl;
+
+import io.prestosql.spi.block.Block;
+import io.prestosql.spi.block.BlockBuilder;
+
+import org.apache.carbondata.presto.CarbonVectorBatch;
+
+/**
+ * Class to read the Array Stream
+ */
+
+public class ArrayStreamReader extends CarbonColumnVectorImpl implements PrestoVectorBlockBuilder {
+
+  protected int batchSize;
+
+  protected Type type;
+  protected BlockBuilder builder;
+  Block childBlock = null;
+  private int index = 0;
+
+  public ArrayStreamReader(int batchSize, DataType dataType, StructField field) {
+    super(batchSize, dataType);
+    this.batchSize = batchSize;
+    this.type = getArrayOfType(field, dataType);
+    setChildrenVector(
+        CarbonVectorBatch.createDirectStreamReader(this.batchSize, field.getDataType(), field));
+    this.builder = type.createBlockBuilder(null, batchSize);
+  }
+
+  public int getIndex() {
+    return index;
+  }
+
+  public void setIndex(int index) {
+    this.index = index;
+  }
+
+  public String getDataTypeName() {
+    return "ARRAY";
+  }
+
+  Type getArrayOfType(StructField field, DataType dataType) {
+    if (dataType == DataTypes.STRING) {
+      return new ArrayType(VarcharType.VARCHAR);

Review comment:
       use equals instead of == , it is string

##########
File path: integration/presto/src/main/prestosql/org/apache/carbondata/presto/readers/ArrayStreamReader.java
##########
@@ -0,0 +1,145 @@
+/*
+ * 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.apache.carbondata.presto.readers;
+
+import io.prestosql.spi.type.*;
+
+import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
+import org.apache.carbondata.core.metadata.datatype.StructField;
+import org.apache.carbondata.core.scan.result.vector.impl.CarbonColumnVectorImpl;
+
+import io.prestosql.spi.block.Block;
+import io.prestosql.spi.block.BlockBuilder;
+
+import org.apache.carbondata.presto.CarbonVectorBatch;
+
+/**
+ * Class to read the Array Stream
+ */
+
+public class ArrayStreamReader extends CarbonColumnVectorImpl implements PrestoVectorBlockBuilder {
+
+  protected int batchSize;
+
+  protected Type type;
+  protected BlockBuilder builder;
+  Block childBlock = null;
+  private int index = 0;
+
+  public ArrayStreamReader(int batchSize, DataType dataType, StructField field) {
+    super(batchSize, dataType);
+    this.batchSize = batchSize;
+    this.type = getArrayOfType(field, dataType);
+    setChildrenVector(
+        CarbonVectorBatch.createDirectStreamReader(this.batchSize, field.getDataType(), field));
+    this.builder = type.createBlockBuilder(null, batchSize);
+  }
+
+  public int getIndex() {
+    return index;
+  }
+
+  public void setIndex(int index) {
+    this.index = index;
+  }
+
+  public String getDataTypeName() {
+    return "ARRAY";
+  }
+
+  Type getArrayOfType(StructField field, DataType dataType) {
+    if (dataType == DataTypes.STRING) {
+      return new ArrayType(VarcharType.VARCHAR);
+    } else if (dataType == DataTypes.INT) {
+      return new ArrayType(IntegerType.INTEGER);
+    } else if (dataType == DataTypes.LONG) {
+      return new ArrayType(BigintType.BIGINT);
+    } else if (dataType == DataTypes.DOUBLE) {
+      return new ArrayType(DoubleType.DOUBLE);
+    } else if (dataType == DataTypes.FLOAT) {
+      return new ArrayType(RealType.REAL);
+    } else if (dataType == DataTypes.BOOLEAN) {
+      return new ArrayType(BooleanType.BOOLEAN);
+    } else {
+      StructField childField = field.getChildren().get(0);
+      return new ArrayType(getArrayOfType(childField, childField.getDataType()));
+    }
+  }
+
+  @Override
+  public Block buildBlock() {
+    return builder.build();
+  }
+
+  public boolean isComplex() {
+    return true;
+  }
+
+  @Override
+  public void setBatchSize(int batchSize) {
+    this.batchSize = batchSize;
+  }
+
+  @Override
+  public void putObject(int rowId, Object value) {
+    if (value == null) {
+      putNull(rowId);
+    } else {
+      getChildrenVector().putObject(rowId, value);
+    }
+  }
+
+  public void putArrayObject() {
+    if (this.getType().getName() == "ARRAY") {
+      childBlock = ((ArrayStreamReader) getChildrenVector()).buildBlock();
+    } else if (this.getType().getName() == "STRING") {
+      childBlock = ((SliceStreamReader) getChildrenVector()).buildBlock();
+    } else if (this.getType().getName() == "INT") {

Review comment:
       use equals instead of == , as name is string vale

##########
File path: integration/presto/src/main/prestosql/org/apache/carbondata/presto/readers/ArrayStreamReader.java
##########
@@ -0,0 +1,145 @@
+/*
+ * 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.apache.carbondata.presto.readers;
+
+import io.prestosql.spi.type.*;
+
+import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
+import org.apache.carbondata.core.metadata.datatype.StructField;
+import org.apache.carbondata.core.scan.result.vector.impl.CarbonColumnVectorImpl;
+
+import io.prestosql.spi.block.Block;
+import io.prestosql.spi.block.BlockBuilder;
+
+import org.apache.carbondata.presto.CarbonVectorBatch;
+
+/**
+ * Class to read the Array Stream
+ */
+
+public class ArrayStreamReader extends CarbonColumnVectorImpl implements PrestoVectorBlockBuilder {
+
+  protected int batchSize;
+
+  protected Type type;
+  protected BlockBuilder builder;
+  Block childBlock = null;
+  private int index = 0;
+
+  public ArrayStreamReader(int batchSize, DataType dataType, StructField field) {
+    super(batchSize, dataType);
+    this.batchSize = batchSize;
+    this.type = getArrayOfType(field, dataType);
+    setChildrenVector(
+        CarbonVectorBatch.createDirectStreamReader(this.batchSize, field.getDataType(), field));
+    this.builder = type.createBlockBuilder(null, batchSize);
+  }
+
+  public int getIndex() {
+    return index;
+  }
+
+  public void setIndex(int index) {
+    this.index = index;
+  }
+
+  public String getDataTypeName() {
+    return "ARRAY";
+  }
+
+  Type getArrayOfType(StructField field, DataType dataType) {
+    if (dataType == DataTypes.STRING) {
+      return new ArrayType(VarcharType.VARCHAR);
+    } else if (dataType == DataTypes.INT) {
+      return new ArrayType(IntegerType.INTEGER);
+    } else if (dataType == DataTypes.LONG) {
+      return new ArrayType(BigintType.BIGINT);
+    } else if (dataType == DataTypes.DOUBLE) {
+      return new ArrayType(DoubleType.DOUBLE);
+    } else if (dataType == DataTypes.FLOAT) {
+      return new ArrayType(RealType.REAL);
+    } else if (dataType == DataTypes.BOOLEAN) {
+      return new ArrayType(BooleanType.BOOLEAN);
+    } else {
+      StructField childField = field.getChildren().get(0);
+      return new ArrayType(getArrayOfType(childField, childField.getDataType()));
+    }
+  }
+
+  @Override
+  public Block buildBlock() {
+    return builder.build();
+  }
+
+  public boolean isComplex() {
+    return true;
+  }
+
+  @Override
+  public void setBatchSize(int batchSize) {
+    this.batchSize = batchSize;
+  }
+
+  @Override
+  public void putObject(int rowId, Object value) {
+    if (value == null) {
+      putNull(rowId);
+    } else {
+      getChildrenVector().putObject(rowId, value);
+    }
+  }
+
+  public void putArrayObject() {
+    if (this.getType().getName() == "ARRAY") {
+      childBlock = ((ArrayStreamReader) getChildrenVector()).buildBlock();
+    } else if (this.getType().getName() == "STRING") {
+      childBlock = ((SliceStreamReader) getChildrenVector()).buildBlock();
+    } else if (this.getType().getName() == "INT") {

Review comment:
       use equals instead of == , as name is string vale
   
   Also check how current testcases are passing. Because of this childblock may be null always

##########
File path: integration/presto/src/main/prestosql/org/apache/carbondata/presto/readers/ArrayStreamReader.java
##########
@@ -0,0 +1,145 @@
+/*
+ * 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.apache.carbondata.presto.readers;
+
+import io.prestosql.spi.type.*;
+
+import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
+import org.apache.carbondata.core.metadata.datatype.StructField;
+import org.apache.carbondata.core.scan.result.vector.impl.CarbonColumnVectorImpl;
+
+import io.prestosql.spi.block.Block;
+import io.prestosql.spi.block.BlockBuilder;
+
+import org.apache.carbondata.presto.CarbonVectorBatch;
+
+/**
+ * Class to read the Array Stream
+ */
+
+public class ArrayStreamReader extends CarbonColumnVectorImpl implements PrestoVectorBlockBuilder {
+
+  protected int batchSize;
+
+  protected Type type;
+  protected BlockBuilder builder;
+  Block childBlock = null;
+  private int index = 0;
+
+  public ArrayStreamReader(int batchSize, DataType dataType, StructField field) {
+    super(batchSize, dataType);
+    this.batchSize = batchSize;
+    this.type = getArrayOfType(field, dataType);
+    setChildrenVector(
+        CarbonVectorBatch.createDirectStreamReader(this.batchSize, field.getDataType(), field));
+    this.builder = type.createBlockBuilder(null, batchSize);
+  }
+
+  public int getIndex() {
+    return index;
+  }
+
+  public void setIndex(int index) {
+    this.index = index;
+  }
+
+  public String getDataTypeName() {
+    return "ARRAY";
+  }
+
+  Type getArrayOfType(StructField field, DataType dataType) {
+    if (dataType == DataTypes.STRING) {
+      return new ArrayType(VarcharType.VARCHAR);
+    } else if (dataType == DataTypes.INT) {
+      return new ArrayType(IntegerType.INTEGER);
+    } else if (dataType == DataTypes.LONG) {
+      return new ArrayType(BigintType.BIGINT);
+    } else if (dataType == DataTypes.DOUBLE) {
+      return new ArrayType(DoubleType.DOUBLE);
+    } else if (dataType == DataTypes.FLOAT) {
+      return new ArrayType(RealType.REAL);
+    } else if (dataType == DataTypes.BOOLEAN) {
+      return new ArrayType(BooleanType.BOOLEAN);
+    } else {

Review comment:
       Seems short, byte, date , time is missing. Please refer some existing data type function to make sure you cover all the data type

##########
File path: integration/presto/src/main/prestosql/org/apache/carbondata/presto/readers/ArrayStreamReader.java
##########
@@ -0,0 +1,145 @@
+/*
+ * 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.apache.carbondata.presto.readers;
+
+import io.prestosql.spi.type.*;
+
+import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
+import org.apache.carbondata.core.metadata.datatype.StructField;
+import org.apache.carbondata.core.scan.result.vector.impl.CarbonColumnVectorImpl;
+
+import io.prestosql.spi.block.Block;
+import io.prestosql.spi.block.BlockBuilder;
+
+import org.apache.carbondata.presto.CarbonVectorBatch;
+
+/**
+ * Class to read the Array Stream
+ */
+
+public class ArrayStreamReader extends CarbonColumnVectorImpl implements PrestoVectorBlockBuilder {
+
+  protected int batchSize;
+
+  protected Type type;
+  protected BlockBuilder builder;
+  Block childBlock = null;
+  private int index = 0;
+
+  public ArrayStreamReader(int batchSize, DataType dataType, StructField field) {
+    super(batchSize, dataType);
+    this.batchSize = batchSize;
+    this.type = getArrayOfType(field, dataType);
+    setChildrenVector(
+        CarbonVectorBatch.createDirectStreamReader(this.batchSize, field.getDataType(), field));
+    this.builder = type.createBlockBuilder(null, batchSize);
+  }
+
+  public int getIndex() {
+    return index;
+  }
+
+  public void setIndex(int index) {
+    this.index = index;
+  }
+
+  public String getDataTypeName() {
+    return "ARRAY";
+  }
+
+  Type getArrayOfType(StructField field, DataType dataType) {
+    if (dataType == DataTypes.STRING) {
+      return new ArrayType(VarcharType.VARCHAR);
+    } else if (dataType == DataTypes.INT) {
+      return new ArrayType(IntegerType.INTEGER);
+    } else if (dataType == DataTypes.LONG) {
+      return new ArrayType(BigintType.BIGINT);
+    } else if (dataType == DataTypes.DOUBLE) {
+      return new ArrayType(DoubleType.DOUBLE);
+    } else if (dataType == DataTypes.FLOAT) {
+      return new ArrayType(RealType.REAL);
+    } else if (dataType == DataTypes.BOOLEAN) {
+      return new ArrayType(BooleanType.BOOLEAN);
+    } else {
+      StructField childField = field.getChildren().get(0);
+      return new ArrayType(getArrayOfType(childField, childField.getDataType()));

Review comment:
       cannot assume else case as array, have else if () for array
   and keep an else case for
   } else {
         throw new UnsupportedOperationException("unsupported type: " + dataType);
       }

##########
File path: integration/presto/src/main/prestosql/org/apache/carbondata/presto/readers/ArrayStreamReader.java
##########
@@ -0,0 +1,145 @@
+/*
+ * 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.apache.carbondata.presto.readers;
+
+import io.prestosql.spi.type.*;
+
+import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
+import org.apache.carbondata.core.metadata.datatype.StructField;
+import org.apache.carbondata.core.scan.result.vector.impl.CarbonColumnVectorImpl;
+
+import io.prestosql.spi.block.Block;
+import io.prestosql.spi.block.BlockBuilder;
+
+import org.apache.carbondata.presto.CarbonVectorBatch;
+
+/**
+ * Class to read the Array Stream
+ */
+
+public class ArrayStreamReader extends CarbonColumnVectorImpl implements PrestoVectorBlockBuilder {
+
+  protected int batchSize;
+
+  protected Type type;
+  protected BlockBuilder builder;
+  Block childBlock = null;
+  private int index = 0;
+
+  public ArrayStreamReader(int batchSize, DataType dataType, StructField field) {
+    super(batchSize, dataType);
+    this.batchSize = batchSize;
+    this.type = getArrayOfType(field, dataType);
+    setChildrenVector(
+        CarbonVectorBatch.createDirectStreamReader(this.batchSize, field.getDataType(), field));
+    this.builder = type.createBlockBuilder(null, batchSize);
+  }
+
+  public int getIndex() {
+    return index;
+  }
+
+  public void setIndex(int index) {
+    this.index = index;
+  }
+
+  public String getDataTypeName() {
+    return "ARRAY";
+  }
+
+  Type getArrayOfType(StructField field, DataType dataType) {
+    if (dataType == DataTypes.STRING) {
+      return new ArrayType(VarcharType.VARCHAR);
+    } else if (dataType == DataTypes.INT) {
+      return new ArrayType(IntegerType.INTEGER);
+    } else if (dataType == DataTypes.LONG) {
+      return new ArrayType(BigintType.BIGINT);
+    } else if (dataType == DataTypes.DOUBLE) {
+      return new ArrayType(DoubleType.DOUBLE);
+    } else if (dataType == DataTypes.FLOAT) {
+      return new ArrayType(RealType.REAL);
+    } else if (dataType == DataTypes.BOOLEAN) {
+      return new ArrayType(BooleanType.BOOLEAN);
+    } else {
+      StructField childField = field.getChildren().get(0);
+      return new ArrayType(getArrayOfType(childField, childField.getDataType()));
+    }
+  }
+
+  @Override
+  public Block buildBlock() {
+    return builder.build();
+  }
+
+  public boolean isComplex() {
+    return true;
+  }
+
+  @Override
+  public void setBatchSize(int batchSize) {
+    this.batchSize = batchSize;
+  }
+
+  @Override
+  public void putObject(int rowId, Object value) {
+    if (value == null) {
+      putNull(rowId);
+    } else {
+      getChildrenVector().putObject(rowId, value);
+    }
+  }
+
+  public void putArrayObject() {
+    if (this.getType().getName() == "ARRAY") {
+      childBlock = ((ArrayStreamReader) getChildrenVector()).buildBlock();
+    } else if (this.getType().getName() == "STRING") {
+      childBlock = ((SliceStreamReader) getChildrenVector()).buildBlock();
+    } else if (this.getType().getName() == "INT") {

Review comment:
       or you can use this.getType() == DataTypes.STRING




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] CarbonDataQA1 commented on pull request #3773: [CARBONDATA-3830]Presto complex columns read support

GitBox
In reply to this post by GitBox

CarbonDataQA1 commented on pull request #3773:
URL: https://github.com/apache/carbondata/pull/3773#issuecomment-665938820






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] akkio-97 commented on a change in pull request #3773: [CARBONDATA-3830]Presto complex columns read support

GitBox
In reply to this post by GitBox

akkio-97 commented on a change in pull request #3773:
URL: https://github.com/apache/carbondata/pull/3773#discussion_r462599726



##########
File path: core/src/main/java/org/apache/carbondata/core/scan/executor/impl/AbstractQueryExecutor.java
##########
@@ -508,7 +508,8 @@ private BlockExecutionInfo getBlockExecutionInfoForBlock(QueryModel queryModel,
     int[] dimensionChunkIndexes = QueryUtil.getDimensionChunkIndexes(projectDimensions,
         segmentProperties.getDimensionOrdinalToChunkMapping(),
         currentBlockFilterDimensions, allProjectionListDimensionIndexes);
-    ReusableDataBuffer[] dimensionBuffer = new ReusableDataBuffer[projectDimensions.size()];
+    // 4 because each column(including itself) can have a maximum of 3 nested complex levels
+    ReusableDataBuffer[] dimensionBuffer = new ReusableDataBuffer[projectDimensions.size() * 4];

Review comment:
       done

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/BlockletScannedResult.java
##########
@@ -153,6 +154,8 @@
 
   private ReusableDataBuffer[] measureReusableBuffer;
 
+  int startIndex = 0;

Review comment:
       done
   

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/vector/CarbonColumnVector.java
##########
@@ -114,4 +114,14 @@
 
   void setLazyPage(LazyPageLoader lazyPage);
 
+  CarbonColumnVector getColumnVector();
+
+  CarbonColumnVector getChildrenVector();

Review comment:
       done

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/vector/CarbonColumnVector.java
##########
@@ -114,4 +114,14 @@
 
   void setLazyPage(LazyPageLoader lazyPage);
 
+  CarbonColumnVector getColumnVector();
+
+  CarbonColumnVector getChildrenVector();
+
+  void putArrayObject();
+
+  int getIndex();

Review comment:
       done

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/vector/CarbonColumnVector.java
##########
@@ -114,4 +114,14 @@
 
   void setLazyPage(LazyPageLoader lazyPage);
 
+  CarbonColumnVector getColumnVector();

Review comment:
       done

##########
File path: integration/presto/src/main/java/org/apache/carbondata/presto/PrestoCarbonVectorizedRecordReader.java
##########
@@ -176,8 +191,16 @@ private void initBatch() {
     for (int i = 0; i < queryDimension.size(); i++) {
       ProjectionDimension dim = queryDimension.get(i);
       if (dim.getDimension().isComplex()) {
+        List<CarbonDimension> childDimensions =
+                dim.getDimension().getListOfChildDimensions();
+        ArrayList<StructField> childFields = new ArrayList<StructField>();
+        for (int ind = 0; ind < childDimensions.size(); ind++) {

Review comment:
       done

##########
File path: integration/presto/src/main/prestosql/org/apache/carbondata/presto/readers/ArrayStreamReader.java
##########
@@ -0,0 +1,145 @@
+/*
+ * 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.apache.carbondata.presto.readers;
+
+import io.prestosql.spi.type.*;
+
+import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
+import org.apache.carbondata.core.metadata.datatype.StructField;
+import org.apache.carbondata.core.scan.result.vector.impl.CarbonColumnVectorImpl;
+
+import io.prestosql.spi.block.Block;
+import io.prestosql.spi.block.BlockBuilder;
+
+import org.apache.carbondata.presto.CarbonVectorBatch;
+
+/**
+ * Class to read the Array Stream
+ */
+
+public class ArrayStreamReader extends CarbonColumnVectorImpl implements PrestoVectorBlockBuilder {
+
+  protected int batchSize;
+
+  protected Type type;
+  protected BlockBuilder builder;
+  Block childBlock = null;
+  private int index = 0;
+
+  public ArrayStreamReader(int batchSize, DataType dataType, StructField field) {
+    super(batchSize, dataType);
+    this.batchSize = batchSize;
+    this.type = getArrayOfType(field, dataType);
+    setChildrenVector(
+        CarbonVectorBatch.createDirectStreamReader(this.batchSize, field.getDataType(), field));
+    this.builder = type.createBlockBuilder(null, batchSize);
+  }
+
+  public int getIndex() {
+    return index;
+  }
+
+  public void setIndex(int index) {
+    this.index = index;
+  }
+
+  public String getDataTypeName() {
+    return "ARRAY";
+  }
+
+  Type getArrayOfType(StructField field, DataType dataType) {
+    if (dataType == DataTypes.STRING) {
+      return new ArrayType(VarcharType.VARCHAR);
+    } else if (dataType == DataTypes.INT) {
+      return new ArrayType(IntegerType.INTEGER);
+    } else if (dataType == DataTypes.LONG) {
+      return new ArrayType(BigintType.BIGINT);
+    } else if (dataType == DataTypes.DOUBLE) {
+      return new ArrayType(DoubleType.DOUBLE);
+    } else if (dataType == DataTypes.FLOAT) {
+      return new ArrayType(RealType.REAL);
+    } else if (dataType == DataTypes.BOOLEAN) {
+      return new ArrayType(BooleanType.BOOLEAN);
+    } else {
+      StructField childField = field.getChildren().get(0);
+      return new ArrayType(getArrayOfType(childField, childField.getDataType()));
+    }
+  }
+
+  @Override
+  public Block buildBlock() {
+    return builder.build();
+  }
+
+  public boolean isComplex() {
+    return true;
+  }
+
+  @Override
+  public void setBatchSize(int batchSize) {
+    this.batchSize = batchSize;
+  }
+
+  @Override
+  public void putObject(int rowId, Object value) {
+    if (value == null) {
+      putNull(rowId);
+    } else {
+      getChildrenVector().putObject(rowId, value);
+    }
+  }
+
+  public void putArrayObject() {
+    if (this.getType().getName() == "ARRAY") {
+      childBlock = ((ArrayStreamReader) getChildrenVector()).buildBlock();
+    } else if (this.getType().getName() == "STRING") {

Review comment:
       done

##########
File path: integration/presto/src/test/scala/org/apache/carbondata/presto/integrationtest/PrestoReadTableFilesTest.scala
##########
@@ -0,0 +1,443 @@
+package org.apache.carbondata.presto.integrationtest
+
+import java.io.File
+import java.sql.{SQLException, Timestamp}
+import java.util
+import java.util.Arrays.asList
+
+import io.prestosql.jdbc.PrestoArray
+import org.apache.carbondata.common.logging.LogServiceFactory
+import org.apache.carbondata.core.constants.CarbonCommonConstants
+import org.apache.carbondata.core.datastore.filesystem.CarbonFile
+import org.apache.carbondata.core.datastore.impl.FileFactory
+import org.apache.carbondata.core.metadata.datatype.{DataTypes, Field}
+import org.apache.carbondata.core.util.{CarbonProperties, CarbonUtil}
+import org.apache.carbondata.presto.server.PrestoServer
+import org.apache.carbondata.sdk.file.{CarbonWriter, Schema}
+import org.apache.commons.io.FileUtils
+import org.apache.commons.lang.RandomStringUtils
+import org.apache.spark.sql.Row
+import org.scalatest.{BeforeAndAfterAll, FunSuiteLike, BeforeAndAfterEach}
+
+import scala.collection.mutable
+import scala.collection.JavaConverters._
+class PrestoReadTableFilesTest extends FunSuiteLike with BeforeAndAfterAll with BeforeAndAfterEach{
+  private val logger = LogServiceFactory
+    .getLogService(classOf[PrestoTestNonTransactionalTableFiles].getCanonicalName)
+
+  private val rootPath = new File(this.getClass.getResource("/").getPath
+    + "../../../..").getCanonicalPath
+  private val storePath = s"$rootPath/integration/presto/target/store"
+  private val systemPath = s"$rootPath/integration/presto/target/system"
+  private var writerPath = storePath + "/sdk_output/files"
+  private val prestoServer = new PrestoServer
+  private var varcharString = new String
+
+  override def beforeAll: Unit = {
+    CarbonProperties.getInstance().addProperty(CarbonCommonConstants.CARBON_WRITTEN_BY_APPNAME,
+      "Presto")
+    CarbonProperties.getInstance().addProperty(CarbonCommonConstants.CARBON_WRITTEN_BY_APPNAME,
+      "Presto")
+    val map = new util.HashMap[String, String]()
+    map.put("hive.metastore", "file")
+    map.put("hive.metastore.catalog.dir", s"file://$storePath")
+
+    prestoServer.startServer("sdk_output", map)
+  }
+
+  override def afterAll(): Unit = {
+    prestoServer.stopServer()
+    CarbonUtil.deleteFoldersAndFiles(FileFactory.getCarbonFile(storePath))
+  }
+
+  private def createComplexTableForSingleLevelArray = {
+    prestoServer.execute("drop table if exists sdk_output.files")
+    prestoServer.execute("drop schema if exists sdk_output")
+    prestoServer.execute("create schema sdk_output")
+    prestoServer
+      .execute(
+        "create table sdk_output.files(stringCol varchar, intCol int, doubleCol double, realCol real, boolCol boolean, arrayStringCol1 array(varchar), arrayStringcol2 array(varchar), arrayIntCol array(int), arrayBigIntCol array(bigint), arrayRealCol array(real), arrayDoubleCol array(double), arrayBooleanCol array(boolean)) with(format='CARBON') ")
+  }
+
+  private def createComplexTableFor2LevelArray = {
+    prestoServer.execute("drop table if exists sdk_output.files2")
+    prestoServer.execute("drop schema if exists sdk_output")
+    prestoServer.execute("create schema sdk_output")
+        prestoServer
+      .execute(
+        "create table sdk_output.files2(arrayArrayInt array(array(int)), arrayArrayBigInt array(array(bigint)), arrayArrayReal array(array(real)), arrayArrayDouble array(array(double)), arrayArrayString array(array(varchar)), arrayArrayBoolean array(array(boolean))) with(format='CARBON') ")
+  }
+
+  private def createComplexTableFor3LevelArray = {
+    prestoServer.execute("drop table if exists sdk_output.files3")
+    prestoServer.execute("drop schema if exists sdk_output")
+    prestoServer.execute("create schema sdk_output")
+    prestoServer
+        .execute(
+          "create table sdk_output.files3(array3_Int array(array(array(int))), array3_BigInt array(array(array(bigint))), array3_Real array(array(array(real))), array3_Double array(array(array(double))), array3_String array(array(array(varchar))), array3_Boolean array(array(array(boolean))) ) with(format='CARBON') ")
+    }
+
+  def buildComplexTestForSingleLevelArray(): Any = {
+    FileUtils.deleteDirectory(new File(writerPath))
+    createComplexTableForSingleLevelArray
+    import java.io.IOException
+    val source = new File(this.getClass.getResource("/").getPath + "../../" + "/temp/table1").getCanonicalPath
+    val srcDir = new File(source)
+    val destination = new File(this.getClass.getResource("/").getPath + "../../" + "/target/store/sdk_output/files/").getCanonicalPath
+    val destDir = new File(destination)
+    try FileUtils.copyDirectory(srcDir, destDir)
+    catch {
+      case e: IOException =>
+        e.printStackTrace()
+    }
+  }
+
+  def buildComplexTestFor2LevelArray(): Any = {
+    writerPath = storePath + "/sdk_output/files2"
+    FileUtils.deleteDirectory(new File(writerPath))
+    createComplexTableFor2LevelArray
+    import java.io.IOException
+    val source = new File(this.getClass.getResource("/").getPath + "../../" + "/temp/table2").getCanonicalPath
+    val srcDir = new File(source)
+    val destination = new File(this.getClass.getResource("/").getPath + "../../" + "/target/store/sdk_output/files2/").getCanonicalPath
+    val destDir = new File(destination)
+    try FileUtils.copyDirectory(srcDir, destDir)
+    catch {
+      case e: IOException =>
+        e.printStackTrace()

Review comment:
       done

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/BlockletScannedResult.java
##########
@@ -153,6 +154,8 @@
 
   private ReusableDataBuffer[] measureReusableBuffer;
 
+  int startIndex = 0;

Review comment:
       done

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/vector/CarbonColumnVector.java
##########
@@ -114,4 +114,14 @@
 
   void setLazyPage(LazyPageLoader lazyPage);
 
+  CarbonColumnVector getColumnVector();
+
+  CarbonColumnVector getChildrenVector();

Review comment:
       done

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/BlockletScannedResult.java
##########
@@ -153,6 +154,8 @@
 
   private ReusableDataBuffer[] measureReusableBuffer;
 
+  int startIndex = 0;

Review comment:
       done

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/vector/CarbonColumnVector.java
##########
@@ -114,4 +114,14 @@
 
   void setLazyPage(LazyPageLoader lazyPage);
 
+  CarbonColumnVector getColumnVector();
+
+  CarbonColumnVector getChildrenVector();
+
+  void putArrayObject();
+
+  int getIndex();

Review comment:
       done

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/vector/CarbonColumnVector.java
##########
@@ -114,4 +114,14 @@
 
   void setLazyPage(LazyPageLoader lazyPage);
 
+  CarbonColumnVector getColumnVector();

Review comment:
       yes

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/executor/impl/AbstractQueryExecutor.java
##########
@@ -508,7 +508,8 @@ private BlockExecutionInfo getBlockExecutionInfoForBlock(QueryModel queryModel,
     int[] dimensionChunkIndexes = QueryUtil.getDimensionChunkIndexes(projectDimensions,
         segmentProperties.getDimensionOrdinalToChunkMapping(),
         currentBlockFilterDimensions, allProjectionListDimensionIndexes);
-    ReusableDataBuffer[] dimensionBuffer = new ReusableDataBuffer[projectDimensions.size()];
+    // 4 because each column(including itself) can have a maximum of 3 nested complex levels
+    ReusableDataBuffer[] dimensionBuffer = new ReusableDataBuffer[projectDimensions.size() * 4];

Review comment:
       done

##########
File path: core/src/main/java/org/apache/carbondata/core/metadata/schema/table/column/CarbonDimension.java
##########
@@ -39,6 +39,16 @@
    */
   private int keyOrdinal;
 
+  private byte[] childElements;

Review comment:
       done

##########
File path: core/src/main/java/org/apache/carbondata/core/datastore/page/encoding/compress/DirectCompressCodec.java
##########
@@ -246,7 +241,28 @@ public void decodeAndFillVector(byte[] pageData, ColumnVectorInfo vectorInfo, Bi
       vector = ColumnarVectorWrapperDirectFactory
           .getDirectVectorWrapperFactory(vector, vectorInfo.invertedIndex, nullBits, deletedRows,
               true, false);
-      fillVector(pageData, vector, vectorDataType, pageDataType, pageSize, vectorInfo, nullBits);
+      Deque<CarbonColumnVectorImpl> vectorStack = vectorInfo.getVectorStack();
+      // initialize vectorStack if null
+      if (vectorStack == null && vectorInfo.vector.getColumnVector() != null) {
+        vectorStack = new ArrayDeque<CarbonColumnVectorImpl>();
+        vectorStack.push((CarbonColumnVectorImpl) vectorInfo.vector.getColumnVector());
+        vectorInfo.setVectorStack(vectorStack);

Review comment:
       done

##########
File path: core/src/main/java/org/apache/carbondata/core/datastore/page/encoding/compress/DirectCompressCodec.java
##########
@@ -32,29 +29,27 @@
 import org.apache.carbondata.core.datastore.page.ColumnPageValueConverter;
 import org.apache.carbondata.core.datastore.page.LazyColumnPage;
 import org.apache.carbondata.core.datastore.page.VarLengthColumnPageBase;
-import org.apache.carbondata.core.datastore.page.encoding.ColumnPageCodec;
-import org.apache.carbondata.core.datastore.page.encoding.ColumnPageDecoder;
-import org.apache.carbondata.core.datastore.page.encoding.ColumnPageEncoder;
-import org.apache.carbondata.core.datastore.page.encoding.ColumnPageEncoderMeta;
+import org.apache.carbondata.core.datastore.page.encoding.*;
 import org.apache.carbondata.core.metadata.datatype.DataType;
 import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.datatype.DecimalConverterFactory;
 import org.apache.carbondata.core.scan.result.vector.CarbonColumnVector;
 import org.apache.carbondata.core.scan.result.vector.ColumnVectorInfo;
+import org.apache.carbondata.core.scan.result.vector.impl.CarbonColumnVectorImpl;
 import org.apache.carbondata.core.scan.result.vector.impl.directread.ColumnarVectorWrapperDirectFactory;
 import org.apache.carbondata.core.scan.result.vector.impl.directread.ConvertibleVector;
 import org.apache.carbondata.core.scan.result.vector.impl.directread.SequentialFill;
-import org.apache.carbondata.core.util.ByteUtil;
 import org.apache.carbondata.format.Encoding;
 
 /**
  * This codec directly apply compression on the input data
  */
+//public class DirectCompressCodec extends SerializeComplexTypes implements ColumnPageCodec {

Review comment:
       done

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/vector/CarbonColumnVector.java
##########
@@ -114,4 +114,14 @@
 
   void setLazyPage(LazyPageLoader lazyPage);
 
+  CarbonColumnVector getColumnVector();

Review comment:
       yes

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/vector/CarbonColumnVector.java
##########
@@ -114,4 +114,14 @@
 
   void setLazyPage(LazyPageLoader lazyPage);
 
+  CarbonColumnVector getColumnVector();
+
+  CarbonColumnVector getChildrenVector();
+
+  void putArrayObject();
+
+  int getIndex();

Review comment:
       done

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/vector/CarbonColumnVector.java
##########
@@ -114,4 +114,14 @@
 
   void setLazyPage(LazyPageLoader lazyPage);
 
+  CarbonColumnVector getColumnVector();
+
+  CarbonColumnVector getChildrenVector();

Review comment:
       done

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/BlockletScannedResult.java
##########
@@ -153,6 +154,8 @@
 
   private ReusableDataBuffer[] measureReusableBuffer;
 
+  int startIndex = 0;

Review comment:
       done

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/result/BlockletScannedResult.java
##########
@@ -153,6 +154,8 @@
 
   private ReusableDataBuffer[] measureReusableBuffer;
 
+  int startIndex = 0;

Review comment:
       done
   

##########
File path: core/src/main/java/org/apache/carbondata/core/scan/executor/impl/AbstractQueryExecutor.java
##########
@@ -508,7 +508,8 @@ private BlockExecutionInfo getBlockExecutionInfoForBlock(QueryModel queryModel,
     int[] dimensionChunkIndexes = QueryUtil.getDimensionChunkIndexes(projectDimensions,
         segmentProperties.getDimensionOrdinalToChunkMapping(),
         currentBlockFilterDimensions, allProjectionListDimensionIndexes);
-    ReusableDataBuffer[] dimensionBuffer = new ReusableDataBuffer[projectDimensions.size()];
+    // 4 because each column(including itself) can have a maximum of 3 nested complex levels
+    ReusableDataBuffer[] dimensionBuffer = new ReusableDataBuffer[projectDimensions.size() * 4];

Review comment:
       done




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[hidden email]


123456