Github user bhavya411 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/2139#discussion_r179913431
  
    --- Diff: 
integration/presto/src/main/java/org/apache/carbondata/presto/impl/CarbonTableReader.java
 ---
    @@ -415,14 +440,56 @@ public TBase create() {
         return result;
       }
     
    +  /** Returns list of partition specs to query based on the domain 
constraints
    +   * @param constraints
    +   * @param carbonTable
    +   * @throws IOException
    +   */
    +  private List<PartitionSpec> 
findRequiredPartitions(TupleDomain<ColumnHandle> constraints, CarbonTable 
carbonTable,
    +      LoadMetadataDetails[]loadMetadataDetails)  {
    +    Set<PartitionSpec> partitionSpecs = new HashSet<>();
    +    List<PartitionSpec> prunePartitions = new ArrayList();
    +
    +    for (LoadMetadataDetails loadMetadataDetail : loadMetadataDetails) {
    +      SegmentFileStore segmentFileStore = null;
    +      try {
    +        segmentFileStore =
    +            new SegmentFileStore(carbonTable.getTablePath(), 
loadMetadataDetail.getSegmentFile());
    +        partitionSpecs.addAll(segmentFileStore.getPartitionSpecs());
    +
    +      } catch (IOException e) {
    +        e.printStackTrace();
    +      }
    +    }
    +
    +    List<String> partitionValuesFromExpression =
    +        PrestoFilterUtil.getPartitionFilters(carbonTable, constraints);
    +
    +    List<List<String>> partitionSpecNamesList = 
partitionSpecs.stream().map(
    +        PartitionSpec::getPartitions).collect(Collectors.toList());
    +
    +    List<PartitionSpec> partitionSpecsList = new ArrayList(partitionSpecs);
    +
    +    for (int i = 0; i < partitionSpecNamesList.size(); i++) {
    +      List<String> partitionSpecNames = partitionSpecNamesList.get(i);
    +      if (partitionSpecNames.containsAll(partitionValuesFromExpression)) {
    +        prunePartitions
    +            .add(partitionSpecsList.get(i));
    +      }
    +    }
    +    return prunePartitions;
    +  }
    +
       private CarbonTableInputFormat<Object>  createInputFormat( Configuration 
conf,
    -       AbsoluteTableIdentifier identifier, Expression filterExpression)
    -          throws IOException {
    +      AbsoluteTableIdentifier identifier, Expression filterExpression, 
List<PartitionSpec> filteredPartitions)
    +      throws IOException {
         CarbonTableInputFormat format = new CarbonTableInputFormat<Object>();
         CarbonTableInputFormat.setTablePath(conf,
    -            identifier.appendWithLocalPrefix(identifier.getTablePath()));
    +        identifier.appendWithLocalPrefix(identifier.getTablePath()));
         CarbonTableInputFormat.setFilterPredicates(conf, filterExpression);
    -
    +    if(filteredPartitions.size() != 0) {
    +      CarbonTableInputFormat.setPartitionsToPrune(conf, new 
ArrayList<>(filteredPartitions));
    --- End diff --
    
    Why Create a new ArrayList here when the calling method is already 
returning a List


---

Reply via email to