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

    https://github.com/apache/incubator-hawq/pull/906#discussion_r83092740
  
    --- Diff: 
pxf/pxf-hive/src/main/java/org/apache/hawq/pxf/plugins/hive/HiveAccessor.java 
---
    @@ -205,55 +217,138 @@ private boolean isFiltered(List<HivePartition> 
partitionFields,
             return testOneFilter(partitionFields, filter, inputData);
         }
     
    -    /*
    -     * We are testing one filter against all the partition fields. The 
filter
    -     * has the form "fieldA = valueA". The partitions have the form
    -     * 
partitionOne=valueOne/partitionTwo=ValueTwo/partitionThree=valueThree 1.
    -     * For a filter to match one of the partitions, lets say partitionA for
    -     * example, we need: fieldA = partittionOne and valueA = valueOne. If 
this
    -     * condition occurs, we return true. 2. If fieldA does not match any 
one of
    -     * the partition fields we also return true, it means we ignore this 
filter
    -     * because it is not on a partition field. 3. If fieldA = 
partittionOne and
    -     * valueA != valueOne, then we return false.
    -     */
    -    private boolean testOneFilter(List<HivePartition> partitionFields,
    -                                  Object filter, InputData input) {
    -        // Let's look first at the filter
    -        FilterParser.BasicFilter bFilter = (FilterParser.BasicFilter) 
filter;
    +    private boolean testForUnsupportedOperators(List<Object> filterList) {
    +        boolean nonAndOp = true;
    +        for (Object filter : filterList) {
    +            if (filter instanceof LogicalFilter) {
    +                if (((LogicalFilter) filter).getOperator() != 
FilterParser.LogicalOperation.HDOP_AND)
    +                    return false;
    +                if (((LogicalFilter) filter).getFilterList() != null)
    +                    nonAndOp = 
testForUnsupportedOperators(((LogicalFilter) filter).getFilterList());
    +            }
    +        }
    +        return nonAndOp;
    +    }
     
    -        boolean isFilterOperationEqual = (bFilter.getOperation() == 
FilterParser.Operation.HDOP_EQ);
    -        if (!isFilterOperationEqual) /*
    +    private boolean testForPartitionEquality(List<HivePartition> 
partitionFields, List<Object> filterList, InputData input) {
    +        boolean partitionAllowed = true;
    +        for (Object filter : filterList) {
    +            if (filter instanceof BasicFilter) {
    +                BasicFilter bFilter = (BasicFilter) filter;
    +                boolean isFilterOperationEqual = (bFilter.getOperation() 
== FilterParser.Operation.HDOP_EQ);
    +                if (!isFilterOperationEqual) /*
                                           * in case this is not an "equality 
filter"
                                           * we ignore it here - in partition
                                           * filtering
                                           */{
    -            return true;
    -        }
    +                    return true;
    +                }
    +
    +                int filterColumnIndex = bFilter.getColumn().index();
    +                String filterValue = 
bFilter.getConstant().constant().toString();
    +                ColumnDescriptor filterColumn = 
input.getColumn(filterColumnIndex);
    +                String filterColumnName = filterColumn.columnName();
     
    -        int filterColumnIndex = bFilter.getColumn().index();
    -        String filterValue = bFilter.getConstant().constant().toString();
    -        ColumnDescriptor filterColumn = input.getColumn(filterColumnIndex);
    -        String filterColumnName = filterColumn.columnName();
    +                for (HivePartition partition : partitionFields) {
    +                    if (filterColumnName.equals(partition.name)) {
     
    -        for (HivePartition partition : partitionFields) {
    -            if (filterColumnName.equals(partition.name)) {
                     /*
                      * the filter field matches a partition field, but the 
values do
                      * not match
                      */
    -                return filterValue.equals(partition.val);
    -            }
    -        }
    +                        boolean keepPartition = 
filterValue.equals(partition.val);
    +
    +                        /*
    +                         * If the string comparison fails then we should 
check the comparison of
    +                         * the two operands as typed values
    +                         */
    +                        if (!keepPartition && 
!partition.val.equals("__HIVE_DEFAULT_PARTITION__")){
    --- End diff --
    
    Make "__HIVE_DEFAULT_PARTITION__" a constant?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to