You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Marta Kuczora (JIRA)" <ji...@apache.org> on 2018/05/03 13:51:00 UTC

[jira] [Commented] (HIVE-18977) Listing partitions returns different results with JDO and direct SQL

    [ https://issues.apache.org/jira/browse/HIVE-18977?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16462467#comment-16462467 ] 

Marta Kuczora commented on HIVE-18977:
--------------------------------------

* In the ObjectStore.listMPartitions method, the range was set only if the max parameter was bigger than 0. Because of this, all partitions were returned if the max parameter was 0. Fixed the condition to set the 0 max value as well.
 * When listing the partitions with the filter 'yYyY=2017', an expression tree is built where the keyName is 'yYyY'. The JDO filter is generated in the ExpressionTree.generateJDOFilterOverPartitions method. In this method first get the partition column index in the table partition column list that corresponds to the key in the tree node:
{noformat}
    public int getPartColIndexForFilter(
        Table table, FilterBuilder filterBuilder) throws MetaException {
      int partitionColumnIndex;
      assert (table.getPartitionKeys().size() > 0);
      for (partitionColumnIndex = 0; partitionColumnIndex < table.getPartitionKeys().size();
          ++partitionColumnIndex) {
        if (table.getPartitionKeys().get(partitionColumnIndex).getName().
            equalsIgnoreCase(keyName)) {
          break;
        }
      }
      if( partitionColumnIndex == table.getPartitionKeys().size()) {
        filterBuilder.setError("Specified key <" + keyName +
            "> is not a partitioning key for the table");
        return -1;
      }

      return partitionColumnIndex;
    }
{noformat}
The comparism is case insensitive, so the column name 'yYyY' will be accepted, even though it is saved as 'yyyy'.
 But later when creating the filter for Equals operator, the keyName will be passed which will be 'yYyY', so the partition won't be found in the db.
{noformat}
      if (isOpEquals || operator == Operator.NOTEQUALS || operator == Operator.NOTEQUALS2) {
        makeFilterForEquals(keyName, valueAsString, paramName, params,
            partitionColumnIndex, partitionColumnCount, isOpEquals, filterBuilder);
        return;
      }
{noformat}
 

 * There were differences also in the testGetNumPartitionsByFilterNullTblName and testGetNumPartitionsByFilterNullDbName tests when directSQL was enabled and disabled. They threw AssertionError if directSQL was enabled, because of the "assert table != null" check in the MetaStoreDirectSql.generateSqlFilter method. This method is not called if directSQL is disabled in config, so no AssertionError will occur in this case.

> Listing partitions returns different results with JDO and direct SQL
> --------------------------------------------------------------------
>
>                 Key: HIVE-18977
>                 URL: https://issues.apache.org/jira/browse/HIVE-18977
>             Project: Hive
>          Issue Type: Bug
>          Components: Metastore
>    Affects Versions: 3.0.0
>            Reporter: Alan Gates
>            Assignee: Marta Kuczora
>            Priority: Major
>         Attachments: HIVE-18977.1.patch
>
>
> Some of the tests in TestListPartitions fail when using JDO instead of direct SQL.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)