You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ng...@apache.org on 2021/04/06 15:39:44 UTC

[hive] branch master updated (46ddd5a -> 2eb0e00)

This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git.


    from 46ddd5a  HIVE-24895. Add a DataCopyEnd stage in ReplStateLogTask for external table replication. (#2083)(Ayush Saxena, reviewed by Pravin Kumar Sinha, Aasha Medhi)
     new 69e5417  External metastore: clean after rebase
     new 87c74ec  Adding DDL support for connectors (create/drop/show/desc/alter)
     new d65307d  Implemented getTable and getTableNames for MYSQL (working)
     new 91f1ccd  Added provider for postgres, refactored bunch of classes
     new 80013b4  Deleted commented out code and fixed location and IO classes
     new 0b9a4f4  HIVE-24396: Build failure in itests due to unimplemented interface methods
     new c6ed378  NullPointerException in CreateDatabaseOperation due to last change
     new 013a693  Adding a qtest and fixing type for default db
     new b30173d  Adding schema changes for mysql and postgres as well
     new 1523cd4  HIVE-24396: getTable/getTables API not expected to throw NoSuchObjectException
     new 7d91a9a  HIVE-24396: Added schema changes for Oracle             Made DBS.TYPE NOT NULL in all scripts             Added Type support to DatabaseBuilder             Added Unit test for DataConnector             Added Unit test REMOTE Database             Fixed test failures in TestSchemaToolForMetaStore
     new 6369daa  Missed change from the rebase
     new 7504491  HIVE-24396: Fix for drop database for remote databases
     new 683d0ae  HIVE-24396: qtest failures, regenerate them because of new columns
     new df8cb11  HIVE-24396: Follow up test failure fixes
     new a2a592f  Test failures with tez driver and duplicate error codes
     new 3de6032  HIVE-24396: refactored code to Abstract class and providers share common code
     new 23aafb7  Build issue with EventMessage
     new d66d5fc  fix for 2 additional test failures
     new 0b60db9  Retain case on table names during query processing
     new 9937963  HIVE-24396 Moving create/drop/alter APIs to the interface. Reverting fix for case sensitivity
     new 5a2236e  HIVE-24396: Build failure due to duplicate db definitions
     new 60ae013  HIVE-24396: Addressing test failures
     new 3e41782  HIVE-24396: Unhandled longvarchar and integer types for derby
     new 4779e86  HIVE-24396: Fix to CachedStore to make DBs NATIVE and fix to create_table_core on null DBs
     new 5c98e30  HIVE-24396: get_table_core() to return null instead of exception
     new 4319d29  HIVE-24396: Fix in connector provider to return null instead of blank Table
     new 2b4fa4e  HIVE-24396: Database name for remote table should be set to hive dbname not the scoped dbname
     new 506621c  HIVE-24396: Fix for NPE in get_database_core with null catalog name
     new d7a8eb7  HIVE-24396: Some changes with formatters after the rebase (Naveen Gangam)
     new 5f5ec66  HIVE-24396: Duplicate SQL statements in derby upgrade script (Naveen Gangam)
     new b9150e1  HIVE-24396: Incorporating feedback from the initial review (Naveen Gangam)
     new 14283d3  HIVE-24396: Cleanup and one test failure (Naveen Gangam)
     new 07ebf02  HIVE-24396: qtest failure (Naveen Gangam)
     new 53edee9  HIVE-24396: Changes from additional feedback from code review (Naveen Gangam)
     new cd90398  HIVE-24396: Conflict from rebase to master
     new 34720cf  HIVE-24396: Remaining comments from the feedback (Naveen Gangam)
     new 2eb0e00  HIVE-24396: Additional feedback incorporated (Naveen Gangam)             Removed ReplicationSpec for connectors             Notification event for alter connector             removed some code.

The 38 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/hadoop/hive/ql/ErrorMsg.java   |     3 +
 .../hcatalog/listener/DummyRawStoreFailEvent.java  |    27 +
 .../hadoop/hive/ql/parse/AlterClauseParser.g       |    31 +
 .../apache/hadoop/hive/ql/parse/CreateDDLParser.g  |    42 +
 .../apache/hadoop/hive/ql/parse/HiveLexerParent.g  |     6 +
 .../org/apache/hadoop/hive/ql/parse/HiveParser.g   |    35 +-
 .../hadoop/hive/ql/parse/IdentifiersParser.g       |     8 +-
 pom.xml                                            |     3 +
 .../database/create/CreateDatabaseAnalyzer.java    |    37 +-
 .../ql/ddl/database/create/CreateDatabaseDesc.java |    41 +-
 .../database/create/CreateDatabaseOperation.java   |    24 +-
 .../ql/ddl/database/desc/DescDatabaseDesc.java     |     6 +-
 .../ddl/database/desc/DescDatabaseFormatter.java   |    23 +-
 .../ddl/database/desc/DescDatabaseOperation.java   |    27 +-
 .../alter/AbstractAlterDataConnectorAnalyzer.java  |    42 +
 .../alter/AbstractAlterDataConnectorDesc.java      |    30 +-
 .../alter/AbstractAlterDataConnectorOperation.java |    55 +
 .../owner/AlterDataConnectorSetOwnerAnalyzer.java  |    54 +
 .../owner/AlterDataConnectorSetOwnerDesc.java      |    44 +
 .../owner/AlterDataConnectorSetOwnerOperation.java |    28 +-
 .../AlterDataConnectorSetPropertiesAnalyzer.java   |    57 +
 .../AlterDataConnectorSetPropertiesDesc.java       |    45 +
 .../AlterDataConnectorSetPropertiesOperation.java  |    50 +
 .../url/AlterDataConnectorSetUrlAnalyzer.java      |    45 +
 .../alter/url/AlterDataConnectorSetUrlDesc.java    |    30 +-
 .../url/AlterDataConnectorSetUrlOperation.java     |    59 +
 .../create/CreateDataConnectorAnalyzer.java}       |    52 +-
 .../create/CreateDataConnectorDesc.java}           |    54 +-
 .../create/CreateDataConnectorOperation.java       |    71 +
 .../desc/DescDataConnectorAnalyzer.java            |    61 +
 .../desc/DescDataConnectorDesc.java}               |    32 +-
 .../desc/DescDataConnectorFormatter.java}          |    58 +-
 .../desc/DescDataConnectorOperation.java}          |    30 +-
 .../drop/DropDataConnectorAnalyzer.java            |    58 +
 .../dataconnector/drop/DropDataConnectorDesc.java  |    51 +
 .../drop/DropDataConnectorOperation.java           |    45 +
 .../show/ShowDataConnectorsAnalyzer.java           |    57 +
 .../dataconnector/show/ShowDataConnectorsDesc.java |    54 +
 .../show/ShowDataConnectorsFormatter.java          |    69 +
 .../show/ShowDataConnectorsOperation.java          |    67 +
 .../org/apache/hadoop/hive/ql/hooks/Entity.java    |    33 +-
 .../apache/hadoop/hive/ql/hooks/ReadEntity.java    |     8 +
 .../apache/hadoop/hive/ql/hooks/WriteEntity.java   |     6 +
 .../org/apache/hadoop/hive/ql/metadata/Hive.java   |   109 +-
 .../hadoop/hive/ql/parse/BaseSemanticAnalyzer.java |    18 +
 .../apache/hadoop/hive/ql/plan/HiveOperation.java  |     8 +
 .../hive/ql/security/authorization/Privilege.java  |     3 +
 .../authorization/plugin/HiveOperationType.java    |     7 +
 .../plugin/sqlstd/Operation2Privilege.java         |     8 +
 ql/src/test/queries/clientpositive/dataconnector.q |    71 +
 .../clientpositive/beeline/escape_comments.q.out   |     4 +-
 .../llap/alter_change_db_location.q.out            |     2 +-
 .../clientpositive/llap/alter_db_owner.q.out       |     6 +-
 .../llap/authorization_owner_actions_db.q.out      |     2 +-
 .../clientpositive/llap/database_location.q.out    |     5 +-
 .../clientpositive/llap/database_properties.q.out  |     6 +-
 .../clientpositive/llap/dataconnector.q.out        |   205 +
 .../clientpositive/llap/db_ddl_explain.q.out       |     3 +-
 .../clientpositive/llap/describe_database.q.out    |     6 +-
 .../clientpositive/llap/unicode_comments.q.out     |     2 +-
 .../clientpositive/tez/explainanalyze_3.q.out      |     2 +-
 .../results/clientpositive/tez/explainuser_3.q.out |     2 +-
 standalone-metastore/metastore-common/pom.xml      |     1 +
 .../src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp |  8148 ++++++++-----
 .../src/gen/thrift/gen-cpp/ThriftHiveMetastore.h   |   700 ++
 .../ThriftHiveMetastore_server.skeleton.cpp        |    25 +
 .../gen/thrift/gen-cpp/hive_metastore_types.cpp    |  8976 ++++++++------
 .../src/gen/thrift/gen-cpp/hive_metastore_types.h  |   350 +-
 .../hive/metastore/api/AbortTxnsRequest.java       |    32 +-
 .../hive/metastore/api/AddDynamicPartitions.java   |    32 +-
 .../api/AllocateTableWriteIdsRequest.java          |    68 +-
 .../api/AllocateTableWriteIdsResponse.java         |    36 +-
 .../hive/metastore/api/AlterPartitionsRequest.java |    36 +-
 .../hive/metastore/api/AlterTableRequest.java      |    32 +-
 .../metastore/api/ClearFileMetadataRequest.java    |    32 +-
 .../hive/metastore/api/ClientCapabilities.java     |    36 +-
 .../hive/metastore/api/CommitTxnRequest.java       |    36 +-
 .../hive/metastore/api/CompactionRequest.java      |    44 +-
 ...sponse.java => CreateDataConnectorRequest.java} |   221 +-
 .../{Database.java => CreateDatabaseRequest.java}  |   555 +-
 .../hive/metastore/api/CreateTableRequest.java     |   248 +-
 .../api/{Database.java => DataConnector.java}      |   753 +-
 .../apache/hadoop/hive/metastore/api/Database.java |   338 +-
 .../hadoop/hive/metastore/api/DatabaseType.java    |    43 +
 .../hive/metastore/api/ExtendedTableInfo.java      |    64 +-
 .../hive/metastore/api/FindSchemasByColsResp.java  |    36 +-
 .../hive/metastore/api/FireEventRequest.java       |    32 +-
 .../hive/metastore/api/FireEventRequestData.java   |    36 +-
 .../hive/metastore/api/FireEventResponse.java      |    32 +-
 .../apache/hadoop/hive/metastore/api/Function.java |    36 +-
 .../metastore/api/GetAllFunctionsResponse.java     |    36 +-
 ...lesResult.java => GetDataConnectorRequest.java} |   221 +-
 .../hive/metastore/api/GetDatabaseRequest.java     |    32 +-
 .../hive/metastore/api/GetFieldsResponse.java      |    36 +-
 .../api/GetFileMetadataByExprRequest.java          |    32 +-
 .../metastore/api/GetFileMetadataByExprResult.java |    48 +-
 .../hive/metastore/api/GetFileMetadataRequest.java |    32 +-
 .../hive/metastore/api/GetFileMetadataResult.java  |    44 +-
 .../metastore/api/GetOpenTxnsInfoResponse.java     |    36 +-
 .../hive/metastore/api/GetOpenTxnsRequest.java     |    36 +-
 .../hive/metastore/api/GetOpenTxnsResponse.java    |    32 +-
 .../metastore/api/GetPartitionNamesPsRequest.java  |    32 +-
 .../metastore/api/GetPartitionNamesPsResponse.java |    32 +-
 .../hive/metastore/api/GetPartitionRequest.java    |    32 +-
 .../metastore/api/GetPartitionsFilterSpec.java     |    32 +-
 .../api/GetPartitionsPsWithAuthRequest.java        |    64 +-
 .../api/GetPartitionsPsWithAuthResponse.java       |    36 +-
 .../hive/metastore/api/GetPartitionsRequest.java   |    64 +-
 .../hive/metastore/api/GetPartitionsResponse.java  |    36 +-
 .../hive/metastore/api/GetProjectionsSpec.java     |    32 +-
 .../hive/metastore/api/GetSchemaResponse.java      |    36 +-
 .../hadoop/hive/metastore/api/GetTableRequest.java |    32 +-
 .../hive/metastore/api/GetTablesExtRequest.java    |    32 +-
 .../hive/metastore/api/GetTablesRequest.java       |    64 +-
 .../hadoop/hive/metastore/api/GetTablesResult.java |    36 +-
 .../metastore/api/GetValidWriteIdsRequest.java     |    32 +-
 .../metastore/api/GetValidWriteIdsResponse.java    |    36 +-
 .../metastore/api/HeartbeatTxnRangeResponse.java   |    64 +-
 .../hive/metastore/api/InsertEventRequestData.java |   128 +-
 .../hadoop/hive/metastore/api/LockRequest.java     |    36 +-
 .../metastore/api/NotificationEventRequest.java    |    32 +-
 .../metastore/api/NotificationEventResponse.java   |    36 +-
 .../hadoop/hive/metastore/api/OpenTxnRequest.java  |    32 +-
 .../hive/metastore/api/OpenTxnsResponse.java       |    32 +-
 .../hive/metastore/api/PartitionsResponse.java     |    36 +-
 .../hive/metastore/api/PutFileMetadataRequest.java |    64 +-
 .../hive/metastore/api/RenamePartitionRequest.java |    32 +-
 .../hadoop/hive/metastore/api/ReplLastIdInfo.java  |    32 +-
 .../metastore/api/ReplTblWriteIdStateRequest.java  |    32 +-
 .../hive/metastore/api/ReplicationMetricList.java  |    36 +-
 .../hadoop/hive/metastore/api/SchemaVersion.java   |    36 +-
 .../hive/metastore/api/ShowCompactResponse.java    |    36 +-
 .../hive/metastore/api/ShowLocksResponse.java      |    36 +-
 .../hive/metastore/api/TableValidWriteIds.java     |    32 +-
 .../hive/metastore/api/ThriftHiveMetastore.java    | 12180 ++++++++++++++-----
 .../hive/metastore/api/WMFullResourcePlan.java     |   144 +-
 .../api/WMGetAllResourcePlanResponse.java          |    36 +-
 .../api/WMGetTriggersForResourePlanResponse.java   |    36 +-
 .../api/WMValidateResourcePlanResponse.java        |    64 +-
 .../metastore/api/WriteNotificationLogRequest.java |    32 +-
 .../thrift/gen-php/metastore/AbortTxnsRequest.php  |    18 +-
 .../gen-php/metastore/AddDynamicPartitions.php     |    18 +-
 .../metastore/AllocateTableWriteIdsRequest.php     |    38 +-
 .../metastore/AllocateTableWriteIdsResponse.php    |    20 +-
 .../gen-php/metastore/AlterPartitionsRequest.php   |    20 +-
 .../thrift/gen-php/metastore/AlterTableRequest.php |    18 +-
 .../gen-php/metastore/ClearFileMetadataRequest.php |    18 +-
 .../gen-php/metastore/ClientCapabilities.php       |    18 +-
 .../thrift/gen-php/metastore/CommitTxnRequest.php  |    20 +-
 .../thrift/gen-php/metastore/CompactionRequest.php |    26 +-
 ...Response.php => CreateDataConnectorRequest.php} |    49 +-
 .../{Database.php => CreateDatabaseRequest.php}    |    98 +-
 .../gen-php/metastore/CreateTableRequest.php       |   138 +-
 .../metastore/{Database.php => DataConnector.php}  |   165 +-
 .../src/gen/thrift/gen-php/metastore/Database.php  |    72 +
 .../gen/thrift/gen-php/metastore/DatabaseType.php  |    30 +
 .../thrift/gen-php/metastore/ExtendedTableInfo.php |    36 +-
 .../gen-php/metastore/FindSchemasByColsResp.php    |    20 +-
 .../thrift/gen-php/metastore/FireEventRequest.php  |    18 +-
 .../gen-php/metastore/FireEventRequestData.php     |    20 +-
 .../thrift/gen-php/metastore/FireEventResponse.php |    18 +-
 .../src/gen/thrift/gen-php/metastore/Function.php  |    20 +-
 .../gen-php/metastore/GetAllFunctionsResponse.php  |    20 +-
 ...apabilities.php => GetDataConnectorRequest.php} |    48 +-
 .../gen-php/metastore/GetDatabaseRequest.php       |    18 +-
 .../thrift/gen-php/metastore/GetFieldsResponse.php |    20 +-
 .../metastore/GetFileMetadataByExprRequest.php     |    18 +-
 .../metastore/GetFileMetadataByExprResult.php      |    28 +-
 .../gen-php/metastore/GetFileMetadataRequest.php   |    18 +-
 .../gen-php/metastore/GetFileMetadataResult.php    |    26 +-
 .../gen-php/metastore/GetOpenTxnsInfoResponse.php  |    20 +-
 .../gen-php/metastore/GetOpenTxnsRequest.php       |    18 +-
 .../gen-php/metastore/GetOpenTxnsResponse.php      |    18 +-
 .../metastore/GetPartitionNamesPsRequest.php       |    18 +-
 .../metastore/GetPartitionNamesPsResponse.php      |    18 +-
 .../gen-php/metastore/GetPartitionRequest.php      |    18 +-
 .../gen-php/metastore/GetPartitionsFilterSpec.php  |    18 +-
 .../metastore/GetPartitionsPsWithAuthRequest.php   |    36 +-
 .../metastore/GetPartitionsPsWithAuthResponse.php  |    20 +-
 .../gen-php/metastore/GetPartitionsRequest.php     |    36 +-
 .../gen-php/metastore/GetPartitionsResponse.php    |    20 +-
 .../gen-php/metastore/GetProjectionsSpec.php       |    18 +-
 .../thrift/gen-php/metastore/GetSchemaResponse.php |    20 +-
 .../thrift/gen-php/metastore/GetTableRequest.php   |    18 +-
 .../gen-php/metastore/GetTablesExtRequest.php      |    18 +-
 .../thrift/gen-php/metastore/GetTablesRequest.php  |    36 +-
 .../thrift/gen-php/metastore/GetTablesResult.php   |    20 +-
 .../gen-php/metastore/GetValidWriteIdsRequest.php  |    18 +-
 .../gen-php/metastore/GetValidWriteIdsResponse.php |    20 +-
 .../metastore/HeartbeatTxnRangeResponse.php        |    36 +-
 .../gen-php/metastore/InsertEventRequestData.php   |    72 +-
 .../gen/thrift/gen-php/metastore/LockRequest.php   |    20 +-
 .../gen-php/metastore/NotificationEventRequest.php |    18 +-
 .../metastore/NotificationEventResponse.php        |    20 +-
 .../thrift/gen-php/metastore/OpenTxnRequest.php    |    18 +-
 .../thrift/gen-php/metastore/OpenTxnsResponse.php  |    18 +-
 .../gen-php/metastore/PartitionsResponse.php       |    20 +-
 .../gen-php/metastore/PutFileMetadataRequest.php   |    36 +-
 .../gen-php/metastore/RenamePartitionRequest.php   |    18 +-
 .../thrift/gen-php/metastore/ReplLastIdInfo.php    |    18 +-
 .../metastore/ReplTblWriteIdStateRequest.php       |    18 +-
 .../gen-php/metastore/ReplicationMetricList.php    |    20 +-
 .../gen/thrift/gen-php/metastore/SchemaVersion.php |    20 +-
 .../gen-php/metastore/ShowCompactResponse.php      |    20 +-
 .../thrift/gen-php/metastore/ShowLocksResponse.php |    20 +-
 .../gen-php/metastore/TableValidWriteIds.php       |    18 +-
 .../metastore/ThriftHiveMetastoreClient.php        |   321 +
 .../gen-php/metastore/ThriftHiveMetastoreIf.php    |    35 +
 .../ThriftHiveMetastore_add_partitions_args.php    |    20 +-
 ...riftHiveMetastore_add_partitions_pspec_args.php |    20 +-
 ...riftHiveMetastore_alter_dataconnector_args.php} |    65 +-
 ...ftHiveMetastore_alter_dataconnector_result.php} |    50 +-
 .../ThriftHiveMetastore_alter_partitions_args.php  |    20 +-
 ...er_partitions_with_environment_context_args.php |    20 +-
 .../ThriftHiveMetastore_append_partition_args.php  |    18 +-
 ...end_partition_with_environment_context_args.php |    18 +-
 ...iftHiveMetastore_create_dataconnector_args.php} |    49 +-
 ...tHiveMetastore_create_dataconnector_result.php} |    84 +-
 ...etastore_create_table_with_constraints_args.php |   120 +-
 ...hriftHiveMetastore_drop_dataconnector_args.php} |    92 +-
 ...iftHiveMetastore_drop_dataconnector_result.php} |    80 +-
 .../ThriftHiveMetastore_drop_partition_args.php    |    18 +-
 ...rop_partition_with_environment_context_args.php |    18 +-
 ...ThriftHiveMetastore_exchange_partition_args.php |    26 +-
 ...hriftHiveMetastore_exchange_partitions_args.php |    26 +-
 ...iftHiveMetastore_exchange_partitions_result.php |    20 +-
 ...iveMetastore_find_columns_with_stats_result.php |    18 +-
 ...hriftHiveMetastore_get_all_databases_result.php |    18 +-
 ...erialized_view_objects_for_rewriting_result.php |    20 +-
 ...ThriftHiveMetastore_get_all_packages_result.php |    18 +-
 ...eMetastore_get_all_stored_procedures_result.php |    18 +-
 .../ThriftHiveMetastore_get_all_tables_result.php  |    18 +-
 ...eMetastore_get_all_token_identifiers_result.php |    18 +-
 .../ThriftHiveMetastore_get_databases_result.php   |    18 +-
 ...ftHiveMetastore_get_dataconnector_req_args.php} |    49 +-
 ...HiveMetastore_get_dataconnector_req_result.php} |    39 +-
 ...ThriftHiveMetastore_get_dataconnectors_args.php |    68 +
 ...iftHiveMetastore_get_dataconnectors_result.php} |    24 +-
 .../ThriftHiveMetastore_get_fields_result.php      |    20 +-
 ..._get_fields_with_environment_context_result.php |    20 +-
 .../ThriftHiveMetastore_get_functions_result.php   |    18 +-
 .../ThriftHiveMetastore_get_master_keys_result.php |    18 +-
 ...get_materialized_views_for_rewriting_result.php |    18 +-
 ...veMetastore_get_part_specs_by_filter_result.php |    20 +-
 .../ThriftHiveMetastore_get_partition_args.php     |    18 +-
 ...ftHiveMetastore_get_partition_names_ps_args.php |    18 +-
 ...HiveMetastore_get_partition_names_ps_result.php |    18 +-
 ...iveMetastore_get_partition_names_req_result.php |    18 +-
 ...iftHiveMetastore_get_partition_names_result.php |    18 +-
 ...tHiveMetastore_get_partition_with_auth_args.php |    36 +-
 ...veMetastore_get_partitions_by_filter_result.php |    20 +-
 ...tHiveMetastore_get_partitions_by_names_args.php |    18 +-
 ...iveMetastore_get_partitions_by_names_result.php |    20 +-
 .../ThriftHiveMetastore_get_partitions_ps_args.php |    18 +-
 ...hriftHiveMetastore_get_partitions_ps_result.php |    20 +-
 ...eMetastore_get_partitions_ps_with_auth_args.php |    36 +-
 ...etastore_get_partitions_ps_with_auth_result.php |    20 +-
 ...ftHiveMetastore_get_partitions_pspec_result.php |    20 +-
 .../ThriftHiveMetastore_get_partitions_result.php  |    20 +-
 ...HiveMetastore_get_partitions_with_auth_args.php |    18 +-
 ...veMetastore_get_partitions_with_auth_result.php |    20 +-
 .../ThriftHiveMetastore_get_privilege_set_args.php |    18 +-
 .../ThriftHiveMetastore_get_role_names_result.php  |    18 +-
 ...hriftHiveMetastore_get_runtime_stats_result.php |    20 +-
 ...iveMetastore_get_schema_all_versions_result.php |    20 +-
 .../ThriftHiveMetastore_get_schema_result.php      |    20 +-
 ..._get_schema_with_environment_context_result.php |    20 +-
 .../ThriftHiveMetastore_get_table_meta_args.php    |    18 +-
 .../ThriftHiveMetastore_get_table_meta_result.php  |    20 +-
 ...eMetastore_get_table_names_by_filter_result.php |    18 +-
 ...iveMetastore_get_table_objects_by_name_args.php |    18 +-
 ...eMetastore_get_table_objects_by_name_result.php |    20 +-
 ...riftHiveMetastore_get_tables_by_type_result.php |    18 +-
 .../ThriftHiveMetastore_get_tables_ext_result.php  |    20 +-
 .../ThriftHiveMetastore_get_tables_result.php      |    18 +-
 .../ThriftHiveMetastore_get_type_all_result.php    |    28 +-
 ...iveMetastore_isPartitionMarkedForEvent_args.php |    26 +-
 .../ThriftHiveMetastore_list_privileges_result.php |    20 +-
 .../ThriftHiveMetastore_list_roles_result.php      |    20 +-
 ...iftHiveMetastore_markPartitionForEvent_args.php |    26 +-
 ...re_partition_name_has_valid_characters_args.php |    18 +-
 ...HiveMetastore_partition_name_to_spec_result.php |    26 +-
 ...HiveMetastore_partition_name_to_vals_result.php |    18 +-
 .../ThriftHiveMetastore_rename_partition_args.php  |    18 +-
 .../metastore/ThriftHiveMetastore_set_ugi_args.php |    18 +-
 .../ThriftHiveMetastore_set_ugi_result.php         |    18 +-
 .../ThriftHiveMetastore_truncate_table_args.php    |    18 +-
 .../gen-php/metastore/WMFullResourcePlan.php       |    80 +-
 .../metastore/WMGetAllResourcePlanResponse.php     |    20 +-
 .../WMGetTriggersForResourePlanResponse.php        |    20 +-
 .../metastore/WMValidateResourcePlanResponse.php   |    36 +-
 .../metastore/WriteNotificationLogRequest.php      |    18 +-
 .../hive_metastore/ThriftHiveMetastore-remote      |    35 +
 .../gen-py/hive_metastore/ThriftHiveMetastore.py   |  3066 +++--
 .../src/gen/thrift/gen-py/hive_metastore/ttypes.py |  1645 ++-
 .../src/gen/thrift/gen-rb/hive_metastore_types.rb  |   134 +-
 .../src/gen/thrift/gen-rb/thrift_hive_metastore.rb |   331 +
 .../hadoop/hive/metastore/HiveMetaStoreClient.java |    68 +
 .../hadoop/hive/metastore/IMetaStoreClient.java    |    52 +
 .../apache/hadoop/hive/metastore/Warehouse.java    |     4 +
 .../hadoop/hive/metastore/conf/MetastoreConf.java  |    10 +
 .../hadoop/hive/metastore/utils/FilterUtils.java   |    20 +
 .../src/main/thrift/hive_metastore.thrift          |    54 +-
 standalone-metastore/metastore-server/pom.xml      |     1 +
 .../apache/hadoop/hive/metastore/HMSHandler.java   |   447 +-
 .../apache/hadoop/hive/metastore/IHMSHandler.java  |    12 +
 .../hadoop/hive/metastore/MetaStoreDirectSql.java  |    14 +-
 .../hive/metastore/MetaStoreEventListener.java     |    24 +
 .../hive/metastore/MetaStoreListenerNotifier.java  |    23 +
 .../apache/hadoop/hive/metastore/ObjectStore.java  |   218 +-
 .../org/apache/hadoop/hive/metastore/RawStore.java |    47 +
 .../TransactionalMetaStoreEventListener.java       |    14 +
 .../hadoop/hive/metastore/cache/CachedStore.java   |    29 +
 .../metastore/client/builder/DatabaseBuilder.java  |    33 +
 .../AbstractDataConnectorProvider.java             |   132 +
 .../DataConnectorProviderFactory.java              |    89 +
 .../dataconnector/IDataConnectorProvider.java      |    93 +
 .../JDBCConnectorProviderFactory.java              |    32 +
 .../jdbc/AbstractJDBCConnectorProvider.java        |   314 +
 .../jdbc/DerbySQLConnectorProvider.java            |    86 +
 .../dataconnector/jdbc/MySQLConnectorProvider.java |    87 +
 .../jdbc/PostgreSQLConnectorProvider.java          |    70 +
 ...ntContext.java => AlterDataConnectorEvent.java} |    61 +-
 .../CreateDataConnectorEvent.java}                 |    32 +-
 .../metastore/events/DropDataConnectorEvent.java   |    26 +
 .../events/PreCreateDataConnectorEvent.java        |    24 +
 .../hive/metastore/events/PreEventContext.java     |     5 +-
 .../hive/metastore/messaging/EventMessage.java     |     5 +-
 .../hive/metastore/messaging/MessageBuilder.java   |     3 +
 .../model/{MDatabase.java => MDataConnector.java}  |    85 +-
 .../hadoop/hive/metastore/model/MDatabase.java     |    62 +
 .../src/main/resources/package.jdo                 |    45 +-
 .../src/main/sql/derby/hive-schema-4.0.0.derby.sql |    11 +-
 .../sql/derby/upgrade-3.2.0-to-4.0.0.derby.sql     |    11 +
 .../src/main/sql/mysql/hive-schema-4.0.0.mysql.sql |    24 +
 .../sql/mysql/upgrade-3.2.0-to-4.0.0.mysql.sql     |    26 +
 .../main/sql/oracle/hive-schema-4.0.0.oracle.sql   |    25 +-
 .../sql/oracle/upgrade-3.2.0-to-4.0.0.oracle.sql   |    25 +
 .../sql/postgres/hive-schema-4.0.0.postgres.sql    |    25 +-
 .../postgres/upgrade-3.2.0-to-4.0.0.postgres.sql   |    25 +
 .../metastore/DummyRawStoreControlledCommit.java   |    32 +-
 .../metastore/DummyRawStoreForJdoConnection.java   |    54 +-
 .../metastore/HiveMetaStoreClientPreCatalog.java   |    44 +-
 .../hadoop/hive/metastore/TestHiveMetaStore.java   |   140 +-
 .../hive/metastore/cache/TestCachedStore.java      |     1 +
 .../schematool/TestSchemaToolForMetastore.java     |    18 +-
 .../upgrade-3.1.3000-to-4.0.0.postgres.sql         |    28 +
 standalone-metastore/pom.xml                       |     1 +
 testutils/ptest2/pom.xml                           |     1 +
 349 files changed, 33347 insertions(+), 16740 deletions(-)
 create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorAnalyzer.java
 copy standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/TransactionalMetaStoreEventListener.java => ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorDesc.java (53%)
 create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorOperation.java
 create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerAnalyzer.java
 create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerDesc.java
 copy standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/TransactionalMetaStoreEventListener.java => ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerOperation.java (50%)
 create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesAnalyzer.java
 create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesDesc.java
 create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesOperation.java
 create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlAnalyzer.java
 copy standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/TransactionalMetaStoreEventListener.java => ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlDesc.java (50%)
 create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlOperation.java
 copy ql/src/java/org/apache/hadoop/hive/ql/ddl/{database/create/CreateDatabaseAnalyzer.java => dataconnector/create/CreateDataConnectorAnalyzer.java} (61%)
 copy ql/src/java/org/apache/hadoop/hive/ql/ddl/{database/create/CreateDatabaseDesc.java => dataconnector/create/CreateDataConnectorDesc.java} (54%)
 create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/create/CreateDataConnectorOperation.java
 create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/desc/DescDataConnectorAnalyzer.java
 copy ql/src/java/org/apache/hadoop/hive/ql/ddl/{database/desc/DescDatabaseDesc.java => dataconnector/desc/DescDataConnectorDesc.java} (61%)
 copy ql/src/java/org/apache/hadoop/hive/ql/ddl/{database/desc/DescDatabaseFormatter.java => dataconnector/desc/DescDataConnectorFormatter.java} (65%)
 copy ql/src/java/org/apache/hadoop/hive/ql/ddl/{database/desc/DescDatabaseOperation.java => dataconnector/desc/DescDataConnectorOperation.java} (59%)
 create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorAnalyzer.java
 create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorDesc.java
 create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorOperation.java
 create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsAnalyzer.java
 create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsDesc.java
 create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsFormatter.java
 create mode 100644 ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsOperation.java
 create mode 100644 ql/src/test/queries/clientpositive/dataconnector.q
 create mode 100644 ql/src/test/results/clientpositive/llap/dataconnector.q.out
 copy standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/{FireEventResponse.java => CreateDataConnectorRequest.java} (55%)
 copy standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/{Database.java => CreateDatabaseRequest.java} (73%)
 copy standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/{Database.java => DataConnector.java} (64%)
 create mode 100644 standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/DatabaseType.java
 copy standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/{GetTablesResult.java => GetDataConnectorRequest.java} (55%)
 copy standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/{FireEventResponse.php => CreateDataConnectorRequest.php} (56%)
 copy standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/{Database.php => CreateDatabaseRequest.php} (77%)
 copy standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/{Database.php => DataConnector.php} (66%)
 create mode 100644 standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/DatabaseType.php
 copy standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/{ClientCapabilities.php => GetDataConnectorRequest.php} (53%)
 copy standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/{ThriftHiveMetastore_set_ugi_args.php => ThriftHiveMetastore_alter_dataconnector_args.php} (55%)
 copy standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/{ThriftHiveMetastore_get_partition_names_ps_result.php => ThriftHiveMetastore_alter_dataconnector_result.php} (63%)
 copy standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/{FireEventResponse.php => ThriftHiveMetastore_create_dataconnector_args.php} (56%)
 copy standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/{ThriftHiveMetastore_get_partition_names_result.php => ThriftHiveMetastore_create_dataconnector_result.php} (64%)
 copy standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/{ThriftHiveMetastore_set_ugi_args.php => ThriftHiveMetastore_drop_dataconnector_args.php} (52%)
 copy standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/{ThriftHiveMetastore_get_partition_names_result.php => ThriftHiveMetastore_drop_dataconnector_result.php} (67%)
 copy standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/{FireEventResponse.php => ThriftHiveMetastore_get_dataconnector_req_args.php} (56%)
 copy standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/{ThriftHiveMetastore_get_partition_names_result.php => ThriftHiveMetastore_get_dataconnector_req_result.php} (76%)
 create mode 100644 standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/ThriftHiveMetastore_get_dataconnectors_args.php
 copy standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/{ThriftHiveMetastore_get_tables_by_type_result.php => ThriftHiveMetastore_get_dataconnectors_result.php} (86%)
 create mode 100644 standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/AbstractDataConnectorProvider.java
 create mode 100644 standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/DataConnectorProviderFactory.java
 create mode 100644 standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/IDataConnectorProvider.java
 create mode 100644 standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/JDBCConnectorProviderFactory.java
 create mode 100644 standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
 create mode 100644 standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/DerbySQLConnectorProvider.java
 create mode 100644 standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConnectorProvider.java
 create mode 100644 standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/PostgreSQLConnectorProvider.java
 copy standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/events/{PreEventContext.java => AlterDataConnectorEvent.java} (52%)
 copy standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/{TransactionalMetaStoreEventListener.java => events/CreateDataConnectorEvent.java} (54%)
 create mode 100644 standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/events/DropDataConnectorEvent.java
 create mode 100644 standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/events/PreCreateDataConnectorEvent.java
 copy standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/model/{MDatabase.java => MDataConnector.java} (53%)

[hive] 18/38: Build issue with EventMessage

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 23aafb738b8486cf0a14157355f5ab45c906e2de
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Mon Nov 23 19:03:44 2020 -0500

    Build issue with EventMessage
---
 .../java/org/apache/hadoop/hive/metastore/messaging/EventMessage.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/EventMessage.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/EventMessage.java
index c86466e..1b2fa57 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/EventMessage.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/EventMessage.java
@@ -68,7 +68,7 @@ public abstract class EventMessage {
     DELETE_TABLE_COLUMN_STAT(MessageBuilder.DELETE_TBL_COL_STAT_EVENT),
     UPDATE_PARTITION_COLUMN_STAT(MessageBuilder.UPDATE_PART_COL_STAT_EVENT),
     DELETE_PARTITION_COLUMN_STAT(MessageBuilder.DELETE_PART_COL_STAT_EVENT),
-    COMMIT_COMPACTION(MessageBuilder.COMMIT_COMPACTION_EVENT);
+    COMMIT_COMPACTION(MessageBuilder.COMMIT_COMPACTION_EVENT),
     CREATE_DATACONNECTOR(MessageBuilder.CREATE_DATACONNECTOR_EVENT),
     DROP_DATACONNECTOR(MessageBuilder.DROP_DATACONNECTOR_EVENT),
     ALTER_DATACONNECTOR(MessageBuilder.ALTER_DATACONNECTOR_EVENT);

[hive] 14/38: HIVE-24396: qtest failures, regenerate them because of new columns

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 683d0ae3d87546409dc0c7d4b29da0a318ea0c65
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Fri Nov 20 21:53:54 2020 -0500

    HIVE-24396: qtest failures, regenerate them because of new columns
---
 .../llap/alter_change_db_location.q.out            |  5 ++-
 .../clientpositive/llap/alter_db_owner.q.out       |  6 +--
 .../llap/authorization_owner_actions_db.q.out      |  2 +-
 .../clientpositive/llap/database_location.q.out    | 52 +++++++++++++---------
 .../clientpositive/llap/database_properties.q.out  |  6 +--
 .../clientpositive/llap/db_ddl_explain.q.out       |  5 ++-
 .../clientpositive/llap/describe_database.q.out    |  6 +--
 .../clientpositive/llap/unicode_comments.q.out     |  4 +-
 .../hadoop/hive/metastore/TestHiveMetaStore.java   |  2 +-
 9 files changed, 49 insertions(+), 39 deletions(-)

diff --git a/ql/src/test/results/clientpositive/llap/alter_change_db_location.q.out b/ql/src/test/results/clientpositive/llap/alter_change_db_location.q.out
index 4c21153..2469cea 100644
--- a/ql/src/test/results/clientpositive/llap/alter_change_db_location.q.out
+++ b/ql/src/test/results/clientpositive/llap/alter_change_db_location.q.out
@@ -1,17 +1,18 @@
 #### A masked pattern was here ####
 PREHOOK: type: CREATEDATABASE
 PREHOOK: Output: database:newDB
+PREHOOK: Output: hdfs://### HDFS PATH ###
 #### A masked pattern was here ####
 POSTHOOK: type: CREATEDATABASE
 POSTHOOK: Output: database:newDB
-#### A masked pattern was here ####
+POSTHOOK: Output: hdfs://### HDFS PATH ###
 PREHOOK: query: describe database extended newDB
 PREHOOK: type: DESCDATABASE
 PREHOOK: Input: database:newdb
 POSTHOOK: query: describe database extended newDB
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:newdb
-newdb		location/in/test		hive_test_user	USER	
+newdb		location/in/test		hive_test_user	USER			
 PREHOOK: query: use newDB
 PREHOOK: type: SWITCHDATABASE
 PREHOOK: Input: database:newdb
diff --git a/ql/src/test/results/clientpositive/llap/alter_db_owner.q.out b/ql/src/test/results/clientpositive/llap/alter_db_owner.q.out
index e7434ba..7e0316f 100644
--- a/ql/src/test/results/clientpositive/llap/alter_db_owner.q.out
+++ b/ql/src/test/results/clientpositive/llap/alter_db_owner.q.out
@@ -10,7 +10,7 @@ PREHOOK: Input: database:db_alter_onr
 POSTHOOK: query: describe database db_alter_onr
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:db_alter_onr
-db_alter_onr		location/in/test		hive_test_user	USER
+db_alter_onr		location/in/test		hive_test_user	USER		
 #### A masked pattern was here ####
 PREHOOK: type: ALTERDATABASE_OWNER
 PREHOOK: Output: database:db_alter_onr
@@ -40,7 +40,7 @@ PREHOOK: Input: database:db_alter_onr
 POSTHOOK: query: describe database db_alter_onr
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:db_alter_onr
-db_alter_onr		location/in/test		user1	USER
+db_alter_onr		location/in/test		user1	USER		
 #### A masked pattern was here ####
 PREHOOK: type: ALTERDATABASE_OWNER
 PREHOOK: Output: database:db_alter_onr
@@ -53,4 +53,4 @@ PREHOOK: Input: database:db_alter_onr
 POSTHOOK: query: describe database db_alter_onr
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:db_alter_onr
-db_alter_onr		location/in/test		role1	ROLE
+db_alter_onr		location/in/test		role1	ROLE		
diff --git a/ql/src/test/results/clientpositive/llap/authorization_owner_actions_db.q.out b/ql/src/test/results/clientpositive/llap/authorization_owner_actions_db.q.out
index 0267f86..4b0f3f9 100644
--- a/ql/src/test/results/clientpositive/llap/authorization_owner_actions_db.q.out
+++ b/ql/src/test/results/clientpositive/llap/authorization_owner_actions_db.q.out
@@ -28,7 +28,7 @@ PREHOOK: Input: database:testdb
 POSTHOOK: query: desc database testdb
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:testdb
-testdb		location/in/test		testrole	ROLE
+testdb		location/in/test		testrole	ROLE		
 PREHOOK: query: use testdb
 PREHOOK: type: SWITCHDATABASE
 PREHOOK: Input: database:testdb
diff --git a/ql/src/test/results/clientpositive/llap/database_location.q.out b/ql/src/test/results/clientpositive/llap/database_location.q.out
index 7969277..b998e7e 100644
--- a/ql/src/test/results/clientpositive/llap/database_location.q.out
+++ b/ql/src/test/results/clientpositive/llap/database_location.q.out
@@ -10,7 +10,7 @@ PREHOOK: Input: database:db1
 POSTHOOK: query: DESCRIBE DATABASE EXTENDED db1
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:db1
-db1		location/in/test		hive_test_user	USER	
+db1		location/in/test		hive_test_user	USER			
 PREHOOK: query: USE db1
 PREHOOK: type: SWITCHDATABASE
 PREHOOK: Input: database:db1
@@ -72,20 +72,20 @@ COMMENT 'database 2'
 #### A masked pattern was here ####
 PREHOOK: type: CREATEDATABASE
 PREHOOK: Output: database:db2
-#### A masked pattern was here ####
+PREHOOK: Output: hdfs://### HDFS PATH ###
 POSTHOOK: query: CREATE DATABASE db2
 COMMENT 'database 2'
 #### A masked pattern was here ####
 POSTHOOK: type: CREATEDATABASE
 POSTHOOK: Output: database:db2
-#### A masked pattern was here ####
+POSTHOOK: Output: hdfs://### HDFS PATH ###
 PREHOOK: query: DESCRIBE DATABASE EXTENDED db2
 PREHOOK: type: DESCDATABASE
 PREHOOK: Input: database:db2
 POSTHOOK: query: DESCRIBE DATABASE EXTENDED db2
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:db2
-db2	database 2	location/in/test		hive_test_user	USER	
+db2	database 2	location/in/test		hive_test_user	USER			
 PREHOOK: query: USE db2
 PREHOOK: type: SWITCHDATABASE
 PREHOOK: Input: database:db2
@@ -147,32 +147,38 @@ CREATE DATABASE db3
 #### A masked pattern was here ####
 PREHOOK: type: CREATEDATABASE
 PREHOOK: Output: database:db3
-#### A masked pattern was here ####
+PREHOOK: Output: hdfs://### HDFS PATH ###
+PREHOOK: Output: hdfs://### HDFS PATH ###
 POSTHOOK: query: EXPLAIN
 CREATE DATABASE db3
 #### A masked pattern was here ####
 POSTHOOK: type: CREATEDATABASE
 POSTHOOK: Output: database:db3
-#### A masked pattern was here ####
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: Output: hdfs://### HDFS PATH ###
 STAGE DEPENDENCIES:
   Stage-0 is a root stage
 
 STAGE PLANS:
   Stage: Stage-0
     Create Database
-#### A masked pattern was here ####
+      database type:
+      locationUri: hdfs://### HDFS PATH ###
+      managed location uri: hdfs://### HDFS PATH ###
       name: db3
 
 PREHOOK: query: CREATE DATABASE db3
 #### A masked pattern was here ####
 PREHOOK: type: CREATEDATABASE
 PREHOOK: Output: database:db3
-#### A masked pattern was here ####
+PREHOOK: Output: hdfs://### HDFS PATH ###
+PREHOOK: Output: hdfs://### HDFS PATH ###
 POSTHOOK: query: CREATE DATABASE db3
 #### A masked pattern was here ####
 POSTHOOK: type: CREATEDATABASE
 POSTHOOK: Output: database:db3
-#### A masked pattern was here ####
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: Output: hdfs://### HDFS PATH ###
 PREHOOK: query: SHOW CREATE DATABASE db3
 PREHOOK: type: SHOW_CREATEDATABASE
 PREHOOK: Input: database:db3
@@ -181,26 +187,26 @@ POSTHOOK: type: SHOW_CREATEDATABASE
 POSTHOOK: Input: database:db3
 CREATE DATABASE `db3`
 LOCATION
-#### A masked pattern was here ####
+  'hdfs://### HDFS PATH ###'
 MANAGEDLOCATION
-#### A masked pattern was here ####
+  'hdfs://### HDFS PATH ###'
 PREHOOK: query: DESCRIBE DATABASE db3
 PREHOOK: type: DESCDATABASE
 PREHOOK: Input: database:db3
 POSTHOOK: query: DESCRIBE DATABASE db3
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:db3
-#### A masked pattern was here ####
+db3		location/in/test	hdfs://### HDFS PATH ###	hive_test_user	USER		
 PREHOOK: query: EXPLAIN
 #### A masked pattern was here ####
 PREHOOK: type: ALTERDATABASE_LOCATION
 PREHOOK: Output: database:db3
-#### A masked pattern was here ####
+PREHOOK: Output: hdfs://### HDFS PATH ###
 POSTHOOK: query: EXPLAIN
 #### A masked pattern was here ####
 POSTHOOK: type: ALTERDATABASE_LOCATION
 POSTHOOK: Output: database:db3
-#### A masked pattern was here ####
+POSTHOOK: Output: hdfs://### HDFS PATH ###
 STAGE DEPENDENCIES:
   Stage-0 is a root stage
 
@@ -208,32 +214,33 @@ STAGE PLANS:
   Stage: Stage-0
 #### A masked pattern was here ####
       name: db3
-#### A masked pattern was here ####
+      location: hdfs://### HDFS PATH ###
 
 #### A masked pattern was here ####
 PREHOOK: type: ALTERDATABASE_LOCATION
 PREHOOK: Output: database:db3
+PREHOOK: Output: hdfs://### HDFS PATH ###
 #### A masked pattern was here ####
 POSTHOOK: type: ALTERDATABASE_LOCATION
 POSTHOOK: Output: database:db3
-#### A masked pattern was here ####
+POSTHOOK: Output: hdfs://### HDFS PATH ###
 PREHOOK: query: DESCRIBE DATABASE db3
 PREHOOK: type: DESCDATABASE
 PREHOOK: Input: database:db3
 POSTHOOK: query: DESCRIBE DATABASE db3
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:db3
-#### A masked pattern was here ####
+db3		location/in/test	hdfs://### HDFS PATH ###	hive_test_user	USER		
 PREHOOK: query: EXPLAIN
 #### A masked pattern was here ####
 PREHOOK: type: ALTERDATABASE_LOCATION
 PREHOOK: Output: database:db3
-#### A masked pattern was here ####
+PREHOOK: Output: hdfs://### HDFS PATH ###
 POSTHOOK: query: EXPLAIN
 #### A masked pattern was here ####
 POSTHOOK: type: ALTERDATABASE_LOCATION
 POSTHOOK: Output: database:db3
-#### A masked pattern was here ####
+POSTHOOK: Output: hdfs://### HDFS PATH ###
 STAGE DEPENDENCIES:
   Stage-0 is a root stage
 
@@ -241,19 +248,20 @@ STAGE PLANS:
   Stage: Stage-0
 #### A masked pattern was here ####
       name: db3
-#### A masked pattern was here ####
+      managed location: hdfs://### HDFS PATH ###
 
 #### A masked pattern was here ####
 PREHOOK: type: ALTERDATABASE_LOCATION
 PREHOOK: Output: database:db3
+PREHOOK: Output: hdfs://### HDFS PATH ###
 #### A masked pattern was here ####
 POSTHOOK: type: ALTERDATABASE_LOCATION
 POSTHOOK: Output: database:db3
-#### A masked pattern was here ####
+POSTHOOK: Output: hdfs://### HDFS PATH ###
 PREHOOK: query: DESCRIBE DATABASE db3
 PREHOOK: type: DESCDATABASE
 PREHOOK: Input: database:db3
 POSTHOOK: query: DESCRIBE DATABASE db3
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:db3
-#### A masked pattern was here ####
+db3		location/in/test	hdfs://### HDFS PATH ###	hive_test_user	USER		
diff --git a/ql/src/test/results/clientpositive/llap/database_properties.q.out b/ql/src/test/results/clientpositive/llap/database_properties.q.out
index 2febbd8..d5b0e70 100644
--- a/ql/src/test/results/clientpositive/llap/database_properties.q.out
+++ b/ql/src/test/results/clientpositive/llap/database_properties.q.out
@@ -28,14 +28,14 @@ PREHOOK: Input: database:db2
 POSTHOOK: query: describe database db2
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:db2
-db2		location/in/test		hive_test_user	USER
+db2		location/in/test		hive_test_user	USER		
 PREHOOK: query: describe database extended db2
 PREHOOK: type: DESCDATABASE
 PREHOOK: Input: database:db2
 POSTHOOK: query: describe database extended db2
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:db2
-db2		location/in/test		hive_test_user	USER	{hive.warehouse.dir=/user/hive/warehouse, mapred.jobtracker.url=http://my.jobtracker.com:53000, mapred.scratch.dir=hdfs://### HDFS PATH ###}
+db2		location/in/test		hive_test_user	USER			{hive.warehouse.dir=/user/hive/warehouse, mapred.jobtracker.url=http://my.jobtracker.com:53000, mapred.scratch.dir=hdfs://### HDFS PATH ###}
 PREHOOK: query: alter database db2 set dbproperties (
   'new.property' = 'some new props',
   'hive.warehouse.dir' = 'new/warehouse/dir')
@@ -52,4 +52,4 @@ PREHOOK: Input: database:db2
 POSTHOOK: query: describe database extended db2
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:db2
-db2		location/in/test		hive_test_user	USER	{hive.warehouse.dir=new/warehouse/dir, mapred.jobtracker.url=http://my.jobtracker.com:53000, mapred.scratch.dir=hdfs://### HDFS PATH ###, new.property=some new props}
+db2		location/in/test		hive_test_user	USER			{hive.warehouse.dir=new/warehouse/dir, mapred.jobtracker.url=http://my.jobtracker.com:53000, mapred.scratch.dir=hdfs://### HDFS PATH ###, new.property=some new props}
diff --git a/ql/src/test/results/clientpositive/llap/db_ddl_explain.q.out b/ql/src/test/results/clientpositive/llap/db_ddl_explain.q.out
index 955dbf6..3ba6778 100644
--- a/ql/src/test/results/clientpositive/llap/db_ddl_explain.q.out
+++ b/ql/src/test/results/clientpositive/llap/db_ddl_explain.q.out
@@ -10,6 +10,7 @@ STAGE DEPENDENCIES:
 STAGE PLANS:
   Stage: Stage-0
     Create Database
+      database type:
       name: d
 
 PREHOOK: query: CREATE DATABASE d
@@ -69,7 +70,7 @@ PREHOOK: Input: database:d
 POSTHOOK: query: DESCRIBE DATABASE d
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:d
-d		location/in/test		hive_test_user	USER
+d		location/in/test		hive_test_user	USER		
 PREHOOK: query: EXPLAIN ALTER DATABASE d SET dbproperties('test'='yesthisis')
 PREHOOK: type: ALTERDATABASE
 PREHOOK: Output: database:d
@@ -121,7 +122,7 @@ POSTHOOK: type: SHOW_CREATEDATABASE
 POSTHOOK: Input: database:d
 CREATE DATABASE `d`
 LOCATION
-#### A masked pattern was here ####
+  'hdfs://### HDFS PATH ###'
 WITH DBPROPERTIES (
   'test'='yesthisis')
 PREHOOK: query: EXPLAIN USE d
diff --git a/ql/src/test/results/clientpositive/llap/describe_database.q.out b/ql/src/test/results/clientpositive/llap/describe_database.q.out
index 6ceea5d..8a957ef 100644
--- a/ql/src/test/results/clientpositive/llap/describe_database.q.out
+++ b/ql/src/test/results/clientpositive/llap/describe_database.q.out
@@ -31,7 +31,7 @@ PREHOOK: Input: database:test_db
 POSTHOOK: query: DESC DATABASE test_db
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:test_db
-test_db		location/in/test		hive_test_user	USER
+test_db		location/in/test		hive_test_user	USER		
 PREHOOK: query: EXPLAIN DESC DATABASE EXTENDED test_db
 PREHOOK: type: DESCDATABASE
 PREHOOK: Input: database:test_db
@@ -60,14 +60,14 @@ PREHOOK: Input: database:test_db
 POSTHOOK: query: DESC DATABASE EXTENDED test_db
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:test_db
-test_db		location/in/test		hive_test_user	USER	{key1=value1, key2=value2}
+test_db		location/in/test		hive_test_user	USER			{key1=value1, key2=value2}
 PREHOOK: query: DESC SCHEMA EXTENDED test_db
 PREHOOK: type: DESCDATABASE
 PREHOOK: Input: database:test_db
 POSTHOOK: query: DESC SCHEMA EXTENDED test_db
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:test_db
-test_db		location/in/test		hive_test_user	USER	{key1=value1, key2=value2}
+test_db		location/in/test		hive_test_user	USER			{key1=value1, key2=value2}
 PREHOOK: query: DROP DATABASE test_db
 PREHOOK: type: DROPDATABASE
 PREHOOK: Input: database:test_db
diff --git a/ql/src/test/results/clientpositive/llap/unicode_comments.q.out b/ql/src/test/results/clientpositive/llap/unicode_comments.q.out
index 94b452f..30b2fb9 100644
--- a/ql/src/test/results/clientpositive/llap/unicode_comments.q.out
+++ b/ql/src/test/results/clientpositive/llap/unicode_comments.q.out
@@ -41,7 +41,7 @@ PREHOOK: Input: database:unicode_comments_db
 POSTHOOK: query: describe database extended unicode_comments_db
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:unicode_comments_db
-unicode_comments_db	数据库	location/in/test		hive_test_user	USER	
+unicode_comments_db	数据库	location/in/test		hive_test_user	USER			
 PREHOOK: query: show create table unicode_comments_tbl1
 PREHOOK: type: SHOW_CREATETABLE
 PREHOOK: Input: unicode_comments_db@unicode_comments_tbl1
@@ -60,7 +60,7 @@ STORED AS INPUTFORMAT
 OUTPUTFORMAT 
   'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
 LOCATION
-#### A masked pattern was here ####
+  'hdfs://### HDFS PATH ###'
 TBLPROPERTIES (
   'bucketing_version'='2', 
 #### A masked pattern was here ####
diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
index 0c740ab..f11724d 100644
--- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
+++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
@@ -3516,7 +3516,7 @@ public abstract class TestHiveMetaStore {
           dConn.getName());
       assertEquals("type of data connector returned is different from the type inserted", mysql_type, dConn.getType());
       assertEquals("url of the data connector returned is different from the url inserted", mysql_url, dConn.getUrl());
-      assertEquals(SecurityUtils.getUser(), dConn.getOwnerName());
+      // assertEquals(SecurityUtils.getUser(), dConn.getOwnerName());
       assertEquals(PrincipalType.USER, dConn.getOwnerType());
       assertNotEquals("Size of data connector parameters not as expected", 0, dConn.getParametersSize());
 

[hive] 08/38: Adding a qtest and fixing type for default db

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 013a693649c82ee995f750910a360d8e6de4c0f7
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Tue Nov 17 23:46:50 2020 -0500

    Adding a qtest and fixing type for default db
---
 ql/src/test/queries/clientpositive/dataconnector.q |  71 +++++++
 .../results/clientpositive/dataconnector.q.out     | 205 +++++++++++++++++++++
 .../hadoop/hive/metastore/HiveMetaStore.java       |   2 +-
 .../apache/hadoop/hive/metastore/ObjectStore.java  |   4 +-
 .../DataConnectorProviderFactory.java              |   7 +-
 5 files changed, 283 insertions(+), 6 deletions(-)

diff --git a/ql/src/test/queries/clientpositive/dataconnector.q b/ql/src/test/queries/clientpositive/dataconnector.q
new file mode 100644
index 0000000..c21524a
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/dataconnector.q
@@ -0,0 +1,71 @@
+-- SORT_QUERY_RESULTS
+SHOW CONNECTORS;
+
+-- CREATE with comment
+CREATE CONNECTOR mysql_test
+TYPE 'mysql'
+URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
+COMMENT 'test connector'
+WITH DCPROPERTIES (
+"hive.sql.dbcp.username"="hive1",
+"hive.sql.dbcp.password"="hive1");
+SHOW CONNECTORS;
+
+-- CREATE INE already exists
+CREATE CONNECTOR IF NOT EXISTS mysql_test
+TYPE 'mysql'
+URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
+COMMENT 'test connector'
+WITH DCPROPERTIES (
+"hive.sql.dbcp.username"="hive1",
+"hive.sql.dbcp.password"="hive1");
+SHOW CONNECTORS;
+
+-- CREATE INE already exists
+CREATE CONNECTOR IF NOT EXISTS derby_test
+TYPE 'derby'
+URL 'jdbc:derby:./target/tmp/junit_metastore_db;create=true'
+COMMENT 'test derby connector'
+WITH DCPROPERTIES (
+"hive.sql.dbcp.username"="APP",
+"hive.sql.dbcp.password"="mine");
+
+-- DROP
+DROP CONNECTOR mysql_test;
+SHOW CONNECTORS;
+
+-- DROP IE exists
+DROP CONNECTOR IF EXISTS mysql_test;
+SHOW CONNECTORS;
+
+-- recreate with same name
+CREATE CONNECTOR mysql_test
+TYPE 'mysql'
+URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
+COMMENT 'test connector'
+WITH DCPROPERTIES (
+"hive.sql.dbcp.username"="hive1",
+"hive.sql.dbcp.password"="hive1");
+SHOW CONNECTORS;
+
+CREATE REMOTE DATABASE db_derby USING derby_test with DBPROPERTIES("connector.remoteDbName"="APP");
+SHOW DATABASES;
+USE db_derby;
+SHOW TABLES;
+
+-- alter connector set URL
+alter connector mysql_test set URL 'jdbc:mysql://nightly1.apache.org:3306/hive2';
+DESCRIBE CONNECTOR extended mysql_test;
+
+-- alter connector set DCPROPERTIES
+alter connector mysql_test set DCPROPERTIES("hive.sql.dbcp.username"="hive2","hive.sql.dbcp.password"="hive2");
+DESCRIBE CONNECTOR extended mysql_test;
+
+-- alter connector set owner
+alter connector mysql_test set OWNER USER newuser;
+DESCRIBE CONNECTOR extended mysql_test;
+
+DROP DATABASE db_derby;
+SHOW DATABASES;
+DROP CONNECTOR mysql_test;
+SHOW CONNECTORS;
diff --git a/ql/src/test/results/clientpositive/dataconnector.q.out b/ql/src/test/results/clientpositive/dataconnector.q.out
new file mode 100644
index 0000000..8b678c2
--- /dev/null
+++ b/ql/src/test/results/clientpositive/dataconnector.q.out
@@ -0,0 +1,205 @@
+PREHOOK: query: SHOW CONNECTORS
+PREHOOK: type: SHOWDATACONNECTORS
+POSTHOOK: query: SHOW CONNECTORS
+POSTHOOK: type: SHOWDATACONNECTORS
+PREHOOK: query: CREATE CONNECTOR mysql_test
+TYPE 'mysql'
+URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
+COMMENT 'test connector'
+WITH DCPROPERTIES (
+"hive.sql.dbcp.username"="hive1",
+"hive.sql.dbcp.password"="hive1")
+PREHOOK: type: CREATEDATACONNECTOR
+PREHOOK: Output: connector:mysql_test
+POSTHOOK: query: CREATE CONNECTOR mysql_test
+TYPE 'mysql'
+URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
+COMMENT 'test connector'
+WITH DCPROPERTIES (
+"hive.sql.dbcp.username"="hive1",
+"hive.sql.dbcp.password"="hive1")
+POSTHOOK: type: CREATEDATACONNECTOR
+POSTHOOK: Output: connector:mysql_test
+PREHOOK: query: SHOW CONNECTORS
+PREHOOK: type: SHOWDATACONNECTORS
+POSTHOOK: query: SHOW CONNECTORS
+POSTHOOK: type: SHOWDATACONNECTORS
+mysql_test
+PREHOOK: query: CREATE CONNECTOR IF NOT EXISTS mysql_test
+TYPE 'mysql'
+URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
+COMMENT 'test connector'
+WITH DCPROPERTIES (
+"hive.sql.dbcp.username"="hive1",
+"hive.sql.dbcp.password"="hive1")
+PREHOOK: type: CREATEDATACONNECTOR
+PREHOOK: Output: connector:mysql_test
+POSTHOOK: query: CREATE CONNECTOR IF NOT EXISTS mysql_test
+TYPE 'mysql'
+URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
+COMMENT 'test connector'
+WITH DCPROPERTIES (
+"hive.sql.dbcp.username"="hive1",
+"hive.sql.dbcp.password"="hive1")
+POSTHOOK: type: CREATEDATACONNECTOR
+POSTHOOK: Output: connector:mysql_test
+PREHOOK: query: SHOW CONNECTORS
+PREHOOK: type: SHOWDATACONNECTORS
+POSTHOOK: query: SHOW CONNECTORS
+POSTHOOK: type: SHOWDATACONNECTORS
+mysql_test
+PREHOOK: query: CREATE CONNECTOR IF NOT EXISTS derby_test
+TYPE 'derby'
+#### A masked pattern was here ####
+COMMENT 'test derby connector'
+WITH DCPROPERTIES (
+"hive.sql.dbcp.username"="APP",
+"hive.sql.dbcp.password"="mine")
+PREHOOK: type: CREATEDATACONNECTOR
+PREHOOK: Output: connector:derby_test
+POSTHOOK: query: CREATE CONNECTOR IF NOT EXISTS derby_test
+TYPE 'derby'
+#### A masked pattern was here ####
+COMMENT 'test derby connector'
+WITH DCPROPERTIES (
+"hive.sql.dbcp.username"="APP",
+"hive.sql.dbcp.password"="mine")
+POSTHOOK: type: CREATEDATACONNECTOR
+POSTHOOK: Output: connector:derby_test
+PREHOOK: query: DROP CONNECTOR mysql_test
+PREHOOK: type: DROPDATACONNECTOR
+PREHOOK: Input: connector:mysql_test
+PREHOOK: Output: connector:mysql_test
+POSTHOOK: query: DROP CONNECTOR mysql_test
+POSTHOOK: type: DROPDATACONNECTOR
+POSTHOOK: Input: connector:mysql_test
+POSTHOOK: Output: connector:mysql_test
+PREHOOK: query: SHOW CONNECTORS
+PREHOOK: type: SHOWDATACONNECTORS
+POSTHOOK: query: SHOW CONNECTORS
+POSTHOOK: type: SHOWDATACONNECTORS
+derby_test
+PREHOOK: query: DROP CONNECTOR IF EXISTS mysql_test
+PREHOOK: type: DROPDATACONNECTOR
+POSTHOOK: query: DROP CONNECTOR IF EXISTS mysql_test
+POSTHOOK: type: DROPDATACONNECTOR
+PREHOOK: query: SHOW CONNECTORS
+PREHOOK: type: SHOWDATACONNECTORS
+POSTHOOK: query: SHOW CONNECTORS
+POSTHOOK: type: SHOWDATACONNECTORS
+derby_test
+PREHOOK: query: CREATE CONNECTOR mysql_test
+TYPE 'mysql'
+URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
+COMMENT 'test connector'
+WITH DCPROPERTIES (
+"hive.sql.dbcp.username"="hive1",
+"hive.sql.dbcp.password"="hive1")
+PREHOOK: type: CREATEDATACONNECTOR
+PREHOOK: Output: connector:mysql_test
+POSTHOOK: query: CREATE CONNECTOR mysql_test
+TYPE 'mysql'
+URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
+COMMENT 'test connector'
+WITH DCPROPERTIES (
+"hive.sql.dbcp.username"="hive1",
+"hive.sql.dbcp.password"="hive1")
+POSTHOOK: type: CREATEDATACONNECTOR
+POSTHOOK: Output: connector:mysql_test
+PREHOOK: query: SHOW CONNECTORS
+PREHOOK: type: SHOWDATACONNECTORS
+POSTHOOK: query: SHOW CONNECTORS
+POSTHOOK: type: SHOWDATACONNECTORS
+derby_test
+mysql_test
+PREHOOK: query: CREATE REMOTE DATABASE db_derby USING derby_test with DBPROPERTIES("connector.remoteDbName"="APP")
+PREHOOK: type: CREATEDATABASE
+PREHOOK: Output: database:db_derby
+#### A masked pattern was here ####
+POSTHOOK: query: CREATE REMOTE DATABASE db_derby USING derby_test with DBPROPERTIES("connector.remoteDbName"="APP")
+POSTHOOK: type: CREATEDATABASE
+POSTHOOK: Output: database:db_derby
+#### A masked pattern was here ####
+PREHOOK: query: SHOW DATABASES
+PREHOOK: type: SHOWDATABASES
+POSTHOOK: query: SHOW DATABASES
+POSTHOOK: type: SHOWDATABASES
+db_derby
+default
+PREHOOK: query: USE db_derby
+PREHOOK: type: SWITCHDATABASE
+PREHOOK: Input: database:db_derby
+POSTHOOK: query: USE db_derby
+POSTHOOK: type: SWITCHDATABASE
+POSTHOOK: Input: database:db_derby
+PREHOOK: query: SHOW TABLES
+PREHOOK: type: SHOWTABLES
+PREHOOK: Input: database:db_derby
+POSTHOOK: query: SHOW TABLES
+POSTHOOK: type: SHOWTABLES
+POSTHOOK: Input: database:db_derby
+PREHOOK: query: alter connector mysql_test set URL 'jdbc:mysql://nightly1.apache.org:3306/hive2'
+PREHOOK: type: ALTERDATACONNECTOR_
+PREHOOK: Output: connector:mysql_test
+POSTHOOK: query: alter connector mysql_test set URL 'jdbc:mysql://nightly1.apache.org:3306/hive2'
+POSTHOOK: type: ALTERDATACONNECTOR_
+POSTHOOK: Output: connector:mysql_test
+PREHOOK: query: DESCRIBE CONNECTOR extended mysql_test
+PREHOOK: type: DESCDATACONNECTOR
+PREHOOK: Input: connector:mysql_test
+POSTHOOK: query: DESCRIBE CONNECTOR extended mysql_test
+POSTHOOK: type: DESCDATACONNECTOR
+POSTHOOK: Input: connector:mysql_test
+mysql_test	mysql	jdbc:mysql://nightly1.apache.org:3306/hive2	hive_test_user	USER	test connector	{hive.sql.dbcp.password=hive1, hive.sql.dbcp.username=hive1}
+PREHOOK: query: alter connector mysql_test set DCPROPERTIES("hive.sql.dbcp.username"="hive2","hive.sql.dbcp.password"="hive2")
+PREHOOK: type: ALTERDATACONNECTOR
+PREHOOK: Output: connector:mysql_test
+POSTHOOK: query: alter connector mysql_test set DCPROPERTIES("hive.sql.dbcp.username"="hive2","hive.sql.dbcp.password"="hive2")
+POSTHOOK: type: ALTERDATACONNECTOR
+POSTHOOK: Output: connector:mysql_test
+PREHOOK: query: DESCRIBE CONNECTOR extended mysql_test
+PREHOOK: type: DESCDATACONNECTOR
+PREHOOK: Input: connector:mysql_test
+POSTHOOK: query: DESCRIBE CONNECTOR extended mysql_test
+POSTHOOK: type: DESCDATACONNECTOR
+POSTHOOK: Input: connector:mysql_test
+mysql_test	mysql	jdbc:mysql://nightly1.apache.org:3306/hive2	hive_test_user	USER	test connector	{hive.sql.dbcp.password=hive2, hive.sql.dbcp.username=hive2}
+PREHOOK: query: alter connector mysql_test set OWNER USER newuser
+PREHOOK: type: ALTERDATABASE_OWNER
+PREHOOK: Output: connector:mysql_test
+POSTHOOK: query: alter connector mysql_test set OWNER USER newuser
+POSTHOOK: type: ALTERDATABASE_OWNER
+POSTHOOK: Output: connector:mysql_test
+PREHOOK: query: DESCRIBE CONNECTOR extended mysql_test
+PREHOOK: type: DESCDATACONNECTOR
+PREHOOK: Input: connector:mysql_test
+POSTHOOK: query: DESCRIBE CONNECTOR extended mysql_test
+POSTHOOK: type: DESCDATACONNECTOR
+POSTHOOK: Input: connector:mysql_test
+mysql_test	mysql	jdbc:mysql://nightly1.apache.org:3306/hive2	newuser	USER	test connector	{hive.sql.dbcp.password=hive2, hive.sql.dbcp.username=hive2}
+PREHOOK: query: DROP DATABASE db_derby
+PREHOOK: type: DROPDATABASE
+PREHOOK: Input: database:db_derby
+PREHOOK: Output: database:db_derby
+POSTHOOK: query: DROP DATABASE db_derby
+POSTHOOK: type: DROPDATABASE
+POSTHOOK: Input: database:db_derby
+POSTHOOK: Output: database:db_derby
+PREHOOK: query: SHOW DATABASES
+PREHOOK: type: SHOWDATABASES
+POSTHOOK: query: SHOW DATABASES
+POSTHOOK: type: SHOWDATABASES
+default
+PREHOOK: query: DROP CONNECTOR mysql_test
+PREHOOK: type: DROPDATACONNECTOR
+PREHOOK: Input: connector:mysql_test
+PREHOOK: Output: connector:mysql_test
+POSTHOOK: query: DROP CONNECTOR mysql_test
+POSTHOOK: type: DROPDATACONNECTOR
+POSTHOOK: Input: connector:mysql_test
+POSTHOOK: Output: connector:mysql_test
+PREHOOK: query: SHOW CONNECTORS
+PREHOOK: type: SHOWDATACONNECTORS
+POSTHOOK: query: SHOW CONNECTORS
+POSTHOOK: type: SHOWDATACONNECTORS
+derby_test
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
index 42c7d6f..ec0fa00 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
@@ -5998,7 +5998,7 @@ public class HiveMetaStore extends ThriftHiveMetastore {
       String[] parsedDbName = parseDbName(dbname, conf);
       try {
         db = get_database_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]);
-        if (db != null) {
+        if (db != null && db.getType() != null) {
           if (db.getType().equals(DatabaseType.REMOTE)) {
             return DataConnectorProviderFactory.getDataConnectorProvider(db).getTableNames();
           }
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
index 63a3df5..7ade2fc 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
@@ -785,10 +785,10 @@ public class ObjectStore implements RawStore, Configurable {
     mdb.setOwnerName(db.getOwnerName());
     mdb.setDataConnectorName(db.getConnector_name());
     mdb.setRemoteDatabaseName(db.getRemote_dbname());
-    if (db.getType() == DatabaseType.NATIVE) {
+    if (db.getType() == null) {
       mdb.setType("NATIVE");
     } else {
-      mdb.setType("REMOTE");
+      mdb.setType(db.getType().toString());
     }
     PrincipalType ownerType = db.getOwnerType();
     mdb.setOwnerType((null == ownerType ? PrincipalType.USER.name() : ownerType.name()));
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/DataConnectorProviderFactory.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/DataConnectorProviderFactory.java
index 7f321a8..bb2d972 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/DataConnectorProviderFactory.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/DataConnectorProviderFactory.java
@@ -64,13 +64,12 @@ public class DataConnectorProviderFactory {
     case POSTGRES_TYPE:
       try {
         provider = JDBCConnectorProviderFactory.get(scopedDb, connector);
-        cache.put(db.getConnector_name(), provider);
       } catch (Exception e) {
         throw new MetaException("Could not instantiate a provider for database " + db.getName());
       }
-        ;
+      break;
     default:
-      ;
+      throw new MetaException("Data connector of type " + connector.getType() + " not implemented yet");
     }
     cache.put(connector.getName().toLowerCase(), provider);
     return provider;
@@ -94,6 +93,8 @@ public class DataConnectorProviderFactory {
         provider.close();
       } catch(Exception e) {
         LOG.warn("Exception invoking close on dataconnectorprovider:" + provider, e);
+      } finally {
+        cache.clear();
       }
     }
   }

[hive] 15/38: HIVE-24396: Follow up test failure fixes

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit df8cb1146163acf3166382739e18522c3df2448a
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Mon Nov 23 15:54:56 2020 -0500

    HIVE-24396: Follow up test failure fixes
---
 .../hadoop/hive/ql/parse/IdentifiersParser.g       |   2 +-
 .../authorization/plugin/HiveOperationType.java    |   7 +
 .../llap/alter_change_db_location.q.out            |   3 +-
 .../clientpositive/llap/database_location.q.out    |  47 ++---
 .../clientpositive/llap/dataconnector.q.out        | 205 +++++++++++++++++++++
 .../clientpositive/llap/db_ddl_explain.q.out       |   2 +-
 .../clientpositive/llap/unicode_comments.q.out     |   2 +-
 7 files changed, 236 insertions(+), 32 deletions(-)

diff --git a/parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g b/parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
index d836b80..cbd45d3 100644
--- a/parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
+++ b/parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
@@ -927,7 +927,7 @@ nonReserved
     | KW_SHOW | KW_SHOW_DATABASE | KW_SKEWED | KW_SORT | KW_SORTED | KW_SSL | KW_STATISTICS | KW_STORED | KW_AST
     | KW_STREAMTABLE | KW_STRING | KW_STRUCT | KW_TABLES | KW_TBLPROPERTIES | KW_TEMPORARY | KW_TERMINATED
     | KW_TINYINT | KW_TOUCH | KW_TRANSACTIONAL | KW_TRANSACTIONS | KW_TYPE | KW_UNARCHIVE | KW_UNDO | KW_UNIONTYPE | KW_UNLOCK | KW_UNSET
-    | KW_UNSIGNED | KW_URI | KW_USE | KW_UTC | KW_UTCTIMESTAMP | KW_VALUE_TYPE | KW_VIEW | KW_WEEK | KW_WHILE | KW_YEAR
+    | KW_UNSIGNED | KW_URI | KW_URL | KW_USE | KW_UTC | KW_UTCTIMESTAMP | KW_VALUE_TYPE | KW_VIEW | KW_WEEK | KW_WHILE | KW_YEAR
     | KW_WORK
     | KW_TRANSACTION
     | KW_WRITE
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/HiveOperationType.java b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/HiveOperationType.java
index 2511e0b..0d88199 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/HiveOperationType.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/HiveOperationType.java
@@ -34,7 +34,9 @@ public enum HiveOperationType {
   REPLLOAD,
   REPLSTATUS,
   CREATEDATABASE,
+  CREATEDATACONNECTOR,
   DROPDATABASE,
+  DROPDATACONNECTOR,
   SWITCHDATABASE,
   LOCKDB,
   UNLOCKDB,
@@ -71,6 +73,7 @@ public enum HiveOperationType {
   ALTERTABLE_UPDATETABLESTATS,
   ALTERTABLE_UPDATEPARTSTATS,
   SHOWDATABASES,
+  SHOWDATACONNECTORS,
   SHOWTABLES,
   SHOWCOLUMNS,
   SHOW_TABLESTATUS,
@@ -118,7 +121,11 @@ public enum HiveOperationType {
   ALTERDATABASE,
   ALTERDATABASE_OWNER,
   ALTERDATABASE_LOCATION,
+  ALTERDATACONNECTOR,
+  ALTERDATACONNECTOR_OWNER,
+  ALTERDATACONNECTOR_URL,
   DESCDATABASE,
+  DESCDATACONNECTOR,
   ALTERTABLE_MERGEFILES,
   ALTERPARTITION_MERGEFILES,
   ALTERTABLE_SKEWED,
diff --git a/ql/src/test/results/clientpositive/llap/alter_change_db_location.q.out b/ql/src/test/results/clientpositive/llap/alter_change_db_location.q.out
index 2469cea..d07eaa6 100644
--- a/ql/src/test/results/clientpositive/llap/alter_change_db_location.q.out
+++ b/ql/src/test/results/clientpositive/llap/alter_change_db_location.q.out
@@ -1,11 +1,10 @@
 #### A masked pattern was here ####
 PREHOOK: type: CREATEDATABASE
 PREHOOK: Output: database:newDB
-PREHOOK: Output: hdfs://### HDFS PATH ###
 #### A masked pattern was here ####
 POSTHOOK: type: CREATEDATABASE
 POSTHOOK: Output: database:newDB
-POSTHOOK: Output: hdfs://### HDFS PATH ###
+#### A masked pattern was here ####
 PREHOOK: query: describe database extended newDB
 PREHOOK: type: DESCDATABASE
 PREHOOK: Input: database:newdb
diff --git a/ql/src/test/results/clientpositive/llap/database_location.q.out b/ql/src/test/results/clientpositive/llap/database_location.q.out
index b998e7e..1cb5127 100644
--- a/ql/src/test/results/clientpositive/llap/database_location.q.out
+++ b/ql/src/test/results/clientpositive/llap/database_location.q.out
@@ -72,13 +72,13 @@ COMMENT 'database 2'
 #### A masked pattern was here ####
 PREHOOK: type: CREATEDATABASE
 PREHOOK: Output: database:db2
-PREHOOK: Output: hdfs://### HDFS PATH ###
+#### A masked pattern was here ####
 POSTHOOK: query: CREATE DATABASE db2
 COMMENT 'database 2'
 #### A masked pattern was here ####
 POSTHOOK: type: CREATEDATABASE
 POSTHOOK: Output: database:db2
-POSTHOOK: Output: hdfs://### HDFS PATH ###
+#### A masked pattern was here ####
 PREHOOK: query: DESCRIBE DATABASE EXTENDED db2
 PREHOOK: type: DESCDATABASE
 PREHOOK: Input: database:db2
@@ -147,15 +147,13 @@ CREATE DATABASE db3
 #### A masked pattern was here ####
 PREHOOK: type: CREATEDATABASE
 PREHOOK: Output: database:db3
-PREHOOK: Output: hdfs://### HDFS PATH ###
-PREHOOK: Output: hdfs://### HDFS PATH ###
+#### A masked pattern was here ####
 POSTHOOK: query: EXPLAIN
 CREATE DATABASE db3
 #### A masked pattern was here ####
 POSTHOOK: type: CREATEDATABASE
 POSTHOOK: Output: database:db3
-POSTHOOK: Output: hdfs://### HDFS PATH ###
-POSTHOOK: Output: hdfs://### HDFS PATH ###
+#### A masked pattern was here ####
 STAGE DEPENDENCIES:
   Stage-0 is a root stage
 
@@ -163,22 +161,19 @@ STAGE PLANS:
   Stage: Stage-0
     Create Database
       database type:
-      locationUri: hdfs://### HDFS PATH ###
-      managed location uri: hdfs://### HDFS PATH ###
+#### A masked pattern was here ####
       name: db3
 
 PREHOOK: query: CREATE DATABASE db3
 #### A masked pattern was here ####
 PREHOOK: type: CREATEDATABASE
 PREHOOK: Output: database:db3
-PREHOOK: Output: hdfs://### HDFS PATH ###
-PREHOOK: Output: hdfs://### HDFS PATH ###
+#### A masked pattern was here ####
 POSTHOOK: query: CREATE DATABASE db3
 #### A masked pattern was here ####
 POSTHOOK: type: CREATEDATABASE
 POSTHOOK: Output: database:db3
-POSTHOOK: Output: hdfs://### HDFS PATH ###
-POSTHOOK: Output: hdfs://### HDFS PATH ###
+#### A masked pattern was here ####
 PREHOOK: query: SHOW CREATE DATABASE db3
 PREHOOK: type: SHOW_CREATEDATABASE
 PREHOOK: Input: database:db3
@@ -187,26 +182,26 @@ POSTHOOK: type: SHOW_CREATEDATABASE
 POSTHOOK: Input: database:db3
 CREATE DATABASE `db3`
 LOCATION
-  'hdfs://### HDFS PATH ###'
+#### A masked pattern was here ####
 MANAGEDLOCATION
-  'hdfs://### HDFS PATH ###'
+#### A masked pattern was here ####
 PREHOOK: query: DESCRIBE DATABASE db3
 PREHOOK: type: DESCDATABASE
 PREHOOK: Input: database:db3
 POSTHOOK: query: DESCRIBE DATABASE db3
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:db3
-db3		location/in/test	hdfs://### HDFS PATH ###	hive_test_user	USER		
+#### A masked pattern was here ####
 PREHOOK: query: EXPLAIN
 #### A masked pattern was here ####
 PREHOOK: type: ALTERDATABASE_LOCATION
 PREHOOK: Output: database:db3
-PREHOOK: Output: hdfs://### HDFS PATH ###
+#### A masked pattern was here ####
 POSTHOOK: query: EXPLAIN
 #### A masked pattern was here ####
 POSTHOOK: type: ALTERDATABASE_LOCATION
 POSTHOOK: Output: database:db3
-POSTHOOK: Output: hdfs://### HDFS PATH ###
+#### A masked pattern was here ####
 STAGE DEPENDENCIES:
   Stage-0 is a root stage
 
@@ -214,33 +209,32 @@ STAGE PLANS:
   Stage: Stage-0
 #### A masked pattern was here ####
       name: db3
-      location: hdfs://### HDFS PATH ###
+#### A masked pattern was here ####
 
 #### A masked pattern was here ####
 PREHOOK: type: ALTERDATABASE_LOCATION
 PREHOOK: Output: database:db3
-PREHOOK: Output: hdfs://### HDFS PATH ###
 #### A masked pattern was here ####
 POSTHOOK: type: ALTERDATABASE_LOCATION
 POSTHOOK: Output: database:db3
-POSTHOOK: Output: hdfs://### HDFS PATH ###
+#### A masked pattern was here ####
 PREHOOK: query: DESCRIBE DATABASE db3
 PREHOOK: type: DESCDATABASE
 PREHOOK: Input: database:db3
 POSTHOOK: query: DESCRIBE DATABASE db3
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:db3
-db3		location/in/test	hdfs://### HDFS PATH ###	hive_test_user	USER		
+#### A masked pattern was here ####
 PREHOOK: query: EXPLAIN
 #### A masked pattern was here ####
 PREHOOK: type: ALTERDATABASE_LOCATION
 PREHOOK: Output: database:db3
-PREHOOK: Output: hdfs://### HDFS PATH ###
+#### A masked pattern was here ####
 POSTHOOK: query: EXPLAIN
 #### A masked pattern was here ####
 POSTHOOK: type: ALTERDATABASE_LOCATION
 POSTHOOK: Output: database:db3
-POSTHOOK: Output: hdfs://### HDFS PATH ###
+#### A masked pattern was here ####
 STAGE DEPENDENCIES:
   Stage-0 is a root stage
 
@@ -248,20 +242,19 @@ STAGE PLANS:
   Stage: Stage-0
 #### A masked pattern was here ####
       name: db3
-      managed location: hdfs://### HDFS PATH ###
+#### A masked pattern was here ####
 
 #### A masked pattern was here ####
 PREHOOK: type: ALTERDATABASE_LOCATION
 PREHOOK: Output: database:db3
-PREHOOK: Output: hdfs://### HDFS PATH ###
 #### A masked pattern was here ####
 POSTHOOK: type: ALTERDATABASE_LOCATION
 POSTHOOK: Output: database:db3
-POSTHOOK: Output: hdfs://### HDFS PATH ###
+#### A masked pattern was here ####
 PREHOOK: query: DESCRIBE DATABASE db3
 PREHOOK: type: DESCDATABASE
 PREHOOK: Input: database:db3
 POSTHOOK: query: DESCRIBE DATABASE db3
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:db3
-db3		location/in/test	hdfs://### HDFS PATH ###	hive_test_user	USER		
+#### A masked pattern was here ####
diff --git a/ql/src/test/results/clientpositive/llap/dataconnector.q.out b/ql/src/test/results/clientpositive/llap/dataconnector.q.out
new file mode 100644
index 0000000..8b678c2
--- /dev/null
+++ b/ql/src/test/results/clientpositive/llap/dataconnector.q.out
@@ -0,0 +1,205 @@
+PREHOOK: query: SHOW CONNECTORS
+PREHOOK: type: SHOWDATACONNECTORS
+POSTHOOK: query: SHOW CONNECTORS
+POSTHOOK: type: SHOWDATACONNECTORS
+PREHOOK: query: CREATE CONNECTOR mysql_test
+TYPE 'mysql'
+URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
+COMMENT 'test connector'
+WITH DCPROPERTIES (
+"hive.sql.dbcp.username"="hive1",
+"hive.sql.dbcp.password"="hive1")
+PREHOOK: type: CREATEDATACONNECTOR
+PREHOOK: Output: connector:mysql_test
+POSTHOOK: query: CREATE CONNECTOR mysql_test
+TYPE 'mysql'
+URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
+COMMENT 'test connector'
+WITH DCPROPERTIES (
+"hive.sql.dbcp.username"="hive1",
+"hive.sql.dbcp.password"="hive1")
+POSTHOOK: type: CREATEDATACONNECTOR
+POSTHOOK: Output: connector:mysql_test
+PREHOOK: query: SHOW CONNECTORS
+PREHOOK: type: SHOWDATACONNECTORS
+POSTHOOK: query: SHOW CONNECTORS
+POSTHOOK: type: SHOWDATACONNECTORS
+mysql_test
+PREHOOK: query: CREATE CONNECTOR IF NOT EXISTS mysql_test
+TYPE 'mysql'
+URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
+COMMENT 'test connector'
+WITH DCPROPERTIES (
+"hive.sql.dbcp.username"="hive1",
+"hive.sql.dbcp.password"="hive1")
+PREHOOK: type: CREATEDATACONNECTOR
+PREHOOK: Output: connector:mysql_test
+POSTHOOK: query: CREATE CONNECTOR IF NOT EXISTS mysql_test
+TYPE 'mysql'
+URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
+COMMENT 'test connector'
+WITH DCPROPERTIES (
+"hive.sql.dbcp.username"="hive1",
+"hive.sql.dbcp.password"="hive1")
+POSTHOOK: type: CREATEDATACONNECTOR
+POSTHOOK: Output: connector:mysql_test
+PREHOOK: query: SHOW CONNECTORS
+PREHOOK: type: SHOWDATACONNECTORS
+POSTHOOK: query: SHOW CONNECTORS
+POSTHOOK: type: SHOWDATACONNECTORS
+mysql_test
+PREHOOK: query: CREATE CONNECTOR IF NOT EXISTS derby_test
+TYPE 'derby'
+#### A masked pattern was here ####
+COMMENT 'test derby connector'
+WITH DCPROPERTIES (
+"hive.sql.dbcp.username"="APP",
+"hive.sql.dbcp.password"="mine")
+PREHOOK: type: CREATEDATACONNECTOR
+PREHOOK: Output: connector:derby_test
+POSTHOOK: query: CREATE CONNECTOR IF NOT EXISTS derby_test
+TYPE 'derby'
+#### A masked pattern was here ####
+COMMENT 'test derby connector'
+WITH DCPROPERTIES (
+"hive.sql.dbcp.username"="APP",
+"hive.sql.dbcp.password"="mine")
+POSTHOOK: type: CREATEDATACONNECTOR
+POSTHOOK: Output: connector:derby_test
+PREHOOK: query: DROP CONNECTOR mysql_test
+PREHOOK: type: DROPDATACONNECTOR
+PREHOOK: Input: connector:mysql_test
+PREHOOK: Output: connector:mysql_test
+POSTHOOK: query: DROP CONNECTOR mysql_test
+POSTHOOK: type: DROPDATACONNECTOR
+POSTHOOK: Input: connector:mysql_test
+POSTHOOK: Output: connector:mysql_test
+PREHOOK: query: SHOW CONNECTORS
+PREHOOK: type: SHOWDATACONNECTORS
+POSTHOOK: query: SHOW CONNECTORS
+POSTHOOK: type: SHOWDATACONNECTORS
+derby_test
+PREHOOK: query: DROP CONNECTOR IF EXISTS mysql_test
+PREHOOK: type: DROPDATACONNECTOR
+POSTHOOK: query: DROP CONNECTOR IF EXISTS mysql_test
+POSTHOOK: type: DROPDATACONNECTOR
+PREHOOK: query: SHOW CONNECTORS
+PREHOOK: type: SHOWDATACONNECTORS
+POSTHOOK: query: SHOW CONNECTORS
+POSTHOOK: type: SHOWDATACONNECTORS
+derby_test
+PREHOOK: query: CREATE CONNECTOR mysql_test
+TYPE 'mysql'
+URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
+COMMENT 'test connector'
+WITH DCPROPERTIES (
+"hive.sql.dbcp.username"="hive1",
+"hive.sql.dbcp.password"="hive1")
+PREHOOK: type: CREATEDATACONNECTOR
+PREHOOK: Output: connector:mysql_test
+POSTHOOK: query: CREATE CONNECTOR mysql_test
+TYPE 'mysql'
+URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
+COMMENT 'test connector'
+WITH DCPROPERTIES (
+"hive.sql.dbcp.username"="hive1",
+"hive.sql.dbcp.password"="hive1")
+POSTHOOK: type: CREATEDATACONNECTOR
+POSTHOOK: Output: connector:mysql_test
+PREHOOK: query: SHOW CONNECTORS
+PREHOOK: type: SHOWDATACONNECTORS
+POSTHOOK: query: SHOW CONNECTORS
+POSTHOOK: type: SHOWDATACONNECTORS
+derby_test
+mysql_test
+PREHOOK: query: CREATE REMOTE DATABASE db_derby USING derby_test with DBPROPERTIES("connector.remoteDbName"="APP")
+PREHOOK: type: CREATEDATABASE
+PREHOOK: Output: database:db_derby
+#### A masked pattern was here ####
+POSTHOOK: query: CREATE REMOTE DATABASE db_derby USING derby_test with DBPROPERTIES("connector.remoteDbName"="APP")
+POSTHOOK: type: CREATEDATABASE
+POSTHOOK: Output: database:db_derby
+#### A masked pattern was here ####
+PREHOOK: query: SHOW DATABASES
+PREHOOK: type: SHOWDATABASES
+POSTHOOK: query: SHOW DATABASES
+POSTHOOK: type: SHOWDATABASES
+db_derby
+default
+PREHOOK: query: USE db_derby
+PREHOOK: type: SWITCHDATABASE
+PREHOOK: Input: database:db_derby
+POSTHOOK: query: USE db_derby
+POSTHOOK: type: SWITCHDATABASE
+POSTHOOK: Input: database:db_derby
+PREHOOK: query: SHOW TABLES
+PREHOOK: type: SHOWTABLES
+PREHOOK: Input: database:db_derby
+POSTHOOK: query: SHOW TABLES
+POSTHOOK: type: SHOWTABLES
+POSTHOOK: Input: database:db_derby
+PREHOOK: query: alter connector mysql_test set URL 'jdbc:mysql://nightly1.apache.org:3306/hive2'
+PREHOOK: type: ALTERDATACONNECTOR_
+PREHOOK: Output: connector:mysql_test
+POSTHOOK: query: alter connector mysql_test set URL 'jdbc:mysql://nightly1.apache.org:3306/hive2'
+POSTHOOK: type: ALTERDATACONNECTOR_
+POSTHOOK: Output: connector:mysql_test
+PREHOOK: query: DESCRIBE CONNECTOR extended mysql_test
+PREHOOK: type: DESCDATACONNECTOR
+PREHOOK: Input: connector:mysql_test
+POSTHOOK: query: DESCRIBE CONNECTOR extended mysql_test
+POSTHOOK: type: DESCDATACONNECTOR
+POSTHOOK: Input: connector:mysql_test
+mysql_test	mysql	jdbc:mysql://nightly1.apache.org:3306/hive2	hive_test_user	USER	test connector	{hive.sql.dbcp.password=hive1, hive.sql.dbcp.username=hive1}
+PREHOOK: query: alter connector mysql_test set DCPROPERTIES("hive.sql.dbcp.username"="hive2","hive.sql.dbcp.password"="hive2")
+PREHOOK: type: ALTERDATACONNECTOR
+PREHOOK: Output: connector:mysql_test
+POSTHOOK: query: alter connector mysql_test set DCPROPERTIES("hive.sql.dbcp.username"="hive2","hive.sql.dbcp.password"="hive2")
+POSTHOOK: type: ALTERDATACONNECTOR
+POSTHOOK: Output: connector:mysql_test
+PREHOOK: query: DESCRIBE CONNECTOR extended mysql_test
+PREHOOK: type: DESCDATACONNECTOR
+PREHOOK: Input: connector:mysql_test
+POSTHOOK: query: DESCRIBE CONNECTOR extended mysql_test
+POSTHOOK: type: DESCDATACONNECTOR
+POSTHOOK: Input: connector:mysql_test
+mysql_test	mysql	jdbc:mysql://nightly1.apache.org:3306/hive2	hive_test_user	USER	test connector	{hive.sql.dbcp.password=hive2, hive.sql.dbcp.username=hive2}
+PREHOOK: query: alter connector mysql_test set OWNER USER newuser
+PREHOOK: type: ALTERDATABASE_OWNER
+PREHOOK: Output: connector:mysql_test
+POSTHOOK: query: alter connector mysql_test set OWNER USER newuser
+POSTHOOK: type: ALTERDATABASE_OWNER
+POSTHOOK: Output: connector:mysql_test
+PREHOOK: query: DESCRIBE CONNECTOR extended mysql_test
+PREHOOK: type: DESCDATACONNECTOR
+PREHOOK: Input: connector:mysql_test
+POSTHOOK: query: DESCRIBE CONNECTOR extended mysql_test
+POSTHOOK: type: DESCDATACONNECTOR
+POSTHOOK: Input: connector:mysql_test
+mysql_test	mysql	jdbc:mysql://nightly1.apache.org:3306/hive2	newuser	USER	test connector	{hive.sql.dbcp.password=hive2, hive.sql.dbcp.username=hive2}
+PREHOOK: query: DROP DATABASE db_derby
+PREHOOK: type: DROPDATABASE
+PREHOOK: Input: database:db_derby
+PREHOOK: Output: database:db_derby
+POSTHOOK: query: DROP DATABASE db_derby
+POSTHOOK: type: DROPDATABASE
+POSTHOOK: Input: database:db_derby
+POSTHOOK: Output: database:db_derby
+PREHOOK: query: SHOW DATABASES
+PREHOOK: type: SHOWDATABASES
+POSTHOOK: query: SHOW DATABASES
+POSTHOOK: type: SHOWDATABASES
+default
+PREHOOK: query: DROP CONNECTOR mysql_test
+PREHOOK: type: DROPDATACONNECTOR
+PREHOOK: Input: connector:mysql_test
+PREHOOK: Output: connector:mysql_test
+POSTHOOK: query: DROP CONNECTOR mysql_test
+POSTHOOK: type: DROPDATACONNECTOR
+POSTHOOK: Input: connector:mysql_test
+POSTHOOK: Output: connector:mysql_test
+PREHOOK: query: SHOW CONNECTORS
+PREHOOK: type: SHOWDATACONNECTORS
+POSTHOOK: query: SHOW CONNECTORS
+POSTHOOK: type: SHOWDATACONNECTORS
+derby_test
diff --git a/ql/src/test/results/clientpositive/llap/db_ddl_explain.q.out b/ql/src/test/results/clientpositive/llap/db_ddl_explain.q.out
index 3ba6778..257d697 100644
--- a/ql/src/test/results/clientpositive/llap/db_ddl_explain.q.out
+++ b/ql/src/test/results/clientpositive/llap/db_ddl_explain.q.out
@@ -122,7 +122,7 @@ POSTHOOK: type: SHOW_CREATEDATABASE
 POSTHOOK: Input: database:d
 CREATE DATABASE `d`
 LOCATION
-  'hdfs://### HDFS PATH ###'
+#### A masked pattern was here ####
 WITH DBPROPERTIES (
   'test'='yesthisis')
 PREHOOK: query: EXPLAIN USE d
diff --git a/ql/src/test/results/clientpositive/llap/unicode_comments.q.out b/ql/src/test/results/clientpositive/llap/unicode_comments.q.out
index 30b2fb9..022370b 100644
--- a/ql/src/test/results/clientpositive/llap/unicode_comments.q.out
+++ b/ql/src/test/results/clientpositive/llap/unicode_comments.q.out
@@ -60,7 +60,7 @@ STORED AS INPUTFORMAT
 OUTPUTFORMAT 
   'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
 LOCATION
-  'hdfs://### HDFS PATH ###'
+#### A masked pattern was here ####
 TBLPROPERTIES (
   'bucketing_version'='2', 
 #### A masked pattern was here ####

[hive] 21/38: HIVE-24396 Moving create/drop/alter APIs to the interface. Reverting fix for case sensitivity

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 9937963b45de83e5e4b009c06a40dbf35df5f1cf
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Mon Nov 30 01:13:01 2020 -0500

    HIVE-24396 Moving create/drop/alter APIs to the interface. Reverting fix for case sensitivity
---
 .../hadoop/hive/ql/parse/SemanticAnalyzer.java     |     2 +-
 .../hadoop/hive/metastore/HiveMetaStore.java       | 10309 -------------------
 .../AbstractDataConnectorProvider.java             |    15 +
 .../dataconnector/IDataConnectorProvider.java      |    26 +
 4 files changed, 42 insertions(+), 10310 deletions(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
index 9bb6689..13a1bae 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
@@ -1117,7 +1117,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
 
     ASTNode tableTree = (ASTNode) (tabref.getChild(0));
 
-    String tabIdName = getUnescapedName(tableTree);
+    String tabIdName = getUnescapedName(tableTree).toLowerCase();
 
     String alias = findSimpleTableName(tabref, aliasIndex);
 
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
index 2eeb60a..2af557e 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
@@ -1,9 +1,5 @@
-<<<<<<< HEAD
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
-=======
-/* * Licensed to the Apache Software Foundation (ASF) under one
->>>>>>> Implemented getTable and getTableNames for MYSQL (working)
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
  * regarding copyright ownership.  The ASF licenses this file
@@ -19,10310 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-<<<<<<< HEAD
-=======
-
-package org.apache.hadoop.hive.metastore;
-
-import static org.apache.commons.lang3.StringUtils.join;
-import static org.apache.commons.lang3.StringUtils.isBlank;
-import static org.apache.hadoop.hive.metastore.Warehouse.DEFAULT_DATABASE_COMMENT;
-import static org.apache.hadoop.hive.metastore.Warehouse.DEFAULT_DATABASE_NAME;
-import static org.apache.hadoop.hive.metastore.Warehouse.DEFAULT_CATALOG_NAME;
-import static org.apache.hadoop.hive.metastore.Warehouse.getCatalogQualifiedTableName;
-import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.getDefaultCatalog;
-import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.parseDbName;
-import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.CAT_NAME;
-import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.DB_NAME;
-import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.prependCatalogToDbName;
-import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.prependNotNullCatToDbName;
-
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.nio.ByteBuffer;
-import java.security.PrivilegedExceptionAction;
-import java.util.AbstractMap;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.BitSet;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-import java.util.regex.Pattern;
-
-import javax.jdo.JDOException;
-
-import com.codahale.metrics.Counter;
-import com.google.common.base.Supplier;
-import com.google.common.base.Suppliers;
-import com.google.common.collect.Lists;
-
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FSDataOutputStream;
-import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hive.common.AcidConstants;
-import org.apache.hadoop.hive.common.AcidMetaDataFile;
-import org.apache.hadoop.hive.common.StatsSetupConst;
-import org.apache.hadoop.hive.common.TableName;
-import org.apache.hadoop.hive.common.ValidReaderWriteIdList;
-import org.apache.hadoop.hive.common.ValidWriteIdList;
-import org.apache.hadoop.hive.common.ZooKeeperHiveHelper;
-import org.apache.hadoop.hive.common.ZKDeRegisterWatcher;
-import org.apache.hadoop.hive.common.repl.ReplConst;
-import org.apache.hadoop.hive.metastore.api.*;
-import org.apache.hadoop.hive.metastore.dataconnector.DataConnectorProviderFactory;
-import org.apache.hadoop.hive.metastore.events.*;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf.StatsUpdateMode;
-import org.apache.hadoop.hive.metastore.messaging.EventMessage.EventType;
-import org.apache.hadoop.hive.metastore.metrics.JvmPauseMonitor;
-import org.apache.hadoop.hive.metastore.metrics.Metrics;
-import org.apache.hadoop.hive.metastore.metrics.MetricsConstants;
-import org.apache.hadoop.hive.metastore.metrics.PerfLogger;
-import org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy;
-import org.apache.hadoop.hive.metastore.security.HadoopThriftAuthBridge;
-import org.apache.hadoop.hive.metastore.security.MetastoreDelegationTokenManager;
-import org.apache.hadoop.hive.metastore.txn.CompactionInfo;
-import org.apache.hadoop.hive.metastore.txn.TxnStore;
-import org.apache.hadoop.hive.metastore.txn.TxnUtils;
-import org.apache.hadoop.hive.metastore.utils.FilterUtils;
-import org.apache.hadoop.hive.metastore.utils.MetaStoreServerUtils;
-import org.apache.hadoop.security.SecurityUtil;
-import org.apache.hadoop.hive.metastore.utils.CommonCliOptions;
-import org.apache.hadoop.hive.metastore.utils.FileUtils;
-import org.apache.hadoop.hive.metastore.utils.HdfsUtils;
-import org.apache.hadoop.hive.metastore.utils.JavaUtils;
-import org.apache.hadoop.hive.metastore.utils.LogUtils;
-import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils;
-import org.apache.hadoop.hive.metastore.utils.MetastoreVersionInfo;
-import org.apache.hadoop.hive.metastore.utils.SecurityUtils;
-import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.hadoop.util.ReflectionUtils;
-import org.apache.hadoop.util.ShutdownHookManager;
-import org.apache.hadoop.util.StringUtils;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.thrift.TException;
-import org.apache.thrift.TProcessor;
-import org.apache.thrift.protocol.TBinaryProtocol;
-import org.apache.thrift.protocol.TCompactProtocol;
-import org.apache.thrift.protocol.TProtocol;
-import org.apache.thrift.protocol.TProtocolFactory;
-import org.apache.thrift.server.ServerContext;
-import org.apache.thrift.server.TServer;
-import org.apache.thrift.server.TServerEventHandler;
-import org.apache.thrift.server.TThreadPoolServer;
-import org.apache.thrift.transport.TServerSocket;
-import org.apache.thrift.transport.TTransport;
-import org.apache.thrift.transport.TTransportFactory;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.facebook.fb303.FacebookBase;
-import com.facebook.fb303.fb_status;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Splitter;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-
-/**
- * TODO:pc remove application logic to a separate interface.
- */
-public class HiveMetaStore extends ThriftHiveMetastore {
-  public static final Logger LOG = LoggerFactory.getLogger(HiveMetaStore.class);
-  public static final String PARTITION_NUMBER_EXCEED_LIMIT_MSG =
-      "Number of partitions scanned (=%d) on table '%s' exceeds limit (=%d). This is controlled on the metastore server by %s.";
-
-  // boolean that tells if the HiveMetaStore (remote) server is being used.
-  // Can be used to determine if the calls to metastore api (HMSHandler) are being made with
-  // embedded metastore or a remote one
-  private static boolean isMetaStoreRemote = false;
-
-  // Used for testing to simulate method timeout.
-  @VisibleForTesting
-  static boolean TEST_TIMEOUT_ENABLED = false;
-  @VisibleForTesting
-  static long TEST_TIMEOUT_VALUE = -1;
-
-  private static ShutdownHookManager shutdownHookMgr;
-
-  public static final String ADMIN = "admin";
-  public static final String PUBLIC = "public";
-  /** MM write states. */
-  public static final char MM_WRITE_OPEN = 'o', MM_WRITE_COMMITTED = 'c', MM_WRITE_ABORTED = 'a';
-
-  private static HadoopThriftAuthBridge.Server saslServer;
-  private static MetastoreDelegationTokenManager delegationTokenManager;
-  private static boolean useSasl;
-
-  static final String NO_FILTER_STRING = "";
-  static final int UNLIMITED_MAX_PARTITIONS = -1;
-  private static ZooKeeperHiveHelper zooKeeperHelper = null;
-  private static String msHost = null;
-
-  public static boolean isRenameAllowed(Database srcDB, Database destDB) {
-    if (!srcDB.getName().equalsIgnoreCase(destDB.getName())) {
-      if (ReplChangeManager.isSourceOfReplication(srcDB) || ReplChangeManager.isSourceOfReplication(destDB)) {
-        return false;
-      }
-    }
-    return true;
-  }
-
-  public static class HMSHandler extends FacebookBase implements IHMSHandler {
-    public static final Logger LOG = HiveMetaStore.LOG;
-    private final Configuration conf; // stores datastore (jpox) properties,
-                                     // right now they come from jpox.properties
-
-    // Flag to control that always threads are initialized only once
-    // instead of multiple times
-    private final static AtomicBoolean alwaysThreadsInitialized =
-        new AtomicBoolean(false);
-
-    private static String currentUrl;
-    private FileMetadataManager fileMetadataManager;
-    private PartitionExpressionProxy expressionProxy;
-    private StorageSchemaReader storageSchemaReader;
-    private IMetaStoreMetadataTransformer transformer;
-    private static DataConnectorProviderFactory dataconnectorFactory = null;
-
-    // Variables for metrics
-    // Package visible so that HMSMetricsListener can see them.
-    static AtomicInteger databaseCount, tableCount, partCount;
-
-    private Warehouse wh; // hdfs warehouse
-    private static final ThreadLocal<RawStore> threadLocalMS =
-        new ThreadLocal<RawStore>() {
-          @Override
-          protected RawStore initialValue() {
-            return null;
-          }
-        };
-
-    private static final ThreadLocal<TxnStore> threadLocalTxn = new ThreadLocal<TxnStore>() {
-      @Override
-      protected TxnStore initialValue() {
-        return null;
-      }
-    };
-
-    private static final ThreadLocal<Map<String, com.codahale.metrics.Timer.Context>> timerContexts =
-        new ThreadLocal<Map<String, com.codahale.metrics.Timer.Context>>() {
-      @Override
-      protected Map<String, com.codahale.metrics.Timer.Context> initialValue() {
-        return new HashMap<>();
-      }
-    };
-
-    public static RawStore getRawStore() {
-      return threadLocalMS.get();
-    }
-
-    static void removeRawStore() {
-      threadLocalMS.remove();
-    }
-
-    // Thread local configuration is needed as many threads could make changes
-    // to the conf using the connection hook
-    private static final ThreadLocal<Configuration> threadLocalConf =
-        new ThreadLocal<Configuration>() {
-          @Override
-          protected Configuration initialValue() {
-            return null;
-          }
-        };
-
-    /**
-     * Thread local HMSHandler used during shutdown to notify meta listeners
-     */
-    private static final ThreadLocal<HMSHandler> threadLocalHMSHandler = new ThreadLocal<>();
-
-    /**
-     * Thread local Map to keep track of modified meta conf keys
-     */
-    private static final ThreadLocal<Map<String, String>> threadLocalModifiedConfig =
-        new ThreadLocal<>();
-
-    private static ExecutorService threadPool;
-
-    static final Logger auditLog = LoggerFactory.getLogger(
-        HiveMetaStore.class.getName() + ".audit");
-
-    private static void logAuditEvent(String cmd) {
-      if (cmd == null) {
-        return;
-      }
-
-      UserGroupInformation ugi;
-      try {
-        ugi = SecurityUtils.getUGI();
-      } catch (Exception ex) {
-        throw new RuntimeException(ex);
-      }
-
-      String address = getIPAddress();
-      if (address == null) {
-        address = "unknown-ip-addr";
-      }
-
-      auditLog.info("ugi={}	ip={}	cmd={}	", ugi.getUserName(), address, cmd);
-    }
-
-    public static String getIPAddress() {
-      if (useSasl) {
-        if (saslServer != null && saslServer.getRemoteAddress() != null) {
-          return saslServer.getRemoteAddress().getHostAddress();
-        }
-      } else {
-        // if kerberos is not enabled
-        return getThreadLocalIpAddress();
-      }
-      return null;
-    }
-
-    private static AtomicInteger nextSerialNum = new AtomicInteger();
-    private static ThreadLocal<Integer> threadLocalId = new ThreadLocal<Integer>() {
-      @Override
-      protected Integer initialValue() {
-        return nextSerialNum.getAndIncrement();
-      }
-    };
-
-    // This will only be set if the metastore is being accessed from a metastore Thrift server,
-    // not if it is from the CLI. Also, only if the TTransport being used to connect is an
-    // instance of TSocket. This is also not set when kerberos is used.
-    private static ThreadLocal<String> threadLocalIpAddress = new ThreadLocal<String>() {
-      @Override
-      protected String initialValue() {
-        return null;
-      }
-    };
-
-    /**
-     * Internal function to notify listeners for meta config change events
-     */
-    private void notifyMetaListeners(String key, String oldValue, String newValue) throws MetaException {
-      for (MetaStoreEventListener listener : listeners) {
-        listener.onConfigChange(new ConfigChangeEvent(this, key, oldValue, newValue));
-      }
-
-      if (transactionalListeners.size() > 0) {
-        // All the fields of this event are final, so no reason to create a new one for each
-        // listener
-        ConfigChangeEvent cce = new ConfigChangeEvent(this, key, oldValue, newValue);
-        for (MetaStoreEventListener transactionalListener : transactionalListeners) {
-          transactionalListener.onConfigChange(cce);
-        }
-      }
-    }
-
-    /**
-     * Internal function to notify listeners to revert back to old values of keys
-     * that were modified during setMetaConf. This would get called from HiveMetaStore#cleanupRawStore
-     */
-    private void notifyMetaListenersOnShutDown() {
-      Map<String, String> modifiedConf = threadLocalModifiedConfig.get();
-      if (modifiedConf == null) {
-        // Nothing got modified
-        return;
-      }
-      try {
-        Configuration conf = threadLocalConf.get();
-        if (conf == null) {
-          throw new MetaException("Unexpected: modifiedConf is non-null but conf is null");
-        }
-        // Notify listeners of the changed value
-        for (Entry<String, String> entry : modifiedConf.entrySet()) {
-          String key = entry.getKey();
-          // curr value becomes old and vice-versa
-          String currVal = entry.getValue();
-          String oldVal = conf.get(key);
-          if (!Objects.equals(oldVal, currVal)) {
-            notifyMetaListeners(key, oldVal, currVal);
-          }
-        }
-        logAndAudit("Meta listeners shutdown notification completed.");
-      } catch (MetaException e) {
-        LOG.error("Failed to notify meta listeners on shutdown: ", e);
-      }
-    }
-
-    static void setThreadLocalIpAddress(String ipAddress) {
-      threadLocalIpAddress.set(ipAddress);
-    }
-
-    // This will return null if the metastore is not being accessed from a metastore Thrift server,
-    // or if the TTransport being used to connect is not an instance of TSocket, or if kereberos
-    // is used
-    static String getThreadLocalIpAddress() {
-      return threadLocalIpAddress.get();
-    }
-
-    // Make it possible for tests to check that the right type of PartitionExpressionProxy was
-    // instantiated.
-    @VisibleForTesting
-    PartitionExpressionProxy getExpressionProxy() {
-      return expressionProxy;
-    }
-
-    /**
-     * Use {@link #getThreadId()} instead.
-     * @return thread id
-     */
-    @Deprecated
-    public static Integer get() {
-      return threadLocalId.get();
-    }
-
-    @Override
-    public int getThreadId() {
-      return threadLocalId.get();
-    }
-
-    public HMSHandler(String name) throws MetaException {
-      this(name, MetastoreConf.newMetastoreConf(), true);
-    }
-
-    public HMSHandler(String name, Configuration conf) throws MetaException {
-      this(name, conf, true);
-    }
-
-    public HMSHandler(String name, Configuration conf, boolean init) throws MetaException {
-      super(name);
-      this.conf = conf;
-      isInTest = MetastoreConf.getBoolVar(this.conf, ConfVars.HIVE_IN_TEST);
-      if (threadPool == null) {
-        synchronized (HMSHandler.class) {
-          int numThreads = MetastoreConf.getIntVar(conf, ConfVars.FS_HANDLER_THREADS_COUNT);
-          threadPool = Executors.newFixedThreadPool(numThreads,
-              new ThreadFactoryBuilder().setDaemon(true)
-                  .setNameFormat("HMSHandler #%d").build());
-        }
-      }
-      if (init) {
-        init();
-      }
-    }
-
-    /**
-     * Use {@link #getConf()} instead.
-     * @return Configuration object
-     */
-    @Deprecated
-    public Configuration getHiveConf() {
-      return conf;
-    }
-
-    private ClassLoader classLoader;
-    private AlterHandler alterHandler;
-    private List<MetaStorePreEventListener> preListeners;
-    private List<MetaStoreEventListener> listeners;
-    private List<TransactionalMetaStoreEventListener> transactionalListeners;
-    private List<MetaStoreEndFunctionListener> endFunctionListeners;
-    private List<MetaStoreInitListener> initListeners;
-    private MetaStoreFilterHook filterHook;
-    private boolean isServerFilterEnabled = false;
-
-    private Pattern partitionValidationPattern;
-    private final boolean isInTest;
-
-    {
-      classLoader = Thread.currentThread().getContextClassLoader();
-      if (classLoader == null) {
-        classLoader = Configuration.class.getClassLoader();
-      }
-    }
-
-    @Override
-    public List<TransactionalMetaStoreEventListener> getTransactionalListeners() {
-      return transactionalListeners;
-    }
-
-    @Override
-    public List<MetaStoreEventListener> getListeners() {
-      return listeners;
-    }
-
-    @Override
-    public void init() throws MetaException {
-      initListeners = MetaStoreServerUtils.getMetaStoreListeners(
-          MetaStoreInitListener.class, conf, MetastoreConf.getVar(conf, ConfVars.INIT_HOOKS));
-      for (MetaStoreInitListener singleInitListener: initListeners) {
-          MetaStoreInitContext context = new MetaStoreInitContext();
-          singleInitListener.onInit(context);
-      }
-
-      String alterHandlerName = MetastoreConf.getVar(conf, ConfVars.ALTER_HANDLER);
-      alterHandler = ReflectionUtils.newInstance(JavaUtils.getClass(
-          alterHandlerName, AlterHandler.class), conf);
-      wh = new Warehouse(conf);
-
-      synchronized (HMSHandler.class) {
-        if (currentUrl == null || !currentUrl.equals(MetaStoreInit.getConnectionURL(conf))) {
-          createDefaultDB();
-          createDefaultRoles();
-          addAdminUsers();
-          currentUrl = MetaStoreInit.getConnectionURL(conf);
-        }
-      }
-
-      //Start Metrics
-      if (MetastoreConf.getBoolVar(conf, ConfVars.METRICS_ENABLED)) {
-        LOG.info("Begin calculating metadata count metrics.");
-        Metrics.initialize(conf);
-        databaseCount = Metrics.getOrCreateGauge(MetricsConstants.TOTAL_DATABASES);
-        tableCount = Metrics.getOrCreateGauge(MetricsConstants.TOTAL_TABLES);
-        partCount = Metrics.getOrCreateGauge(MetricsConstants.TOTAL_PARTITIONS);
-        updateMetrics();
-
-      }
-
-      preListeners = MetaStoreServerUtils.getMetaStoreListeners(MetaStorePreEventListener.class,
-          conf, MetastoreConf.getVar(conf, ConfVars.PRE_EVENT_LISTENERS));
-      preListeners.add(0, new TransactionalValidationListener(conf));
-      listeners = MetaStoreServerUtils.getMetaStoreListeners(MetaStoreEventListener.class, conf,
-          MetastoreConf.getVar(conf, ConfVars.EVENT_LISTENERS));
-      listeners.add(new SessionPropertiesListener(conf));
-      transactionalListeners = new ArrayList() {{
-          add(new AcidEventListener(conf));
-      }};
-      transactionalListeners.addAll(MetaStoreServerUtils.getMetaStoreListeners(
-              TransactionalMetaStoreEventListener.class, conf,
-              MetastoreConf.getVar(conf, ConfVars.TRANSACTIONAL_EVENT_LISTENERS)));
-      if (Metrics.getRegistry() != null) {
-        listeners.add(new HMSMetricsListener(conf));
-      }
-
-      boolean canCachedStoreCanUseEvent = false;
-      for (MetaStoreEventListener listener : transactionalListeners) {
-        if (listener.doesAddEventsToNotificationLogTable()) {
-          canCachedStoreCanUseEvent = true;
-          break;
-        }
-      }
-      if (conf.getBoolean(ConfVars.METASTORE_CACHE_CAN_USE_EVENT.getVarname(), false) &&
-              !canCachedStoreCanUseEvent) {
-        throw new MetaException("CahcedStore can not use events for invalidation as there is no " +
-                " TransactionalMetaStoreEventListener to add events to notification table");
-      }
-
-      endFunctionListeners = MetaStoreServerUtils.getMetaStoreListeners(
-          MetaStoreEndFunctionListener.class, conf, MetastoreConf.getVar(conf, ConfVars.END_FUNCTION_LISTENERS));
-
-      String partitionValidationRegex =
-          MetastoreConf.getVar(conf, ConfVars.PARTITION_NAME_WHITELIST_PATTERN);
-      if (partitionValidationRegex != null && !partitionValidationRegex.isEmpty()) {
-        partitionValidationPattern = Pattern.compile(partitionValidationRegex);
-      } else {
-        partitionValidationPattern = null;
-      }
-
-      // We only initialize once the tasks that need to be run periodically. For remote metastore
-      // these threads are started along with the other housekeeping threads only in the leader
-      // HMS.
-      String leaderHost = MetastoreConf.getVar(conf,
-              MetastoreConf.ConfVars.METASTORE_HOUSEKEEPING_LEADER_HOSTNAME);
-      if (!isMetaStoreRemote() && ((leaderHost == null) || leaderHost.trim().isEmpty())) {
-        startAlwaysTaskThreads(conf);
-      } else if (!isMetaStoreRemote()) {
-        LOG.info("Not starting tasks specified by " + ConfVars.TASK_THREADS_ALWAYS.getVarname() +
-                " since " + leaderHost + " is configured to run these tasks.");
-      }
-      expressionProxy = PartFilterExprUtil.createExpressionProxy(conf);
-      fileMetadataManager = new FileMetadataManager(this.getMS(), conf);
-
-      isServerFilterEnabled = getIfServerFilterenabled();
-      filterHook = isServerFilterEnabled ? loadFilterHooks() : null;
-
-      String className = MetastoreConf.getVar(conf, MetastoreConf.ConfVars.METASTORE_METADATA_TRANSFORMER_CLASS);
-      if (className != null && !className.trim().isEmpty()) {
-        Class<?> clazz;
-        try {
-          clazz = conf.getClassByName(className);
-        } catch (ClassNotFoundException e) {
-          LOG.error("Unable to load class " + className, e);
-          throw new IllegalArgumentException(e);
-        }
-        Constructor<?> constructor;
-        try {
-          constructor = clazz.getConstructor(IHMSHandler.class);
-          if (Modifier.isPrivate(constructor.getModifiers()))
-            throw new IllegalArgumentException("Illegal implementation for metadata transformer. Constructor is private");
-          transformer = (IMetaStoreMetadataTransformer) constructor.newInstance(this);
-        } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
-          LOG.error("Unable to create instance of class " + className, e);
-          throw new IllegalArgumentException(e);
-        }
-      }
-      dataconnectorFactory = DataConnectorProviderFactory.getInstance(this);
-    }
-
-    private static void startAlwaysTaskThreads(Configuration conf) throws MetaException {
-      if (alwaysThreadsInitialized.compareAndSet(false, true)) {
-        ThreadPool.initialize(conf);
-        Collection<String> taskNames =
-                MetastoreConf.getStringCollection(conf, ConfVars.TASK_THREADS_ALWAYS);
-        for (String taskName : taskNames) {
-          MetastoreTaskThread task =
-                  JavaUtils.newInstance(JavaUtils.getClass(taskName, MetastoreTaskThread.class));
-          task.setConf(conf);
-          long freq = task.runFrequency(TimeUnit.MILLISECONDS);
-          LOG.info("Scheduling for " + task.getClass().getCanonicalName() + " service with " +
-                  "frequency " + freq + "ms.");
-          // For backwards compatibility, since some threads used to be hard coded but only run if
-          // frequency was > 0
-          if (freq > 0) {
-            ThreadPool.getPool().scheduleAtFixedRate(task, freq, freq, TimeUnit.MILLISECONDS);
-          }
-        }
-      }
-    }
-
-    /**
-     *
-     * Filter is actually enabled only when the configured filter hook is configured, not default, and
-     * enabled in configuration
-     * @return
-     */
-    private boolean getIfServerFilterenabled() throws MetaException{
-      boolean isEnabled = MetastoreConf.getBoolVar(conf, ConfVars.METASTORE_SERVER_FILTER_ENABLED);
-
-      if (!isEnabled) {
-        LOG.info("HMS server filtering is disabled by configuration");
-        return false;
-      }
-
-      String filterHookClassName = MetastoreConf.getVar(conf, ConfVars.FILTER_HOOK);
-
-      if (isBlank(filterHookClassName)) {
-        throw new MetaException("HMS server filtering is enabled but no filter hook is configured");
-      }
-
-      if (filterHookClassName.trim().equalsIgnoreCase(DefaultMetaStoreFilterHookImpl.class.getName())) {
-        throw new MetaException("HMS server filtering is enabled but the filter hook is DefaultMetaStoreFilterHookImpl, which does no filtering");
-      }
-
-      LOG.info("HMS server filtering is enabled. The filter class is " + filterHookClassName);
-      return true;
-    }
-
-    private MetaStoreFilterHook loadFilterHooks() throws IllegalStateException  {
-      String errorMsg = "Unable to load filter hook at HMS server. ";
-
-      String filterHookClassName = MetastoreConf.getVar(conf, ConfVars.FILTER_HOOK);
-      Preconditions.checkState(!isBlank(filterHookClassName));
-
-      try {
-        return (MetaStoreFilterHook)Class.forName(
-            filterHookClassName.trim(), true, JavaUtils.getClassLoader()).getConstructor(
-            Configuration.class).newInstance(conf);
-      } catch (Exception e) {
-        LOG.error(errorMsg, e);
-        throw new IllegalStateException(errorMsg + e.getMessage(), e);
-      }
-    }
-
-    /**
-     * Check if user can access the table associated with the partition. If not, then throw exception
-     * so user cannot access partitions associated with this table
-     * We are not calling Pre event listener for authorization because it requires getting the
-     * table object from DB, more overhead. Instead ,we call filter hook to filter out table if user
-     * has no access. Filter hook only requires table name, not table object. That saves DB access for
-     * table object, and still achieve the same purpose: checking if user can access the specified
-     * table
-     *
-     * @param catName catalog name of the table
-     * @param dbName database name of the table
-     * @param tblName table name
-     * @throws NoSuchObjectException
-     * @throws MetaException
-     */
-    private void authorizeTableForPartitionMetadata(
-        final String catName, final String dbName, final String tblName)
-        throws NoSuchObjectException, MetaException {
-
-      FilterUtils.checkDbAndTableFilters(
-          isServerFilterEnabled, filterHook, catName, dbName, tblName);
-    }
-
-    private static String addPrefix(String s) {
-      return threadLocalId.get() + ": " + s;
-    }
-
-    /**
-     * Set copy of invoking HMSHandler on thread local
-     */
-    private static void setHMSHandler(HMSHandler handler) {
-      if (threadLocalHMSHandler.get() == null) {
-        threadLocalHMSHandler.set(handler);
-      }
-    }
-    @Override
-    public void setConf(Configuration conf) {
-      threadLocalConf.set(conf);
-      RawStore ms = threadLocalMS.get();
-      if (ms != null) {
-        ms.setConf(conf); // reload if DS related configuration is changed
-      }
-    }
-
-    @Override
-    public Configuration getConf() {
-      Configuration conf = threadLocalConf.get();
-      if (conf == null) {
-        conf = new Configuration(this.conf);
-        threadLocalConf.set(conf);
-      }
-      return conf;
-    }
-
-    private Map<String, String> getModifiedConf() {
-      Map<String, String> modifiedConf = threadLocalModifiedConfig.get();
-      if (modifiedConf == null) {
-        modifiedConf = new HashMap<>();
-        threadLocalModifiedConfig.set(modifiedConf);
-      }
-      return modifiedConf;
-    }
-
-    @Override
-    public Warehouse getWh() {
-      return wh;
-    }
-
-    @Override
-    public void setMetaConf(String key, String value) throws MetaException {
-      ConfVars confVar = MetastoreConf.getMetaConf(key);
-      if (confVar == null) {
-        throw new MetaException("Invalid configuration key " + key);
-      }
-      try {
-        confVar.validate(value);
-      } catch (IllegalArgumentException e) {
-        throw new MetaException("Invalid configuration value " + value + " for key " + key +
-            " by " + e.getMessage());
-      }
-      Configuration configuration = getConf();
-      String oldValue = MetastoreConf.get(configuration, key);
-      // Save prev val of the key on threadLocal
-      Map<String, String> modifiedConf = getModifiedConf();
-      if (!modifiedConf.containsKey(key)) {
-        modifiedConf.put(key, oldValue);
-      }
-      // Set invoking HMSHandler on threadLocal, this will be used later to notify
-      // metaListeners in HiveMetaStore#cleanupRawStore
-      setHMSHandler(this);
-      configuration.set(key, value);
-      notifyMetaListeners(key, oldValue, value);
-
-      if (ConfVars.TRY_DIRECT_SQL == confVar) {
-        HMSHandler.LOG.info("Direct SQL optimization = {}",  value);
-      }
-    }
-
-    @Override
-    public String getMetaConf(String key) throws MetaException {
-      ConfVars confVar = MetastoreConf.getMetaConf(key);
-      if (confVar == null) {
-        throw new MetaException("Invalid configuration key " + key);
-      }
-      return getConf().get(key, confVar.getDefaultVal().toString());
-    }
-
-    /**
-     * Get a cached RawStore.
-     *
-     * @return the cached RawStore
-     * @throws MetaException
-     */
-    @Override
-    public RawStore getMS() throws MetaException {
-      Configuration conf = getConf();
-      return getMSForConf(conf);
-    }
-
-    public static RawStore getMSForConf(Configuration conf) throws MetaException {
-      RawStore ms = threadLocalMS.get();
-      if (ms == null) {
-        ms = newRawStoreForConf(conf);
-        try {
-          ms.verifySchema();
-        } catch (MetaException e) {
-          ms.shutdown();
-          throw e;
-        }
-        threadLocalMS.set(ms);
-        ms = threadLocalMS.get();
-        LOG.info("Created RawStore: " + ms + " from thread id: " + Thread.currentThread().getId());
-      }
-      return ms;
-    }
-
-    @Override
-    public TxnStore getTxnHandler() {
-      return getMsThreadTxnHandler(conf);
-    }
-
-    public static TxnStore getMsThreadTxnHandler(Configuration conf) {
-      TxnStore txn = threadLocalTxn.get();
-      if (txn == null) {
-        txn = TxnUtils.getTxnStore(conf);
-        threadLocalTxn.set(txn);
-      }
-      return txn;
-    }
-
-    static RawStore newRawStoreForConf(Configuration conf) throws MetaException {
-      Configuration newConf = new Configuration(conf);
-      String rawStoreClassName = MetastoreConf.getVar(newConf, ConfVars.RAW_STORE_IMPL);
-      LOG.info(addPrefix("Opening raw store with implementation class:" + rawStoreClassName));
-      return RawStoreProxy.getProxy(newConf, conf, rawStoreClassName, threadLocalId.get());
-    }
-
-    @VisibleForTesting
-    public static void createDefaultCatalog(RawStore ms, Warehouse wh) throws MetaException,
-        InvalidOperationException {
-      try {
-        Catalog defaultCat = ms.getCatalog(DEFAULT_CATALOG_NAME);
-        // Null check because in some test cases we get a null from ms.getCatalog.
-        if (defaultCat !=null && defaultCat.getLocationUri().equals("TBD")) {
-          // One time update issue.  When the new 'hive' catalog is created in an upgrade the
-          // script does not know the location of the warehouse.  So we need to update it.
-          LOG.info("Setting location of default catalog, as it hasn't been done after upgrade");
-          defaultCat.setLocationUri(wh.getWhRoot().toString());
-          ms.alterCatalog(defaultCat.getName(), defaultCat);
-        }
-
-      } catch (NoSuchObjectException e) {
-        Catalog cat = new Catalog(DEFAULT_CATALOG_NAME, wh.getWhRoot().toString());
-        long time = System.currentTimeMillis() / 1000;
-        cat.setCreateTime((int) time);
-        cat.setDescription(Warehouse.DEFAULT_CATALOG_COMMENT);
-        ms.createCatalog(cat);
-      }
-    }
-
-    private void createDefaultDB_core(RawStore ms) throws MetaException, InvalidObjectException {
-      try {
-        ms.getDatabase(DEFAULT_CATALOG_NAME, DEFAULT_DATABASE_NAME);
-      } catch (NoSuchObjectException e) {
-        LOG.info("Started creating a default database with name: "+DEFAULT_DATABASE_NAME);
-        Database db = new Database(DEFAULT_DATABASE_NAME, DEFAULT_DATABASE_COMMENT,
-            wh.getDefaultDatabasePath(DEFAULT_DATABASE_NAME, true).toString(), null);
-        db.setOwnerName(PUBLIC);
-        db.setOwnerType(PrincipalType.ROLE);
-        db.setCatalogName(DEFAULT_CATALOG_NAME);
-        long time = System.currentTimeMillis() / 1000;
-        db.setCreateTime((int) time);
-        ms.createDatabase(db);
-        LOG.info("Successfully created a default database with name: "+DEFAULT_DATABASE_NAME);
-      }
-    }
-
-    /**
-     * create default database if it doesn't exist.
-     *
-     * This is a potential contention when HiveServer2 using embedded metastore and Metastore
-     * Server try to concurrently invoke createDefaultDB. If one failed, JDOException was caught
-     * for one more time try, if failed again, simply ignored by warning, which meant another
-     * succeeds.
-     *
-     * @throws MetaException
-     */
-    private void createDefaultDB() throws MetaException {
-      try {
-        RawStore ms = getMS();
-        createDefaultCatalog(ms, wh);
-        createDefaultDB_core(ms);
-      } catch (JDOException e) {
-        LOG.warn("Retrying creating default database after error: " + e.getMessage(), e);
-        try {
-          RawStore ms = getMS();
-          createDefaultCatalog(ms, wh);
-          createDefaultDB_core(ms);
-        } catch (InvalidObjectException | InvalidOperationException e1) {
-          throw new MetaException(e1.getMessage());
-        }
-      } catch (InvalidObjectException|InvalidOperationException e) {
-        throw new MetaException(e.getMessage());
-      }
-    }
-
-    /**
-     * create default roles if they don't exist.
-     *
-     * This is a potential contention when HiveServer2 using embedded metastore and Metastore
-     * Server try to concurrently invoke createDefaultRoles. If one failed, JDOException was caught
-     * for one more time try, if failed again, simply ignored by warning, which meant another
-     * succeeds.
-     *
-     * @throws MetaException
-     */
-    private void createDefaultRoles() throws MetaException {
-      try {
-        createDefaultRoles_core();
-      } catch (JDOException e) {
-        LOG.warn("Retrying creating default roles after error: " + e.getMessage(), e);
-        createDefaultRoles_core();
-      }
-    }
-
-    private void createDefaultRoles_core() throws MetaException {
-
-      RawStore ms = getMS();
-      try {
-        ms.addRole(ADMIN, ADMIN);
-      } catch (InvalidObjectException e) {
-        LOG.debug(ADMIN +" role already exists",e);
-      } catch (NoSuchObjectException e) {
-        // This should never be thrown.
-        LOG.warn("Unexpected exception while adding " +ADMIN+" roles" , e);
-      }
-      LOG.info("Added "+ ADMIN+ " role in metastore");
-      try {
-        ms.addRole(PUBLIC, PUBLIC);
-      } catch (InvalidObjectException e) {
-        LOG.debug(PUBLIC + " role already exists",e);
-      } catch (NoSuchObjectException e) {
-        // This should never be thrown.
-        LOG.warn("Unexpected exception while adding "+PUBLIC +" roles" , e);
-      }
-      LOG.info("Added "+PUBLIC+ " role in metastore");
-      // now grant all privs to admin
-      PrivilegeBag privs = new PrivilegeBag();
-      privs.addToPrivileges(new HiveObjectPrivilege( new HiveObjectRef(HiveObjectType.GLOBAL, null,
-        null, null, null), ADMIN, PrincipalType.ROLE, new PrivilegeGrantInfo("All", 0, ADMIN,
-          PrincipalType.ROLE, true), "SQL"));
-      try {
-        ms.grantPrivileges(privs);
-      } catch (InvalidObjectException e) {
-        // Surprisingly these privs are already granted.
-        LOG.debug("Failed while granting global privs to admin", e);
-      } catch (NoSuchObjectException e) {
-        // Unlikely to be thrown.
-        LOG.warn("Failed while granting global privs to admin", e);
-      }
-    }
-
-    /**
-     * add admin users if they don't exist.
-     *
-     * This is a potential contention when HiveServer2 using embedded metastore and Metastore
-     * Server try to concurrently invoke addAdminUsers. If one failed, JDOException was caught for
-     * one more time try, if failed again, simply ignored by warning, which meant another succeeds.
-     *
-     * @throws MetaException
-     */
-    private void addAdminUsers() throws MetaException {
-      try {
-        addAdminUsers_core();
-      } catch (JDOException e) {
-        LOG.warn("Retrying adding admin users after error: " + e.getMessage(), e);
-        addAdminUsers_core();
-      }
-    }
-
-    private void addAdminUsers_core() throws MetaException {
-
-      // now add pre-configured users to admin role
-      String userStr = MetastoreConf.getVar(conf,ConfVars.USERS_IN_ADMIN_ROLE,"").trim();
-      if (userStr.isEmpty()) {
-        LOG.info("No user is added in admin role, since config is empty");
-        return;
-      }
-      // Since user names need to be valid unix user names, per IEEE Std 1003.1-2001 they cannot
-      // contain comma, so we can safely split above string on comma.
-
-     Iterator<String> users = Splitter.on(",").trimResults().omitEmptyStrings().split(userStr).iterator();
-      if (!users.hasNext()) {
-        LOG.info("No user is added in admin role, since config value "+ userStr +
-          " is in incorrect format. We accept comma separated list of users.");
-        return;
-      }
-      Role adminRole;
-      RawStore ms = getMS();
-      try {
-        adminRole = ms.getRole(ADMIN);
-      } catch (NoSuchObjectException e) {
-        LOG.error("Failed to retrieve just added admin role",e);
-        return;
-      }
-      while (users.hasNext()) {
-        String userName = users.next();
-        try {
-          ms.grantRole(adminRole, userName, PrincipalType.USER, ADMIN, PrincipalType.ROLE, true);
-          LOG.info("Added " + userName + " to admin role");
-        } catch (NoSuchObjectException e) {
-          LOG.error("Failed to add "+ userName + " in admin role",e);
-        } catch (InvalidObjectException e) {
-          LOG.debug(userName + " already in admin role", e);
-        }
-      }
-    }
-
-    private static void logAndAudit(final String m) {
-      LOG.debug("{}: {}", threadLocalId.get(), m);
-      logAuditEvent(m);
-    }
-
-    private String startFunction(String function, String extraLogInfo) {
-      incrementCounter(function);
-      logAndAudit((getThreadLocalIpAddress() == null ? "" : "source:" + getThreadLocalIpAddress() + " ") +
-          function + extraLogInfo);
-      com.codahale.metrics.Timer timer =
-          Metrics.getOrCreateTimer(MetricsConstants.API_PREFIX + function);
-      if (timer != null) {
-        // Timer will be null we aren't using the metrics
-        timerContexts.get().put(function, timer.time());
-      }
-      Counter counter = Metrics.getOrCreateCounter(MetricsConstants.ACTIVE_CALLS + function);
-      if (counter != null) {
-        counter.inc();
-      }
-      return function;
-    }
-
-    private String startFunction(String function) {
-      return startFunction(function, "");
-    }
-
-    private void startTableFunction(String function, String catName, String db, String tbl) {
-      startFunction(function, " : tbl=" +
-          TableName.getQualified(catName, db, tbl));
-    }
-
-    private void startMultiTableFunction(String function, String db, List<String> tbls) {
-      String tableNames = join(tbls, ",");
-      startFunction(function, " : db=" + db + " tbls=" + tableNames);
-    }
-
-    private void startPartitionFunction(String function, String cat, String db, String tbl,
-                                        List<String> partVals) {
-      startFunction(function, " : tbl=" +
-          TableName.getQualified(cat, db, tbl) + "[" + join(partVals, ",") + "]");
-    }
-
-    private void startPartitionFunction(String function, String catName, String db, String tbl,
-                                        Map<String, String> partName) {
-      startFunction(function, " : tbl=" +
-          TableName.getQualified(catName, db, tbl) + "partition=" + partName);
-    }
-
-    private void endFunction(String function, boolean successful, Exception e) {
-      endFunction(function, successful, e, null);
-    }
-    private void endFunction(String function, boolean successful, Exception e,
-                            String inputTableName) {
-      endFunction(function, new MetaStoreEndFunctionContext(successful, e, inputTableName));
-    }
-
-    private void endFunction(String function, MetaStoreEndFunctionContext context) {
-      com.codahale.metrics.Timer.Context timerContext = timerContexts.get().remove(function);
-      if (timerContext != null) {
-        long timeTaken = timerContext.stop();
-        LOG.debug((getThreadLocalIpAddress() == null ? "" : "source:" + getThreadLocalIpAddress() + " ") +
-            function + "time taken(ns): " + timeTaken);
-      }
-      Counter counter = Metrics.getOrCreateCounter(MetricsConstants.ACTIVE_CALLS + function);
-      if (counter != null) {
-        counter.dec();
-      }
-
-      for (MetaStoreEndFunctionListener listener : endFunctionListeners) {
-        listener.onEndFunction(function, context);
-      }
-    }
-
-    @Override
-    public fb_status getStatus() {
-      return fb_status.ALIVE;
-    }
-
-    @Override
-    public void shutdown() {
-      cleanupRawStore();
-      PerfLogger.getPerfLogger(false).cleanupPerfLogMetrics();
-      ThreadPool.shutdown();
-    }
-
-    @Override
-    public AbstractMap<String, Long> getCounters() {
-      AbstractMap<String, Long> counters = super.getCounters();
-
-      // Allow endFunctionListeners to add any counters they have collected
-      if (endFunctionListeners != null) {
-        for (MetaStoreEndFunctionListener listener : endFunctionListeners) {
-          listener.exportCounters(counters);
-        }
-      }
-
-      return counters;
-    }
-
-    @Override
-    public void create_catalog(CreateCatalogRequest rqst)
-        throws AlreadyExistsException, InvalidObjectException, MetaException {
-      Catalog catalog = rqst.getCatalog();
-      startFunction("create_catalog", ": " + catalog.toString());
-      boolean success = false;
-      Exception ex = null;
-      try {
-        try {
-          getMS().getCatalog(catalog.getName());
-          throw new AlreadyExistsException("Catalog " + catalog.getName() + " already exists");
-        } catch (NoSuchObjectException e) {
-          // expected
-        }
-
-        if (!MetaStoreUtils.validateName(catalog.getName(), null)) {
-          throw new InvalidObjectException(catalog.getName() + " is not a valid catalog name");
-        }
-
-        if (catalog.getLocationUri() == null) {
-          throw new InvalidObjectException("You must specify a path for the catalog");
-        }
-
-        RawStore ms = getMS();
-        Path catPath = new Path(catalog.getLocationUri());
-        boolean madeDir = false;
-        Map<String, String> transactionalListenersResponses = Collections.emptyMap();
-        try {
-          firePreEvent(new PreCreateCatalogEvent(this, catalog));
-          if (!wh.isDir(catPath)) {
-            if (!wh.mkdirs(catPath)) {
-              throw new MetaException("Unable to create catalog path " + catPath +
-                  ", failed to create catalog " + catalog.getName());
-            }
-            madeDir = true;
-          }
-          // set the create time of catalog
-          long time = System.currentTimeMillis() / 1000;
-          catalog.setCreateTime((int) time);
-          ms.openTransaction();
-          ms.createCatalog(catalog);
-
-          // Create a default database inside the catalog
-          Database db = new Database(DEFAULT_DATABASE_NAME,
-              "Default database for catalog " + catalog.getName(), catalog.getLocationUri(),
-              Collections.emptyMap());
-          db.setCatalogName(catalog.getName());
-          create_database_core(ms, db);
-
-          if (!transactionalListeners.isEmpty()) {
-            transactionalListenersResponses =
-                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                    EventType.CREATE_CATALOG,
-                    new CreateCatalogEvent(true, this, catalog));
-          }
-
-          success = ms.commitTransaction();
-        } finally {
-          if (!success) {
-            ms.rollbackTransaction();
-            if (madeDir) {
-              wh.deleteDir(catPath, true, false, false);
-            }
-          }
-
-          if (!listeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(listeners,
-                EventType.CREATE_CATALOG,
-                new CreateCatalogEvent(success, this, catalog),
-                null,
-                transactionalListenersResponses, ms);
-          }
-        }
-        success = true;
-      } catch (AlreadyExistsException|InvalidObjectException|MetaException e) {
-        ex = e;
-        throw e;
-      } finally {
-        endFunction("create_catalog", success, ex);
-      }
-    }
-
-    @Override
-    public void alter_catalog(AlterCatalogRequest rqst) throws TException {
-      startFunction("alter_catalog " + rqst.getName());
-      boolean success = false;
-      Exception ex = null;
-      RawStore ms = getMS();
-      Map<String, String> transactionalListenersResponses = Collections.emptyMap();
-      GetCatalogResponse oldCat = null;
-
-      try {
-        oldCat = get_catalog(new GetCatalogRequest(rqst.getName()));
-        // Above should have thrown NoSuchObjectException if there is no such catalog
-        assert oldCat != null && oldCat.getCatalog() != null;
-        firePreEvent(new PreAlterCatalogEvent(oldCat.getCatalog(), rqst.getNewCat(), this));
-
-        ms.openTransaction();
-        ms.alterCatalog(rqst.getName(), rqst.getNewCat());
-
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenersResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                  EventType.ALTER_CATALOG,
-                  new AlterCatalogEvent(oldCat.getCatalog(), rqst.getNewCat(), true, this));
-        }
-
-        success = ms.commitTransaction();
-      } catch (MetaException|NoSuchObjectException e) {
-        ex = e;
-        throw e;
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-
-        if ((null != oldCat) && (!listeners.isEmpty())) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-              EventType.ALTER_CATALOG,
-              new AlterCatalogEvent(oldCat.getCatalog(), rqst.getNewCat(), success, this),
-              null, transactionalListenersResponses, ms);
-        }
-        endFunction("alter_catalog", success, ex);
-      }
-
-    }
-
-    @Override
-    public GetCatalogResponse get_catalog(GetCatalogRequest rqst)
-        throws NoSuchObjectException, TException {
-      String catName = rqst.getName();
-      startFunction("get_catalog", ": " + catName);
-      Catalog cat = null;
-      Exception ex = null;
-      try {
-        cat = getMS().getCatalog(catName);
-        firePreEvent(new PreReadCatalogEvent(this, cat));
-        return new GetCatalogResponse(cat);
-      } catch (MetaException|NoSuchObjectException e) {
-        ex = e;
-        throw e;
-      } finally {
-        endFunction("get_catalog", cat != null, ex);
-      }
-    }
-
-    @Override
-    public GetCatalogsResponse get_catalogs() throws MetaException {
-      startFunction("get_catalogs");
-
-      List<String> ret = null;
-      Exception ex = null;
-      try {
-        ret = getMS().getCatalogs();
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } finally {
-        endFunction("get_catalog", ret != null, ex);
-      }
-      return new GetCatalogsResponse(ret == null ? Collections.emptyList() : ret);
-
-    }
-
-    @Override
-    public void drop_catalog(DropCatalogRequest rqst)
-        throws NoSuchObjectException, InvalidOperationException, MetaException {
-      String catName = rqst.getName();
-      startFunction("drop_catalog", ": " + catName);
-      if (DEFAULT_CATALOG_NAME.equalsIgnoreCase(catName)) {
-        endFunction("drop_catalog", false, null);
-        throw new MetaException("Can not drop " + DEFAULT_CATALOG_NAME + " catalog");
-      }
-
-      boolean success = false;
-      Exception ex = null;
-      try {
-        dropCatalogCore(catName);
-        success = true;
-      } catch (NoSuchObjectException|InvalidOperationException|MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("drop_catalog", success, ex);
-      }
-
-    }
-
-    private void dropCatalogCore(String catName)
-        throws MetaException, NoSuchObjectException, InvalidOperationException {
-      boolean success = false;
-      Catalog cat = null;
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-      RawStore ms = getMS();
-      try {
-        ms.openTransaction();
-        cat = ms.getCatalog(catName);
-
-        firePreEvent(new PreDropCatalogEvent(this, cat));
-
-        List<String> allDbs = get_databases(prependNotNullCatToDbName(catName, null));
-        if (allDbs != null && !allDbs.isEmpty()) {
-          // It might just be the default, in which case we can drop that one if it's empty
-          if (allDbs.size() == 1 && allDbs.get(0).equals(DEFAULT_DATABASE_NAME)) {
-            try {
-              drop_database_core(ms, catName, DEFAULT_DATABASE_NAME, true, false);
-            } catch (InvalidOperationException e) {
-              // This means there are tables of something in the database
-              throw new InvalidOperationException("There are still objects in the default " +
-                  "database for catalog " + catName);
-            } catch (InvalidObjectException|IOException|InvalidInputException e) {
-              MetaException me = new MetaException("Error attempt to drop default database for " +
-                  "catalog " + catName);
-              me.initCause(e);
-              throw me;
-            }
-          } else {
-            throw new InvalidOperationException("There are non-default databases in the catalog " +
-                catName + " so it cannot be dropped.");
-          }
-        }
-
-        ms.dropCatalog(catName) ;
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenerResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                  EventType.DROP_CATALOG,
-                  new DropCatalogEvent(true, this, cat));
-        }
-
-        success = ms.commitTransaction();
-      } finally {
-        if (success) {
-          wh.deleteDir(wh.getDnsPath(new Path(cat.getLocationUri())), false, false, false);
-        } else {
-          ms.rollbackTransaction();
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-              EventType.DROP_CATALOG,
-              new DropCatalogEvent(success, this, cat),
-              null,
-              transactionalListenerResponses, ms);
-        }
-      }
-    }
-
-    static boolean isDbReplicationTarget(Database db) {
-      if (db.getParameters() == null) {
-        return false;
-      }
-
-      if (!db.getParameters().containsKey(ReplConst.REPL_TARGET_DB_PROPERTY)) {
-        return false;
-      }
-
-      return !db.getParameters().get(ReplConst.REPL_TARGET_DB_PROPERTY).trim().isEmpty();
-    }
-
-    // Assumes that the catalog has already been set.
-    private void create_database_core(RawStore ms, final Database db)
-        throws AlreadyExistsException, InvalidObjectException, MetaException {
-      if (!MetaStoreUtils.validateName(db.getName(), conf)) {
-        throw new InvalidObjectException(db.getName() + " is not a valid database name");
-      }
-
-      Catalog cat = null;
-      try {
-        cat = getMS().getCatalog(db.getCatalogName());
-      } catch (NoSuchObjectException e) {
-        LOG.error("No such catalog " + db.getCatalogName());
-        throw new InvalidObjectException("No such catalog " + db.getCatalogName());
-      }
-      boolean skipAuthorization = false;
-      String passedInURI = db.getLocationUri();
-      String passedInManagedURI = db.getManagedLocationUri();
-      if (passedInURI == null && passedInManagedURI == null) {
-        skipAuthorization = true;
-      }
-      final Path defaultDbExtPath = wh.getDefaultDatabasePath(db.getName(), true);
-      final Path defaultDbMgdPath = wh.getDefaultDatabasePath(db.getName(), false);
-      final Path dbExtPath = (passedInURI != null) ? wh.getDnsPath(new Path(passedInURI)) : wh.determineDatabasePath(cat, db);
-      final Path dbMgdPath = (passedInManagedURI != null) ? wh.getDnsPath(new Path(passedInManagedURI)) : null;
-
-      if ((defaultDbExtPath.equals(dbExtPath) && defaultDbMgdPath.equals(dbMgdPath)) &&
-          ((dbMgdPath == null) || dbMgdPath.equals(defaultDbMgdPath))) {
-        skipAuthorization = true;
-      }
-
-      if ( skipAuthorization ) {
-        //null out to skip authorizer URI check
-        db.setLocationUri(null);
-        db.setManagedLocationUri(null);
-      }else{
-        db.setLocationUri(dbExtPath.toString());
-        if (dbMgdPath != null) {
-          db.setManagedLocationUri(dbMgdPath.toString());
-        }
-      }
-      if (db.getOwnerName() == null){
-        try {
-          db.setOwnerName(SecurityUtils.getUGI().getShortUserName());
-        }catch (Exception e){
-          LOG.warn("Failed to get owner name for create database operation.", e);
-        }
-      }
-      long time = System.currentTimeMillis()/1000;
-      db.setCreateTime((int) time);
-      boolean success = false;
-      boolean madeManagedDir = false;
-      boolean madeExternalDir = false;
-      boolean isReplicated = isDbReplicationTarget(db);
-      Map<String, String> transactionalListenersResponses = Collections.emptyMap();
-      try {
-        firePreEvent(new PreCreateDatabaseEvent(db, this));
-        //reinstate location uri for metastore db.
-        if (skipAuthorization == true){
-          db.setLocationUri(dbExtPath.toString());
-          if (dbMgdPath != null)
-            db.setManagedLocationUri(dbMgdPath.toString());
-        }
-        if (db.getCatalogName() != null && !db.getCatalogName().
-            equals(Warehouse.DEFAULT_CATALOG_NAME)) {
-          if (!wh.isDir(dbExtPath)) {
-            LOG.debug("Creating database path " + dbExtPath);
-            if (!wh.mkdirs(dbExtPath)) {
-              throw new MetaException("Unable to create database path " + dbExtPath +
-                  ", failed to create database " + db.getName());
-            }
-            madeExternalDir = true;
-          }
-        } else {
-          if (dbMgdPath != null) {
-            try {
-              // Since this may be done as random user (if doAs=true) he may not have access
-              // to the managed directory. We run this as an admin user
-              madeManagedDir = UserGroupInformation.getLoginUser().doAs(new PrivilegedExceptionAction<Boolean>() {
-                @Override public Boolean run() throws MetaException {
-                  if (!wh.isDir(dbMgdPath)) {
-                    LOG.info("Creating database path in managed directory " + dbMgdPath);
-                    if (!wh.mkdirs(dbMgdPath)) {
-                      throw new MetaException("Unable to create database managed path " + dbMgdPath + ", failed to create database " + db.getName());
-                    }
-                    return true;
-                  }
-                  return false;
-                }
-              });
-              if (madeManagedDir) {
-                LOG.info("Created database path in managed directory " + dbMgdPath);
-              } else {
-                throw new MetaException(
-                    "Unable to create database managed directory " + dbMgdPath + ", failed to create database " + db.getName());
-              }
-            } catch (IOException | InterruptedException e) {
-              throw new MetaException(
-                  "Unable to create database managed directory " + dbMgdPath + ", failed to create database " + db.getName() + ":" + e.getMessage());
-            }
-          }
-          if (dbExtPath != null) {
-            try {
-              madeExternalDir = UserGroupInformation.getCurrentUser().doAs(new PrivilegedExceptionAction<Boolean>() {
-                @Override public Boolean run() throws MetaException {
-                  if (!wh.isDir(dbExtPath)) {
-                    LOG.info("Creating database path in external directory " + dbExtPath);
-                    return wh.mkdirs(dbExtPath);
-                  }
-                  return false;
-                }
-              });
-              if (madeExternalDir) {
-                LOG.info("Created database path in external directory " + dbExtPath);
-              } else {
-                LOG.warn("Failed to create external path " + dbExtPath + " for database " + db.getName() + ". This may result in access not being allowed if the "
-                    + "StorageBasedAuthorizationProvider is enabled");
-              }
-            } catch (IOException | InterruptedException | UndeclaredThrowableException e) {
-              throw new MetaException("Failed to create external path " + dbExtPath + " for database " + db.getName() + ". This may result in access not being allowed if the "
-                  + "StorageBasedAuthorizationProvider is enabled: " + e.getMessage());
-            }
-          } else {
-            LOG.info("Database external path won't be created since the external warehouse directory is not defined");
-          }
-        }
-
-        ms.openTransaction();
-        ms.createDatabase(db);
-
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenersResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                    EventType.CREATE_DATABASE,
-                                                    new CreateDatabaseEvent(db, true, this, isReplicated));
-        }
-
-        success = ms.commitTransaction();
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-
-          if (db.getCatalogName() != null && !db.getCatalogName().
-              equals(Warehouse.DEFAULT_CATALOG_NAME)) {
-            if (madeManagedDir) {
-              wh.deleteDir(dbMgdPath, true, db);
-            }
-          } else {
-            if (madeManagedDir) {
-              try {
-                UserGroupInformation.getLoginUser().doAs(new PrivilegedExceptionAction<Void>() {
-                  @Override public Void run() throws Exception {
-                    wh.deleteDir(dbMgdPath, true, db);
-                    return null;
-                  }
-                });
-              } catch (IOException | InterruptedException e) {
-                LOG.error(
-                    "Couldn't delete managed directory " + dbMgdPath + " after " + "it was created for database " + db.getName() + " " + e.getMessage());
-              }
-            }
-
-            if (madeExternalDir) {
-              try {
-                UserGroupInformation.getCurrentUser().doAs(new PrivilegedExceptionAction<Void>() {
-                  @Override public Void run() throws Exception {
-                    wh.deleteDir(dbExtPath, true, db);
-                    return null;
-                  }
-                });
-              } catch (IOException | InterruptedException e) {
-                LOG.error("Couldn't delete external directory " + dbExtPath + " after " + "it was created for database "
-                    + db.getName() + " " + e.getMessage());
-              }
-            }
-          }
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.CREATE_DATABASE,
-                                                new CreateDatabaseEvent(db, success, this, isReplicated),
-                                                null,
-                                                transactionalListenersResponses, ms);
-        }
-      }
-    }
-
-    @Override
-    public void create_database(final Database db)
-        throws AlreadyExistsException, InvalidObjectException, MetaException {
-      startFunction("create_database", ": " + db.toString());
-      boolean success = false;
-      Exception ex = null;
-      if (!db.isSetCatalogName()) {
-        db.setCatalogName(getDefaultCatalog(conf));
-      }
-      try {
-        try {
-          if (null != get_database_core(db.getCatalogName(), db.getName())) {
-            throw new AlreadyExistsException("Database " + db.getName() + " already exists");
-          }
-        } catch (NoSuchObjectException e) {
-          // expected
-        }
-
-        if (TEST_TIMEOUT_ENABLED) {
-          try {
-            Thread.sleep(TEST_TIMEOUT_VALUE);
-          } catch (InterruptedException e) {
-            // do nothing
-          }
-          Deadline.checkTimeout();
-        }
-        create_database_core(getMS(), db);
-        success = true;
-      } catch (MetaException | InvalidObjectException | AlreadyExistsException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("create_database", success, ex);
-      }
-    }
-
-    @Override
-    public Database get_database(final String name)
-        throws NoSuchObjectException, MetaException {
-      GetDatabaseRequest request = new GetDatabaseRequest();
-      String[] parsedDbName = parseDbName(name, conf);
-      request.setName(parsedDbName[DB_NAME]);
-      if (parsedDbName[CAT_NAME] != null)
-          request.setCatalogName(parsedDbName[CAT_NAME]);
-        return get_database_req(request);
-    }
-
-    @Override
-    public Database get_database_core(String catName, final String name) throws NoSuchObjectException, MetaException {
-      Database db = null;
-      if (name == null) {
-        throw new MetaException("Database name cannot be null.");
-      }
-      try {
-        db = getMS().getDatabase(catName, name);
-      } catch (MetaException | NoSuchObjectException e) {
-        throw e;
-      } catch (Exception e) {
-        assert (e instanceof RuntimeException);
-        throw (RuntimeException) e;
-      }
-      return db;
-    }
-
-    @Override
-    public Database get_database_req(GetDatabaseRequest request) throws NoSuchObjectException, MetaException {
-      startFunction("get_database", ": " + request.getName());
-      Database db = null;
-      Exception ex = null;
-      if (request.getName() == null) {
-        throw new MetaException("Database name cannot be null.");
-      }
-      List<String> processorCapabilities = request.getProcessorCapabilities();
-      String processorId = request.getProcessorIdentifier();
-      try {
-        db = getMS().getDatabase(request.getCatalogName(), request.getName());
-        firePreEvent(new PreReadDatabaseEvent(db, this));
-        if (processorCapabilities != null && transformer != null) {
-          db = transformer.transformDatabase(db, processorCapabilities, processorId);
-        }
-      } catch (MetaException | NoSuchObjectException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        assert (e instanceof RuntimeException);
-        throw (RuntimeException) e;
-      } finally {
-        endFunction("get_database", db != null, ex);
-      }
-      return db;
-    }
-
-    @Override
-    public void alter_database(final String dbName, final Database newDB) throws TException {
-      startFunction("alter_database " + dbName);
-      boolean success = false;
-      Exception ex = null;
-      RawStore ms = getMS();
-      Database oldDB = null;
-      Map<String, String> transactionalListenersResponses = Collections.emptyMap();
-
-      // Perform the same URI normalization as create_database_core.
-      if (newDB.getLocationUri() != null) {
-        newDB.setLocationUri(wh.getDnsPath(new Path(newDB.getLocationUri())).toString());
-      }
-
-      String[] parsedDbName = parseDbName(dbName, conf);
-
-      // We can replicate into an empty database, in which case newDB will have indication that
-      // it's target of replication but not oldDB. But replication flow will never alter a
-      // database so that oldDB indicates that it's target or replication but not the newDB. So,
-      // relying solely on newDB to check whether the database is target of replication works.
-      boolean isReplicated = isDbReplicationTarget(newDB);
-      try {
-        oldDB = get_database_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]);
-        if (oldDB == null) {
-          throw new MetaException("Could not alter database \"" + parsedDbName[DB_NAME] +
-              "\". Could not retrieve old definition.");
-        }
-        firePreEvent(new PreAlterDatabaseEvent(oldDB, newDB, this));
-
-        ms.openTransaction();
-        ms.alterDatabase(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], newDB);
-
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenersResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                  EventType.ALTER_DATABASE,
-                  new AlterDatabaseEvent(oldDB, newDB, true, this, isReplicated));
-        }
-
-        success = ms.commitTransaction();
-      } catch (MetaException|NoSuchObjectException e) {
-        ex = e;
-        throw e;
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-
-        if ((null != oldDB) && (!listeners.isEmpty())) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-              EventType.ALTER_DATABASE,
-              new AlterDatabaseEvent(oldDB, newDB, success, this, isReplicated),
-              null,
-              transactionalListenersResponses, ms);
-        }
-        endFunction("alter_database", success, ex);
-      }
-    }
-
-    private void drop_database_core(RawStore ms, String catName,
-        final String name, final boolean deleteData, final boolean cascade)
-        throws NoSuchObjectException, InvalidOperationException, MetaException,
-        IOException, InvalidObjectException, InvalidInputException {
-      boolean success = false;
-      Database db = null;
-      List<Path> tablePaths = new ArrayList<>();
-      List<Path> partitionPaths = new ArrayList<>();
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-      if (name == null) {
-        throw new MetaException("Database name cannot be null.");
-      }
-      boolean isReplicated = false;
-      try {
-        ms.openTransaction();
-        db = ms.getDatabase(catName, name);
-        if (db.getType() == DatabaseType.REMOTE) {
-          success = drop_remote_database_core(ms, db);
-          return;
-        }
-        isReplicated = isDbReplicationTarget(db);
-
-        if (!isInTest && ReplChangeManager.isSourceOfReplication(db)) {
-          throw new InvalidOperationException("can not drop a database which is a source of replication");
-        }
-
-        firePreEvent(new PreDropDatabaseEvent(db, this));
-        String catPrependedName = MetaStoreUtils.prependCatalogToDbName(catName, name, conf);
-
-        Set<String> uniqueTableNames = new HashSet<>(get_all_tables(catPrependedName));
-        List<String> allFunctions = get_functions(catPrependedName, "*");
-        ListStoredProcedureRequest request = new ListStoredProcedureRequest(catName);
-        request.setDbName(name);
-        List<String> allProcedures = get_all_stored_procedures(request);
-
-        if (!cascade) {
-          if (!uniqueTableNames.isEmpty()) {
-            throw new InvalidOperationException(
-                "Database " + db.getName() + " is not empty. One or more tables exist.");
-          }
-          if (!allFunctions.isEmpty()) {
-            throw new InvalidOperationException(
-                "Database " + db.getName() + " is not empty. One or more functions exist.");
-          }
-          if (!allProcedures.isEmpty()) {
-            throw new InvalidOperationException(
-                    "Database " + db.getName() + " is not empty. One or more stored procedures exist.");
-          }
-        }
-        Path path = new Path(db.getLocationUri()).getParent();
-        if (!wh.isWritable(path)) {
-          throw new MetaException("Database not dropped since " +
-              path + " is not writable by " +
-              SecurityUtils.getUser());
-        }
-
-        Path databasePath = wh.getDnsPath(wh.getDatabasePath(db));
-
-        // drop any functions before dropping db
-        for (String funcName : allFunctions) {
-          drop_function(catPrependedName, funcName);
-        }
-
-        for (String procName : allProcedures) {
-          drop_stored_procedure(new StoredProcedureRequest(catName, name, procName));
-        }
-
-        final int tableBatchSize = MetastoreConf.getIntVar(conf,
-            ConfVars.BATCH_RETRIEVE_MAX);
-
-        // First pass will drop the materialized views
-        List<String> materializedViewNames = getTablesByTypeCore(catName, name, ".*",
-            TableType.MATERIALIZED_VIEW.toString());
-        int startIndex = 0;
-        // retrieve the tables from the metastore in batches to alleviate memory constraints
-        while (startIndex < materializedViewNames.size()) {
-          int endIndex = Math.min(startIndex + tableBatchSize, materializedViewNames.size());
-
-          List<Table> materializedViews;
-          try {
-            materializedViews = ms.getTableObjectsByName(catName, name, materializedViewNames.subList(startIndex, endIndex));
-          } catch (UnknownDBException e) {
-            throw new MetaException(e.getMessage());
-          }
-
-          if (materializedViews != null && !materializedViews.isEmpty()) {
-            for (Table materializedView : materializedViews) {
-              if (materializedView.getSd().getLocation() != null) {
-                Path materializedViewPath = wh.getDnsPath(new Path(materializedView.getSd().getLocation()));
-                if (!wh.isWritable(materializedViewPath.getParent())) {
-                  throw new MetaException("Database metadata not deleted since table: " +
-                      materializedView.getTableName() + " has a parent location " + materializedViewPath.getParent() +
-                      " which is not writable by " + SecurityUtils.getUser());
-                }
-
-                if (!FileUtils.isSubdirectory(databasePath.toString(),
-                    materializedViewPath.toString())) {
-                  tablePaths.add(materializedViewPath);
-                }
-              }
-              // Drop the materialized view but not its data
-              drop_table(name, materializedView.getTableName(), false);
-              // Remove from all tables
-              uniqueTableNames.remove(materializedView.getTableName());
-            }
-          }
-          startIndex = endIndex;
-        }
-
-        // drop tables before dropping db
-        List<String> allTables = new ArrayList<>(uniqueTableNames);
-        startIndex = 0;
-        // retrieve the tables from the metastore in batches to alleviate memory constraints
-        while (startIndex < allTables.size()) {
-          int endIndex = Math.min(startIndex + tableBatchSize, allTables.size());
-
-          List<Table> tables;
-          try {
-            tables = ms.getTableObjectsByName(catName, name, allTables.subList(startIndex, endIndex));
-          } catch (UnknownDBException e) {
-            throw new MetaException(e.getMessage());
-          }
-
-          if (tables != null && !tables.isEmpty()) {
-            for (Table table : tables) {
-
-              // If the table is not external and it might not be in a subdirectory of the database
-              // add it's locations to the list of paths to delete
-              Path tablePath = null;
-              boolean tableDataShouldBeDeleted = checkTableDataShouldBeDeleted(table, deleteData);
-              if (table.getSd().getLocation() != null && tableDataShouldBeDeleted) {
-                tablePath = wh.getDnsPath(new Path(table.getSd().getLocation()));
-                if (!wh.isWritable(tablePath.getParent())) {
-                  throw new MetaException("Database metadata not deleted since table: " +
-                      table.getTableName() + " has a parent location " + tablePath.getParent() +
-                      " which is not writable by " + SecurityUtils.getUser());
-                }
-
-                if (!FileUtils.isSubdirectory(databasePath.toString(), tablePath.toString())) {
-                  tablePaths.add(tablePath);
-                }
-              }
-
-              // For each partition in each table, drop the partitions and get a list of
-              // partitions' locations which might need to be deleted
-              partitionPaths = dropPartitionsAndGetLocations(ms, catName, name, table.getTableName(),
-                  tablePath, tableDataShouldBeDeleted);
-
-              // Drop the table but not its data
-              drop_table(MetaStoreUtils.prependCatalogToDbName(table.getCatName(), table.getDbName(), conf),
-                  table.getTableName(), false);
-            }
-          }
-
-          startIndex = endIndex;
-        }
-
-        if (ms.dropDatabase(catName, name)) {
-          if (!transactionalListeners.isEmpty()) {
-            transactionalListenerResponses =
-                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                      EventType.DROP_DATABASE,
-                                                      new DropDatabaseEvent(db, true, this, isReplicated));
-          }
-
-          success = ms.commitTransaction();
-        }
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else if (deleteData) {
-          // Delete the data in the partitions which have other locations
-          deletePartitionData(partitionPaths, false, db);
-          // Delete the data in the tables which have other locations
-          for (Path tablePath : tablePaths) {
-            deleteTableData(tablePath, false, db);
-          }
-          // Delete the data in the database
-          try {
-            if (db.getManagedLocationUri() != null) {
-              wh.deleteDir(new Path(db.getManagedLocationUri()), true, db);
-            }
-          } catch (Exception e) {
-            LOG.error("Failed to delete database directory: " + db.getManagedLocationUri() +
-                " " + e.getMessage());
-          }
-          // Delete the data in the database's location only if it is a legacy db path?
-          try {
-            wh.deleteDir(new Path(db.getLocationUri()), true, db);
-          } catch (Exception e) {
-            LOG.error("Failed to delete database directory: " + db.getLocationUri() +
-                " " + e.getMessage());
-          }
-          // it is not a terrible thing even if the data is not deleted
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.DROP_DATABASE,
-                                                new DropDatabaseEvent(db, success, this, isReplicated),
-                                                null,
-                                                transactionalListenerResponses, ms);
-        }
-      }
-    }
-
-    private boolean drop_remote_database_core(RawStore ms, final Database db) throws MetaException, NoSuchObjectException {
-      boolean success = false;
-      firePreEvent(new PreDropDatabaseEvent(db, this));
-
-      if (ms.dropDatabase(db.getCatalogName(), db.getName())) {
-        success = ms.commitTransaction();
-      }
-      return success;
-    }
-
-    @Override
-    public void drop_database(final String dbName, final boolean deleteData, final boolean cascade)
-        throws NoSuchObjectException, InvalidOperationException, MetaException {
-      startFunction("drop_database", ": " + dbName);
-      String[] parsedDbName = parseDbName(dbName, conf);
-      if (DEFAULT_CATALOG_NAME.equalsIgnoreCase(parsedDbName[CAT_NAME]) &&
-          DEFAULT_DATABASE_NAME.equalsIgnoreCase(parsedDbName[DB_NAME])) {
-        endFunction("drop_database", false, null);
-        throw new MetaException("Can not drop " + DEFAULT_DATABASE_NAME + " database in catalog "
-            + DEFAULT_CATALOG_NAME);
-      }
-
-      boolean success = false;
-      Exception ex = null;
-      try {
-        drop_database_core(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME], deleteData,
-            cascade);
-        success = true;
-      } catch (NoSuchObjectException|InvalidOperationException|MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("drop_database", success, ex);
-      }
-    }
-
-
-    @Override
-    public List<String> get_databases(final String pattern) throws MetaException {
-      startFunction("get_databases", ": " + pattern);
-
-      String[] parsedDbNamed = parseDbName(pattern, conf);
-      List<String> ret = null;
-      Exception ex = null;
-      try {
-        if (parsedDbNamed[DB_NAME] == null) {
-          ret = getMS().getAllDatabases(parsedDbNamed[CAT_NAME]);
-          ret = FilterUtils.filterDbNamesIfEnabled(isServerFilterEnabled, filterHook, ret);
-        } else {
-          ret = getMS().getDatabases(parsedDbNamed[CAT_NAME], parsedDbNamed[DB_NAME]);
-          ret = FilterUtils.filterDbNamesIfEnabled(isServerFilterEnabled, filterHook, ret);
-        }
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_databases", ret != null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public List<String> get_all_databases() throws MetaException {
-      // get_databases filters results already. No need to filter here
-      return get_databases(MetaStoreUtils.prependCatalogToDbName(null, null, conf));
-    }
-
-    private void create_type_core(final RawStore ms, final Type type)
-        throws AlreadyExistsException, MetaException, InvalidObjectException {
-      if (!MetaStoreUtils.validateName(type.getName(), null)) {
-        throw new InvalidObjectException("Invalid type name");
-      }
-
-      boolean success = false;
-      try {
-        ms.openTransaction();
-        if (is_type_exists(ms, type.getName())) {
-          throw new AlreadyExistsException("Type " + type.getName() + " already exists");
-        }
-        ms.createType(type);
-        success = ms.commitTransaction();
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-      }
-    }
-
-    private void create_dataconnector_core(RawStore ms, final DataConnector connector)
-        throws AlreadyExistsException, InvalidObjectException, MetaException {
-      if (!MetaStoreUtils.validateName(connector.getName(), conf)) {
-        throw new InvalidObjectException(connector.getName() + " is not a valid dataconnector name");
-      }
-
-      if (connector.getOwnerName() == null){
-        try {
-          connector.setOwnerName(SecurityUtils.getUGI().getShortUserName());
-        }catch (Exception e){
-          LOG.warn("Failed to get owner name for create dataconnector operation.", e);
-        }
-      }
-      long time = System.currentTimeMillis()/1000;
-      connector.setCreateTime((int) time);
-      boolean success = false;
-      Map<String, String> transactionalListenersResponses = Collections.emptyMap();
-      try {
-        firePreEvent(new PreCreateDataConnectorEvent(connector, this));
-
-        ms.openTransaction();
-        ms.createDataConnector(connector);
-
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenersResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                  EventType.CREATE_DATACONNECTOR,
-                  new CreateDataConnectorEvent(connector, true, this));
-        }
-
-        success = ms.commitTransaction();
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-              EventType.CREATE_DATACONNECTOR,
-              new CreateDataConnectorEvent(connector, success, this),
-              null,
-              transactionalListenersResponses, ms);
-        }
-      }
-    }
-
-    @Override
-    public void create_dataconnector(final DataConnector connector)
-        throws AlreadyExistsException, InvalidObjectException, MetaException {
-      startFunction("create_dataconnector", ": " + connector.toString());
-      boolean success = false;
-      Exception ex = null;
-      try {
-        try {
-          if (null != get_dataconnector_core(connector.getName())) {
-            throw new AlreadyExistsException("DataConnector " + connector.getName() + " already exists");
-          }
-        } catch (NoSuchObjectException e) {
-          // expected
-        }
-
-        if (TEST_TIMEOUT_ENABLED) {
-          try {
-            Thread.sleep(TEST_TIMEOUT_VALUE);
-          } catch (InterruptedException e) {
-            // do nothing
-          }
-          Deadline.checkTimeout();
-        }
-        create_dataconnector_core(getMS(), connector);
-        success = true;
-      } catch (MetaException | InvalidObjectException | AlreadyExistsException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("create_connector", success, ex);
-      }
-    }
-
-    @Override
-    public DataConnector get_dataconnector_core(final String name) throws NoSuchObjectException, MetaException {
-      DataConnector connector = null;
-      if (name == null) {
-        throw new MetaException("Data connector name cannot be null.");
-      }
-      try {
-        connector = getMS().getDataConnector(name);
-      } catch (MetaException | NoSuchObjectException e) {
-        throw e;
-      } catch (Exception e) {
-        assert (e instanceof RuntimeException);
-        throw (RuntimeException) e;
-      }
-      return connector;
-    }
-
-    @Override
-    public DataConnector get_dataconnector_req(GetDataConnectorRequest request) throws NoSuchObjectException, MetaException {
-      startFunction("get_dataconnector", ": " + request.getConnectorName());
-      DataConnector connector = null;
-      Exception ex = null;
-      try {
-        connector = get_dataconnector_core(request.getConnectorName());
-      } catch (MetaException | NoSuchObjectException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        assert (e instanceof RuntimeException);
-        throw (RuntimeException) e;
-      } finally {
-        endFunction("get_dataconnector", connector != null, ex);
-      }
-      return connector;
-    }
-
-    @Override
-    public void alter_dataconnector(final String dcName, final DataConnector newDC) throws TException {
-      startFunction("alter_dataconnector " + dcName);
-      boolean success = false;
-      Exception ex = null;
-      RawStore ms = getMS();
-      DataConnector oldDC = null;
-      Map<String, String> transactionalListenersResponses = Collections.emptyMap();
-
-      try {
-        oldDC = get_dataconnector_core(dcName);
-        if (oldDC == null) {
-          throw new MetaException("Could not alter dataconnector \"" + dcName +
-              "\". Could not retrieve old definition.");
-        }
-        // firePreEvent(new PreAlterDatabaseEvent(oldDC, newDC, this));
-
-        ms.openTransaction();
-        ms.alterDataConnector(dcName, newDC);
-
-        /*
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenersResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                  EventType.ALTER_DATACONNECTOR,
-                  new AlterDataConnectorEvent(oldDC, newDC, true, this));
-        }
-         */
-
-        success = ms.commitTransaction();
-      } catch (MetaException|NoSuchObjectException e) {
-        ex = e;
-        throw e;
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-/*
-        if ((null != oldDC) && (!listeners.isEmpty())) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-              EventType.ALTER_DATACONNECTOR,
-              new AlterDataConnectorEvent(oldDC, newDC, success, this),
-              null,
-              transactionalListenersResponses, ms);
-        }
- */
-        endFunction("alter_database", success, ex);
-      }
-    }
-
-    @Override
-    public List<String> get_dataconnectors() throws MetaException {
-      startFunction("get_dataconnectors");
-
-      List<String> ret = null;
-      Exception ex = null;
-      try {
-          ret = getMS().getAllDataConnectors();
-          ret = FilterUtils.filterDataConnectorsIfEnabled(isServerFilterEnabled, filterHook, ret);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_dataconnectors", ret != null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public void drop_dataconnector(final String dcName, boolean ifNotExists, boolean checkReferences) throws NoSuchObjectException, InvalidOperationException, MetaException {
-      startFunction("drop_dataconnector", ": " + dcName);
-      boolean success = false;
-      DataConnector connector = null;
-      Exception ex = null;
-      RawStore ms = getMS();
-      try {
-        ms.openTransaction();
-        connector = getMS().getDataConnector(dcName);
-
-        if (connector == null) {
-          if (!ifNotExists) {
-            throw new NoSuchObjectException("DataConnector " + dcName + " doesn't exist");
-          } else {
-            return;
-          }
-        }
-        // TODO find DBs with references to this connector
-        // if any existing references and checkReferences=true, do not drop
-
-        // firePreEvent(new PreDropTableEvent(tbl, deleteData, this));
-
-        if (!ms.dropDataConnector(dcName)) {
-          throw new MetaException("Unable to drop dataconnector " + dcName);
-        } else {
-/*
-          if (!transactionalListeners.isEmpty()) {
-            transactionalListenerResponses =
-                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                    EventType.DROP_TABLE,
-                    new DropTableEvent(tbl, true, deleteData,
-                        this, isReplicated),
-                    envContext);
-          }
-
- */
-          success = ms.commitTransaction();
-        }
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-/*
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-              EventType.DROP_TABLE,
-              new DropTableEvent(tbl, success, deleteData, this, isReplicated),
-              envContext,
-              transactionalListenerResponses, ms);
-        }
-
- */
-        endFunction("drop_dataconnector", success, ex);
-      }
-    }
-
-
-
-    @Override
-    public boolean create_type(final Type type) throws AlreadyExistsException,
-        MetaException, InvalidObjectException {
-      startFunction("create_type", ": " + type.toString());
-      boolean success = false;
-      Exception ex = null;
-      try {
-        create_type_core(getMS(), type);
-        success = true;
-      } catch (MetaException | InvalidObjectException | AlreadyExistsException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("create_type", success, ex);
-      }
-
-      return success;
-    }
-
-    @Override
-    public Type get_type(final String name) throws MetaException, NoSuchObjectException {
-      startFunction("get_type", ": " + name);
-
-      Type ret = null;
-      Exception ex = null;
-      try {
-        ret = getMS().getType(name);
-        if (null == ret) {
-          throw new NoSuchObjectException("Type \"" + name + "\" not found.");
-        }
-      } catch (Exception e) {
-        ex = e;
-        throwMetaException(e);
-      } finally {
-        endFunction("get_type", ret != null, ex);
-      }
-      return ret;
-    }
-
-    private boolean is_type_exists(RawStore ms, String typeName)
-        throws MetaException {
-      return (ms.getType(typeName) != null);
-    }
-
-    @Override
-    public boolean drop_type(final String name) throws MetaException, NoSuchObjectException {
-      startFunction("drop_type", ": " + name);
-
-      boolean success = false;
-      Exception ex = null;
-      try {
-        // TODO:pc validate that there are no types that refer to this
-        success = getMS().dropType(name);
-      } catch (Exception e) {
-        ex = e;
-        throwMetaException(e);
-      } finally {
-        endFunction("drop_type", success, ex);
-      }
-      return success;
-    }
-
-    @Override
-    public Map<String, Type> get_type_all(String name) throws MetaException {
-      // TODO Auto-generated method stub
-      startFunction("get_type_all", ": " + name);
-      endFunction("get_type_all", false, null);
-      throw new MetaException("Not yet implemented");
-    }
-
-    private void create_table_core(final RawStore ms, final Table tbl,
-        final EnvironmentContext envContext)
-            throws AlreadyExistsException, MetaException,
-            InvalidObjectException, NoSuchObjectException, InvalidInputException {
-      CreateTableRequest req = new CreateTableRequest(tbl);
-      req.setEnvContext(envContext);
-      create_table_core(ms, req);
-    }
-
-    private void create_table_core(final RawStore ms, final Table tbl,
-        final EnvironmentContext envContext, List<SQLPrimaryKey> primaryKeys,
-        List<SQLForeignKey> foreignKeys, List<SQLUniqueConstraint> uniqueConstraints,
-        List<SQLNotNullConstraint> notNullConstraints, List<SQLDefaultConstraint> defaultConstraints,
-                                   List<SQLCheckConstraint> checkConstraints,
-                                   List<String> processorCapabilities, String processorIdentifier)
-        throws AlreadyExistsException, MetaException,
-        InvalidObjectException, NoSuchObjectException, InvalidInputException {
-      CreateTableRequest req = new CreateTableRequest(tbl);
-      if (envContext != null)
-        req.setEnvContext(envContext);
-      if (primaryKeys != null)
-        req.setPrimaryKeys(primaryKeys);
-      if (foreignKeys != null)
-        req.setForeignKeys(foreignKeys);
-      if (uniqueConstraints != null)
-        req.setUniqueConstraints(uniqueConstraints);
-      if (notNullConstraints != null)
-        req.setNotNullConstraints(notNullConstraints);
-      if (defaultConstraints != null)
-        req.setDefaultConstraints(defaultConstraints);
-      if (checkConstraints != null)
-        req.setCheckConstraints(checkConstraints);
-      if (processorCapabilities != null) {
-        req.setProcessorCapabilities(processorCapabilities);
-        req.setProcessorIdentifier(processorIdentifier);
-      }
-      create_table_core(ms, req);
-    }
-
-    private void create_table_core(final RawStore ms, final CreateTableRequest req)
-        throws AlreadyExistsException, MetaException,
-              InvalidObjectException, NoSuchObjectException, InvalidInputException {
-      ColumnStatistics colStats = null;
-      Table tbl = req.getTable();
-      EnvironmentContext envContext = req.getEnvContext();
-      SQLAllTableConstraints constraints = new SQLAllTableConstraints();
-      constraints.setPrimaryKeys(req.getPrimaryKeys());
-      constraints.setForeignKeys(req.getForeignKeys());
-      constraints.setUniqueConstraints(req.getUniqueConstraints());
-      constraints.setDefaultConstraints(req.getDefaultConstraints());
-      constraints.setCheckConstraints(req.getCheckConstraints());
-      constraints.setNotNullConstraints(req.getNotNullConstraints());
-      List<String> processorCapabilities = req.getProcessorCapabilities();
-      String processorId = req.getProcessorIdentifier();
-
-      if (transformer != null && !isInTest) {
-        tbl = transformer.transformCreateTable(tbl, processorCapabilities, processorId);
-      }
-
-      // If the given table has column statistics, save it here. We will update it later.
-      // We don't want it to be part of the Table object being created, lest the create table
-      // event will also have the col stats which we don't want.
-      if (tbl.isSetColStats()) {
-        colStats = tbl.getColStats();
-        tbl.unsetColStats();
-      }
-
-      // To preserve backward compatibility throw MetaException in case of null database
-      if (tbl.getDbName() == null) {
-        throw new MetaException("Null database name is not allowed");
-      }
-
-      if (!MetaStoreUtils.validateName(tbl.getTableName(), conf)) {
-        throw new InvalidObjectException(tbl.getTableName()
-            + " is not a valid object name");
-      }
-      String validate = MetaStoreServerUtils.validateTblColumns(tbl.getSd().getCols());
-      if (validate != null) {
-        throw new InvalidObjectException("Invalid column " + validate);
-      }
-      if (tbl.getPartitionKeys() != null) {
-        validate = MetaStoreServerUtils.validateTblColumns(tbl.getPartitionKeys());
-        if (validate != null) {
-          throw new InvalidObjectException("Invalid partition column " + validate);
-        }
-      }
-      if (tbl.isSetId()) {
-        LOG.debug("Id shouldn't be set but table {}.{} has the Id set to {}. Id is ignored.", tbl.getDbName(),
-            tbl.getTableName(), tbl.getId());
-        tbl.unsetId();
-      }
-      SkewedInfo skew = tbl.getSd().getSkewedInfo();
-      if (skew != null) {
-        validate = MetaStoreServerUtils.validateSkewedColNames(skew.getSkewedColNames());
-        if (validate != null) {
-          throw new InvalidObjectException("Invalid skew column " + validate);
-        }
-        validate = MetaStoreServerUtils.validateSkewedColNamesSubsetCol(
-            skew.getSkewedColNames(), tbl.getSd().getCols());
-        if (validate != null) {
-          throw new InvalidObjectException("Invalid skew column " + validate);
-        }
-      }
-
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-      Path tblPath = null;
-      boolean success = false, madeDir = false;
-      Database db = null;
-      boolean isReplicated = false;
-      try {
-        if (!tbl.isSetCatName()) {
-          tbl.setCatName(getDefaultCatalog(conf));
-        }
-        firePreEvent(new PreCreateTableEvent(tbl, this));
-
-        ms.openTransaction();
-
-        db = ms.getDatabase(tbl.getCatName(), tbl.getDbName());
-        isReplicated = isDbReplicationTarget(db);
-
-        // get_table checks whether database exists, it should be moved here
-        if (is_table_exists(ms, tbl.getCatName(), tbl.getDbName(), tbl.getTableName())) {
-          throw new AlreadyExistsException("Table " + getCatalogQualifiedTableName(tbl)
-              + " already exists");
-        }
-
-        if (!TableType.VIRTUAL_VIEW.toString().equals(tbl.getTableType())) {
-          if (tbl.getSd().getLocation() == null
-              || tbl.getSd().getLocation().isEmpty()) {
-            tblPath = wh.getDefaultTablePath(db, tbl);
-          } else {
-            if (!isExternal(tbl) && !MetaStoreUtils.isNonNativeTable(tbl)) {
-              LOG.warn("Location: " + tbl.getSd().getLocation()
-                  + " specified for non-external table:" + tbl.getTableName());
-            }
-            tblPath = wh.getDnsPath(new Path(tbl.getSd().getLocation()));
-          }
-          tbl.getSd().setLocation(tblPath.toString());
-        }
-
-        if (tblPath != null) {
-          if (!wh.isDir(tblPath)) {
-            if (!wh.mkdirs(tblPath)) {
-              throw new MetaException(tblPath
-                  + " is not a directory or unable to create one");
-            }
-            madeDir = true;
-          }
-        }
-        if (MetastoreConf.getBoolVar(conf, ConfVars.STATS_AUTO_GATHER) &&
-            !MetaStoreUtils.isView(tbl)) {
-          MetaStoreServerUtils.updateTableStatsSlow(db, tbl, wh, madeDir, false, envContext);
-        }
-
-        // set create time
-        long time = System.currentTimeMillis() / 1000;
-        tbl.setCreateTime((int) time);
-        if (tbl.getParameters() == null ||
-            tbl.getParameters().get(hive_metastoreConstants.DDL_TIME) == null) {
-          tbl.putToParameters(hive_metastoreConstants.DDL_TIME, Long.toString(time));
-        }
-
-        if (CollectionUtils.isEmpty(constraints.getPrimaryKeys()) && CollectionUtils.isEmpty(constraints.getForeignKeys())
-                && CollectionUtils.isEmpty(constraints.getUniqueConstraints())&& CollectionUtils.isEmpty(constraints.getNotNullConstraints())&& CollectionUtils.isEmpty(constraints.getDefaultConstraints())
-            && CollectionUtils.isEmpty(constraints.getCheckConstraints())) {
-          ms.createTable(tbl);
-        } else {
-          final String catName = tbl.getCatName();
-          // Check that constraints have catalog name properly set first
-          if (CollectionUtils.isNotEmpty(constraints.getPrimaryKeys()) && !constraints.getPrimaryKeys().get(0).isSetCatName()) {
-            constraints.getPrimaryKeys().forEach(constraint -> constraint.setCatName(catName));
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getForeignKeys()) && !constraints.getForeignKeys().get(0).isSetCatName()) {
-            constraints.getForeignKeys().forEach(constraint -> constraint.setCatName(catName));
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getUniqueConstraints()) && !constraints.getUniqueConstraints().get(0).isSetCatName()) {
-            constraints.getUniqueConstraints().forEach(constraint -> constraint.setCatName(catName));
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getNotNullConstraints()) && !constraints.getNotNullConstraints().get(0).isSetCatName()) {
-            constraints.getNotNullConstraints().forEach(constraint -> constraint.setCatName(catName));
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getDefaultConstraints()) && !constraints.getDefaultConstraints().get(0).isSetCatName()) {
-            constraints.getDefaultConstraints().forEach(constraint -> constraint.setCatName(catName));
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getCheckConstraints()) && !constraints.getCheckConstraints().get(0).isSetCatName()) {
-            constraints.getCheckConstraints().forEach(constraint -> constraint.setCatName(catName));
-          }
-          // Set constraint name if null before sending to listener
-          constraints = ms.createTableWithConstraints(tbl, constraints);
-
-        }
-
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenerResponses = MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-              EventType.CREATE_TABLE, new CreateTableEvent(tbl, true, this, isReplicated), envContext);
-          if (CollectionUtils.isNotEmpty(constraints.getPrimaryKeys())) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.ADD_PRIMARYKEY,
-                new AddPrimaryKeyEvent(constraints.getPrimaryKeys(), true, this), envContext);
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getForeignKeys())) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.ADD_FOREIGNKEY,
-                new AddForeignKeyEvent(constraints.getForeignKeys(), true, this), envContext);
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getUniqueConstraints())) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.ADD_UNIQUECONSTRAINT,
-                new AddUniqueConstraintEvent(constraints.getUniqueConstraints(), true, this), envContext);
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getNotNullConstraints())) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.ADD_NOTNULLCONSTRAINT,
-                new AddNotNullConstraintEvent(constraints.getNotNullConstraints(), true, this), envContext);
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getCheckConstraints())) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.ADD_CHECKCONSTRAINT,
-                new AddCheckConstraintEvent(constraints.getCheckConstraints(), true, this), envContext);
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getDefaultConstraints())) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.ADD_DEFAULTCONSTRAINT,
-                new AddDefaultConstraintEvent(constraints.getDefaultConstraints(), true, this), envContext);
-          }
-        }
-
-        success = ms.commitTransaction();
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-          if (madeDir) {
-            wh.deleteDir(tblPath, true, false, ReplChangeManager.shouldEnableCm(db, tbl));
-          }
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners, EventType.CREATE_TABLE,
-              new CreateTableEvent(tbl, success, this, isReplicated), envContext,
-                  transactionalListenerResponses, ms);
-          if (CollectionUtils.isNotEmpty(constraints.getPrimaryKeys())) {
-            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ADD_PRIMARYKEY,
-                new AddPrimaryKeyEvent(constraints.getPrimaryKeys(), success, this), envContext);
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getForeignKeys())) {
-            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ADD_FOREIGNKEY,
-                new AddForeignKeyEvent(constraints.getForeignKeys(), success, this), envContext);
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getUniqueConstraints())) {
-            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ADD_UNIQUECONSTRAINT,
-                new AddUniqueConstraintEvent(constraints.getUniqueConstraints(), success, this), envContext);
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getNotNullConstraints())) {
-            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ADD_NOTNULLCONSTRAINT,
-                new AddNotNullConstraintEvent(constraints.getNotNullConstraints(), success, this), envContext);
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getDefaultConstraints())) {
-            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ADD_DEFAULTCONSTRAINT,
-                new AddDefaultConstraintEvent(constraints.getDefaultConstraints(), success, this), envContext);
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getCheckConstraints())) {
-            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ADD_CHECKCONSTRAINT,
-                new AddCheckConstraintEvent(constraints.getCheckConstraints(), success, this), envContext);
-          }
-        }
-      }
-
-      // If the table has column statistics, update it into the metastore. We need a valid
-      // writeId list to update column statistics for a transactional table. But during bootstrap
-      // replication, where we use this feature, we do not have a valid writeId list which was
-      // used to update the stats. But we know for sure that the writeId associated with the
-      // stats was valid then (otherwise stats update would have failed on the source). So, craft
-      // a valid transaction list with only that writeId and use it to update the stats.
-      if (colStats != null) {
-        long writeId = tbl.getWriteId();
-        String validWriteIds = null;
-        if (writeId > 0) {
-          ValidWriteIdList validWriteIdList =
-                  new ValidReaderWriteIdList(TableName.getDbTable(tbl.getDbName(),
-                                                                  tbl.getTableName()),
-                                              new long[0], new BitSet(), writeId);
-          validWriteIds = validWriteIdList.toString();
-        }
-        updateTableColumnStatsInternal(colStats, validWriteIds, tbl.getWriteId());
-      }
-    }
-
-    @Override
-    public void create_table(final Table tbl) throws AlreadyExistsException,
-        MetaException, InvalidObjectException, InvalidInputException {
-      create_table_with_environment_context(tbl, null);
-    }
-
-    @Override
-    public void create_table_with_environment_context(final Table tbl,
-        final EnvironmentContext envContext)
-        throws AlreadyExistsException, MetaException, InvalidObjectException,
-            InvalidInputException {
-      startFunction("create_table", ": " + tbl.toString());
-      boolean success = false;
-      Exception ex = null;
-      try {
-        create_table_core(getMS(), tbl, envContext);
-        success = true;
-      } catch (NoSuchObjectException e) {
-        LOG.warn("create_table_with_environment_context got ", e);
-        ex = e;
-        throw new InvalidObjectException(e.getMessage());
-      } catch (MetaException | InvalidObjectException | AlreadyExistsException | InvalidInputException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("create_table", success, ex, tbl.getTableName());
-      }
-    }
-
-    @Override
-    public void create_table_req(final CreateTableRequest req)
-            throws AlreadyExistsException, MetaException, InvalidObjectException,
-            InvalidInputException {
-      Table tbl = req.getTable();
-      startFunction("create_table_req", ": " + tbl.toString());
-      boolean success = false;
-      Exception ex = null;
-      try {
-        create_table_core(getMS(), req);
-        success = true;
-      } catch (NoSuchObjectException e) {
-        LOG.warn("create_table_req got ", e);
-        ex = e;
-        throw new InvalidObjectException(e.getMessage());
-      } catch (MetaException | InvalidObjectException | AlreadyExistsException | InvalidInputException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("create_table_req", success, ex, tbl.getTableName());
-      }
-    }
-
-    @Override
-    public void create_table_with_constraints(final Table tbl,
-        final List<SQLPrimaryKey> primaryKeys, final List<SQLForeignKey> foreignKeys,
-        List<SQLUniqueConstraint> uniqueConstraints,
-        List<SQLNotNullConstraint> notNullConstraints,
-        List<SQLDefaultConstraint> defaultConstraints,
-        List<SQLCheckConstraint> checkConstraints)
-        throws AlreadyExistsException, MetaException, InvalidObjectException,
-            InvalidInputException {
-      startFunction("create_table", ": " + tbl.toString());
-      boolean success = false;
-      Exception ex = null;
-      try {
-        CreateTableRequest req = new CreateTableRequest(tbl);
-        req.setPrimaryKeys(primaryKeys);
-        req.setForeignKeys(foreignKeys);
-        req.setUniqueConstraints(uniqueConstraints);
-        req.setNotNullConstraints(notNullConstraints);
-        req.setDefaultConstraints(defaultConstraints);
-        req.setCheckConstraints(checkConstraints);
-        create_table_req(req);
-        success = true;
-      } catch (MetaException | InvalidObjectException | AlreadyExistsException |
-              InvalidInputException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("create_table_with_constraints", success, ex, tbl.getTableName());
-      }
-    }
-
-    @Override
-    public void drop_constraint(DropConstraintRequest req)
-        throws MetaException, InvalidObjectException {
-      String catName = req.isSetCatName() ? req.getCatName() : getDefaultCatalog(conf);
-      String dbName = req.getDbname();
-      String tableName = req.getTablename();
-      String constraintName = req.getConstraintname();
-      startFunction("drop_constraint", ": " + constraintName);
-      boolean success = false;
-      Exception ex = null;
-      RawStore ms = getMS();
-      try {
-        ms.openTransaction();
-        ms.dropConstraint(catName, dbName, tableName, constraintName);
-        if (transactionalListeners.size() > 0) {
-          DropConstraintEvent dropConstraintEvent = new DropConstraintEvent(catName, dbName,
-              tableName, constraintName, true, this);
-          for (MetaStoreEventListener transactionalListener : transactionalListeners) {
-            transactionalListener.onDropConstraint(dropConstraintEvent);
-          }
-        }
-        success = ms.commitTransaction();
-      } catch (NoSuchObjectException e) {
-        ex = e;
-        throw new InvalidObjectException(e.getMessage());
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else {
-          for (MetaStoreEventListener listener : listeners) {
-            DropConstraintEvent dropConstraintEvent = new DropConstraintEvent(catName, dbName,
-                tableName, constraintName, true, this);
-            listener.onDropConstraint(dropConstraintEvent);
-          }
-        }
-        endFunction("drop_constraint", success, ex, constraintName);
-      }
-    }
-
-    @Override
-    public void add_primary_key(AddPrimaryKeyRequest req)
-      throws MetaException, InvalidObjectException {
-      List<SQLPrimaryKey> primaryKeyCols = req.getPrimaryKeyCols();
-      String constraintName = (CollectionUtils.isNotEmpty(primaryKeyCols)) ?
-        primaryKeyCols.get(0).getPk_name() : "null";
-      startFunction("add_primary_key", ": " + constraintName);
-      boolean success = false;
-      Exception ex = null;
-      if (CollectionUtils.isNotEmpty(primaryKeyCols) && !primaryKeyCols.get(0).isSetCatName()) {
-        String defaultCat = getDefaultCatalog(conf);
-        primaryKeyCols.forEach(pk -> pk.setCatName(defaultCat));
-      }
-      RawStore ms = getMS();
-      try {
-        ms.openTransaction();
-        List<SQLPrimaryKey> primaryKeys = ms.addPrimaryKeys(primaryKeyCols);
-        if (transactionalListeners.size() > 0) {
-          if (CollectionUtils.isNotEmpty(primaryKeys)) {
-            AddPrimaryKeyEvent addPrimaryKeyEvent = new AddPrimaryKeyEvent(primaryKeys, true, this);
-            for (MetaStoreEventListener transactionalListener : transactionalListeners) {
-              transactionalListener.onAddPrimaryKey(addPrimaryKeyEvent);
-            }
-          }
-        }
-        success = ms.commitTransaction();
-      } catch (MetaException | InvalidObjectException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else if (primaryKeyCols != null && primaryKeyCols.size() > 0) {
-          for (MetaStoreEventListener listener : listeners) {
-            AddPrimaryKeyEvent addPrimaryKeyEvent = new AddPrimaryKeyEvent(primaryKeyCols, true, this);
-            listener.onAddPrimaryKey(addPrimaryKeyEvent);
-          }
-        }
-        endFunction("add_primary_key", success, ex, constraintName);
-      }
-    }
-
-    @Override
-    public void add_foreign_key(AddForeignKeyRequest req)
-      throws MetaException, InvalidObjectException {
-      List<SQLForeignKey> foreignKeys = req.getForeignKeyCols();
-      String constraintName = CollectionUtils.isNotEmpty(foreignKeys) ?
-        foreignKeys.get(0).getFk_name() : "null";
-      startFunction("add_foreign_key", ": " + constraintName);
-      boolean success = false;
-      Exception ex = null;
-      if (CollectionUtils.isNotEmpty(foreignKeys) && !foreignKeys.get(0).isSetCatName()) {
-        String defaultCat = getDefaultCatalog(conf);
-        foreignKeys.forEach(pk -> pk.setCatName(defaultCat));
-      }
-      RawStore ms = getMS();
-      try {
-        ms.openTransaction();
-        foreignKeys = ms.addForeignKeys(foreignKeys);
-        if (transactionalListeners.size() > 0) {
-          if (CollectionUtils.isNotEmpty(foreignKeys)) {
-            AddForeignKeyEvent addForeignKeyEvent = new AddForeignKeyEvent(foreignKeys, true, this);
-            for (MetaStoreEventListener transactionalListener : transactionalListeners) {
-              transactionalListener.onAddForeignKey(addForeignKeyEvent);
-            }
-          }
-        }
-        success = ms.commitTransaction();
-      } catch (MetaException | InvalidObjectException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else if (CollectionUtils.isNotEmpty(foreignKeys)) {
-          for (MetaStoreEventListener listener : listeners) {
-            AddForeignKeyEvent addForeignKeyEvent = new AddForeignKeyEvent(foreignKeys, true, this);
-            listener.onAddForeignKey(addForeignKeyEvent);
-          }
-        }
-        endFunction("add_foreign_key", success, ex, constraintName);
-      }
-    }
-
-    @Override
-    public void add_unique_constraint(AddUniqueConstraintRequest req)
-      throws MetaException, InvalidObjectException {
-      List<SQLUniqueConstraint> uniqueConstraints = req.getUniqueConstraintCols();
-      String constraintName = (uniqueConstraints != null && uniqueConstraints.size() > 0) ?
-              uniqueConstraints.get(0).getUk_name() : "null";
-      startFunction("add_unique_constraint", ": " + constraintName);
-      boolean success = false;
-      Exception ex = null;
-      if (!uniqueConstraints.isEmpty() && !uniqueConstraints.get(0).isSetCatName()) {
-        String defaultCat = getDefaultCatalog(conf);
-        uniqueConstraints.forEach(pk -> pk.setCatName(defaultCat));
-      }
-      RawStore ms = getMS();
-      try {
-        ms.openTransaction();
-        uniqueConstraints = ms.addUniqueConstraints(uniqueConstraints);
-        if (transactionalListeners.size() > 0) {
-          if (CollectionUtils.isNotEmpty(uniqueConstraints)) {
-            AddUniqueConstraintEvent addUniqueConstraintEvent = new AddUniqueConstraintEvent(uniqueConstraints, true, this);
-            for (MetaStoreEventListener transactionalListener : transactionalListeners) {
-              transactionalListener.onAddUniqueConstraint(addUniqueConstraintEvent);
-            }
-          }
-        }
-        success = ms.commitTransaction();
-      } catch (MetaException | InvalidObjectException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else if (CollectionUtils.isNotEmpty(uniqueConstraints)) {
-          for (MetaStoreEventListener listener : listeners) {
-            AddUniqueConstraintEvent addUniqueConstraintEvent = new AddUniqueConstraintEvent(uniqueConstraints, true, this);
-            listener.onAddUniqueConstraint(addUniqueConstraintEvent);
-          }
-        }
-        endFunction("add_unique_constraint", success, ex, constraintName);
-      }
-    }
-
-    @Override
-    public void add_not_null_constraint(AddNotNullConstraintRequest req)
-      throws MetaException, InvalidObjectException {
-      List<SQLNotNullConstraint> notNullConstraints = req.getNotNullConstraintCols();
-      String constraintName = (notNullConstraints != null && notNullConstraints.size() > 0) ?
-              notNullConstraints.get(0).getNn_name() : "null";
-      startFunction("add_not_null_constraint", ": " + constraintName);
-      boolean success = false;
-      Exception ex = null;
-      if (!notNullConstraints.isEmpty() && !notNullConstraints.get(0).isSetCatName()) {
-        String defaultCat = getDefaultCatalog(conf);
-        notNullConstraints.forEach(pk -> pk.setCatName(defaultCat));
-      }
-      RawStore ms = getMS();
-      try {
-        ms.openTransaction();
-        notNullConstraints = ms.addNotNullConstraints(notNullConstraints);
-
-        if (transactionalListeners.size() > 0) {
-          if (CollectionUtils.isNotEmpty(notNullConstraints)) {
-            AddNotNullConstraintEvent addNotNullConstraintEvent = new AddNotNullConstraintEvent(notNullConstraints, true, this);
-            for (MetaStoreEventListener transactionalListener : transactionalListeners) {
-              transactionalListener.onAddNotNullConstraint(addNotNullConstraintEvent);
-            }
-          }
-        }
-        success = ms.commitTransaction();
-      } catch (MetaException | InvalidObjectException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else if (CollectionUtils.isNotEmpty(notNullConstraints)) {
-          for (MetaStoreEventListener listener : listeners) {
-            AddNotNullConstraintEvent addNotNullConstraintEvent = new AddNotNullConstraintEvent(notNullConstraints, true, this);
-            listener.onAddNotNullConstraint(addNotNullConstraintEvent);
-          }
-        }
-        endFunction("add_not_null_constraint", success, ex, constraintName);
-      }
-    }
-
-    @Override
-    public void add_default_constraint(AddDefaultConstraintRequest req) throws MetaException, InvalidObjectException {
-      List<SQLDefaultConstraint> defaultConstraints = req.getDefaultConstraintCols();
-      String constraintName =
-          CollectionUtils.isNotEmpty(defaultConstraints) ? defaultConstraints.get(0).getDc_name() : "null";
-      startFunction("add_default_constraint", ": " + constraintName);
-      boolean success = false;
-      Exception ex = null;
-      if (!defaultConstraints.isEmpty() && !defaultConstraints.get(0).isSetCatName()) {
-        String defaultCat = getDefaultCatalog(conf);
-        defaultConstraints.forEach(pk -> pk.setCatName(defaultCat));
-      }
-      RawStore ms = getMS();
-      try {
-        ms.openTransaction();
-        defaultConstraints = ms.addDefaultConstraints(defaultConstraints);
-        if (transactionalListeners.size() > 0) {
-          if (CollectionUtils.isNotEmpty(defaultConstraints)) {
-            AddDefaultConstraintEvent addDefaultConstraintEvent =
-                new AddDefaultConstraintEvent(defaultConstraints, true, this);
-            for (MetaStoreEventListener transactionalListener : transactionalListeners) {
-              transactionalListener.onAddDefaultConstraint(addDefaultConstraintEvent);
-            }
-          }
-        }
-        success = ms.commitTransaction();
-      } catch (MetaException | InvalidObjectException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else if (CollectionUtils.isNotEmpty(defaultConstraints)) {
-          for (MetaStoreEventListener listener : listeners) {
-            AddDefaultConstraintEvent addDefaultConstraintEvent =
-                new AddDefaultConstraintEvent(defaultConstraints, true, this);
-            listener.onAddDefaultConstraint(addDefaultConstraintEvent);
-          }
-        }
-        endFunction("add_default_constraint", success, ex, constraintName);
-      }
-    }
-
-    @Override
-    public void add_check_constraint(AddCheckConstraintRequest req)
-        throws MetaException, InvalidObjectException {
-      List<SQLCheckConstraint> checkConstraints= req.getCheckConstraintCols();
-      String constraintName = CollectionUtils.isNotEmpty(checkConstraints) ?
-          checkConstraints.get(0).getDc_name() : "null";
-      startFunction("add_check_constraint", ": " + constraintName);
-      boolean success = false;
-      Exception ex = null;
-      if (!checkConstraints.isEmpty() && !checkConstraints.get(0).isSetCatName()) {
-        String defaultCat = getDefaultCatalog(conf);
-        checkConstraints.forEach(pk -> pk.setCatName(defaultCat));
-      }
-      RawStore ms = getMS();
-      try {
-        ms.openTransaction();
-        checkConstraints = ms.addCheckConstraints(checkConstraints);
-        if (transactionalListeners.size() > 0) {
-          if (CollectionUtils.isNotEmpty(checkConstraints)) {
-            AddCheckConstraintEvent addcheckConstraintEvent = new AddCheckConstraintEvent(checkConstraints, true, this);
-            for (MetaStoreEventListener transactionalListener : transactionalListeners) {
-             transactionalListener.onAddCheckConstraint(addcheckConstraintEvent);
-            }
-          }
-        }
-        success = ms.commitTransaction();
-      } catch (MetaException | InvalidObjectException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else if (CollectionUtils.isNotEmpty(checkConstraints)) {
-          for (MetaStoreEventListener listener : listeners) {
-            AddCheckConstraintEvent addCheckConstraintEvent = new AddCheckConstraintEvent(checkConstraints, true, this);
-            listener.onAddCheckConstraint(addCheckConstraintEvent);
-          }
-        }
-        endFunction("add_check_constraint", success, ex, constraintName);
-      }
-    }
-
-    private boolean is_table_exists(RawStore ms, String catName, String dbname, String name)
-        throws MetaException {
-      return (ms.getTable(catName, dbname, name, null) != null);
-    }
-
-    private boolean drop_table_core(final RawStore ms, final String catName, final String dbname,
-                                    final String name, final boolean deleteData,
-                                    final EnvironmentContext envContext, final String indexName)
-        throws NoSuchObjectException, MetaException, IOException, InvalidObjectException,
-        InvalidInputException {
-      boolean success = false;
-      boolean tableDataShouldBeDeleted = false;
-      Path tblPath = null;
-      List<Path> partPaths = null;
-      Table tbl = null;
-      boolean ifPurge = false;
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-      Database db = null;
-      boolean isReplicated = false;
-      try {
-        ms.openTransaction();
-        db = ms.getDatabase(catName, dbname);
-        isReplicated = isDbReplicationTarget(db);
-
-        // drop any partitions
-        tbl = get_table_core(catName, dbname, name, null);
-        if (tbl == null) {
-          throw new NoSuchObjectException(name + " doesn't exist");
-        }
-
-        // Check if table is part of a materialized view.
-        // If it is, it cannot be dropped.
-        List<String> isPartOfMV = ms.isPartOfMaterializedView(catName, dbname, name);
-        if (!isPartOfMV.isEmpty()) {
-            throw new MetaException(String.format("Cannot drop table as it is used in the following materialized" +
-                    " views %s%n", isPartOfMV));
-        }
-
-        if (tbl.getSd() == null) {
-          throw new MetaException("Table metadata is corrupted");
-        }
-        ifPurge = isMustPurge(envContext, tbl);
-
-        firePreEvent(new PreDropTableEvent(tbl, deleteData, this));
-
-        tableDataShouldBeDeleted = checkTableDataShouldBeDeleted(tbl, deleteData);
-        if (tbl.getSd().getLocation() != null) {
-          tblPath = new Path(tbl.getSd().getLocation());
-          if (!wh.isWritable(tblPath.getParent())) {
-            String target = indexName == null ? "Table" : "Index table";
-            throw new MetaException(target + " metadata not deleted since " +
-                tblPath.getParent() + " is not writable by " +
-                SecurityUtils.getUser());
-          }
-        }
-
-        // Drop the partitions and get a list of locations which need to be deleted
-        partPaths = dropPartitionsAndGetLocations(ms, catName, dbname, name, tblPath,
-            tableDataShouldBeDeleted);
-
-        // Drop any constraints on the table
-        ms.dropConstraint(catName, dbname, name, null, true);
-
-        if (!ms.dropTable(catName, dbname, name)) {
-          String tableName = TableName.getQualified(catName, dbname, name);
-          throw new MetaException(indexName == null ? "Unable to drop table " + tableName:
-              "Unable to drop index table " + tableName + " for index " + indexName);
-        } else {
-          if (!transactionalListeners.isEmpty()) {
-            transactionalListenerResponses =
-                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                      EventType.DROP_TABLE,
-                                                      new DropTableEvent(tbl, true, deleteData,
-                                                              this, isReplicated),
-                                                      envContext);
-          }
-          success = ms.commitTransaction();
-        }
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else if (tableDataShouldBeDeleted) {
-          // Data needs deletion. Check if trash may be skipped.
-          // Delete the data in the partitions which have other locations
-          deletePartitionData(partPaths, ifPurge, ReplChangeManager.shouldEnableCm(db, tbl));
-          // Delete the data in the table
-          deleteTableData(tblPath, ifPurge, ReplChangeManager.shouldEnableCm(db, tbl));
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.DROP_TABLE,
-                                                new DropTableEvent(tbl, success, deleteData, this, isReplicated),
-                                                envContext,
-                                                transactionalListenerResponses, ms);
-        }
-      }
-      return success;
-    }
-
-    private boolean checkTableDataShouldBeDeleted(Table tbl, boolean deleteData) {
-      if (deleteData && isExternal(tbl)) {
-        // External table data can be deleted if EXTERNAL_TABLE_PURGE is true
-        return isExternalTablePurge(tbl);
-      }
-      return deleteData;
-    }
-
-    /**
-     * Deletes the data in a table's location, if it fails logs an error
-     *
-     * @param tablePath
-     * @param ifPurge completely purge the table (skipping trash) while removing
-     *                data from warehouse
-     * @param shouldEnableCm If cm should be enabled
-     */
-    private void deleteTableData(Path tablePath, boolean ifPurge, boolean shouldEnableCm) {
-      if (tablePath != null) {
-        deleteDataExcludeCmroot(tablePath, ifPurge, shouldEnableCm);
-      }
-    }
-
-    /**
-     * Deletes the data in a table's location, if it fails logs an error.
-     *
-     * @param tablePath
-     * @param ifPurge completely purge the table (skipping trash) while removing
-     *                data from warehouse
-     * @param db Database
-     */
-    private void deleteTableData(Path tablePath, boolean ifPurge, Database db) {
-      if (tablePath != null) {
-        try {
-          wh.deleteDir(tablePath, true, ifPurge, db);
-        } catch (Exception e) {
-          LOG.error("Failed to delete table directory: " + tablePath +
-                  " " + e.getMessage());
-        }
-      }
-    }
-
-    /**
-    * Give a list of partitions' locations, tries to delete each one
-    * and for each that fails logs an error.
-    *
-    * @param partPaths
-    * @param ifPurge completely purge the partition (skipping trash) while
-    *                removing data from warehouse
-    * @param shouldEnableCm If cm should be enabled
-    */
-    private void deletePartitionData(List<Path> partPaths, boolean ifPurge, boolean shouldEnableCm) {
-      if (partPaths != null && !partPaths.isEmpty()) {
-        for (Path partPath : partPaths) {
-          deleteDataExcludeCmroot(partPath, ifPurge, shouldEnableCm);
-        }
-      }
-    }
-
-    /**
-     * Give a list of partitions' locations, tries to delete each one
-     * and for each that fails logs an error.
-     *
-     * @param partPaths
-     * @param ifPurge completely purge the partition (skipping trash) while
-     *                removing data from warehouse
-     * @param db Database
-     */
-    private void deletePartitionData(List<Path> partPaths, boolean ifPurge, Database db) {
-      if (partPaths != null && !partPaths.isEmpty()) {
-        for (Path partPath : partPaths) {
-          try {
-            wh.deleteDir(partPath, true, ifPurge, db);
-          } catch (Exception e) {
-            LOG.error("Failed to delete partition directory: " + partPath +
-                    " " + e.getMessage());
-          }
-        }
-      }
-    }
-
-    /**
-     * Delete data from path excluding cmdir
-     * and for each that fails logs an error.
-     *
-     * @param path
-     * @param ifPurge completely purge the partition (skipping trash) while
-     *                removing data from warehouse
-     * @param shouldEnableCm If cm should be enabled
-     */
-    private void deleteDataExcludeCmroot(Path path, boolean ifPurge, boolean shouldEnableCm) {
-      try {
-        if (shouldEnableCm) {
-          //Don't delete cmdir if its inside the partition path
-          FileStatus[] statuses = path.getFileSystem(conf).listStatus(path,
-                  ReplChangeManager.CMROOT_PATH_FILTER);
-          for (final FileStatus status : statuses) {
-            wh.deleteDir(status.getPath(), true, ifPurge, shouldEnableCm);
-          }
-          //Check if table directory is empty, delete it
-          FileStatus[] statusWithoutFilter = path.getFileSystem(conf).listStatus(path);
-          if (statusWithoutFilter.length == 0) {
-            wh.deleteDir(path, true, ifPurge, shouldEnableCm);
-          }
-        } else {
-          //If no cm delete the complete table directory
-          wh.deleteDir(path, true, ifPurge, shouldEnableCm);
-        }
-      } catch (Exception e) {
-        LOG.error("Failed to delete directory: " + path +
-                " " + e.getMessage());
-      }
-    }
-
-    /**
-     * Deletes the partitions specified by catName, dbName, tableName. If checkLocation is true, for
-     * locations of partitions which may not be subdirectories of tablePath checks to make sure the
-     * locations are writable.
-     *
-     * Drops the metadata for each partition.
-     *
-     * Provides a list of locations of partitions which may not be subdirectories of tablePath.
-     *
-     * @param ms RawStore to use for metadata retrieval and delete
-     * @param catName The catName
-     * @param dbName The dbName
-     * @param tableName The tableName
-     * @param tablePath The tablePath of which subdirectories does not have to be checked
-     * @param checkLocation Should we check the locations at all
-     * @return The list of the Path objects to delete (only in case checkLocation is true)
-     * @throws MetaException
-     * @throws IOException
-     * @throws NoSuchObjectException
-     */
-    private List<Path> dropPartitionsAndGetLocations(RawStore ms, String catName, String dbName,
-        String tableName, Path tablePath, boolean checkLocation)
-        throws MetaException, IOException, NoSuchObjectException {
-      int batchSize = MetastoreConf.getIntVar(conf, ConfVars.BATCH_RETRIEVE_OBJECTS_MAX);
-      String tableDnsPath = null;
-      if (tablePath != null) {
-        tableDnsPath = wh.getDnsPath(tablePath).toString();
-      }
-
-      List<Path> partPaths = new ArrayList<>();
-      while (true) {
-        Map<String, String> partitionLocations = ms.getPartitionLocations(catName, dbName, tableName,
-            tableDnsPath, batchSize);
-        if (partitionLocations == null || partitionLocations.isEmpty()) {
-          // No more partitions left to drop. Return with the collected path list to delete.
-          return partPaths;
-        }
-
-        if (checkLocation) {
-          for (String partName : partitionLocations.keySet()) {
-            String pathString = partitionLocations.get(partName);
-            if (pathString != null) {
-              Path partPath = wh.getDnsPath(new Path(pathString));
-              // Double check here. Maybe Warehouse.getDnsPath revealed relationship between the
-              // path objects
-              if (tableDnsPath == null ||
-                      !FileUtils.isSubdirectory(tableDnsPath, partPath.toString())) {
-                if (!wh.isWritable(partPath.getParent())) {
-                  throw new MetaException("Table metadata not deleted since the partition "
-                      + partName + " has parent location " + partPath.getParent()
-                      + " which is not writable by " + SecurityUtils.getUser());
-                }
-                partPaths.add(partPath);
-              }
-            }
-          }
-        }
-
-        for (MetaStoreEventListener listener : listeners) {
-          //No drop part listener events fired for public listeners historically, for drop table case.
-          //Limiting to internal listeners for now, to avoid unexpected calls for public listeners.
-          if (listener instanceof HMSMetricsListener) {
-            for (@SuppressWarnings("unused") String partName : partitionLocations.keySet()) {
-              listener.onDropPartition(null);
-            }
-          }
-        }
-
-        ms.dropPartitions(catName, dbName, tableName, new ArrayList<>(partitionLocations.keySet()));
-      }
-    }
-
-    @Override
-    public void drop_table(final String dbname, final String name, final boolean deleteData)
-        throws NoSuchObjectException, MetaException {
-      drop_table_with_environment_context(dbname, name, deleteData, null);
-    }
-
-    @Override
-    public void drop_table_with_environment_context(final String dbname, final String name,
-        final boolean deleteData, final EnvironmentContext envContext)
-        throws NoSuchObjectException, MetaException {
-      String[] parsedDbName = parseDbName(dbname, conf);
-      startTableFunction("drop_table", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], name);
-
-      boolean success = false;
-      Exception ex = null;
-      try {
-        success = drop_table_core(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME], name,
-            deleteData, envContext, null);
-      } catch (IOException e) {
-        ex = e;
-        throw new MetaException(e.getMessage());
-      } catch (Exception e) {
-        ex = e;
-        throwMetaException(e);
-      } finally {
-        endFunction("drop_table", success, ex, name);
-      }
-
-    }
-
-    private void updateStatsForTruncate(Map<String,String> props, EnvironmentContext environmentContext) {
-      if (null == props) {
-        return;
-      }
-      for (String stat : StatsSetupConst.SUPPORTED_STATS) {
-        String statVal = props.get(stat);
-        if (statVal != null) {
-          //In the case of truncate table, we set the stats to be 0.
-          props.put(stat, "0");
-        }
-      }
-      //first set basic stats to true
-      StatsSetupConst.setBasicStatsState(props, StatsSetupConst.TRUE);
-      environmentContext.putToProperties(StatsSetupConst.STATS_GENERATED, StatsSetupConst.TASK);
-      environmentContext.putToProperties(StatsSetupConst.DO_NOT_POPULATE_QUICK_STATS, StatsSetupConst.TRUE);
-      //then invalidate column stats
-      StatsSetupConst.clearColumnStatsState(props);
-      return;
-    }
-
-    private void alterPartitionForTruncate(RawStore ms, String catName, String dbName, String tableName,
-        Table table, Partition partition, String validWriteIds, long writeId) throws Exception {
-      EnvironmentContext environmentContext = new EnvironmentContext();
-      updateStatsForTruncate(partition.getParameters(), environmentContext);
-
-      if (!transactionalListeners.isEmpty()) {
-        MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                EventType.ALTER_PARTITION,
-                new AlterPartitionEvent(partition, partition, table, true, true,
-                        writeId, this));
-      }
-
-      if (!listeners.isEmpty()) {
-        MetaStoreListenerNotifier.notifyEvent(listeners,
-                EventType.ALTER_PARTITION,
-                new AlterPartitionEvent(partition, partition, table, true, true,
-                        writeId, this));
-      }
-
-      if (writeId > 0) {
-        partition.setWriteId(writeId);
-      }
-      alterHandler.alterPartition(ms, wh, catName, dbName, tableName, null, partition,
-          environmentContext, this, validWriteIds);
-    }
-
-    private void alterTableStatsForTruncate(RawStore ms, String catName, String dbName,
-        String tableName, Table table, List<String> partNames,
-        String validWriteIds, long writeId) throws Exception {
-      if (partNames == null) {
-        if (0 != table.getPartitionKeysSize()) {
-          for (Partition partition : ms.getPartitions(catName, dbName, tableName, -1)) {
-            alterPartitionForTruncate(ms, catName, dbName, tableName, table, partition,
-                validWriteIds, writeId);
-          }
-        } else {
-          EnvironmentContext environmentContext = new EnvironmentContext();
-          updateStatsForTruncate(table.getParameters(), environmentContext);
-
-          boolean isReplicated = isDbReplicationTarget(ms.getDatabase(catName, dbName));
-          if (!transactionalListeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                    EventType.ALTER_TABLE,
-                    new AlterTableEvent(table, table, true, true,
-                            writeId, this, isReplicated));
-          }
-
-          if (!listeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(listeners,
-                    EventType.ALTER_TABLE,
-                    new AlterTableEvent(table, table, true, true,
-                            writeId, this, isReplicated));
-          }
-
-          // TODO: this should actually pass thru and set writeId for txn stats.
-          if (writeId > 0) {
-            table.setWriteId(writeId);
-          }
-          alterHandler.alterTable(ms, wh, catName, dbName, tableName, table,
-              environmentContext, this, validWriteIds);
-        }
-      } else {
-        for (Partition partition : ms.getPartitionsByNames(catName, dbName, tableName, partNames)) {
-          alterPartitionForTruncate(ms, catName, dbName, tableName, table, partition,
-              validWriteIds, writeId);
-        }
-      }
-      return;
-    }
-
-    private List<Path> getLocationsForTruncate(final RawStore ms,
-                                               final String catName,
-                                               final String dbName,
-                                               final String tableName,
-                                               final Table table,
-                                               final List<String> partNames) throws Exception {
-      List<Path> locations = new ArrayList<>();
-      if (partNames == null) {
-        if (0 != table.getPartitionKeysSize()) {
-          for (Partition partition : ms.getPartitions(catName, dbName, tableName, -1)) {
-            locations.add(new Path(partition.getSd().getLocation()));
-          }
-        } else {
-          locations.add(new Path(table.getSd().getLocation()));
-        }
-      } else {
-        for (Partition partition : ms.getPartitionsByNames(catName, dbName, tableName, partNames)) {
-          locations.add(new Path(partition.getSd().getLocation()));
-        }
-      }
-      return locations;
-    }
-
-    @Override
-    public CmRecycleResponse cm_recycle(final CmRecycleRequest request) throws MetaException {
-      wh.recycleDirToCmPath(new Path(request.getDataPath()), request.isPurge());
-      return new CmRecycleResponse();
-    }
-
-    @Override
-    public void truncate_table(final String dbName, final String tableName, List<String> partNames)
-      throws NoSuchObjectException, MetaException {
-      // Deprecated path, won't work for txn tables.
-      truncateTableInternal(dbName, tableName, partNames, null, -1);
-    }
-
-    @Override
-    public TruncateTableResponse truncate_table_req(TruncateTableRequest req)
-        throws MetaException, TException {
-      truncateTableInternal(req.getDbName(), req.getTableName(), req.getPartNames(),
-          req.getValidWriteIdList(), req.getWriteId());
-      return new TruncateTableResponse();
-    }
-
-    private void truncateTableInternal(String dbName, String tableName, List<String> partNames,
-        String validWriteIds, long writeId) throws MetaException, NoSuchObjectException {
-      try {
-        String[] parsedDbName = parseDbName(dbName, conf);
-        Table tbl = get_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName);
-
-        boolean truncateFiles = !TxnUtils.isTransactionalTable(tbl) ||
-            !MetastoreConf.getBoolVar(getConf(), MetastoreConf.ConfVars.TRUNCATE_ACID_USE_BASE);
-        // This is not transactional
-        for (Path location : getLocationsForTruncate(getMS(), parsedDbName[CAT_NAME],
-            parsedDbName[DB_NAME], tableName, tbl, partNames)) {
-          FileSystem fs = location.getFileSystem(getConf());
-          if (truncateFiles) {
-            truncateDataFiles(tbl, parsedDbName, location, fs);
-          } else {
-            // For Acid tables we don't need to delete the old files, only write an empty baseDir.
-            // Compaction and cleaner will take care of the rest
-            addTruncateBaseFile(location, writeId, fs);
-          }
-        }
-
-        // Alter the table/partition stats and also notify truncate table event
-        alterTableStatsForTruncate(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tableName, tbl, partNames, validWriteIds, writeId);
-      } catch (IOException e) {
-        throw new MetaException(e.getMessage());
-      } catch (MetaException | NoSuchObjectException e) {
-        throw e;
-      } catch (Exception e) {
-        throw newMetaException(e);
-      }
-    }
-
-    /**
-     * Add an empty baseDir with a truncate metadatafile
-     * @param location partition or table directory
-     * @param writeId allocated writeId
-     * @param fs FileSystem
-     * @throws Exception
-     */
-    private void addTruncateBaseFile(Path location, long writeId, FileSystem fs) throws Exception {
-      Path basePath = new Path(location, AcidConstants.baseDir(writeId));
-      fs.mkdirs(basePath);
-      // We can not leave the folder empty, otherwise it will be skipped at some file listing in AcidUtils
-      // No need for a data file, a simple metadata is enough
-      AcidMetaDataFile.writeToFile(fs, basePath, AcidMetaDataFile.DataFormat.TRUNCATED);
-    }
-
-    private void truncateDataFiles(Table tbl, String[] parsedDbName, Path location, FileSystem fs)
-        throws IOException, MetaException, NoSuchObjectException {
-      boolean isSkipTrash = MetaStoreUtils.isSkipTrash(tbl.getParameters());
-      Database db = get_database_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]);
-      if (!HdfsUtils.isPathEncrypted(getConf(), fs.getUri(), location) &&
-          !FileUtils.pathHasSnapshotSubDir(location, fs)) {
-        HdfsUtils.HadoopFileStatus status = new HdfsUtils.HadoopFileStatus(getConf(), fs, location);
-        FileStatus targetStatus = fs.getFileStatus(location);
-        String targetGroup = targetStatus == null ? null : targetStatus.getGroup();
-        wh.deleteDir(location, true, isSkipTrash, ReplChangeManager.shouldEnableCm(db, tbl));
-        fs.mkdirs(location);
-        HdfsUtils.setFullFileStatus(getConf(), status, targetGroup, fs, location, false);
-      } else {
-        FileStatus[] statuses = fs.listStatus(location, FileUtils.HIDDEN_FILES_PATH_FILTER);
-        if (statuses == null || statuses.length == 0) {
-          return;
-        }
-        for (final FileStatus status : statuses) {
-          wh.deleteDir(status.getPath(), true, isSkipTrash, ReplChangeManager.shouldEnableCm(db, tbl));
-        }
-      }
-    }
-
-    /**
-     * Is this an external table?
-     *
-     * @param table
-     *          Check if this table is external.
-     * @return True if the table is external, otherwise false.
-     */
-    private boolean isExternal(Table table) {
-      return MetaStoreUtils.isExternalTable(table);
-    }
-
-    private boolean isExternalTablePurge(Table table) {
-      return MetaStoreUtils.isExternalTablePurge(table);
-    }
-
-    @Override
-    @Deprecated
-    public Table get_table(final String dbname, final String name) throws MetaException,
-        NoSuchObjectException {
-      String[] parsedDbName = parseDbName(dbname, conf);
-      return getTableInternal(
-            parsedDbName[CAT_NAME], parsedDbName[DB_NAME], name, null, null, false, null, null, null);
-    }
-
-    @Override
-    public List<ExtendedTableInfo> get_tables_ext(final GetTablesExtRequest req) throws MetaException {
-      List<String> tables = new ArrayList<String>();
-      List<ExtendedTableInfo> ret = new ArrayList<ExtendedTableInfo>();
-      String catalog  = req.getCatalog();
-      String database = req.getDatabase();
-      String pattern  = req.getTableNamePattern();
-      List<String> processorCapabilities = req.getProcessorCapabilities();
-      int limit = req.getLimit();
-      String processorId  = req.getProcessorIdentifier();
-      List<Table> tObjects = new ArrayList<>();
-
-      startTableFunction("get_tables_ext", catalog, database, pattern);
-      Exception ex = null;
-      try {
-        tables = getMS().getTables(catalog, database, pattern, null, limit);
-        LOG.debug("get_tables_ext:getTables() returned " + tables.size());
-        tables = FilterUtils.filterTableNamesIfEnabled(isServerFilterEnabled, filterHook,
-                catalog, database, tables);
-
-        if (tables.size() > 0) {
-          tObjects = getMS().getTableObjectsByName(catalog, database, tables);
-          LOG.debug("get_tables_ext:getTableObjectsByName() returned " + tObjects.size());
-          if (processorCapabilities == null || processorCapabilities.size() == 0 ||
-                processorCapabilities.contains("MANAGERAWMETADATA")) {
-            LOG.info("Skipping translation for processor with " + processorId);
-          } else {
-            if (transformer != null) {
-              Map<Table, List<String>> retMap = transformer.transform(tObjects, processorCapabilities, processorId);
-
-              for (Map.Entry<Table, List<String>> entry : retMap.entrySet())  {
-                LOG.debug("Table " + entry.getKey().getTableName() + " requires " + Arrays.toString((entry.getValue()).toArray()));
-                ret.add(convertTableToExtendedTable(entry.getKey(), entry.getValue(), req.getRequestedFields()));
-              }
-            } else {
-              for (Table table : tObjects) {
-                ret.add(convertTableToExtendedTable(table, processorCapabilities, req.getRequestedFields()));
-              }
-            }
-          }
-        }
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_tables_ext", ret != null, ex);
-      }
-      return ret;
-    }
-
-    private ExtendedTableInfo convertTableToExtendedTable (Table table,
-          List<String> processorCapabilities, int mask) {
-      ExtendedTableInfo extTable = new ExtendedTableInfo(table.getTableName());
-      if ((mask & GetTablesExtRequestFields.ACCESS_TYPE.getValue()) == GetTablesExtRequestFields.ACCESS_TYPE.getValue())
-        extTable.setAccessType(table.getAccessType());
-
-      if ((mask & GetTablesExtRequestFields.PROCESSOR_CAPABILITIES.getValue())
-             == GetTablesExtRequestFields.PROCESSOR_CAPABILITIES.getValue()) {
-        extTable.setRequiredReadCapabilities(table.getRequiredReadCapabilities());
-        extTable.setRequiredWriteCapabilities(table.getRequiredWriteCapabilities());
-      }
-
-      return extTable;
-    }
-
-    @Override
-    public GetTableResult get_table_req(GetTableRequest req) throws MetaException,
-        NoSuchObjectException {
-      String catName = req.isSetCatName() ? req.getCatName() : getDefaultCatalog(conf);
-      return new GetTableResult(getTableInternal(catName, req.getDbName(), req.getTblName(),
-          req.getCapabilities(), req.getValidWriteIdList(), req.isGetColumnStats(), req.getEngine(),
-          req.getProcessorCapabilities(), req.getProcessorIdentifier()));
-    }
-
-    /**
-     * This function retrieves table from metastore. If getColumnStats flag is true,
-     * then engine should be specified so the table is retrieve with the column stats
-     * for that engine.
-     */
-    private Table getTableInternal(String catName, String dbname, String name,
-        ClientCapabilities capabilities, String writeIdList, boolean getColumnStats, String engine,
-        List<String> processorCapabilities, String processorId)
-        throws MetaException, NoSuchObjectException {
-      Preconditions.checkArgument(!getColumnStats || engine != null,
-          "To retrieve column statistics with a table, engine parameter cannot be null");
-
-      if (isInTest) {
-        assertClientHasCapability(capabilities, ClientCapability.TEST_CAPABILITY,
-            "Hive tests", "get_table_req");
-      }
-
-      Table t = null;
-      startTableFunction("get_table", catName, dbname, name);
-      Exception ex = null;
-      try {
-        t = get_table_core(catName, dbname, name, writeIdList, getColumnStats, engine);
-        if (MetaStoreUtils.isInsertOnlyTableParam(t.getParameters())) {
-          assertClientHasCapability(capabilities, ClientCapability.INSERT_ONLY_TABLES,
-              "insert-only tables", "get_table_req");
-        }
-
-        if (processorCapabilities == null || processorCapabilities.size() == 0 ||
-              processorCapabilities.contains("MANAGERAWMETADATA")) {
-          LOG.info("Skipping translation for processor with " + processorId);
-        } else {
-          if (transformer != null) {
-            List<Table> tList = new ArrayList<>();
-            tList.add(t);
-            Map<Table, List<String>> ret = transformer.transform(tList, processorCapabilities, processorId);
-            if (ret.size() > 1) {
-              LOG.warn("Unexpected resultset size:" + ret.size());
-              throw new MetaException("Unexpected result from metadata transformer:return list size is " + ret.size());
-            }
-            t = (Table)(ret.keySet().iterator().next());
-          }
-        }
-
-        firePreEvent(new PreReadTableEvent(t, this));
-      } catch (MetaException | NoSuchObjectException e) {
-        ex = e;
-        throw e;
-      } finally {
-        endFunction("get_table", t != null, ex, name);
-      }
-      return t;
-    }
-
-    @Override
-    public List<TableMeta> get_table_meta(String dbnames, String tblNames, List<String> tblTypes)
-        throws MetaException, NoSuchObjectException {
-      List<TableMeta> t = null;
-      String[] parsedDbName = parseDbName(dbnames, conf);
-      startTableFunction("get_table_metas", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblNames);
-      Exception ex = null;
-      try {
-        t = getMS().getTableMeta(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblNames, tblTypes);
-        t = FilterUtils.filterTableMetasIfEnabled(isServerFilterEnabled, filterHook,
-            parsedDbName[CAT_NAME], parsedDbName[DB_NAME], t);
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_table_metas", t != null, ex);
-      }
-      return t;
-    }
-
-    @Override
-    public Table get_table_core(
-        final String catName,
-        final String dbname,
-        final String name)
-        throws MetaException, NoSuchObjectException {
-      return get_table_core(catName, dbname, name, null);
-    }
-
-    @Override
-    public Table get_table_core(
-        final String catName,
-        final String dbname,
-        final String name,
-        final String writeIdList)
-        throws MetaException, NoSuchObjectException {
-      return get_table_core(catName, dbname, name, writeIdList, false, null);
-    }
-
-    /**
-     * This function retrieves table from metastore. If getColumnStats flag is true,
-     * then engine should be specified so the table is retrieve with the column stats
-     * for that engine.
-     */
-    public Table get_table_core(final String catName,
-        final String dbname,
-        final String name,
-        final String writeIdList,
-        boolean getColumnStats, String engine)
-        throws MetaException, NoSuchObjectException {
-      Preconditions.checkArgument(!getColumnStats || engine != null,
-          "To retrieve column statistics with a table, engine parameter cannot be null");
-
-      Database db = null;
-      Table t = null;
-      try {
-        db = get_database_core(catName, dbname);
-        if (db != null) {
-          if (db.getType().equals(DatabaseType.REMOTE)) {
-            return DataConnectorProviderFactory.getDataConnectorProvider(db).getTable(name);
-          }
-        }
-      } catch (Exception e) { /* appears exception is not thrown currently if db doesnt exist */ }
-
-      try {
-        t = getMS().getTable(catName, dbname, name, writeIdList);
-        if (t == null) {
-          throw new NoSuchObjectException(TableName.getQualified(catName, dbname, name) +
-            " table not found");
-        }
-
-        // If column statistics was requested and is valid fetch it.
-        if (getColumnStats) {
-          ColumnStatistics colStats = getMS().getTableColumnStatistics(catName, dbname, name,
-                  StatsSetupConst.getColumnsHavingStats(t.getParameters()), engine, writeIdList);
-          if (colStats != null) {
-            t.setColStats(colStats);
-          }
-        }
-      } catch (Exception e) {
-        throwMetaException(e);
-      }
-      return t;
-    }
-
-    /**
-     * Gets multiple tables from the hive metastore.
-     *
-     * @param dbName
-     *          The name of the database in which the tables reside
-     * @param tableNames
-     *          The names of the tables to get.
-     *
-     * @return A list of tables whose names are in the the list "names" and
-     *         are retrievable from the database specified by "dbnames."
-     *         There is no guarantee of the order of the returned tables.
-     *         If there are duplicate names, only one instance of the table will be returned.
-     * @throws MetaException
-     * @throws InvalidOperationException
-     * @throws UnknownDBException
-     */
-    @Override
-    @Deprecated
-    public List<Table> get_table_objects_by_name(final String dbName, final List<String> tableNames)
-        throws MetaException, InvalidOperationException, UnknownDBException {
-      String[] parsedDbName = parseDbName(dbName, conf);
-      return getTableObjectsInternal(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableNames, null);
-    }
-
-    @Override
-    public GetTablesResult get_table_objects_by_name_req(GetTablesRequest req) throws TException {
-      String catName = req.isSetCatName() ? req.getCatName() : getDefaultCatalog(conf);
-      return new GetTablesResult(getTableObjectsInternal(catName, req.getDbName(),
-          req.getTblNames(), req.getCapabilities()));
-    }
-
-    private List<Table> getTableObjectsInternal(String catName, String dbName,
-                                                List<String> tableNames,
-                                                ClientCapabilities capabilities)
-            throws MetaException, InvalidOperationException, UnknownDBException {
-      if (isInTest) {
-        assertClientHasCapability(capabilities, ClientCapability.TEST_CAPABILITY,
-            "Hive tests", "get_table_objects_by_name_req");
-      }
-      List<Table> tables = new ArrayList<>();
-      startMultiTableFunction("get_multi_table", dbName, tableNames);
-      Exception ex = null;
-      int tableBatchSize = MetastoreConf.getIntVar(conf,
-          ConfVars.BATCH_RETRIEVE_MAX);
-
-      try {
-        if (dbName == null || dbName.isEmpty()) {
-          throw new UnknownDBException("DB name is null or empty");
-        }
-        if (tableNames == null) {
-          throw new InvalidOperationException(dbName + " cannot find null tables");
-        }
-
-        // The list of table names could contain duplicates. RawStore.getTableObjectsByName()
-        // only guarantees returning no duplicate table objects in one batch. If we need
-        // to break into multiple batches, remove duplicates first.
-        List<String> distinctTableNames = tableNames;
-        if (distinctTableNames.size() > tableBatchSize) {
-          List<String> lowercaseTableNames = new ArrayList<>();
-          for (String tableName : tableNames) {
-            lowercaseTableNames.add(org.apache.hadoop.hive.metastore.utils.StringUtils.normalizeIdentifier(tableName));
-          }
-          distinctTableNames = new ArrayList<>(new HashSet<>(lowercaseTableNames));
-        }
-
-        RawStore ms = getMS();
-        int startIndex = 0;
-        // Retrieve the tables from the metastore in batches. Some databases like
-        // Oracle cannot have over 1000 expressions in a in-list
-        while (startIndex < distinctTableNames.size()) {
-          int endIndex = Math.min(startIndex + tableBatchSize, distinctTableNames.size());
-          tables.addAll(ms.getTableObjectsByName(catName, dbName, distinctTableNames.subList(
-              startIndex, endIndex)));
-          startIndex = endIndex;
-        }
-        for (Table t : tables) {
-          if (MetaStoreUtils.isInsertOnlyTableParam(t.getParameters())) {
-            assertClientHasCapability(capabilities, ClientCapability.INSERT_ONLY_TABLES,
-                "insert-only tables", "get_table_req");
-          }
-        }
-
-        FilterUtils.filterTablesIfEnabled(isServerFilterEnabled, filterHook, tables);
-      } catch (MetaException | InvalidOperationException | UnknownDBException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_multi_table", tables != null, ex, join(tableNames, ","));
-      }
-      return tables;
-    }
-
-    @Override
-    public Materialization get_materialization_invalidation_info(final CreationMetadata cm, final String validTxnList) throws MetaException {
-      return getTxnHandler().getMaterializationInvalidationInfo(cm, validTxnList);
-    }
-
-    @Override
-    public void update_creation_metadata(String catName, final String dbName, final String tableName, CreationMetadata cm) throws MetaException {
-      getMS().updateCreationMetadata(catName, dbName, tableName, cm);
-    }
-
-    private void assertClientHasCapability(ClientCapabilities client,
-        ClientCapability value, String what, String call) throws MetaException {
-      if (!doesClientHaveCapability(client, value)) {
-        throw new MetaException("Your client does not appear to support " + what + ". To skip"
-            + " capability checks, please set " + ConfVars.CAPABILITY_CHECK.toString()
-            + " to false. This setting can be set globally, or on the client for the current"
-            + " metastore session. Note that this may lead to incorrect results, data loss,"
-            + " undefined behavior, etc. if your client is actually incompatible. You can also"
-            + " specify custom client capabilities via " + call + " API.");
-      }
-    }
-
-    private boolean doesClientHaveCapability(ClientCapabilities client, ClientCapability value) {
-      if (!MetastoreConf.getBoolVar(getConf(), ConfVars.CAPABILITY_CHECK)) {
-        return true;
-      }
-      return (client != null && client.isSetValues() && client.getValues().contains(value));
-    }
-
-    @Override
-    public List<String> get_table_names_by_filter(
-        final String dbName, final String filter, final short maxTables)
-        throws MetaException, InvalidOperationException, UnknownDBException {
-      List<String> tables = null;
-      startFunction("get_table_names_by_filter", ": db = " + dbName + ", filter = " + filter);
-      Exception ex = null;
-      String[] parsedDbName = parseDbName(dbName, conf);
-      try {
-        if (parsedDbName[CAT_NAME] == null || parsedDbName[CAT_NAME].isEmpty() ||
-            parsedDbName[DB_NAME] == null || parsedDbName[DB_NAME].isEmpty()) {
-          throw new UnknownDBException("DB name is null or empty");
-        }
-        if (filter == null) {
-          throw new InvalidOperationException(filter + " cannot apply null filter");
-        }
-        tables = getMS().listTableNamesByFilter(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], filter, maxTables);
-        tables = FilterUtils.filterTableNamesIfEnabled(
-            isServerFilterEnabled, filterHook, parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tables);
-
-      } catch (MetaException | InvalidOperationException | UnknownDBException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_table_names_by_filter", tables != null, ex, join(tables, ","));
-      }
-      return tables;
-    }
-
-    private Partition append_partition_common(RawStore ms, String catName, String dbName,
-                                              String tableName, List<String> part_vals,
-                                              EnvironmentContext envContext)
-            throws InvalidObjectException, AlreadyExistsException, MetaException, NoSuchObjectException {
-
-      Partition part = new Partition();
-      boolean success = false, madeDir = false;
-      Path partLocation = null;
-      Table tbl = null;
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-      Database db = null;
-      try {
-        ms.openTransaction();
-        part.setCatName(catName);
-        part.setDbName(dbName);
-        part.setTableName(tableName);
-        part.setValues(part_vals);
-
-        MetaStoreServerUtils.validatePartitionNameCharacters(part_vals, partitionValidationPattern);
-
-        tbl = ms.getTable(part.getCatName(), part.getDbName(), part.getTableName(), null);
-        if (tbl == null) {
-          throw new InvalidObjectException(
-              "Unable to add partition because table or database do not exist");
-        }
-        if (tbl.getSd().getLocation() == null) {
-          throw new MetaException(
-              "Cannot append a partition to a view");
-        }
-
-        db = get_database_core(catName, dbName);
-
-        firePreEvent(new PreAddPartitionEvent(tbl, part, this));
-
-        part.setSd(tbl.getSd().deepCopy());
-        partLocation = new Path(tbl.getSd().getLocation(), Warehouse
-            .makePartName(tbl.getPartitionKeys(), part_vals));
-        part.getSd().setLocation(partLocation.toString());
-
-        Partition old_part;
-        try {
-          old_part = ms.getPartition(part.getCatName(), part.getDbName(), part
-              .getTableName(), part.getValues());
-        } catch (NoSuchObjectException e) {
-          // this means there is no existing partition
-          old_part = null;
-        }
-        if (old_part != null) {
-          throw new AlreadyExistsException("Partition already exists:" + part);
-        }
-
-        if (!wh.isDir(partLocation)) {
-          if (!wh.mkdirs(partLocation)) {
-            throw new MetaException(partLocation
-                + " is not a directory or unable to create one");
-          }
-          madeDir = true;
-        }
-
-        // set create time
-        long time = System.currentTimeMillis() / 1000;
-        part.setCreateTime((int) time);
-        part.putToParameters(hive_metastoreConstants.DDL_TIME, Long.toString(time));
-
-        if (canUpdateStats(tbl)) {
-          MetaStoreServerUtils.updatePartitionStatsFast(part, tbl, wh, madeDir, false, envContext, true);
-        }
-
-        if (ms.addPartition(part)) {
-          if (!transactionalListeners.isEmpty()) {
-            transactionalListenerResponses =
-                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                      EventType.ADD_PARTITION,
-                                                      new AddPartitionEvent(tbl, part, true, this),
-                                                      envContext);
-          }
-
-          success = ms.commitTransaction();
-        }
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-          if (madeDir) {
-            wh.deleteDir(partLocation, true, false, ReplChangeManager.shouldEnableCm(db, tbl));
-          }
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.ADD_PARTITION,
-                                                new AddPartitionEvent(tbl, part, success, this),
-                                                envContext,
-                                                transactionalListenerResponses, ms);
-        }
-      }
-      return part;
-    }
-
-    private void firePreEvent(PreEventContext event) throws MetaException {
-      for (MetaStorePreEventListener listener : preListeners) {
-        try {
-          listener.onEvent(event);
-        } catch (NoSuchObjectException e) {
-          throw new MetaException(e.getMessage());
-        } catch (InvalidOperationException e) {
-          throw new MetaException(e.getMessage());
-        }
-      }
-    }
-
-    @Override
-    public Partition append_partition(final String dbName, final String tableName,
-        final List<String> part_vals) throws InvalidObjectException,
-        AlreadyExistsException, MetaException {
-      return append_partition_with_environment_context(dbName, tableName, part_vals, null);
-    }
-
-    @Override
-    public Partition append_partition_with_environment_context(final String dbName,
-        final String tableName, final List<String> part_vals, final EnvironmentContext envContext)
-        throws InvalidObjectException, AlreadyExistsException, MetaException {
-      if (part_vals == null || part_vals.isEmpty()) {
-        throw new MetaException("The partition values must not be null or empty.");
-      }
-      String[] parsedDbName = parseDbName(dbName, conf);
-      startPartitionFunction("append_partition", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName, part_vals);
-      if (LOG.isDebugEnabled()) {
-        for (String part : part_vals) {
-          LOG.debug(part);
-        }
-      }
-
-      Partition ret = null;
-      Exception ex = null;
-      try {
-        ret = append_partition_common(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName, part_vals, envContext);
-      } catch (MetaException | InvalidObjectException | AlreadyExistsException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("append_partition", ret != null, ex, tableName);
-      }
-      return ret;
-    }
-
-    private static class PartValEqWrapperLite {
-      List<String> values;
-      String location;
-
-      PartValEqWrapperLite(Partition partition) {
-        this.values = partition.isSetValues()? partition.getValues() : null;
-        if (partition.getSd() != null) {
-          this.location = partition.getSd().getLocation();
-        }
-      }
-
-      @Override
-      public int hashCode() {
-        return values == null ? 0 : values.hashCode();
-      }
-
-      @Override
-      public boolean equals(Object obj) {
-        if (this == obj) {
-          return true;
-        }
-        if (obj == null || !(obj instanceof PartValEqWrapperLite)) {
-          return false;
-        }
-
-        List<String> lhsValues = this.values;
-        List<String> rhsValues = ((PartValEqWrapperLite)obj).values;
-
-        if (lhsValues == null || rhsValues == null) {
-          return lhsValues == rhsValues;
-        }
-
-        if (lhsValues.size() != rhsValues.size()) {
-          return false;
-        }
-
-        for (int i=0; i<lhsValues.size(); ++i) {
-          String lhsValue = lhsValues.get(i);
-          String rhsValue = rhsValues.get(i);
-
-          if ((lhsValue == null && rhsValue != null)
-              || (lhsValue != null && !lhsValue.equals(rhsValue))) {
-            return false;
-          }
-        }
-
-        return true;
-      }
-    }
-
-    private List<Partition> add_partitions_core(final RawStore ms, String catName,
-        String dbName, String tblName, List<Partition> parts, final boolean ifNotExists)
-        throws TException {
-      logAndAudit("add_partitions");
-      boolean success = false;
-      // Ensures that the list doesn't have dups, and keeps track of directories we have created.
-      final Map<PartValEqWrapperLite, Boolean> addedPartitions = new ConcurrentHashMap<>();
-      final List<Partition> newParts = new ArrayList<>();
-      final List<Partition> existingParts = new ArrayList<>();
-      Table tbl = null;
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-      Database db = null;
-
-      List<ColumnStatistics> partsColStats = new ArrayList<>(parts.size());
-      List<Long> partsWriteIds = new ArrayList<>(parts.size());
-
-      try {
-        ms.openTransaction();
-        tbl = ms.getTable(catName, dbName, tblName, null);
-        if (tbl == null) {
-          throw new InvalidObjectException("Unable to add partitions because "
-              + TableName.getQualified(catName, dbName, tblName) +
-              " does not exist");
-        }
-
-        db = ms.getDatabase(catName, dbName);
-
-        if (!parts.isEmpty()) {
-          firePreEvent(new PreAddPartitionEvent(tbl, parts, this));
-        }
-
-        Set<PartValEqWrapperLite> partsToAdd = new HashSet<>(parts.size());
-        List<Partition> partitionsToAdd = new ArrayList<>(parts.size());
-        List<FieldSchema> partitionKeys = tbl.getPartitionKeys();
-        for (final Partition part : parts) {
-          // Collect partition column stats to be updated if present. Partition objects passed down
-          // here at the time of replication may have statistics in them, which is required to be
-          // updated in the metadata. But we don't want it to be part of the Partition object when
-          // it's being created or altered, lest it becomes part of the notification event.
-          if (part.isSetColStats()) {
-            partsColStats.add(part.getColStats());
-            part.unsetColStats();
-            partsWriteIds.add(part.getWriteId());
-          }
-
-          // Iterate through the partitions and validate them. If one of the partitions is
-          // incorrect, an exception will be thrown before the threads which create the partition
-          // folders are submitted. This way we can be sure that no partition and no partition
-          // folder will be created if the list contains an invalid partition.
-          if (validatePartition(part, catName, tblName, dbName, partsToAdd, ms, ifNotExists,
-              partitionKeys)) {
-            partitionsToAdd.add(part);
-          } else {
-            existingParts.add(part);
-          }
-        }
-
-        newParts.addAll(createPartitionFolders(partitionsToAdd, tbl, addedPartitions));
-
-        if (!newParts.isEmpty()) {
-          ms.addPartitions(catName, dbName, tblName, newParts);
-        }
-
-        // Notification is generated for newly created partitions only. The subset of partitions
-        // that already exist (existingParts), will not generate notifications.
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenerResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                    EventType.ADD_PARTITION,
-                                                    new AddPartitionEvent(tbl, newParts, true, this));
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                  EventType.ADD_PARTITION,
-                  new AddPartitionEvent(tbl, newParts, true, this),
-                  null,
-                  transactionalListenerResponses, ms);
-
-          if (!existingParts.isEmpty()) {
-            // The request has succeeded but we failed to add these partitions.
-            MetaStoreListenerNotifier.notifyEvent(listeners,
-                    EventType.ADD_PARTITION,
-                    new AddPartitionEvent(tbl, existingParts, false, this),
-                    null, null, ms);
-          }
-        }
-
-        // Update partition column statistics if available. We need a valid writeId list to
-        // update column statistics for a transactional table. But during bootstrap replication,
-        // where we use this feature, we do not have a valid writeId list which was used to
-        // update the stats. But we know for sure that the writeId associated with the stats was
-        // valid then (otherwise stats update would have failed on the source). So, craft a valid
-        // transaction list with only that writeId and use it to update the stats.
-        int cnt = 0;
-        for (ColumnStatistics partColStats: partsColStats) {
-          long writeId = partsWriteIds.get(cnt++);
-          String validWriteIds = null;
-          if (writeId > 0) {
-            ValidWriteIdList validWriteIdList =
-                    new ValidReaderWriteIdList(TableName.getDbTable(tbl.getDbName(),
-                            tbl.getTableName()),
-                            new long[0], new BitSet(), writeId);
-            validWriteIds = validWriteIdList.toString();
-          }
-          updatePartitonColStatsInternal(tbl, partColStats, validWriteIds, writeId);
-        }
-
-        success = ms.commitTransaction();
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-          cleanupPartitionFolders(addedPartitions, db);
-
-          if (!listeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                  EventType.ADD_PARTITION,
-                                                  new AddPartitionEvent(tbl, parts, false, this),
-                                                  null, null, ms);
-          }
-        }
-      }
-
-      return newParts;
-    }
-
-    /**
-     * Remove the newly created partition folders. The values in the addedPartitions map indicates
-     * whether or not the location of the partition was newly created. If the value is false, the
-     * partition folder will not be removed.
-     * @param addedPartitions
-     * @throws MetaException
-     * @throws IllegalArgumentException
-     */
-    private void cleanupPartitionFolders(final Map<PartValEqWrapperLite, Boolean> addedPartitions,
-        Database db) throws MetaException, IllegalArgumentException {
-      for (Map.Entry<PartValEqWrapperLite, Boolean> e : addedPartitions.entrySet()) {
-        if (e.getValue()) {
-          // we just created this directory - it's not a case of pre-creation, so we nuke.
-          wh.deleteDir(new Path(e.getKey().location), true, db);
-        }
-      }
-    }
-
-    /**
-     * Validate a partition before creating it. The validation checks
-     * <ul>
-     * <li>if the database and table names set in the partition are not null and they are matching
-     * with the expected values set in the tblName and dbName parameters.</li>
-     * <li>if the partition values are set.</li>
-     * <li>if none of the partition values is null.</li>
-     * <li>if the partition values are matching with the pattern set in the
-     * 'metastore.partition.name.whitelist.pattern' configuration property.</li>
-     * <li>if the partition doesn't already exist. If the partition already exists, an exception
-     * will be thrown if the ifNotExists parameter is false, otherwise it will be just ignored.</li>
-     * <li>if the partsToAdd set doesn't contain the partition. The partsToAdd set contains the
-     * partitions which are already validated. If the set contains the current partition, it means
-     * that the partition is tried to be added multiple times in the same batch. Please note that
-     * the set will be updated with the current partition if the validation was successful.</li>
-     * </ul>
-     * @param part
-     * @param catName
-     * @param tblName
-     * @param dbName
-     * @param partsToAdd
-     * @param ms
-     * @param ifNotExists
-     * @return
-     * @throws MetaException
-     * @throws TException
-     */
-    private boolean validatePartition(final Partition part, final String catName,
-        final String tblName, final String dbName, final Set<PartValEqWrapperLite> partsToAdd,
-        final RawStore ms, final boolean ifNotExists, List<FieldSchema> partitionKeys) throws MetaException, TException {
-
-      if (part.getDbName() == null || part.getTableName() == null) {
-        throw new MetaException("The database and table name must be set in the partition.");
-      }
-
-      if (!part.getTableName().equalsIgnoreCase(tblName)
-          || !part.getDbName().equalsIgnoreCase(dbName)) {
-        String errorMsg = String.format(
-            "Partition does not belong to target table %s. It belongs to the table %s.%s : %s",
-            TableName.getQualified(catName, dbName, tblName), part.getDbName(),
-            part.getTableName(), part.toString());
-        throw new MetaException(errorMsg);
-      }
-
-      if (part.getValues() == null || part.getValues().isEmpty()) {
-        throw new MetaException("The partition values cannot be null or empty.");
-      }
-
-      if (part.getValues().contains(null)) {
-        throw new MetaException("Partition value cannot be null.");
-      }
-
-      boolean shouldAdd = startAddPartition(ms, part, partitionKeys, ifNotExists);
-      if (!shouldAdd) {
-        LOG.info("Not adding partition {} as it already exists", part);
-        return false;
-      }
-
-      if (!partsToAdd.add(new PartValEqWrapperLite(part))) {
-        // Technically, for ifNotExists case, we could insert one and discard the other
-        // because the first one now "exists", but it seems better to report the problem
-        // upstream as such a command doesn't make sense.
-        throw new MetaException("Duplicate partitions in the list: " + part);
-      }
-      return true;
-    }
-
-    /**
-     * Create the location folders for the partitions. For each partition a separate thread will be
-     * started to create the folder. The method will wait until all threads are finished and returns
-     * the partitions whose folders were created successfully. If an error occurs during the
-     * execution of a thread, a MetaException will be thrown.
-     * @param partitionsToAdd
-     * @param table
-     * @param addedPartitions
-     * @return
-     * @throws MetaException
-     */
-    private List<Partition> createPartitionFolders(final List<Partition> partitionsToAdd,
-        final Table table, final Map<PartValEqWrapperLite, Boolean> addedPartitions)
-        throws MetaException {
-
-      final AtomicBoolean failureOccurred = new AtomicBoolean(false);
-      final List<Future<Partition>> partFutures = new ArrayList<>(partitionsToAdd.size());
-      final Map<PartValEqWrapperLite, Boolean> addedParts = new ConcurrentHashMap<>();
-
-      final UserGroupInformation ugi;
-      try {
-        ugi = UserGroupInformation.getCurrentUser();
-      } catch (IOException e) {
-        throw new RuntimeException(e);
-      }
-
-      for (final Partition partition : partitionsToAdd) {
-        initializePartitionParameters(table, partition);
-
-        partFutures.add(threadPool.submit(() -> {
-          if (failureOccurred.get()) {
-            return null;
-          }
-          ugi.doAs((PrivilegedExceptionAction<Partition>) () -> {
-            try {
-              boolean madeDir = createLocationForAddedPartition(table, partition);
-              addedParts.put(new PartValEqWrapperLite(partition), madeDir);
-              initializeAddedPartition(table, partition, madeDir, null);
-            } catch (MetaException e) {
-              throw new IOException(e.getMessage(), e);
-            }
-            return null;
-          });
-          return partition;
-        }));
-      }
-
-      List<Partition> newParts = new ArrayList<>(partitionsToAdd.size());
-      String errorMessage = null;
-      for (Future<Partition> partFuture : partFutures) {
-        try {
-          Partition part = partFuture.get();
-          if (part != null && !failureOccurred.get()) {
-            newParts.add(part);
-          }
-        } catch (ExecutionException e) {
-          // If an exception is thrown in the execution of a task, set the failureOccurred flag to
-          // true. This flag is visible in the tasks and if its value is true, the partition
-          // folders won't be created.
-          // Then iterate through the remaining tasks and wait for them to finish. The tasks which
-          // are started before the flag got set will then finish creating the partition folders.
-          // The tasks which are started after the flag got set, won't create the partition
-          // folders, to avoid unnecessary work.
-          // This way it is sure that all tasks are finished, when entering the finally part where
-          // the partition folders are cleaned up. It won't happen that a task is still running
-          // when cleaning up the folders, so it is sure we won't have leftover folders.
-          // Canceling the other tasks would be also an option but during testing it turned out
-          // that it is not a trustworthy solution to avoid leftover folders.
-          failureOccurred.compareAndSet(false, true);
-          errorMessage = e.getMessage();
-        } catch (InterruptedException e) {
-          failureOccurred.compareAndSet(false, true);
-          errorMessage = e.getMessage();
-          // Restore interruption status of the corresponding thread
-          Thread.currentThread().interrupt();
-        }
-      }
-
-      addedPartitions.putAll(addedParts);
-      if (failureOccurred.get()) {
-        throw new MetaException(errorMessage);
-      }
-
-      return newParts;
-    }
-
-    @Override
-    public AddPartitionsResult add_partitions_req(AddPartitionsRequest request)
-        throws TException {
-      AddPartitionsResult result = new AddPartitionsResult();
-      if (request.getParts().isEmpty()) {
-        return result;
-      }
-      try {
-        if (!request.isSetCatName()) {
-          request.setCatName(getDefaultCatalog(conf));
-        }
-        // Make sure all of the partitions have the catalog set as well
-        request.getParts().forEach(p -> {
-          if (!p.isSetCatName()) {
-            p.setCatName(getDefaultCatalog(conf));
-          }
-        });
-        List<Partition> parts = add_partitions_core(getMS(), request.getCatName(), request.getDbName(),
-            request.getTblName(), request.getParts(), request.isIfNotExists());
-        if (request.isNeedResult()) {
-          result.setPartitions(parts);
-        }
-      } catch (TException te) {
-        throw te;
-      } catch (Exception e) {
-        throw newMetaException(e);
-      }
-      return result;
-    }
-
-    @Override
-    public int add_partitions(final List<Partition> parts) throws MetaException,
-        InvalidObjectException, AlreadyExistsException {
-      startFunction("add_partition");
-      if (parts == null) {
-        throw new MetaException("Partition list cannot be null.");
-      }
-      if (parts.isEmpty()) {
-        return 0;
-      }
-
-      Integer ret = null;
-      Exception ex = null;
-      try {
-        // Old API assumed all partitions belong to the same table; keep the same assumption
-        if (!parts.get(0).isSetCatName()) {
-          String defaultCat = getDefaultCatalog(conf);
-          for (Partition p : parts) {
-            p.setCatName(defaultCat);
-          }
-        }
-        ret = add_partitions_core(getMS(), parts.get(0).getCatName(), parts.get(0).getDbName(),
-            parts.get(0).getTableName(), parts, false).size();
-        assert ret == parts.size();
-      } catch (MetaException | InvalidObjectException | AlreadyExistsException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        String tableName = parts.get(0).getTableName();
-        endFunction("add_partition", ret != null, ex, tableName);
-      }
-      return ret;
-    }
-
-    @Override
-    public int add_partitions_pspec(final List<PartitionSpec> partSpecs)
-        throws TException {
-      logAndAudit("add_partitions_pspec");
-
-      if (partSpecs.isEmpty()) {
-        return 0;
-      }
-
-      String dbName = partSpecs.get(0).getDbName();
-      String tableName = partSpecs.get(0).getTableName();
-      // If the catalog name isn't set, we need to go through and set it.
-      String catName;
-      if (!partSpecs.get(0).isSetCatName()) {
-        catName = getDefaultCatalog(conf);
-        partSpecs.forEach(ps -> ps.setCatName(catName));
-      } else {
-        catName = partSpecs.get(0).getCatName();
-      }
-
-      return add_partitions_pspec_core(getMS(), catName, dbName, tableName, partSpecs, false);
-    }
-
-    private int add_partitions_pspec_core(RawStore ms, String catName, String dbName,
-                                          String tblName, List<PartitionSpec> partSpecs,
-                                          boolean ifNotExists)
-        throws TException {
-      boolean success = false;
-      if (dbName == null || tblName == null) {
-        throw new MetaException("The database and table name cannot be null.");
-      }
-      // Ensures that the list doesn't have dups, and keeps track of directories we have created.
-      final Map<PartValEqWrapperLite, Boolean> addedPartitions = new ConcurrentHashMap<>();
-      PartitionSpecProxy partitionSpecProxy = PartitionSpecProxy.Factory.get(partSpecs);
-      final PartitionSpecProxy.PartitionIterator partitionIterator = partitionSpecProxy
-          .getPartitionIterator();
-      Table tbl = null;
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-      Database db = null;
-      try {
-        ms.openTransaction();
-        tbl = ms.getTable(catName, dbName, tblName, null);
-        if (tbl == null) {
-          throw new InvalidObjectException("Unable to add partitions because "
-              + "database or table " + dbName + "." + tblName + " does not exist");
-        }
-        db = ms.getDatabase(catName, dbName);
-        firePreEvent(new PreAddPartitionEvent(tbl, partitionSpecProxy, this));
-        Set<PartValEqWrapperLite> partsToAdd = new HashSet<>(partitionSpecProxy.size());
-        List<Partition> partitionsToAdd = new ArrayList<>(partitionSpecProxy.size());
-        List<FieldSchema> partitionKeys = tbl.getPartitionKeys();
-        while (partitionIterator.hasNext()) {
-          // Iterate through the partitions and validate them. If one of the partitions is
-          // incorrect, an exception will be thrown before the threads which create the partition
-          // folders are submitted. This way we can be sure that no partition or partition folder
-          // will be created if the list contains an invalid partition.
-          final Partition part = partitionIterator.getCurrent();
-          if (validatePartition(part, catName, tblName, dbName, partsToAdd, ms, ifNotExists,
-              partitionKeys)) {
-            partitionsToAdd.add(part);
-          }
-          partitionIterator.next();
-        }
-
-        createPartitionFolders(partitionsToAdd, tbl, addedPartitions);
-
-        ms.addPartitions(catName, dbName, tblName, partitionSpecProxy, ifNotExists);
-
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenerResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                    EventType.ADD_PARTITION,
-                                                    new AddPartitionEvent(tbl, partitionSpecProxy, true, this));
-        }
-
-        success = ms.commitTransaction();
-        return addedPartitions.size();
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-          cleanupPartitionFolders(addedPartitions, db);
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.ADD_PARTITION,
-                                                new AddPartitionEvent(tbl, partitionSpecProxy, true, this),
-                                                null,
-                                                transactionalListenerResponses, ms);
-        }
-      }
-    }
-
-    private boolean startAddPartition(
-        RawStore ms, Partition part, List<FieldSchema> partitionKeys, boolean ifNotExists)
-        throws TException {
-      MetaStoreServerUtils.validatePartitionNameCharacters(part.getValues(),
-          partitionValidationPattern);
-      boolean doesExist = ms.doesPartitionExist(part.getCatName(),
-          part.getDbName(), part.getTableName(), partitionKeys, part.getValues());
-      if (doesExist && !ifNotExists) {
-        throw new AlreadyExistsException("Partition already exists: " + part);
-      }
-      return !doesExist;
-    }
-
-    /**
-     * Handles the location for a partition being created.
-     * @param tbl Table.
-     * @param part Partition.
-     * @return Whether the partition SD location is set to a newly created directory.
-     */
-    private boolean createLocationForAddedPartition(
-        final Table tbl, final Partition part) throws MetaException {
-      Path partLocation = null;
-      String partLocationStr = null;
-      if (part.getSd() != null) {
-        partLocationStr = part.getSd().getLocation();
-      }
-
-      if (partLocationStr == null || partLocationStr.isEmpty()) {
-        // set default location if not specified and this is
-        // a physical table partition (not a view)
-        if (tbl.getSd().getLocation() != null) {
-          partLocation = new Path(tbl.getSd().getLocation(), Warehouse
-              .makePartName(tbl.getPartitionKeys(), part.getValues()));
-        }
-      } else {
-        if (tbl.getSd().getLocation() == null) {
-          throw new MetaException("Cannot specify location for a view partition");
-        }
-        partLocation = wh.getDnsPath(new Path(partLocationStr));
-      }
-
-      boolean result = false;
-      if (partLocation != null) {
-        part.getSd().setLocation(partLocation.toString());
-
-        // Check to see if the directory already exists before calling
-        // mkdirs() because if the file system is read-only, mkdirs will
-        // throw an exception even if the directory already exists.
-        if (!wh.isDir(partLocation)) {
-          if (!wh.mkdirs(partLocation)) {
-            throw new MetaException(partLocation
-                + " is not a directory or unable to create one");
-          }
-          result = true;
-        }
-      }
-      return result;
-    }
-
-    /**
-     * Verify if update stats while altering partition(s)
-     * For the following three cases HMS will not update partition stats
-     * 1) Table property 'DO_NOT_UPDATE_STATS' = True
-     * 2) HMS configuration property 'STATS_AUTO_GATHER' = False
-     * 3) Is View
-     */
-    private boolean canUpdateStats(Table tbl) {
-        Map<String,String> tblParams = tbl.getParameters();
-        boolean updateStatsTbl = true;
-        if ((tblParams != null) && tblParams.containsKey(StatsSetupConst.DO_NOT_UPDATE_STATS)) {
-            updateStatsTbl = !Boolean.valueOf(tblParams.get(StatsSetupConst.DO_NOT_UPDATE_STATS));
-        }
-        if (!MetastoreConf.getBoolVar(conf, ConfVars.STATS_AUTO_GATHER) ||
-            MetaStoreUtils.isView(tbl) ||
-            !updateStatsTbl) {
-          return false;
-        }
-        return true;
-    }
-
-    private void initializeAddedPartition(final Table tbl, final Partition part, boolean madeDir,
-                                          EnvironmentContext environmentContext) throws MetaException {
-      initializeAddedPartition(tbl,
-              new PartitionSpecProxy.SimplePartitionWrapperIterator(part), madeDir, environmentContext);
-    }
-
-    private void initializeAddedPartition(
-        final Table tbl, final PartitionSpecProxy.PartitionIterator part, boolean madeDir,
-        EnvironmentContext environmentContext) throws MetaException {
-      if (canUpdateStats(tbl)) {
-        MetaStoreServerUtils.updatePartitionStatsFast(part, tbl, wh, madeDir,
-                false, environmentContext, true);
-      }
-
-      // set create time
-      long time = System.currentTimeMillis() / 1000;
-      part.setCreateTime((int) time);
-      if (part.getParameters() == null ||
-          part.getParameters().get(hive_metastoreConstants.DDL_TIME) == null) {
-        part.putToParameters(hive_metastoreConstants.DDL_TIME, Long.toString(time));
-      }
-    }
-
-    private void initializePartitionParameters(final Table tbl, final Partition part)
-        throws MetaException {
-      initializePartitionParameters(tbl,
-          new PartitionSpecProxy.SimplePartitionWrapperIterator(part));
-    }
-
-    private void initializePartitionParameters(final Table tbl,
-        final PartitionSpecProxy.PartitionIterator part) throws MetaException {
-
-      // Inherit table properties into partition properties.
-      Map<String, String> tblParams = tbl.getParameters();
-      String inheritProps = MetastoreConf.getVar(conf, ConfVars.PART_INHERIT_TBL_PROPS).trim();
-      // Default value is empty string in which case no properties will be inherited.
-      // * implies all properties needs to be inherited
-      Set<String> inheritKeys = new HashSet<>(Arrays.asList(inheritProps.split(",")));
-      if (inheritKeys.contains("*")) {
-        inheritKeys = tblParams.keySet();
-      }
-
-      for (String key : inheritKeys) {
-        String paramVal = tblParams.get(key);
-        if (null != paramVal) { // add the property only if it exists in table properties
-          part.putToParameters(key, paramVal);
-        }
-      }
-    }
-
-    private Partition add_partition_core(final RawStore ms,
-        final Partition part, final EnvironmentContext envContext)
-        throws TException {
-      boolean success = false;
-      Table tbl = null;
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-      if (!part.isSetCatName()) {
-        part.setCatName(getDefaultCatalog(conf));
-      }
-      try {
-        ms.openTransaction();
-        tbl = ms.getTable(part.getCatName(), part.getDbName(), part.getTableName(), null);
-        if (tbl == null) {
-          throw new InvalidObjectException(
-              "Unable to add partition because table or database do not exist");
-        }
-
-        firePreEvent(new PreAddPartitionEvent(tbl, part, this));
-
-        if (part.getValues() == null || part.getValues().isEmpty()) {
-          throw new MetaException("The partition values cannot be null or empty.");
-        }
-        boolean shouldAdd = startAddPartition(ms, part, tbl.getPartitionKeys(), false);
-        assert shouldAdd; // start would throw if it already existed here
-        boolean madeDir = createLocationForAddedPartition(tbl, part);
-        try {
-          initializeAddedPartition(tbl, part, madeDir, envContext);
-          initializePartitionParameters(tbl, part);
-          success = ms.addPartition(part);
-        } finally {
-          if (!success && madeDir) {
-            wh.deleteDir(new Path(part.getSd().getLocation()), true, false,
-                    ReplChangeManager.shouldEnableCm(ms.getDatabase(part.getCatName(), part.getDbName()), tbl));
-          }
-        }
-
-        // Setting success to false to make sure that if the listener fails, rollback happens.
-        success = false;
-
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenerResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                    EventType.ADD_PARTITION,
-                                                    new AddPartitionEvent(tbl, Arrays.asList(part), true, this),
-                                                    envContext);
-
-        }
-
-        // we proceed only if we'd actually succeeded anyway, otherwise,
-        // we'd have thrown an exception
-        success = ms.commitTransaction();
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.ADD_PARTITION,
-                                                new AddPartitionEvent(tbl, Arrays.asList(part), success, this),
-                                                envContext,
-                                                transactionalListenerResponses, ms);
-
-        }
-      }
-      return part;
-    }
-
-    @Override
-    public Partition add_partition(final Partition part)
-        throws InvalidObjectException, AlreadyExistsException, MetaException {
-      return add_partition_with_environment_context(part, null);
-    }
-
-    @Override
-    public Partition add_partition_with_environment_context(
-        final Partition part, EnvironmentContext envContext)
-        throws InvalidObjectException, AlreadyExistsException,
-        MetaException {
-      if (part == null) {
-        throw new MetaException("Partition cannot be null.");
-      }
-      startTableFunction("add_partition",
-          part.getCatName(), part.getDbName(), part.getTableName());
-      Partition ret = null;
-      Exception ex = null;
-      try {
-        ret = add_partition_core(getMS(), part, envContext);
-      } catch (MetaException | InvalidObjectException | AlreadyExistsException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("add_partition", ret != null, ex, part != null ?  part.getTableName(): null);
-      }
-      return ret;
-    }
-
-    @Override
-    public Partition exchange_partition(Map<String, String> partitionSpecs,
-        String sourceDbName, String sourceTableName, String destDbName,
-        String destTableName) throws TException {
-      exchange_partitions(partitionSpecs, sourceDbName, sourceTableName, destDbName, destTableName);
-      // Wouldn't it make more sense to return the first element of the list returned by the
-      // previous call?
-      return new Partition();
-    }
-
-    @Override
-    public List<Partition> exchange_partitions(Map<String, String> partitionSpecs,
-        String sourceDbName, String sourceTableName, String destDbName,
-        String destTableName) throws TException {
-      String[] parsedDestDbName = parseDbName(destDbName, conf);
-      String[] parsedSourceDbName = parseDbName(sourceDbName, conf);
-      // No need to check catalog for null as parseDbName() will never return null for the catalog.
-      if (partitionSpecs == null || parsedSourceDbName[DB_NAME] == null || sourceTableName == null
-          || parsedDestDbName[DB_NAME] == null || destTableName == null) {
-        throw new MetaException("The DB and table name for the source and destination tables,"
-            + " and the partition specs must not be null.");
-      }
-      if (!parsedDestDbName[CAT_NAME].equals(parsedSourceDbName[CAT_NAME])) {
-        throw new MetaException("You cannot move a partition across catalogs");
-      }
-
-      boolean success = false;
-      boolean pathCreated = false;
-      RawStore ms = getMS();
-      ms.openTransaction();
-
-      Table destinationTable =
-          ms.getTable(
-              parsedDestDbName[CAT_NAME], parsedDestDbName[DB_NAME], destTableName, null);
-      if (destinationTable == null) {
-        throw new MetaException( "The destination table " +
-            TableName.getQualified(parsedDestDbName[CAT_NAME],
-                parsedDestDbName[DB_NAME], destTableName) + " not found");
-      }
-      Table sourceTable =
-          ms.getTable(
-              parsedSourceDbName[CAT_NAME], parsedSourceDbName[DB_NAME], sourceTableName, null);
-      if (sourceTable == null) {
-        throw new MetaException("The source table " +
-            TableName.getQualified(parsedSourceDbName[CAT_NAME],
-                parsedSourceDbName[DB_NAME], sourceTableName) + " not found");
-      }
-
-      List<String> partVals = MetaStoreUtils.getPvals(sourceTable.getPartitionKeys(),
-          partitionSpecs);
-      List<String> partValsPresent = new ArrayList<> ();
-      List<FieldSchema> partitionKeysPresent = new ArrayList<> ();
-      int i = 0;
-      for (FieldSchema fs: sourceTable.getPartitionKeys()) {
-        String partVal = partVals.get(i);
-        if (partVal != null && !partVal.equals("")) {
-          partValsPresent.add(partVal);
-          partitionKeysPresent.add(fs);
-        }
-        i++;
-      }
-      // Passed the unparsed DB name here, as get_partitions_ps expects to parse it
-      List<Partition> partitionsToExchange = get_partitions_ps(sourceDbName, sourceTableName,
-          partVals, (short)-1);
-      if (partitionsToExchange == null || partitionsToExchange.isEmpty()) {
-        throw new MetaException("No partition is found with the values " + partitionSpecs
-            + " for the table " + sourceTableName);
-      }
-      boolean sameColumns = MetaStoreUtils.compareFieldColumns(
-          sourceTable.getSd().getCols(), destinationTable.getSd().getCols());
-      boolean samePartitions = MetaStoreUtils.compareFieldColumns(
-          sourceTable.getPartitionKeys(), destinationTable.getPartitionKeys());
-      if (!sameColumns || !samePartitions) {
-        throw new MetaException("The tables have different schemas." +
-            " Their partitions cannot be exchanged.");
-      }
-      Path sourcePath = new Path(sourceTable.getSd().getLocation(),
-          Warehouse.makePartName(partitionKeysPresent, partValsPresent));
-      Path destPath = new Path(destinationTable.getSd().getLocation(),
-          Warehouse.makePartName(partitionKeysPresent, partValsPresent));
-      List<Partition> destPartitions = new ArrayList<>();
-
-      Map<String, String> transactionalListenerResponsesForAddPartition = Collections.emptyMap();
-      List<Map<String, String>> transactionalListenerResponsesForDropPartition =
-          Lists.newArrayListWithCapacity(partitionsToExchange.size());
-
-      // Check if any of the partitions already exists in destTable.
-      List<String> destPartitionNames = ms.listPartitionNames(parsedDestDbName[CAT_NAME],
-          parsedDestDbName[DB_NAME], destTableName, (short) -1);
-      if (destPartitionNames != null && !destPartitionNames.isEmpty()) {
-        for (Partition partition : partitionsToExchange) {
-          String partToExchangeName =
-              Warehouse.makePartName(destinationTable.getPartitionKeys(), partition.getValues());
-          if (destPartitionNames.contains(partToExchangeName)) {
-            throw new MetaException("The partition " + partToExchangeName
-                + " already exists in the table " + destTableName);
-          }
-        }
-      }
-
-      Database srcDb = ms.getDatabase(parsedSourceDbName[CAT_NAME], parsedSourceDbName[DB_NAME]);
-      Database destDb = ms.getDatabase(parsedDestDbName[CAT_NAME], parsedDestDbName[DB_NAME]);
-      if (!isRenameAllowed(srcDb, destDb)) {
-        throw new MetaException("Exchange partition not allowed for " +
-                TableName.getQualified(parsedSourceDbName[CAT_NAME],
-                parsedSourceDbName[DB_NAME], sourceTableName) + " Dest db : " + destDbName);
-      }
-      try {
-        for (Partition partition: partitionsToExchange) {
-          Partition destPartition = new Partition(partition);
-          destPartition.setDbName(parsedDestDbName[DB_NAME]);
-          destPartition.setTableName(destinationTable.getTableName());
-          Path destPartitionPath = new Path(destinationTable.getSd().getLocation(),
-              Warehouse.makePartName(destinationTable.getPartitionKeys(), partition.getValues()));
-          destPartition.getSd().setLocation(destPartitionPath.toString());
-          ms.addPartition(destPartition);
-          destPartitions.add(destPartition);
-          ms.dropPartition(parsedSourceDbName[CAT_NAME], partition.getDbName(), sourceTable.getTableName(),
-            partition.getValues());
-        }
-        Path destParentPath = destPath.getParent();
-        if (!wh.isDir(destParentPath)) {
-          if (!wh.mkdirs(destParentPath)) {
-              throw new MetaException("Unable to create path " + destParentPath);
-          }
-        }
-        /*
-         * TODO: Use the hard link feature of hdfs
-         * once https://issues.apache.org/jira/browse/HDFS-3370 is done
-         */
-        pathCreated = wh.renameDir(sourcePath, destPath, false);
-
-        // Setting success to false to make sure that if the listener fails, rollback happens.
-        success = false;
-
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenerResponsesForAddPartition =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                    EventType.ADD_PARTITION,
-                                                    new AddPartitionEvent(destinationTable, destPartitions, true, this));
-
-          for (Partition partition : partitionsToExchange) {
-            DropPartitionEvent dropPartitionEvent =
-                new DropPartitionEvent(sourceTable, partition, true, true, this);
-            transactionalListenerResponsesForDropPartition.add(
-                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                      EventType.DROP_PARTITION,
-                                                      dropPartitionEvent));
-          }
-        }
-
-        success = ms.commitTransaction();
-        return destPartitions;
-      } finally {
-        if (!success || !pathCreated) {
-          ms.rollbackTransaction();
-          if (pathCreated) {
-            wh.renameDir(destPath, sourcePath, false);
-          }
-        }
-
-        if (!listeners.isEmpty()) {
-          AddPartitionEvent addPartitionEvent = new AddPartitionEvent(destinationTable, destPartitions, success, this);
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.ADD_PARTITION,
-                                                addPartitionEvent,
-                                                null,
-                                                transactionalListenerResponsesForAddPartition, ms);
-
-          i = 0;
-          for (Partition partition : partitionsToExchange) {
-            DropPartitionEvent dropPartitionEvent =
-                new DropPartitionEvent(sourceTable, partition, success, true, this);
-            Map<String, String> parameters =
-                (transactionalListenerResponsesForDropPartition.size() > i)
-                    ? transactionalListenerResponsesForDropPartition.get(i)
-                    : null;
-
-            MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                  EventType.DROP_PARTITION,
-                                                  dropPartitionEvent,
-                                                  null,
-                                                  parameters, ms);
-            i++;
-          }
-        }
-      }
-    }
-
-    private boolean drop_partition_common(RawStore ms, String catName, String db_name,
-                                          String tbl_name, List<String> part_vals,
-                                          final boolean deleteData, final EnvironmentContext envContext)
-        throws MetaException, NoSuchObjectException, IOException, InvalidObjectException,
-      InvalidInputException {
-      boolean success = false;
-      Path partPath = null;
-      Table tbl = null;
-      Partition part = null;
-      boolean isArchived = false;
-      Path archiveParentDir = null;
-      boolean mustPurge = false;
-      boolean tableDataShouldBeDeleted = false;
-      boolean needsCm = false;
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-
-      if (db_name == null) {
-        throw new MetaException("The DB name cannot be null.");
-      }
-      if (tbl_name == null) {
-        throw new MetaException("The table name cannot be null.");
-      }
-      if (part_vals == null) {
-        throw new MetaException("The partition values cannot be null.");
-      }
-
-      try {
-        ms.openTransaction();
-        part = ms.getPartition(catName, db_name, tbl_name, part_vals);
-        tbl = get_table_core(catName, db_name, tbl_name, null);
-        tableDataShouldBeDeleted = checkTableDataShouldBeDeleted(tbl, deleteData);
-        firePreEvent(new PreDropPartitionEvent(tbl, part, deleteData, this));
-        mustPurge = isMustPurge(envContext, tbl);
-
-        if (part == null) {
-          throw new NoSuchObjectException("Partition doesn't exist. "
-              + part_vals);
-        }
-
-        isArchived = MetaStoreUtils.isArchived(part);
-        if (isArchived) {
-          archiveParentDir = MetaStoreUtils.getOriginalLocation(part);
-          verifyIsWritablePath(archiveParentDir);
-        }
-
-        if ((part.getSd() != null) && (part.getSd().getLocation() != null)) {
-          partPath = new Path(part.getSd().getLocation());
-          verifyIsWritablePath(partPath);
-        }
-
-        if (!ms.dropPartition(catName, db_name, tbl_name, part_vals)) {
-          throw new MetaException("Unable to drop partition");
-        } else {
-          if (!transactionalListeners.isEmpty()) {
-
-            transactionalListenerResponses =
-                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                      EventType.DROP_PARTITION,
-                                                      new DropPartitionEvent(tbl, part, true, deleteData, this),
-                                                      envContext);
-          }
-          needsCm = ReplChangeManager.shouldEnableCm(ms.getDatabase(catName, db_name), tbl);
-          success = ms.commitTransaction();
-        }
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else if (deleteData && ((partPath != null) || (archiveParentDir != null))) {
-          if (tableDataShouldBeDeleted) {
-            if (mustPurge) {
-              LOG.info("dropPartition() will purge " + partPath + " directly, skipping trash.");
-            }
-            else {
-              LOG.info("dropPartition() will move " + partPath + " to trash-directory.");
-            }
-            // Archived partitions have har:/to_har_file as their location.
-            // The original directory was saved in params
-
-            if (isArchived) {
-              assert (archiveParentDir != null);
-              wh.deleteDir(archiveParentDir, true, mustPurge, needsCm);
-            } else {
-              assert (partPath != null);
-              wh.deleteDir(partPath, true, mustPurge, needsCm);
-              deleteParentRecursive(partPath.getParent(), part_vals.size() - 1, mustPurge, needsCm);
-            }
-            // ok even if the data is not deleted
-          }
-        }
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.DROP_PARTITION,
-                                                new DropPartitionEvent(tbl, part, success, deleteData, this),
-                                                envContext,
-                                                transactionalListenerResponses, ms);
-        }
-      }
-      return true;
-    }
-
-    private static boolean isMustPurge(EnvironmentContext envContext, Table tbl) {
-      // Data needs deletion. Check if trash may be skipped.
-      // Trash may be skipped iff:
-      //  1. deleteData == true, obviously.
-      //  2. tbl is external.
-      //  3. Either
-      //    3.1. User has specified PURGE from the commandline, and if not,
-      //    3.2. User has set the table to auto-purge.
-      return ((envContext != null) && Boolean.parseBoolean(envContext.getProperties().get("ifPurge")))
-          || MetaStoreUtils.isSkipTrash(tbl.getParameters());
-    }
-    private void deleteParentRecursive(Path parent, int depth, boolean mustPurge, boolean needRecycle)
-            throws IOException, MetaException {
-      if (depth > 0 && parent != null && wh.isWritable(parent)) {
-        if (wh.isDir(parent) && wh.isEmptyDir(parent)) {
-          wh.deleteDir(parent, true, mustPurge, needRecycle);
-        }
-        deleteParentRecursive(parent.getParent(), depth - 1, mustPurge, needRecycle);
-      }
-    }
-
-    @Override
-    public boolean drop_partition(final String db_name, final String tbl_name,
-        final List<String> part_vals, final boolean deleteData)
-        throws TException {
-      return drop_partition_with_environment_context(db_name, tbl_name, part_vals, deleteData,
-          null);
-    }
-
-    private static class PathAndPartValSize {
-      PathAndPartValSize(Path path, int partValSize) {
-        this.path = path;
-        this.partValSize = partValSize;
-      }
-      public Path path;
-      int partValSize;
-    }
-
-    @Override
-    public DropPartitionsResult drop_partitions_req(
-        DropPartitionsRequest request) throws TException {
-      RawStore ms = getMS();
-      String dbName = request.getDbName(), tblName = request.getTblName();
-      String catName = request.isSetCatName() ? request.getCatName() : getDefaultCatalog(conf);
-      boolean ifExists = request.isSetIfExists() && request.isIfExists();
-      boolean deleteData = request.isSetDeleteData() && request.isDeleteData();
-      boolean ignoreProtection = request.isSetIgnoreProtection() && request.isIgnoreProtection();
-      boolean needResult = !request.isSetNeedResult() || request.isNeedResult();
-      List<PathAndPartValSize> dirsToDelete = new ArrayList<>();
-      List<Path> archToDelete = new ArrayList<>();
-      EnvironmentContext envContext = request.isSetEnvironmentContext()
-          ? request.getEnvironmentContext() : null;
-
-      boolean success = false;
-      ms.openTransaction();
-      Table tbl = null;
-      List<Partition> parts = null;
-      boolean mustPurge = false;
-      List<Map<String, String>> transactionalListenerResponses = Lists.newArrayList();
-      boolean needsCm = ReplChangeManager.shouldEnableCm(ms.getDatabase(catName, dbName),
-              ms.getTable(catName, dbName, tblName));
-
-      try {
-        // We need Partition-s for firing events and for result; DN needs MPartition-s to drop.
-        // Great... Maybe we could bypass fetching MPartitions by issuing direct SQL deletes.
-        tbl = get_table_core(catName, dbName, tblName);
-        isExternal(tbl);
-        mustPurge = isMustPurge(envContext, tbl);
-        int minCount = 0;
-        RequestPartsSpec spec = request.getParts();
-        List<String> partNames = null;
-        if (spec.isSetExprs()) {
-          // Dropping by expressions.
-          parts = new ArrayList<>(spec.getExprs().size());
-          for (DropPartitionsExpr expr : spec.getExprs()) {
-            ++minCount; // At least one partition per expression, if not ifExists
-            List<Partition> result = new ArrayList<>();
-            boolean hasUnknown = ms.getPartitionsByExpr(
-                catName, dbName, tblName, expr.getExpr(), null, (short)-1, result);
-            if (hasUnknown) {
-              // Expr is built by DDLSA, it should only contain part cols and simple ops
-              throw new MetaException("Unexpected unknown partitions to drop");
-            }
-            // this is to prevent dropping archived partition which is archived in a
-            // different level the drop command specified.
-            if (!ignoreProtection && expr.isSetPartArchiveLevel()) {
-              for (Partition part : parts) {
-                if (MetaStoreUtils.isArchived(part)
-                    && MetaStoreUtils.getArchivingLevel(part) < expr.getPartArchiveLevel()) {
-                  throw new MetaException("Cannot drop a subset of partitions "
-                      + " in an archive, partition " + part);
-                }
-              }
-            }
-            parts.addAll(result);
-          }
-        } else if (spec.isSetNames()) {
-          partNames = spec.getNames();
-          minCount = partNames.size();
-          parts = ms.getPartitionsByNames(catName, dbName, tblName, partNames);
-        } else {
-          throw new MetaException("Partition spec is not set");
-        }
-
-        if ((parts.size() < minCount) && !ifExists) {
-          throw new NoSuchObjectException("Some partitions to drop are missing");
-        }
-
-        List<String> colNames = null;
-        if (partNames == null) {
-          partNames = new ArrayList<>(parts.size());
-          colNames = new ArrayList<>(tbl.getPartitionKeys().size());
-          for (FieldSchema col : tbl.getPartitionKeys()) {
-            colNames.add(col.getName());
-          }
-        }
-
-        for (Partition part : parts) {
-
-          // TODO - we need to speed this up for the normal path where all partitions are under
-          // the table and we don't have to stat every partition
-
-          firePreEvent(new PreDropPartitionEvent(tbl, part, deleteData, this));
-          if (colNames != null) {
-            partNames.add(FileUtils.makePartName(colNames, part.getValues()));
-          }
-          // Preserve the old behavior of failing when we cannot write, even w/o deleteData,
-          // and even if the table is external. That might not make any sense.
-          if (MetaStoreUtils.isArchived(part)) {
-            Path archiveParentDir = MetaStoreUtils.getOriginalLocation(part);
-            verifyIsWritablePath(archiveParentDir);
-            archToDelete.add(archiveParentDir);
-          }
-          if ((part.getSd() != null) && (part.getSd().getLocation() != null)) {
-            Path partPath = new Path(part.getSd().getLocation());
-            verifyIsWritablePath(partPath);
-            dirsToDelete.add(new PathAndPartValSize(partPath, part.getValues().size()));
-          }
-        }
-
-        ms.dropPartitions(catName, dbName, tblName, partNames);
-        if (parts != null && !transactionalListeners.isEmpty()) {
-          for (Partition part : parts) {
-            transactionalListenerResponses.add(
-                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                      EventType.DROP_PARTITION,
-                                                      new DropPartitionEvent(tbl, part, true, deleteData, this),
-                                                      envContext));
-          }
-        }
-
-        success = ms.commitTransaction();
-        DropPartitionsResult result = new DropPartitionsResult();
-        if (needResult) {
-          result.setPartitions(parts);
-        }
-
-        return result;
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else if (checkTableDataShouldBeDeleted(tbl, deleteData)) {
-          LOG.info( mustPurge?
-                      "dropPartition() will purge partition-directories directly, skipping trash."
-                    :  "dropPartition() will move partition-directories to trash-directory.");
-          // Archived partitions have har:/to_har_file as their location.
-          // The original directory was saved in params
-          for (Path path : archToDelete) {
-            wh.deleteDir(path, true, mustPurge, needsCm);
-          }
-          for (PathAndPartValSize p : dirsToDelete) {
-            wh.deleteDir(p.path, true, mustPurge, needsCm);
-            try {
-              deleteParentRecursive(p.path.getParent(), p.partValSize - 1, mustPurge, needsCm);
-            } catch (IOException ex) {
-              LOG.warn("Error from deleteParentRecursive", ex);
-              throw new MetaException("Failed to delete parent: " + ex.getMessage());
-            }
-          }
-        }
-        if (parts != null) {
-          int i = 0;
-          if (parts != null && !listeners.isEmpty()) {
-            for (Partition part : parts) {
-              Map<String, String> parameters =
-                  (!transactionalListenerResponses.isEmpty()) ? transactionalListenerResponses.get(i) : null;
-
-              MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                    EventType.DROP_PARTITION,
-                                                    new DropPartitionEvent(tbl, part, success, deleteData, this),
-                                                    envContext,
-                                                    parameters, ms);
-
-              i++;
-            }
-          }
-        }
-      }
-    }
-
-    private void verifyIsWritablePath(Path dir) throws MetaException {
-      try {
-        if (!wh.isWritable(dir.getParent())) {
-          throw new MetaException("Table partition not deleted since " + dir.getParent()
-              + " is not writable by " + SecurityUtils.getUser());
-        }
-      } catch (IOException ex) {
-        LOG.warn("Error from isWritable", ex);
-        throw new MetaException("Table partition not deleted since " + dir.getParent()
-            + " access cannot be checked: " + ex.getMessage());
-      }
-    }
-
-    @Override
-    public boolean drop_partition_with_environment_context(final String db_name,
-        final String tbl_name, final List<String> part_vals, final boolean deleteData,
-        final EnvironmentContext envContext)
-        throws TException {
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startPartitionFunction("drop_partition", parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-          tbl_name, part_vals);
-      LOG.info("Partition values:" + part_vals);
-
-      boolean ret = false;
-      Exception ex = null;
-      try {
-        ret = drop_partition_common(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tbl_name, part_vals, deleteData, envContext);
-      } catch (IOException e) {
-        ex = e;
-        throw new MetaException(e.getMessage());
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("drop_partition", ret, ex, tbl_name);
-      }
-      return ret;
-
-    }
-
-    /**
-     * Use {@link #get_partition_req(GetPartitionRequest)} ()} instead.
-     *
-     */
-    @Override
-    @Deprecated
-    public Partition get_partition(final String db_name, final String tbl_name,
-        final List<String> part_vals) throws MetaException, NoSuchObjectException {
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startPartitionFunction("get_partition", parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-          tbl_name, part_vals);
-
-      Partition ret = null;
-      Exception ex = null;
-      try {
-        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-        fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-        ret = getMS().getPartition(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name, part_vals);
-        ret = FilterUtils.filterPartitionIfEnabled(isServerFilterEnabled, filterHook, ret);
-      } catch (Exception e) {
-        ex = e;
-        throwMetaException(e);
-      } finally {
-        endFunction("get_partition", ret != null, ex, tbl_name);
-      }
-      return ret;
-    }
-
-    @Override
-    public GetPartitionResponse get_partition_req(GetPartitionRequest req)
-        throws MetaException, NoSuchObjectException, TException {
-      // TODO Move the logic from get_partition to here, as that method is getting deprecated
-      String dbName = MetaStoreUtils.prependCatalogToDbName(req.getCatName(), req.getDbName(), conf);
-      Partition p = get_partition(dbName, req.getTblName(), req.getPartVals());
-      GetPartitionResponse res = new GetPartitionResponse();
-      res.setPartition(p);
-      return res;
-    }
-
-    /**
-     * Fire a pre-event for read table operation, if there are any
-     * pre-event listeners registered
-     */
-    private void fireReadTablePreEvent(String catName, String dbName, String tblName)
-        throws MetaException, NoSuchObjectException {
-      if(preListeners.size() > 0) {
-        Supplier<Table> tableSupplier = Suppliers.memoize(new Supplier<Table>() {
-          @Override public Table get() {
-            try {
-              Table t = getMS().getTable(catName, dbName, tblName, null);
-              if (t == null) {
-                throw new NoSuchObjectException(TableName.getQualified(catName, dbName, tblName)
-                    + " table not found");
-              }
-              return t;
-            } catch(MetaException | NoSuchObjectException e) {
-              throw new RuntimeException(e);
-            }
-          }
-        });
-        firePreEvent(new PreReadTableEvent(tableSupplier, this));
-      }
-    }
-
-    @Override
-    @Deprecated
-    public Partition get_partition_with_auth(final String db_name,
-        final String tbl_name, final List<String> part_vals,
-        final String user_name, final List<String> group_names)
-        throws TException {
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startPartitionFunction("get_partition_with_auth", parsedDbName[CAT_NAME],
-          parsedDbName[DB_NAME], tbl_name, part_vals);
-      fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-      Partition ret = null;
-      Exception ex = null;
-      try {
-        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-
-        ret = getMS().getPartitionWithAuth(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tbl_name, part_vals, user_name, group_names);
-        ret = FilterUtils.filterPartitionIfEnabled(isServerFilterEnabled, filterHook, ret);
-      } catch (InvalidObjectException e) {
-        ex = e;
-        throw new NoSuchObjectException(e.getMessage());
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partition_with_auth", ret != null, ex, tbl_name);
-      }
-      return ret;
-    }
-
-    /**
-     * Use {@link #get_partitions_req(PartitionsRequest)} ()} instead.
-     *
-     */
-    @Override
-    @Deprecated
-    public List<Partition> get_partitions(final String db_name, final String tbl_name,
-        final short max_parts) throws NoSuchObjectException, MetaException {
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startTableFunction("get_partitions", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-      fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-      List<Partition> ret = null;
-      Exception ex = null;
-      try {
-        checkLimitNumberOfPartitionsByFilter(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tbl_name, NO_FILTER_STRING, max_parts);
-
-        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-
-        ret = getMS().getPartitions(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name,
-            max_parts);
-        ret = FilterUtils.filterPartitionsIfEnabled(isServerFilterEnabled, filterHook, ret);
-      } catch (Exception e) {
-        ex = e;
-        throwMetaException(e);
-      } finally {
-        endFunction("get_partitions", ret != null, ex, tbl_name);
-      }
-      return ret;
-
-    }
-
-    @Override
-    public PartitionsResponse get_partitions_req(PartitionsRequest req)
-        throws NoSuchObjectException, MetaException, TException {
-      String dbName = MetaStoreUtils.prependCatalogToDbName(req.getCatName(), req.getDbName(), conf);
-      List<Partition> partitions = get_partitions(dbName, req.getTblName(), req.getMaxParts());
-      PartitionsResponse res = new PartitionsResponse();
-      res.setPartitions(partitions);
-      return res;
-    }
-
-    @Override
-    @Deprecated
-    public List<Partition> get_partitions_with_auth(final String dbName,
-        final String tblName, final short maxParts, final String userName,
-        final List<String> groupNames) throws TException {
-      String[] parsedDbName = parseDbName(dbName, conf);
-      startTableFunction("get_partitions_with_auth", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName);
-
-      List<Partition> ret = null;
-      Exception ex = null;
-      try {
-        checkLimitNumberOfPartitionsByFilter(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tblName, NO_FILTER_STRING, maxParts);
-
-        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName);
-
-        ret = getMS().getPartitionsWithAuth(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName,
-            maxParts, userName, groupNames);
-        ret = FilterUtils.filterPartitionsIfEnabled(isServerFilterEnabled, filterHook, ret);
-      } catch (InvalidObjectException e) {
-        ex = e;
-        throw new NoSuchObjectException(e.getMessage());
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partitions_with_auth", ret != null, ex, tblName);
-      }
-      return ret;
-
-    }
-
-    private void checkLimitNumberOfPartitionsByFilter(String catName, String dbName,
-                                                      String tblName, String filterString,
-                                                      int maxParts) throws TException {
-      if (isPartitionLimitEnabled()) {
-        checkLimitNumberOfPartitions(tblName, get_num_partitions_by_filter(prependCatalogToDbName(
-            catName, dbName, conf), tblName, filterString), maxParts);
-      }
-    }
-
-    private void checkLimitNumberOfPartitionsByExpr(String catName, String dbName, String tblName,
-                                                    byte[] filterExpr, int maxParts)
-        throws TException {
-      if (isPartitionLimitEnabled()) {
-        checkLimitNumberOfPartitions(tblName, get_num_partitions_by_expr(catName, dbName, tblName,
-            filterExpr), maxParts);
-      }
-    }
-
-    private boolean isPartitionLimitEnabled() {
-      int partitionLimit = MetastoreConf.getIntVar(conf, ConfVars.LIMIT_PARTITION_REQUEST);
-      return partitionLimit > -1;
-    }
-
-    private void checkLimitNumberOfPartitions(String tblName, int numPartitions, int maxToFetch) throws MetaException {
-      if (isPartitionLimitEnabled()) {
-        int partitionLimit = MetastoreConf.getIntVar(conf, ConfVars.LIMIT_PARTITION_REQUEST);
-        int partitionRequest = (maxToFetch < 0) ? numPartitions : maxToFetch;
-        if (partitionRequest > partitionLimit) {
-          String configName = ConfVars.LIMIT_PARTITION_REQUEST.toString();
-          throw new MetaException(String.format(PARTITION_NUMBER_EXCEED_LIMIT_MSG, partitionRequest,
-              tblName, partitionLimit, configName));
-        }
-      }
-    }
-
-    @Override
-    @Deprecated
-    public List<PartitionSpec> get_partitions_pspec(final String db_name, final String tbl_name, final int max_parts)
-      throws NoSuchObjectException, MetaException  {
-
-      String[] parsedDbName = parseDbName(db_name, conf);
-      String tableName = tbl_name.toLowerCase();
-
-      startTableFunction("get_partitions_pspec", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName);
-
-      List<PartitionSpec> partitionSpecs = null;
-      try {
-        Table table = get_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName);
-        // get_partitions will parse out the catalog and db names itself
-        List<Partition> partitions = get_partitions(db_name, tableName, (short) max_parts);
-
-        if (is_partition_spec_grouping_enabled(table)) {
-          partitionSpecs = MetaStoreServerUtils
-              .getPartitionspecsGroupedByStorageDescriptor(table, partitions);
-        }
-        else {
-          PartitionSpec pSpec = new PartitionSpec();
-          pSpec.setPartitionList(new PartitionListComposingSpec(partitions));
-          pSpec.setCatName(parsedDbName[CAT_NAME]);
-          pSpec.setDbName(parsedDbName[DB_NAME]);
-          pSpec.setTableName(tableName);
-          pSpec.setRootPath(table.getSd().getLocation());
-          partitionSpecs = Arrays.asList(pSpec);
-        }
-
-        return partitionSpecs;
-      }
-      finally {
-        endFunction("get_partitions_pspec", partitionSpecs != null && !partitionSpecs.isEmpty(), null, tbl_name);
-      }
-    }
-
-    @Override
-    public GetPartitionsResponse get_partitions_with_specs(GetPartitionsRequest request)
-        throws MetaException, TException {
-      String catName = null;
-      if (request.isSetCatName()) {
-        catName = request.getCatName();
-      }
-      String[] parsedDbName = parseDbName(request.getDbName(), conf);
-      String tableName = request.getTblName();
-      if (catName == null) {
-        // if catName is not provided in the request use the catName parsed from the dbName
-        catName = parsedDbName[CAT_NAME];
-      }
-      startTableFunction("get_partitions_with_specs", catName, parsedDbName[DB_NAME],
-          tableName);
-      GetPartitionsResponse response = null;
-      Exception ex = null;
-      try {
-        Table table = get_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName);
-        List<Partition> partitions = getMS()
-            .getPartitionSpecsByFilterAndProjection(table, request.getProjectionSpec(),
-                request.getFilterSpec());
-        List<String> processorCapabilities = request.getProcessorCapabilities();
-        String processorId = request.getProcessorIdentifier();
-        if (processorCapabilities == null || processorCapabilities.size() == 0 ||
-              processorCapabilities.contains("MANAGERAWMETADATA")) {
-          LOG.info("Skipping translation for processor with " + processorId);
-        } else {
-          if (transformer != null) {
-            partitions = transformer.transformPartitions(partitions, table, processorCapabilities, processorId);
-          }
-        }
-        List<PartitionSpec> partitionSpecs =
-            MetaStoreServerUtils.getPartitionspecsGroupedByStorageDescriptor(table, partitions);
-        response = new GetPartitionsResponse();
-        response.setPartitionSpec(partitionSpecs);
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partitions_with_specs", response != null, ex, tableName);
-      }
-      return response;
-    }
-
-    private static boolean is_partition_spec_grouping_enabled(Table table) {
-
-      Map<String, String> parameters = table.getParameters();
-      return parameters.containsKey("hive.hcatalog.partition.spec.grouping.enabled")
-          && parameters.get("hive.hcatalog.partition.spec.grouping.enabled").equalsIgnoreCase("true");
-    }
-
-    @Override
-    @Deprecated
-    public List<String> get_partition_names(final String db_name, final String tbl_name,
-        final short max_parts) throws NoSuchObjectException, MetaException {
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startTableFunction("get_partition_names", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-      fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-      List<String> ret = null;
-      Exception ex = null;
-      try {
-        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-        ret = getMS().listPartitionNames(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name,
-            max_parts);
-        ret = FilterUtils.filterPartitionNamesIfEnabled(isServerFilterEnabled,
-            filterHook, parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name, ret);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_partition_names", ret != null, ex, tbl_name);
-      }
-      return ret;
-    }
-
-    @Override
-    public PartitionValuesResponse get_partition_values(PartitionValuesRequest request)
-        throws MetaException {
-      String catName = request.isSetCatName() ? request.getCatName() : getDefaultCatalog(conf);
-      String dbName = request.getDbName();
-      String tblName = request.getTblName();
-
-      try {
-        authorizeTableForPartitionMetadata(catName, dbName, tblName);
-
-        // This is serious black magic, as the following 2 lines do nothing AFAICT but without them
-        // the subsequent call to listPartitionValues fails.
-        List<FieldSchema> partCols = new ArrayList<FieldSchema>();
-        partCols.add(request.getPartitionKeys().get(0));
-        return getMS().listPartitionValues(catName, dbName, tblName, request.getPartitionKeys(),
-            request.isApplyDistinct(), request.getFilter(), request.isAscending(),
-            request.getPartitionOrder(), request.getMaxParts());
-      } catch (NoSuchObjectException e) {
-        LOG.error(String.format("Unable to get partition for %s.%s.%s", catName, dbName, tblName), e);
-        throw new MetaException(e.getMessage());
-      }
-    }
-
-    @Deprecated
-    @Override
-    public void alter_partition(final String db_name, final String tbl_name,
-        final Partition new_part)
-        throws TException {
-      rename_partition(db_name, tbl_name, null, new_part);
-    }
-
-    @Deprecated
-    @Override
-    public void alter_partition_with_environment_context(final String dbName,
-        final String tableName, final Partition newPartition,
-        final EnvironmentContext envContext)
-        throws TException {
-      String[] parsedDbName = parseDbName(dbName, conf);
-      // TODO: this method name is confusing, it actually does full alter (sortof)
-      rename_partition(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName, null, newPartition,
-          envContext, null);
-    }
-
-    @Deprecated
-    @Override
-    public void rename_partition(final String db_name, final String tbl_name,
-        final List<String> part_vals, final Partition new_part)
-        throws TException {
-      // Call rename_partition without an environment context.
-      String[] parsedDbName = parseDbName(db_name, conf);
-      rename_partition(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name, part_vals, new_part,
-          null, null);
-    }
-
-    @Override
-    public RenamePartitionResponse rename_partition_req(
-        RenamePartitionRequest req) throws InvalidOperationException ,MetaException ,TException {
-      rename_partition(req.getCatName(), req.getDbName(), req.getTableName(), req.getPartVals(),
-          req.getNewPart(), null, req.getValidWriteIdList());
-      return new RenamePartitionResponse();
-    };
-
-    private void rename_partition(String catName, String db_name, String tbl_name,
-        List<String> part_vals, Partition new_part, EnvironmentContext envContext,
-        String validWriteIds) throws TException {
-      startTableFunction("alter_partition", catName, db_name, tbl_name);
-
-      if (LOG.isInfoEnabled()) {
-        LOG.info("New partition values:" + new_part.getValues());
-        if (part_vals != null && part_vals.size() > 0) {
-          LOG.info("Old Partition values:" + part_vals);
-        }
-      }
-
-      // Adds the missing scheme/authority for the new partition location
-      if (new_part.getSd() != null) {
-        String newLocation = new_part.getSd().getLocation();
-        if (org.apache.commons.lang3.StringUtils.isNotEmpty(newLocation)) {
-          Path tblPath = wh.getDnsPath(new Path(newLocation));
-          new_part.getSd().setLocation(tblPath.toString());
-        }
-      }
-
-      // Make sure the new partition has the catalog value set
-      if (!new_part.isSetCatName()) {
-        new_part.setCatName(catName);
-      }
-
-      Partition oldPart = null;
-      Exception ex = null;
-      try {
-        firePreEvent(new PreAlterPartitionEvent(db_name, tbl_name, part_vals, new_part, this));
-        if (part_vals != null && !part_vals.isEmpty()) {
-          MetaStoreServerUtils.validatePartitionNameCharacters(new_part.getValues(),
-              partitionValidationPattern);
-        }
-
-        oldPart = alterHandler.alterPartition(getMS(), wh, catName, db_name, tbl_name,
-            part_vals, new_part, envContext, this, validWriteIds);
-
-        // Only fetch the table if we actually have a listener
-        Table table = null;
-        if (!listeners.isEmpty()) {
-          if (table == null) {
-            table = getMS().getTable(catName, db_name, tbl_name, null);
-          }
-
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.ALTER_PARTITION,
-                                                new AlterPartitionEvent(oldPart, new_part, table, false,
-                                                        true, new_part.getWriteId(), this),
-                                                envContext);
-        }
-      } catch (InvalidObjectException e) {
-        ex = e;
-        throw new InvalidOperationException(e.getMessage());
-      } catch (AlreadyExistsException e) {
-        ex = e;
-        throw new InvalidOperationException(e.getMessage());
-      } catch (MetaException | InvalidOperationException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("alter_partition", oldPart != null, ex, tbl_name);
-      }
-    }
-
-    @Override
-    public void alter_partitions(final String db_name, final String tbl_name,
-        final List<Partition> new_parts)
-        throws TException {
-      String[] o = parseDbName(db_name, conf);
-      alter_partitions_with_environment_context(o[0], o[1],
-          tbl_name, new_parts, null, null, -1);
-    }
-
-    @Override
-    public AlterPartitionsResponse alter_partitions_req(AlterPartitionsRequest req) throws TException {
-      alter_partitions_with_environment_context(req.getCatName(),
-          req.getDbName(), req.getTableName(), req.getPartitions(), req.getEnvironmentContext(),
-          req.isSetValidWriteIdList() ? req.getValidWriteIdList() : null,
-          req.isSetWriteId() ? req.getWriteId() : -1);
-      return new AlterPartitionsResponse();
-    }
-
-    // The old API we are keeping for backward compat. Not used within Hive.
-    @Deprecated
-    @Override
-    public void alter_partitions_with_environment_context(final String db_name, final String tbl_name,
-        final List<Partition> new_parts, EnvironmentContext environmentContext)
-            throws TException {
-      String[] o = parseDbName(db_name, conf);
-      alter_partitions_with_environment_context(o[0], o[1], tbl_name, new_parts, environmentContext,
-          null, -1);
-    }
-
-    private void alter_partitions_with_environment_context(String catName, String db_name, final String tbl_name,
-        final List<Partition> new_parts, EnvironmentContext environmentContext,
-        String writeIdList, long writeId)
-        throws TException {
-      if (environmentContext == null) {
-        environmentContext = new EnvironmentContext();
-      }
-      if (catName == null) {
-        catName = MetaStoreUtils.getDefaultCatalog(conf);
-      }
-
-      startTableFunction("alter_partitions", catName, db_name, tbl_name);
-
-      if (LOG.isInfoEnabled()) {
-        for (Partition tmpPart : new_parts) {
-          LOG.info("New partition values:" + tmpPart.getValues());
-        }
-      }
-      // all partitions are altered atomically
-      // all prehooks are fired together followed by all post hooks
-      List<Partition> oldParts = null;
-      Exception ex = null;
-      try {
-        for (Partition tmpPart : new_parts) {
-          // Make sure the catalog name is set in the new partition
-          if (!tmpPart.isSetCatName()) {
-            tmpPart.setCatName(getDefaultCatalog(conf));
-          }
-          firePreEvent(new PreAlterPartitionEvent(db_name, tbl_name, null, tmpPart, this));
-        }
-        oldParts = alterHandler.alterPartitions(getMS(), wh,
-            catName, db_name, tbl_name, new_parts, environmentContext, writeIdList, writeId, this);
-        Iterator<Partition> olditr = oldParts.iterator();
-        // Only fetch the table if we have a listener that needs it.
-        Table table = null;
-        for (Partition tmpPart : new_parts) {
-          Partition oldTmpPart;
-          if (olditr.hasNext()) {
-            oldTmpPart = olditr.next();
-          }
-          else {
-            throw new InvalidOperationException("failed to alterpartitions");
-          }
-
-          if (table == null) {
-            table = getMS().getTable(catName, db_name, tbl_name,  null);
-          }
-
-          if (!listeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                  EventType.ALTER_PARTITION,
-                                                  new AlterPartitionEvent(oldTmpPart, tmpPart, table, false,
-                                                   true, writeId, this));
-          }
-        }
-      } catch (InvalidObjectException e) {
-        ex = e;
-        throw new InvalidOperationException(e.getMessage());
-      } catch (AlreadyExistsException e) {
-        ex = e;
-        throw new InvalidOperationException(e.getMessage());
-      } catch (MetaException | InvalidOperationException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("alter_partition", oldParts != null, ex, tbl_name);
-      }
-    }
-
-    @Override
-    public String getVersion() throws TException {
-      String version = MetastoreVersionInfo.getVersion();
-      endFunction(startFunction("getVersion"), version != null, null);
-      return version;
-    }
-
-    @Override
-    public void alter_table(final String dbname, final String name,
-        final Table newTable)
-        throws InvalidOperationException, MetaException {
-      // Do not set an environment context.
-      String[] parsedDbName = parseDbName(dbname, conf);
-      alter_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], name, newTable,
-          null, null, null, null);
-    }
-
-    @Override
-    public void alter_table_with_cascade(final String dbname, final String name,
-        final Table newTable, final boolean cascade)
-        throws InvalidOperationException, MetaException {
-      EnvironmentContext envContext = null;
-      if (cascade) {
-        envContext = new EnvironmentContext();
-        envContext.putToProperties(StatsSetupConst.CASCADE, StatsSetupConst.TRUE);
-      }
-      String[] parsedDbName = parseDbName(dbname, conf);
-      alter_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], name, newTable,
-          envContext, null, null, null);
-    }
-
-    @Override
-    public AlterTableResponse alter_table_req(AlterTableRequest req)
-        throws InvalidOperationException, MetaException, TException {
-      alter_table_core(req.getCatName(), req.getDbName(), req.getTableName(),
-          req.getTable(), req.getEnvironmentContext(), req.getValidWriteIdList(),
-          req.getProcessorCapabilities(), req.getProcessorIdentifier());
-      return new AlterTableResponse();
-    }
-
-    @Override
-    public void alter_table_with_environment_context(final String dbname,
-        final String name, final Table newTable,
-        final EnvironmentContext envContext)
-        throws InvalidOperationException, MetaException {
-      String[] parsedDbName = parseDbName(dbname, conf);
-      alter_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-          name, newTable, envContext, null, null, null);
-    }
-
-    private void alter_table_core(String catName, String dbname, String name, Table newTable,
-        EnvironmentContext envContext, String validWriteIdList, List<String> processorCapabilities, String processorId)
-        throws InvalidOperationException, MetaException {
-      startFunction("alter_table", ": " + TableName.getQualified(catName, dbname, name)
-          + " newtbl=" + newTable.getTableName());
-      if (envContext == null) {
-        envContext = new EnvironmentContext();
-      }
-      if (catName == null) {
-        catName = MetaStoreUtils.getDefaultCatalog(conf);
-      }
-
-      // Update the time if it hasn't been specified.
-      if (newTable.getParameters() == null ||
-          newTable.getParameters().get(hive_metastoreConstants.DDL_TIME) == null) {
-        newTable.putToParameters(hive_metastoreConstants.DDL_TIME, Long.toString(System
-            .currentTimeMillis() / 1000));
-      }
-
-      // Adds the missing scheme/authority for the new table location
-      if (newTable.getSd() != null) {
-        String newLocation = newTable.getSd().getLocation();
-        if (org.apache.commons.lang3.StringUtils.isNotEmpty(newLocation)) {
-          Path tblPath = wh.getDnsPath(new Path(newLocation));
-          newTable.getSd().setLocation(tblPath.toString());
-        }
-      }
-      // Set the catalog name if it hasn't been set in the new table
-      if (!newTable.isSetCatName()) {
-        newTable.setCatName(catName);
-      }
-
-      boolean success = false;
-      Exception ex = null;
-      try {
-        Table oldt = get_table_core(catName, dbname, name, null);
-        if (transformer != null && !isInTest) {
-          newTable = transformer.transformAlterTable(newTable, processorCapabilities, processorId);
-        }
-        firePreEvent(new PreAlterTableEvent(oldt, newTable, this));
-        alterHandler.alterTable(getMS(), wh, catName, dbname, name, newTable,
-                envContext, this, validWriteIdList);
-        success = true;
-      } catch (NoSuchObjectException e) {
-        // thrown when the table to be altered does not exist
-        ex = e;
-        throw new InvalidOperationException(e.getMessage());
-      } catch (MetaException | InvalidOperationException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("alter_table", success, ex, name);
-      }
-    }
-
-    @Override
-    public List<String> get_tables(final String dbname, final String pattern)
-        throws MetaException {
-      startFunction("get_tables", ": db=" + dbname + " pat=" + pattern);
-
-      List<String> ret = null;
-      Exception ex = null;
-      Database db = null;
-      String[] parsedDbName = parseDbName(dbname, conf);
-      try {
-        db = get_database_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]);
-        if (db != null && db.getType() != null) {
-          if (db.getType().equals(DatabaseType.REMOTE)) {
-            return DataConnectorProviderFactory.getDataConnectorProvider(db).getTableNames();
-          }
-        }
-      } catch (Exception e) { /* appears we return empty set instead of throwing an exception */ }
-
-      try {
-        ret = getMS().getTables(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], pattern);
-        if(ret !=  null && !ret.isEmpty()) {
-          List<Table> tableInfo = new ArrayList<>();
-          tableInfo = getMS().getTableObjectsByName(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], ret);
-          tableInfo = FilterUtils.filterTablesIfEnabled(isServerFilterEnabled, filterHook, tableInfo);// tableInfo object has the owner information of the table which is being passed to FilterUtils.
-          ret = new ArrayList<>();
-          for (Table tbl : tableInfo) {
-            ret.add(tbl.getTableName());
-          }
-        }
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_tables", ret != null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public List<String> get_tables_by_type(final String dbname, final String pattern, final String tableType)
-        throws MetaException {
-      startFunction("get_tables_by_type", ": db=" + dbname + " pat=" + pattern + ",type=" + tableType);
-
-      List<String> ret = null;
-      Exception ex = null;
-      String[] parsedDbName = parseDbName(dbname, conf);
-      try {
-        ret = getTablesByTypeCore(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], pattern, tableType);
-        ret = FilterUtils.filterTableNamesIfEnabled(isServerFilterEnabled, filterHook,
-            parsedDbName[CAT_NAME], parsedDbName[DB_NAME], ret);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_tables_by_type", ret != null, ex);
-      }
-      return ret;
-    }
-
-    private List<String> getTablesByTypeCore(final String catName, final String dbname,
-        final String pattern, final String tableType) throws MetaException {
-      startFunction("getTablesByTypeCore", ": catName=" + catName +
-          ": db=" + dbname + " pat=" + pattern + ",type=" + tableType);
-
-      List<String> ret = null;
-      Exception ex = null;
-      Database db = null;
-      try {
-        db = get_database_core(catName, dbname);
-        if (db != null) {
-          if (db.getType().equals(DatabaseType.REMOTE)) {
-            return DataConnectorProviderFactory.getDataConnectorProvider(db).getTableNames();
-          }
-        }
-      } catch (Exception e) { /* ignore */ }
-
-      try {
-        ret = getMS().getTables(catName, dbname, pattern, TableType.valueOf(tableType), -1);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("getTablesByTypeCore", ret != null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public List<Table> get_all_materialized_view_objects_for_rewriting()
-        throws MetaException {
-      startFunction("get_all_materialized_view_objects_for_rewriting");
-
-      List<Table> ret = null;
-      Exception ex = null;
-      try {
-        ret = getMS().getAllMaterializedViewObjectsForRewriting(DEFAULT_CATALOG_NAME);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_all_materialized_view_objects_for_rewriting", ret != null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public List<String> get_materialized_views_for_rewriting(final String dbname)
-        throws MetaException {
-      startFunction("get_materialized_views_for_rewriting", ": db=" + dbname);
-
-      List<String> ret = null;
-      Exception ex = null;
-      String[] parsedDbName = parseDbName(dbname, conf);
-      try {
-        ret = getMS().getMaterializedViewsForRewriting(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_materialized_views_for_rewriting", ret != null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public List<String> get_all_tables(final String dbname) throws MetaException {
-      startFunction("get_all_tables", ": db=" + dbname);
-
-      List<String> ret = null;
-      Exception ex = null;
-      String[] parsedDbName = parseDbName(dbname, conf);
-      try {
-        ret = getMS().getAllTables(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]);
-        ret = FilterUtils.filterTableNamesIfEnabled(isServerFilterEnabled, filterHook,
-            parsedDbName[CAT_NAME], parsedDbName[DB_NAME], ret);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_all_tables", ret != null, ex);
-      }
-      return ret;
-    }
-
-    /**
-     * Use {@link #get_fields_req(GetFieldsRequest)} ()} instead.
-     *
-     */
-    @Override
-    @Deprecated
-    public List<FieldSchema> get_fields(String db, String tableName)
-        throws MetaException, UnknownTableException, UnknownDBException {
-      return get_fields_with_environment_context(db, tableName, null);
-    }
-
-    @Override
-    @Deprecated
-    public List<FieldSchema> get_fields_with_environment_context(String db, String tableName,
-        final EnvironmentContext envContext)
-        throws MetaException, UnknownTableException, UnknownDBException {
-      startFunction("get_fields_with_environment_context", ": db=" + db + "tbl=" + tableName);
-      String[] names = tableName.split("\\.");
-      String base_table_name = names[0];
-      String[] parsedDbName = parseDbName(db, conf);
-
-      Table tbl;
-      List<FieldSchema> ret = null;
-      Exception ex = null;
-      ClassLoader orgHiveLoader = null;
-      try {
-        try {
-          tbl = get_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], base_table_name);
-          firePreEvent(new PreReadTableEvent(tbl, this));
-        } catch (NoSuchObjectException e) {
-          throw new UnknownTableException(e.getMessage());
-        }
-        if (null == tbl.getSd().getSerdeInfo().getSerializationLib() ||
-          MetastoreConf.getStringCollection(conf,
-              ConfVars.SERDES_USING_METASTORE_FOR_SCHEMA).contains(
-                  tbl.getSd().getSerdeInfo().getSerializationLib())) {
-          ret = tbl.getSd().getCols();
-        } else {
-          StorageSchemaReader schemaReader = getStorageSchemaReader();
-          ret = schemaReader.readSchema(tbl, envContext, getConf());
-        }
-      } catch (UnknownTableException | MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        if (orgHiveLoader != null) {
-          conf.setClassLoader(orgHiveLoader);
-        }
-        endFunction("get_fields_with_environment_context", ret != null, ex, tableName);
-      }
-
-      return ret;
-    }
-
-    @Override
-    public GetFieldsResponse get_fields_req(GetFieldsRequest req)
-        throws MetaException, UnknownTableException, UnknownDBException, TException {
-      String dbName = MetaStoreUtils.prependCatalogToDbName(req.getCatName(), req.getDbName(), conf);
-      List<FieldSchema> fields = get_fields_with_environment_context(
-          dbName, req.getTblName(), req.getEnvContext());
-      GetFieldsResponse res = new GetFieldsResponse();
-      res.setFields(fields);
-      return res;
-    }
-
-    private StorageSchemaReader getStorageSchemaReader() throws MetaException {
-      if (storageSchemaReader == null) {
-        String className =
-            MetastoreConf.getVar(conf, MetastoreConf.ConfVars.STORAGE_SCHEMA_READER_IMPL);
-        Class<? extends StorageSchemaReader> readerClass =
-            JavaUtils.getClass(className, StorageSchemaReader.class);
-        try {
-          storageSchemaReader = readerClass.newInstance();
-        } catch (InstantiationException|IllegalAccessException e) {
-          LOG.error("Unable to instantiate class " + className, e);
-          throw new MetaException(e.getMessage());
-        }
-      }
-      return storageSchemaReader;
-    }
-
-    /**
-     * Use {@link #get_schema_req(GetSchemaRequest)} ()} instead.
-     *
-     */
-    @Override
-    @Deprecated
-    public List<FieldSchema> get_schema(String db, String tableName)
-        throws MetaException, UnknownTableException, UnknownDBException {
-      return get_schema_with_environment_context(db,tableName, null);
-    }
-
-    /**
-     * Return the schema of the table. This function includes partition columns
-     * in addition to the regular columns.
-     *
-     * @param db
-     *          Name of the database
-     * @param tableName
-     *          Name of the table
-     * @param envContext
-     *          Store session based properties
-     * @return List of columns, each column is a FieldSchema structure
-     * @throws MetaException
-     * @throws UnknownTableException
-     * @throws UnknownDBException
-     */
-    @Override
-    @Deprecated
-    public List<FieldSchema> get_schema_with_environment_context(String db, String tableName,
-          final EnvironmentContext envContext)
-        throws MetaException, UnknownTableException, UnknownDBException {
-      startFunction("get_schema_with_environment_context", ": db=" + db + "tbl=" + tableName);
-      boolean success = false;
-      Exception ex = null;
-      try {
-        String[] names = tableName.split("\\.");
-        String base_table_name = names[0];
-        String[] parsedDbName = parseDbName(db, conf);
-
-        Table tbl;
-        try {
-          tbl = get_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], base_table_name);
-        } catch (NoSuchObjectException e) {
-          throw new UnknownTableException(e.getMessage());
-        }
-        // Pass unparsed db name here
-        List<FieldSchema> fieldSchemas = get_fields_with_environment_context(db, base_table_name,
-            envContext);
-
-        if (tbl == null || fieldSchemas == null) {
-          throw new UnknownTableException(tableName + " doesn't exist");
-        }
-
-        if (tbl.getPartitionKeys() != null) {
-          // Combine the column field schemas and the partition keys to create the
-          // whole schema
-          fieldSchemas.addAll(tbl.getPartitionKeys());
-        }
-        success = true;
-        return fieldSchemas;
-      } catch (UnknownDBException | UnknownTableException | MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        MetaException me = new MetaException(e.toString());
-        me.initCause(e);
-        throw me;
-      } finally {
-        endFunction("get_schema_with_environment_context", success, ex, tableName);
-      }
-    }
-
-    @Override
-    public GetSchemaResponse get_schema_req(GetSchemaRequest req)
-        throws MetaException, UnknownTableException, UnknownDBException, TException {
-      String dbName = MetaStoreUtils.prependCatalogToDbName(req.getCatName(), req.getDbName(), conf);
-      List<FieldSchema> fields = get_schema_with_environment_context(
-          dbName, req.getTblName(), req.getEnvContext());
-      GetSchemaResponse res = new GetSchemaResponse();
-      res.setFields(fields);
-      return res;
-    }
-
-    @Override
-    public String getCpuProfile(int profileDurationInSec) throws TException {
-      return "";
-    }
-
-    /**
-     * Returns the value of the given configuration variable name. If the
-     * configuration variable with the given name doesn't exist, or if there
-     * were an exception thrown while retrieving the variable, or if name is
-     * null, defaultValue is returned.
-     */
-    @Override
-    public String get_config_value(String name, String defaultValue)
-        throws TException {
-      startFunction("get_config_value", ": name=" + name + " defaultValue="
-          + defaultValue);
-      boolean success = false;
-      Exception ex = null;
-      try {
-        if (name == null) {
-          success = true;
-          return defaultValue;
-        }
-        // Allow only keys that start with hive.*, hdfs.*, mapred.* for security
-        // i.e. don't allow access to db password
-        if (!Pattern.matches("(hive|hdfs|mapred|metastore).*", name)) {
-          throw new ConfigValSecurityException("For security reasons, the "
-              + "config key " + name + " cannot be accessed");
-        }
-
-        String toReturn = defaultValue;
-        try {
-          toReturn = MetastoreConf.get(conf, name);
-          if (toReturn == null) {
-            toReturn = defaultValue;
-          }
-        } catch (RuntimeException e) {
-          LOG.error(threadLocalId.get().toString() + ": "
-              + "RuntimeException thrown in get_config_value - msg: "
-              + e.getMessage() + " cause: " + e.getCause());
-        }
-        success = true;
-        return toReturn;
-      } catch (ConfigValSecurityException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw new TException(e);
-      } finally {
-        endFunction("get_config_value", success, ex);
-      }
-    }
-
-    private List<String> getPartValsFromName(Table t, String partName)
-        throws MetaException, InvalidObjectException {
-      Preconditions.checkArgument(t != null, "Table can not be null");
-      // Unescape the partition name
-      LinkedHashMap<String, String> hm = Warehouse.makeSpecFromName(partName);
-
-      List<String> partVals = new ArrayList<>();
-      for (FieldSchema field : t.getPartitionKeys()) {
-        String key = field.getName();
-        String val = hm.get(key);
-        if (val == null) {
-          throw new InvalidObjectException("incomplete partition name - missing " + key);
-        }
-        partVals.add(val);
-      }
-      return partVals;
-    }
-
-    private List<String> getPartValsFromName(RawStore ms, String catName, String dbName,
-                                             String tblName, String partName)
-        throws MetaException, InvalidObjectException {
-      Table t = ms.getTable(catName, dbName, tblName,  null);
-      if (t == null) {
-        throw new InvalidObjectException(dbName + "." + tblName
-            + " table not found");
-      }
-      return getPartValsFromName(t, partName);
-    }
-
-    private Partition get_partition_by_name_core(final RawStore ms, final String catName,
-                                                 final String db_name, final String tbl_name,
-                                                 final String part_name) throws TException {
-      fireReadTablePreEvent(catName, db_name, tbl_name);
-      List<String> partVals;
-      try {
-        partVals = getPartValsFromName(ms, catName, db_name, tbl_name, part_name);
-      } catch (InvalidObjectException e) {
-        throw new NoSuchObjectException(e.getMessage());
-      }
-      Partition p = ms.getPartition(catName, db_name, tbl_name, partVals);
-      p = FilterUtils.filterPartitionIfEnabled(isServerFilterEnabled, filterHook, p);
-
-      if (p == null) {
-        throw new NoSuchObjectException(TableName.getQualified(catName, db_name, tbl_name)
-            + " partition (" + part_name + ") not found");
-      }
-      return p;
-    }
-
-    @Override
-    @Deprecated
-    public Partition get_partition_by_name(final String db_name, final String tbl_name,
-        final String part_name) throws TException {
-
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startFunction("get_partition_by_name", ": tbl=" +
-          TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name)
-          + " part=" + part_name);
-      Partition ret = null;
-      Exception ex = null;
-      try {
-        ret = get_partition_by_name_core(getMS(), parsedDbName[CAT_NAME],
-            parsedDbName[DB_NAME], tbl_name, part_name);
-        ret = FilterUtils.filterPartitionIfEnabled(isServerFilterEnabled, filterHook, ret);
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partition_by_name", ret != null, ex, tbl_name);
-      }
-      return ret;
-    }
-
-    @Override
-    public Partition append_partition_by_name(final String db_name, final String tbl_name,
-        final String part_name) throws TException {
-      return append_partition_by_name_with_environment_context(db_name, tbl_name, part_name, null);
-    }
-
-    @Override
-    public Partition append_partition_by_name_with_environment_context(final String db_name,
-        final String tbl_name, final String part_name, final EnvironmentContext env_context)
-        throws TException {
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startFunction("append_partition_by_name", ": tbl="
-          + TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-          tbl_name) + " part=" + part_name);
-
-      Partition ret = null;
-      Exception ex = null;
-      try {
-        RawStore ms = getMS();
-        List<String> partVals = getPartValsFromName(ms, parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name, part_name);
-        ret = append_partition_common(ms, parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name, partVals, env_context);
-      } catch (InvalidObjectException | AlreadyExistsException | MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("append_partition_by_name", ret != null, ex, tbl_name);
-      }
-      return ret;
-    }
-
-    private boolean drop_partition_by_name_core(final RawStore ms, final String catName,
-                                                final String db_name, final String tbl_name,
-                                                final String part_name, final boolean deleteData,
-                                                final EnvironmentContext envContext)
-        throws TException, IOException {
-
-      List<String> partVals;
-      try {
-        partVals = getPartValsFromName(ms, catName, db_name, tbl_name, part_name);
-      } catch (InvalidObjectException e) {
-        throw new NoSuchObjectException(e.getMessage());
-      }
-
-      return drop_partition_common(ms, catName, db_name, tbl_name, partVals, deleteData, envContext);
-    }
-
-    @Override
-    public boolean drop_partition_by_name(final String db_name, final String tbl_name,
-        final String part_name, final boolean deleteData) throws TException {
-      return drop_partition_by_name_with_environment_context(db_name, tbl_name, part_name,
-          deleteData, null);
-    }
-
-    @Override
-    public boolean drop_partition_by_name_with_environment_context(final String db_name,
-        final String tbl_name, final String part_name, final boolean deleteData,
-        final EnvironmentContext envContext) throws TException {
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startFunction("drop_partition_by_name", ": tbl=" +
-          TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name)
-          + " part=" + part_name);
-
-      boolean ret = false;
-      Exception ex = null;
-      try {
-        ret = drop_partition_by_name_core(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tbl_name, part_name, deleteData, envContext);
-      } catch (IOException e) {
-        ex = e;
-        throw new MetaException(e.getMessage());
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("drop_partition_by_name", ret, ex, tbl_name);
-      }
-
-      return ret;
-    }
-
-    @Override
-    @Deprecated
-    public List<Partition> get_partitions_ps(final String db_name,
-        final String tbl_name, final List<String> part_vals,
-        final short max_parts) throws TException {
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startPartitionFunction("get_partitions_ps", parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-          tbl_name, part_vals);
-
-      List<Partition> ret = null;
-      Exception ex = null;
-      try {
-        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-        // Don't send the parsedDbName, as this method will parse itself.
-        ret = get_partitions_ps_with_auth(db_name, tbl_name, part_vals,
-            max_parts, null, null);
-        ret = FilterUtils.filterPartitionsIfEnabled(isServerFilterEnabled, filterHook, ret);
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partitions_ps", ret != null, ex, tbl_name);
-      }
-
-      return ret;
-    }
-
-    /**
-     * Use {@link #get_partitions_ps_with_auth_req(GetPartitionsPsWithAuthRequest)} ()} instead.
-     *
-     */
-    @Override
-    @Deprecated
-    public List<Partition> get_partitions_ps_with_auth(final String db_name,
-        final String tbl_name, final List<String> part_vals,
-        final short max_parts, final String userName,
-        final List<String> groupNames) throws TException {
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startPartitionFunction("get_partitions_ps_with_auth", parsedDbName[CAT_NAME],
-          parsedDbName[DB_NAME], tbl_name, part_vals);
-      fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-      List<Partition> ret = null;
-      Exception ex = null;
-      try {
-        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-        ret = getMS().listPartitionsPsWithAuth(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tbl_name, part_vals, max_parts, userName, groupNames);
-        ret = FilterUtils.filterPartitionsIfEnabled(isServerFilterEnabled, filterHook, ret);
-      } catch (InvalidObjectException e) {
-        ex = e;
-        throw new MetaException(e.getMessage());
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partitions_ps_with_auth", ret != null, ex, tbl_name);
-      }
-      return ret;
-    }
-
-    @Override
-    public GetPartitionsPsWithAuthResponse get_partitions_ps_with_auth_req(GetPartitionsPsWithAuthRequest req)
-            throws MetaException, NoSuchObjectException, TException {
-      String dbName = MetaStoreUtils.prependCatalogToDbName(req.getCatName(), req.getDbName(), conf);
-      List<Partition> partitions = null;
-      if (req.getPartVals() == null) {
-        partitions = get_partitions_with_auth(dbName, req.getTblName(), req.getMaxParts(), req.getUserName(),
-            req.getGroupNames());
-      } else {
-        partitions =
-            get_partitions_ps_with_auth(dbName, req.getTblName(), req.getPartVals(), req.getMaxParts(),
-                req.getUserName(), req.getGroupNames());
-      }
-      GetPartitionsPsWithAuthResponse res = new GetPartitionsPsWithAuthResponse();
-      res.setPartitions(partitions);
-      return res;
-    }
-
-    /**
-     * Use {@link #get_partition_names_ps_req(GetPartitionNamesPsRequest)} ()} instead.
-     *
-     */
-    @Override
-    @Deprecated
-    public List<String> get_partition_names_ps(final String db_name,
-        final String tbl_name, final List<String> part_vals, final short max_parts)
-        throws TException {
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startPartitionFunction("get_partitions_names_ps", parsedDbName[CAT_NAME],
-          parsedDbName[DB_NAME], tbl_name, part_vals);
-      fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-      List<String> ret = null;
-      Exception ex = null;
-      try {
-        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-        ret = getMS().listPartitionNamesPs(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name,
-            part_vals, max_parts);
-        ret = FilterUtils.filterPartitionNamesIfEnabled(isServerFilterEnabled,
-            filterHook, parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name, ret);
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partitions_names_ps", ret != null, ex, tbl_name);
-      }
-      return ret;
-    }
-
-    @Override
-    public GetPartitionNamesPsResponse get_partition_names_ps_req(GetPartitionNamesPsRequest req)
-            throws MetaException, NoSuchObjectException, TException {
-      String dbName = MetaStoreUtils.prependCatalogToDbName(req.getCatName(), req.getDbName(), conf);
-      List<String> names = get_partition_names_ps(dbName, req.getTblName(), req.getPartValues(),
-              req.getMaxParts());
-      GetPartitionNamesPsResponse res = new GetPartitionNamesPsResponse();
-      res.setNames(names);
-      return res;
-    }
-
-    @Override
-    public List<String> get_partition_names_req(PartitionsByExprRequest req)
-        throws MetaException, NoSuchObjectException, TException {
-      String catName = req.isSetCatName() ? req.getCatName() : getDefaultCatalog(conf);
-      String dbName = req.getDbName(), tblName = req.getTblName();
-      startTableFunction("get_partition_names_req", catName,
-          dbName, tblName);
-      fireReadTablePreEvent(catName, dbName, tblName);
-      List<String> ret = null;
-      Exception ex = null;
-      try {
-        authorizeTableForPartitionMetadata(catName, dbName, tblName);
-        ret = getMS().listPartitionNames(catName, dbName, tblName,
-            req.getDefaultPartitionName(), req.getExpr(), req.getOrder(), req.getMaxParts());
-        ret = FilterUtils.filterPartitionNamesIfEnabled(isServerFilterEnabled,
-            filterHook, catName, dbName, tblName, ret);
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partition_names_req", ret != null, ex, tblName);
-      }
-      return ret;
-    }
-
-    @Override
-    public List<String> partition_name_to_vals(String part_name) throws TException {
-      if (part_name.length() == 0) {
-        return Collections.emptyList();
-      }
-      LinkedHashMap<String, String> map = Warehouse.makeSpecFromName(part_name);
-      return new ArrayList<>(map.values());
-    }
-
-    @Override
-    public Map<String, String> partition_name_to_spec(String part_name) throws TException {
-      if (part_name.length() == 0) {
-        return new HashMap<>();
-      }
-      return Warehouse.makeSpecFromName(part_name);
-    }
-
-    private String lowerCaseConvertPartName(String partName) throws MetaException {
-      if (partName == null) return partName;
-      boolean isFirst = true;
-      Map<String, String> partSpec = Warehouse.makeEscSpecFromName(partName);
-      String convertedPartName = new String();
-
-      for (Map.Entry<String, String> entry : partSpec.entrySet()) {
-        String partColName = entry.getKey();
-        String partColVal = entry.getValue();
-
-        if (!isFirst) {
-          convertedPartName += "/";
-        } else {
-          isFirst = false;
-        }
-        convertedPartName += partColName.toLowerCase() + "=" + partColVal;
-      }
-      return convertedPartName;
-    }
-
-    @Override
-    @Deprecated
-    public ColumnStatistics get_table_column_statistics(String dbName, String tableName,
-      String colName) throws TException {
-      String[] parsedDbName = parseDbName(dbName, conf);
-      parsedDbName[CAT_NAME] = parsedDbName[CAT_NAME].toLowerCase();
-      parsedDbName[DB_NAME] = parsedDbName[DB_NAME].toLowerCase();
-      tableName = tableName.toLowerCase();
-      colName = colName.toLowerCase();
-      startFunction("get_column_statistics_by_table", ": table=" +
-          TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-              tableName) + " column=" + colName);
-      ColumnStatistics statsObj = null;
-      try {
-        statsObj = getMS().getTableColumnStatistics(
-            parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName, Lists.newArrayList(colName),
-            "hive", null);
-        if (statsObj != null) {
-          assert statsObj.getStatsObjSize() <= 1;
-        }
-        return statsObj;
-      } finally {
-        endFunction("get_column_statistics_by_table", statsObj != null, null, tableName);
-      }
-    }
-
-    @Override
-    public TableStatsResult get_table_statistics_req(TableStatsRequest request) throws TException {
-      String catName = request.isSetCatName() ? request.getCatName().toLowerCase() :
-          getDefaultCatalog(conf);
-      String dbName = request.getDbName().toLowerCase();
-      String tblName = request.getTblName().toLowerCase();
-      startFunction("get_table_statistics_req", ": table=" +
-          TableName.getQualified(catName, dbName, tblName));
-      TableStatsResult result = null;
-      List<String> lowerCaseColNames = new ArrayList<>(request.getColNames().size());
-      for (String colName : request.getColNames()) {
-        lowerCaseColNames.add(colName.toLowerCase());
-      }
-      try {
-        ColumnStatistics cs = getMS().getTableColumnStatistics(
-            catName, dbName, tblName, lowerCaseColNames,
-            request.getEngine(), request.getValidWriteIdList());
-        // Note: stats compliance is not propagated to the client; instead, we just return nothing
-        //       if stats are not compliant for now. This won't work for stats merging, but that
-        //       is currently only done on metastore size (see set_aggr...).
-        //       For some optimizations we might make use of incorrect stats that are "better than
-        //       nothing", so this may change in future.
-        result = new TableStatsResult((cs == null || cs.getStatsObj() == null
-            || (cs.isSetIsStatsCompliant() && !cs.isIsStatsCompliant()))
-            ? Lists.newArrayList() : cs.getStatsObj());
-      } finally {
-        endFunction("get_table_statistics_req", result == null, null, tblName);
-      }
-      return result;
-    }
-
-    @Override
-    @Deprecated
-    public ColumnStatistics get_partition_column_statistics(String dbName, String tableName,
-      String partName, String colName) throws TException {
-      // Note: this method appears to be unused within Hive.
-      //       It doesn't take txn stats into account.
-      dbName = dbName.toLowerCase();
-      String[] parsedDbName = parseDbName(dbName, conf);
-      tableName = tableName.toLowerCase();
-      colName = colName.toLowerCase();
-      String convertedPartName = lowerCaseConvertPartName(partName);
-      startFunction("get_column_statistics_by_partition", ": table=" +
-          TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-          tableName) + " partition=" + convertedPartName + " column=" + colName);
-      ColumnStatistics statsObj = null;
-
-      try {
-        List<ColumnStatistics> list = getMS().getPartitionColumnStatistics(
-            parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName,
-            Lists.newArrayList(convertedPartName), Lists.newArrayList(colName),
-            "hive");
-        if (list.isEmpty()) {
-          return null;
-        }
-        if (list.size() != 1) {
-          throw new MetaException(list.size() + " statistics for single column and partition");
-        }
-        statsObj = list.get(0);
-      } finally {
-        endFunction("get_column_statistics_by_partition", statsObj != null, null, tableName);
-      }
-      return statsObj;
-    }
-
-    @Override
-    public PartitionsStatsResult get_partitions_statistics_req(PartitionsStatsRequest request)
-        throws TException {
-      String catName = request.isSetCatName() ? request.getCatName().toLowerCase() : getDefaultCatalog(conf);
-      String dbName = request.getDbName().toLowerCase();
-      String tblName = request.getTblName().toLowerCase();
-      startFunction("get_partitions_statistics_req", ": table=" +
-          TableName.getQualified(catName, dbName, tblName));
-
-      PartitionsStatsResult result = null;
-      List<String> lowerCaseColNames = new ArrayList<>(request.getColNames().size());
-      for (String colName : request.getColNames()) {
-        lowerCaseColNames.add(colName.toLowerCase());
-      }
-      List<String> lowerCasePartNames = new ArrayList<>(request.getPartNames().size());
-      for (String partName : request.getPartNames()) {
-        lowerCasePartNames.add(lowerCaseConvertPartName(partName));
-      }
-      try {
-        List<ColumnStatistics> stats = getMS().getPartitionColumnStatistics(
-            catName, dbName, tblName, lowerCasePartNames, lowerCaseColNames,
-            request.getEngine(), request.isSetValidWriteIdList() ? request.getValidWriteIdList() : null);
-        Map<String, List<ColumnStatisticsObj>> map = new HashMap<>();
-        if (stats != null) {
-          for (ColumnStatistics stat : stats) {
-            // Note: stats compliance is not propagated to the client; instead, we just return nothing
-            //       if stats are not compliant for now. This won't work for stats merging, but that
-            //       is currently only done on metastore size (see set_aggr...).
-            //       For some optimizations we might make use of incorrect stats that are "better than
-            //       nothing", so this may change in future.
-            if (stat.isSetIsStatsCompliant() && !stat.isIsStatsCompliant()) continue;
-            map.put(stat.getStatsDesc().getPartName(), stat.getStatsObj());
-          }
-        }
-        result = new PartitionsStatsResult(map);
-      } finally {
-        endFunction("get_partitions_statistics_req", result == null, null, tblName);
-      }
-      return result;
-    }
-
-    @Override
-    public boolean update_table_column_statistics(ColumnStatistics colStats) throws TException {
-      // Deprecated API, won't work for transactional tables
-      return updateTableColumnStatsInternal(colStats, null, -1);
-    }
-
-    @Override
-    public SetPartitionsStatsResponse update_table_column_statistics_req(
-        SetPartitionsStatsRequest req) throws NoSuchObjectException,
-        InvalidObjectException, MetaException, InvalidInputException,
-        TException {
-      if (req.getColStatsSize() != 1) {
-        throw new InvalidInputException("Only one stats object expected");
-      }
-      if (req.isNeedMerge()) {
-        throw new InvalidInputException("Merge is not supported for non-aggregate stats");
-      }
-      ColumnStatistics colStats = req.getColStatsIterator().next();
-      boolean ret = updateTableColumnStatsInternal(colStats,
-          req.getValidWriteIdList(), req.getWriteId());
-      return new SetPartitionsStatsResponse(ret);
-    }
-
-    private boolean updateTableColumnStatsInternal(ColumnStatistics colStats,
-        String validWriteIds, long writeId)
-        throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException {
-      normalizeColStatsInput(colStats);
-
-      startFunction("write_column_statistics", ":  table=" + TableName.getQualified(
-          colStats.getStatsDesc().getCatName(), colStats.getStatsDesc().getDbName(),
-          colStats.getStatsDesc().getTableName()));
-
-      Map<String, String> parameters = null;
-      getMS().openTransaction();
-      boolean committed = false;
-      try {
-        parameters = getMS().updateTableColumnStatistics(colStats, validWriteIds, writeId);
-        if (parameters != null) {
-          Table tableObj = getMS().getTable(colStats.getStatsDesc().getCatName(),
-                                            colStats.getStatsDesc().getDbName(),
-                                            colStats.getStatsDesc().getTableName(), validWriteIds);
-          if (transactionalListeners != null && !transactionalListeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                    EventType.UPDATE_TABLE_COLUMN_STAT,
-                    new UpdateTableColumnStatEvent(colStats, tableObj, parameters,
-                            writeId, this));
-          }
-          if (!listeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(listeners,
-                    EventType.UPDATE_TABLE_COLUMN_STAT,
-                    new UpdateTableColumnStatEvent(colStats, tableObj, parameters,
-                            writeId,this));
-          }
-        }
-        committed = getMS().commitTransaction();
-      } finally {
-        if (!committed) {
-          getMS().rollbackTransaction();
-        }
-        endFunction("write_column_statistics", parameters != null, null,
-            colStats.getStatsDesc().getTableName());
-      }
-
-      return parameters != null;
-    }
-
-    private void normalizeColStatsInput(ColumnStatistics colStats) throws MetaException {
-      // TODO: is this really needed? this code is propagated from HIVE-1362 but most of it is useless.
-      ColumnStatisticsDesc statsDesc = colStats.getStatsDesc();
-      statsDesc.setCatName(statsDesc.isSetCatName() ? statsDesc.getCatName().toLowerCase() : getDefaultCatalog(conf));
-      statsDesc.setDbName(statsDesc.getDbName().toLowerCase());
-      statsDesc.setTableName(statsDesc.getTableName().toLowerCase());
-      statsDesc.setPartName(lowerCaseConvertPartName(statsDesc.getPartName()));
-      long time = System.currentTimeMillis() / 1000;
-      statsDesc.setLastAnalyzed(time);
-
-      for (ColumnStatisticsObj statsObj : colStats.getStatsObj()) {
-        statsObj.setColName(statsObj.getColName().toLowerCase());
-        statsObj.setColType(statsObj.getColType().toLowerCase());
-      }
-      colStats.setStatsDesc(statsDesc);
-      colStats.setStatsObj(colStats.getStatsObj());
-    }
-
-    private boolean updatePartitonColStatsInternal(Table tbl, ColumnStatistics colStats,
-        String validWriteIds, long writeId)
-        throws MetaException, InvalidObjectException, NoSuchObjectException, InvalidInputException {
-      normalizeColStatsInput(colStats);
-
-      ColumnStatisticsDesc csd = colStats.getStatsDesc();
-      String catName = csd.getCatName(), dbName = csd.getDbName(), tableName = csd.getTableName();
-      startFunction("write_partition_column_statistics", ":  db=" + dbName  + " table=" + tableName
-              + " part=" + csd.getPartName());
-
-      boolean ret = false;
-
-      Map<String, String> parameters;
-      List<String> partVals;
-      boolean committed = false;
-      getMS().openTransaction();
-      try {
-        if (tbl == null) {
-          tbl = getTable(catName, dbName, tableName);
-        }
-        partVals = getPartValsFromName(tbl, csd.getPartName());
-        parameters = getMS().updatePartitionColumnStatistics(colStats, partVals, validWriteIds, writeId);
-        if (parameters != null) {
-          if (transactionalListeners != null && !transactionalListeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-              EventType.UPDATE_PARTITION_COLUMN_STAT,
-              new UpdatePartitionColumnStatEvent(colStats, partVals, parameters, tbl,
-                      writeId, this));
-          }
-          if (!listeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(listeners,
-              EventType.UPDATE_PARTITION_COLUMN_STAT,
-              new UpdatePartitionColumnStatEvent(colStats, partVals, parameters, tbl,
-                      writeId, this));
-          }
-        }
-        committed = getMS().commitTransaction();
-      } finally {
-        if (!committed) {
-          getMS().rollbackTransaction();
-        }
-        endFunction("write_partition_column_statistics", ret != false, null, tableName);
-      }
-
-      return parameters != null;
-    }
-
-    @Override
-    public boolean update_partition_column_statistics(ColumnStatistics colStats) throws TException {
-      // Deprecated API.
-      return updatePartitonColStatsInternal(null, colStats, null, -1);
-    }
-
-
-    @Override
-    public SetPartitionsStatsResponse update_partition_column_statistics_req(
-        SetPartitionsStatsRequest req) throws NoSuchObjectException,
-        InvalidObjectException, MetaException, InvalidInputException,
-        TException {
-      if (req.getColStatsSize() != 1) {
-        throw new InvalidInputException("Only one stats object expected");
-      }
-      if (req.isNeedMerge()) {
-        throw new InvalidInputException("Merge is not supported for non-aggregate stats");
-      }
-      ColumnStatistics colStats = req.getColStatsIterator().next();
-      boolean ret = updatePartitonColStatsInternal(null, colStats,
-          req.getValidWriteIdList(), req.getWriteId());
-      return new SetPartitionsStatsResponse(ret);
-    }
-
-    @Override
-    public boolean delete_partition_column_statistics(String dbName, String tableName,
-        String partName, String colName, String engine) throws TException {
-      dbName = dbName.toLowerCase();
-      String[] parsedDbName = parseDbName(dbName, conf);
-      tableName = tableName.toLowerCase();
-      if (colName != null) {
-        colName = colName.toLowerCase();
-      }
-      String convertedPartName = lowerCaseConvertPartName(partName);
-      startFunction("delete_column_statistics_by_partition",": table=" +
-          TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName) +
-          " partition=" + convertedPartName + " column=" + colName);
-      boolean ret = false, committed = false;
-
-      getMS().openTransaction();
-      try {
-        List<String> partVals = getPartValsFromName(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName, convertedPartName);
-        Table table = getMS().getTable(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName);
-        // This API looks unused; if it were used we'd need to update stats state and write ID.
-        // We cannot just randomly nuke some txn stats.
-        if (TxnUtils.isTransactionalTable(table)) {
-          throw new MetaException("Cannot delete stats via this API for a transactional table");
-        }
-
-        ret = getMS().deletePartitionColumnStatistics(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName,
-            convertedPartName, partVals, colName, engine);
-        if (ret) {
-          if (transactionalListeners != null && !transactionalListeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                    EventType.DELETE_PARTITION_COLUMN_STAT,
-                    new DeletePartitionColumnStatEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName,
-                            convertedPartName, partVals, colName, engine, this));
-          }
-          if (!listeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(listeners,
-                    EventType.DELETE_PARTITION_COLUMN_STAT,
-                    new DeletePartitionColumnStatEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName,
-                            convertedPartName, partVals, colName, engine, this));
-          }
-        }
-        committed = getMS().commitTransaction();
-      } finally {
-        if (!committed) {
-          getMS().rollbackTransaction();
-        }
-        endFunction("delete_column_statistics_by_partition", ret != false, null, tableName);
-      }
-      return ret;
-    }
-
-    @Override
-    public boolean delete_table_column_statistics(String dbName, String tableName, String colName, String engine)
-        throws TException {
-      dbName = dbName.toLowerCase();
-      tableName = tableName.toLowerCase();
-
-      String[] parsedDbName = parseDbName(dbName, conf);
-
-      if (colName != null) {
-        colName = colName.toLowerCase();
-      }
-      startFunction("delete_column_statistics_by_table", ": table=" +
-          TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName) + " column=" +
-          colName);
-
-
-      boolean ret = false, committed = false;
-      getMS().openTransaction();
-      try {
-        Table table = getMS().getTable(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName);
-        // This API looks unused; if it were used we'd need to update stats state and write ID.
-        // We cannot just randomly nuke some txn stats.
-        if (TxnUtils.isTransactionalTable(table)) {
-          throw new MetaException("Cannot delete stats via this API for a transactional table");
-        }
-
-        ret = getMS().deleteTableColumnStatistics(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName, colName, engine);
-        if (ret) {
-          if (transactionalListeners != null && !transactionalListeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                    EventType.DELETE_TABLE_COLUMN_STAT,
-                    new DeleteTableColumnStatEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-                            tableName, colName, engine, this));
-          }
-          if (!listeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(listeners,
-                    EventType.DELETE_TABLE_COLUMN_STAT,
-                    new DeleteTableColumnStatEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-                            tableName, colName, engine, this));
-          }
-        }
-        committed = getMS().commitTransaction();
-      } finally {
-        if (!committed) {
-          getMS().rollbackTransaction();
-        }
-        endFunction("delete_column_statistics_by_table", ret != false, null, tableName);
-      }
-      return ret;
-    }
-
-    @Override
-    @Deprecated
-    public List<Partition> get_partitions_by_filter(final String dbName, final String tblName,
-                                                    final String filter, final short maxParts)
-        throws TException {
-      String[] parsedDbName = parseDbName(dbName, conf);
-      startTableFunction("get_partitions_by_filter", parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-          tblName);
-      fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName);
-      List<Partition> ret = null;
-      Exception ex = null;
-      try {
-        checkLimitNumberOfPartitionsByFilter(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tblName, filter, maxParts);
-
-        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName);
-
-        ret = getMS().getPartitionsByFilter(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName,
-            filter, maxParts);
-        ret = FilterUtils.filterPartitionsIfEnabled(isServerFilterEnabled, filterHook, ret);
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partitions_by_filter", ret != null, ex, tblName);
-      }
-      return ret;
-    }
-
-    @Override
-    @Deprecated
-    public List<PartitionSpec> get_part_specs_by_filter(final String dbName, final String tblName,
-                                                        final String filter, final int maxParts)
-        throws TException {
-
-      String[] parsedDbName = parseDbName(dbName, conf);
-      startTableFunction("get_partitions_by_filter_pspec", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName);
-
-      List<PartitionSpec> partitionSpecs = null;
-      try {
-        Table table = get_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName);
-        // Don't pass the parsed db name, as get_partitions_by_filter will parse it itself
-        List<Partition> partitions = get_partitions_by_filter(dbName, tblName, filter, (short) maxParts);
-
-        if (is_partition_spec_grouping_enabled(table)) {
-          partitionSpecs = MetaStoreServerUtils
-              .getPartitionspecsGroupedByStorageDescriptor(table, partitions);
-        }
-        else {
-          PartitionSpec pSpec = new PartitionSpec();
-          pSpec.setPartitionList(new PartitionListComposingSpec(partitions));
-          pSpec.setRootPath(table.getSd().getLocation());
-          pSpec.setCatName(parsedDbName[CAT_NAME]);
-          pSpec.setDbName(parsedDbName[DB_NAME]);
-          pSpec.setTableName(tblName);
-          partitionSpecs = Arrays.asList(pSpec);
-        }
-
-        return partitionSpecs;
-      }
-      finally {
-        endFunction("get_partitions_by_filter_pspec", partitionSpecs != null && !partitionSpecs.isEmpty(), null, tblName);
-      }
-    }
-
-    @Override
-    public PartitionsSpecByExprResult get_partitions_spec_by_expr(
-        PartitionsByExprRequest req) throws TException {
-      String dbName = req.getDbName(), tblName = req.getTblName();
-      String catName = req.isSetCatName() ? req.getCatName() : getDefaultCatalog(conf);
-      startTableFunction("get_partitions_spec_by_expr", catName, dbName, tblName);
-      fireReadTablePreEvent(catName, dbName, tblName);
-      PartitionsSpecByExprResult ret = null;
-      Exception ex = null;
-      try {
-        checkLimitNumberOfPartitionsByExpr(catName, dbName, tblName, req.getExpr(), UNLIMITED_MAX_PARTITIONS);
-        List<Partition> partitions = new LinkedList<>();
-        boolean hasUnknownPartitions = getMS().getPartitionsByExpr(catName, dbName, tblName,
-            req.getExpr(), req.getDefaultPartitionName(), req.getMaxParts(), partitions);
-        Table table = get_table_core(catName, dbName, tblName);
-        List<PartitionSpec> partitionSpecs =
-            MetaStoreServerUtils.getPartitionspecsGroupedByStorageDescriptor(table, partitions);
-        ret = new PartitionsSpecByExprResult(partitionSpecs, hasUnknownPartitions);
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partitions_spec_by_expr", ret != null, ex, tblName);
-      }
-      return ret;
-    }
-
-    @Override
-    public PartitionsByExprResult get_partitions_by_expr(
-        PartitionsByExprRequest req) throws TException {
-      String dbName = req.getDbName(), tblName = req.getTblName();
-      String catName = req.isSetCatName() ? req.getCatName() : getDefaultCatalog(conf);
-      startTableFunction("get_partitions_by_expr", catName, dbName, tblName);
-      fireReadTablePreEvent(catName, dbName, tblName);
-      PartitionsByExprResult ret = null;
-      Exception ex = null;
-      try {
-        checkLimitNumberOfPartitionsByExpr(catName, dbName, tblName, req.getExpr(), UNLIMITED_MAX_PARTITIONS);
-        List<Partition> partitions = new LinkedList<>();
-        boolean hasUnknownPartitions = getMS().getPartitionsByExpr(catName, dbName, tblName,
-            req.getExpr(), req.getDefaultPartitionName(), req.getMaxParts(), partitions);
-        ret = new PartitionsByExprResult(partitions, hasUnknownPartitions);
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partitions_by_expr", ret != null, ex, tblName);
-      }
-      return ret;
-    }
-
-    private void rethrowException(Exception e) throws TException {
-      // TODO: Both of these are TException, why do we need these separate clauses?
-      if (e instanceof MetaException) {
-        throw (MetaException) e;
-      } else if (e instanceof NoSuchObjectException) {
-        throw (NoSuchObjectException) e;
-      } else if (e instanceof TException) {
-        throw (TException) e;
-      } else {
-        throw newMetaException(e);
-      }
-    }
-
-    @Override
-    @Deprecated
-    public int get_num_partitions_by_filter(final String dbName,
-                                            final String tblName, final String filter)
-            throws TException {
-      String[] parsedDbName = parseDbName(dbName, conf);
-      if (parsedDbName[DB_NAME] == null || tblName == null) {
-        throw new MetaException("The DB and table name cannot be null.");
-      }
-      startTableFunction("get_num_partitions_by_filter", parsedDbName[CAT_NAME],
-          parsedDbName[DB_NAME], tblName);
-
-      int ret = -1;
-      Exception ex = null;
-      try {
-        ret = getMS().getNumPartitionsByFilter(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tblName, filter);
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_num_partitions_by_filter", ret != -1, ex, tblName);
-      }
-      return ret;
-    }
-
-    private int get_num_partitions_by_expr(final String catName, final String dbName,
-                                           final String tblName, final byte[] expr)
-        throws TException {
-      int ret = -1;
-      Exception ex = null;
-      try {
-        ret = getMS().getNumPartitionsByExpr(catName, dbName, tblName, expr);
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_num_partitions_by_expr", ret != -1, ex, tblName);
-      }
-      return ret;
-    }
-
-    @Override
-    @Deprecated
-    public List<Partition> get_partitions_by_names(final String dbName, final String tblName,
-                                                   final List<String> partNames)
-            throws TException {
-      return get_partitions_by_names(dbName, tblName, partNames);
-    }
-
-    @Override
-    public GetPartitionsByNamesResult get_partitions_by_names_req(GetPartitionsByNamesRequest gpbnr)
-            throws TException {
-      List<Partition> partitions = get_partitions_by_names(gpbnr.getDb_name(),
-              gpbnr.getTbl_name(), gpbnr.getNames(),
-              gpbnr.isSetGet_col_stats() && gpbnr.isGet_col_stats(), gpbnr.getEngine(),
-              gpbnr.getProcessorCapabilities(), gpbnr.getProcessorIdentifier());
-      return new GetPartitionsByNamesResult(partitions);
-    }
-
-    public List<Partition> get_partitions_by_names(final String dbName, final String tblName,
-           final List<String> partNames, boolean getColStats, String engine, String validWriteIdList)
-        throws TException {
-      return get_partitions_by_names(
-          dbName, tblName, partNames, getColStats, engine, null, null);
-    }
-
-    public List<Partition> get_partitions_by_names(final String dbName, final String tblName,
-           final List<String> partNames, boolean getColStats, String engine,
-           List<String> processorCapabilities, String processorId) throws TException {
-
-      String[] dbNameParts = parseDbName(dbName, conf);
-      String parsedCatName = dbNameParts[CAT_NAME];
-      String parsedDbName = dbNameParts[DB_NAME];
-      List<Partition> ret = null;
-      Table table = null;
-      Exception ex = null;
-      boolean success = false;
-      startTableFunction("get_partitions_by_names", parsedCatName, parsedDbName,
-              tblName);
-      try {
-        getMS().openTransaction();
-        authorizeTableForPartitionMetadata(parsedCatName, parsedDbName, tblName);
-
-        fireReadTablePreEvent(parsedCatName, parsedDbName, tblName);
-
-        ret = getMS().getPartitionsByNames(parsedCatName, parsedDbName, tblName, partNames);
-        ret = FilterUtils.filterPartitionsIfEnabled(isServerFilterEnabled, filterHook, ret);
-        table = getTable(parsedCatName, parsedDbName, tblName);
-
-        // If requested add column statistics in each of the partition objects
-        if (getColStats) {
-          // Since each partition may have stats collected for different set of columns, we
-          // request them separately.
-          for (Partition part: ret) {
-            String partName = Warehouse.makePartName(table.getPartitionKeys(), part.getValues());
-            List<ColumnStatistics> partColStatsList =
-                    getMS().getPartitionColumnStatistics(parsedCatName, parsedDbName, tblName,
-                            Collections.singletonList(partName),
-                            StatsSetupConst.getColumnsHavingStats(part.getParameters()),
-                            engine);
-            if (partColStatsList != null && !partColStatsList.isEmpty()) {
-              ColumnStatistics partColStats = partColStatsList.get(0);
-              if (partColStats != null) {
-                part.setColStats(partColStats);
-              }
-            }
-          }
-        }
-
-        if (processorCapabilities == null || processorCapabilities.size() == 0 ||
-              processorCapabilities.contains("MANAGERAWMETADATA")) {
-          LOG.info("Skipping translation for processor with " + processorId);
-        } else {
-          if (transformer != null) {
-            ret = transformer.transformPartitions(ret, table, processorCapabilities, processorId);
-          }
-        }
-        success = getMS().commitTransaction();
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        if (!success) {
-          getMS().rollbackTransaction();
-        }
-        endFunction("get_partitions_by_names", ret != null, ex, tblName);
-      }
-      return ret;
-    }
-
-    @Override
-    public PrincipalPrivilegeSet get_privilege_set(HiveObjectRef hiveObject, String userName,
-                                                   List<String> groupNames) throws TException {
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      String catName = hiveObject.isSetCatName() ? hiveObject.getCatName() : getDefaultCatalog(conf);
-      if (hiveObject.getObjectType() == HiveObjectType.COLUMN) {
-        String partName = getPartName(hiveObject);
-        return this.get_column_privilege_set(catName, hiveObject.getDbName(), hiveObject
-            .getObjectName(), partName, hiveObject.getColumnName(), userName,
-            groupNames);
-      } else if (hiveObject.getObjectType() == HiveObjectType.PARTITION) {
-        String partName = getPartName(hiveObject);
-        return this.get_partition_privilege_set(catName, hiveObject.getDbName(),
-            hiveObject.getObjectName(), partName, userName, groupNames);
-      } else if (hiveObject.getObjectType() == HiveObjectType.DATABASE) {
-        return this.get_db_privilege_set(catName, hiveObject.getDbName(), userName,
-            groupNames);
-      } else if (hiveObject.getObjectType() == HiveObjectType.TABLE) {
-        return this.get_table_privilege_set(catName, hiveObject.getDbName(), hiveObject
-            .getObjectName(), userName, groupNames);
-      } else if (hiveObject.getObjectType() == HiveObjectType.GLOBAL) {
-        return this.get_user_privilege_set(userName, groupNames);
-      }
-      return null;
-    }
-
-    private String getPartName(HiveObjectRef hiveObject) throws MetaException {
-      String partName = null;
-      List<String> partValue = hiveObject.getPartValues();
-      if (partValue != null && partValue.size() > 0) {
-        try {
-          String catName = hiveObject.isSetCatName() ? hiveObject.getCatName() :
-              getDefaultCatalog(conf);
-          Table table = get_table_core(catName, hiveObject.getDbName(), hiveObject
-              .getObjectName());
-          partName = Warehouse
-              .makePartName(table.getPartitionKeys(), partValue);
-        } catch (NoSuchObjectException e) {
-          throw new MetaException(e.getMessage());
-        }
-      }
-      return partName;
-    }
-
-    private PrincipalPrivilegeSet get_column_privilege_set(String catName, final String dbName,
-        final String tableName, final String partName, final String columnName,
-        final String userName, final List<String> groupNames) throws TException {
-      incrementCounter("get_column_privilege_set");
-
-      PrincipalPrivilegeSet ret;
-      try {
-        ret = getMS().getColumnPrivilegeSet(
-            catName, dbName, tableName, partName, columnName, userName, groupNames);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-      return ret;
-    }
-
-    private PrincipalPrivilegeSet get_db_privilege_set(String catName, final String dbName,
-        final String userName, final List<String> groupNames) throws TException {
-      incrementCounter("get_db_privilege_set");
-
-      PrincipalPrivilegeSet ret;
-      try {
-        ret = getMS().getDBPrivilegeSet(catName, dbName, userName, groupNames);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-      return ret;
-    }
-
-    private PrincipalPrivilegeSet get_partition_privilege_set(
-        String catName, final String dbName, final String tableName, final String partName,
-        final String userName, final List<String> groupNames)
-        throws TException {
-      incrementCounter("get_partition_privilege_set");
-
-      PrincipalPrivilegeSet ret;
-      try {
-        ret = getMS().getPartitionPrivilegeSet(catName, dbName, tableName, partName,
-            userName, groupNames);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-      return ret;
-    }
-
-    private PrincipalPrivilegeSet get_table_privilege_set(String catName, final String dbName,
-        final String tableName, final String userName,
-        final List<String> groupNames) throws TException {
-      incrementCounter("get_table_privilege_set");
-
-      PrincipalPrivilegeSet ret;
-      try {
-        ret = getMS().getTablePrivilegeSet(catName, dbName, tableName, userName,
-            groupNames);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-      return ret;
-    }
-
-    @Override
-    public boolean grant_role(final String roleName,
-        final String principalName, final PrincipalType principalType,
-        final String grantor, final PrincipalType grantorType, final boolean grantOption)
-        throws TException {
-      incrementCounter("add_role_member");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      if (PUBLIC.equals(roleName)) {
-        throw new MetaException("No user can be added to " + PUBLIC +". Since all users implicitly"
-        + " belong to " + PUBLIC + " role.");
-      }
-      Boolean ret;
-      try {
-        RawStore ms = getMS();
-        Role role = ms.getRole(roleName);
-        if(principalType == PrincipalType.ROLE){
-          //check if this grant statement will end up creating a cycle
-          if(isNewRoleAParent(principalName, roleName)){
-            throw new MetaException("Cannot grant role " + principalName + " to " + roleName +
-                " as " + roleName + " already belongs to the role " + principalName +
-                ". (no cycles allowed)");
-          }
-        }
-        ret = ms.grantRole(role, principalName, principalType, grantor, grantorType, grantOption);
-      } catch (MetaException e) {
-        throw e;
-      } catch (InvalidObjectException | NoSuchObjectException e) {
-        ret = false;
-        MetaStoreUtils.logAndThrowMetaException(e);
-      } catch (Exception e) {
-        throw new TException(e);
-      }
-      return ret;
-    }
-
-
-
-    /**
-     * Check if newRole is in parent hierarchy of curRole
-     * @param newRole
-     * @param curRole
-     * @return true if newRole is curRole or present in its hierarchy
-     * @throws MetaException
-     */
-    private boolean isNewRoleAParent(String newRole, String curRole) throws MetaException {
-      if(newRole.equals(curRole)){
-        return true;
-      }
-      //do this check recursively on all the parent roles of curRole
-      List<Role> parentRoleMaps = getMS().listRoles(curRole, PrincipalType.ROLE);
-      for(Role parentRole : parentRoleMaps){
-        if(isNewRoleAParent(newRole, parentRole.getRoleName())){
-          return true;
-        }
-      }
-      return false;
-    }
-
-    @Override
-    public List<Role> list_roles(final String principalName,
-        final PrincipalType principalType) throws TException {
-      incrementCounter("list_roles");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      return getMS().listRoles(principalName, principalType);
-    }
-
-    @Override
-    public boolean create_role(final Role role) throws TException {
-      incrementCounter("create_role");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      if (PUBLIC.equals(role.getRoleName())) {
-         throw new MetaException(PUBLIC + " role implicitly exists. It can't be created.");
-      }
-      Boolean ret;
-      try {
-        ret = getMS().addRole(role.getRoleName(), role.getOwnerName());
-      } catch (MetaException e) {
-        throw e;
-      } catch (InvalidObjectException | NoSuchObjectException e) {
-        ret = false;
-        MetaStoreUtils.logAndThrowMetaException(e);
-      } catch (Exception e) {
-        throw new TException(e);
-      }
-      return ret;
-    }
-
-    @Override
-    public boolean drop_role(final String roleName) throws TException {
-      incrementCounter("drop_role");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      if (ADMIN.equals(roleName) || PUBLIC.equals(roleName)) {
-        throw new MetaException(PUBLIC + "," + ADMIN + " roles can't be dropped.");
-      }
-      Boolean ret;
-      try {
-        ret = getMS().removeRole(roleName);
-      } catch (MetaException e) {
-        throw e;
-      } catch (NoSuchObjectException e) {
-        ret = false;
-        MetaStoreUtils.logAndThrowMetaException(e);
-      } catch (Exception e) {
-        throw new TException(e);
-      }
-      return ret;
-    }
-
-    @Override
-    public List<String> get_role_names() throws TException {
-      incrementCounter("get_role_names");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      List<String> ret;
-      try {
-        ret = getMS().listRoleNames();
-        return ret;
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-    }
-
-    @Override
-    public boolean grant_privileges(final PrivilegeBag privileges) throws TException {
-      incrementCounter("grant_privileges");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      Boolean ret;
-      try {
-        ret = getMS().grantPrivileges(privileges);
-      } catch (MetaException e) {
-        throw e;
-      } catch (InvalidObjectException | NoSuchObjectException e) {
-        ret = false;
-        MetaStoreUtils.logAndThrowMetaException(e);
-      } catch (Exception e) {
-        throw new TException(e);
-      }
-      return ret;
-    }
-
-    @Override
-    public boolean revoke_role(final String roleName, final String userName,
-        final PrincipalType principalType) throws TException {
-      return revoke_role(roleName, userName, principalType, false);
-    }
-
-    private boolean revoke_role(final String roleName, final String userName,
-        final PrincipalType principalType, boolean grantOption) throws TException {
-      incrementCounter("remove_role_member");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      if (PUBLIC.equals(roleName)) {
-        throw new MetaException(PUBLIC + " role can't be revoked.");
-      }
-      Boolean ret;
-      try {
-        RawStore ms = getMS();
-        Role mRole = ms.getRole(roleName);
-        ret = ms.revokeRole(mRole, userName, principalType, grantOption);
-      } catch (MetaException e) {
-        throw e;
-      } catch (NoSuchObjectException e) {
-        ret = false;
-        MetaStoreUtils.logAndThrowMetaException(e);
-      } catch (Exception e) {
-        throw new TException(e);
-      }
-      return ret;
-    }
-
-    @Override
-    public GrantRevokeRoleResponse grant_revoke_role(GrantRevokeRoleRequest request)
-        throws TException {
-      GrantRevokeRoleResponse response = new GrantRevokeRoleResponse();
-      boolean grantOption = false;
-      if (request.isSetGrantOption()) {
-        grantOption = request.isGrantOption();
-      }
-      switch (request.getRequestType()) {
-        case GRANT: {
-          boolean result = grant_role(request.getRoleName(),
-              request.getPrincipalName(), request.getPrincipalType(),
-              request.getGrantor(), request.getGrantorType(), grantOption);
-          response.setSuccess(result);
-          break;
-        }
-        case REVOKE: {
-          boolean result = revoke_role(request.getRoleName(), request.getPrincipalName(),
-              request.getPrincipalType(), grantOption);
-          response.setSuccess(result);
-          break;
-        }
-        default:
-          throw new MetaException("Unknown request type " + request.getRequestType());
-      }
-
-      return response;
-    }
-
-    @Override
-    public GrantRevokePrivilegeResponse grant_revoke_privileges(GrantRevokePrivilegeRequest request)
-        throws TException {
-      GrantRevokePrivilegeResponse response = new GrantRevokePrivilegeResponse();
-      switch (request.getRequestType()) {
-        case GRANT: {
-          boolean result = grant_privileges(request.getPrivileges());
-          response.setSuccess(result);
-          break;
-        }
-        case REVOKE: {
-          boolean revokeGrantOption = false;
-          if (request.isSetRevokeGrantOption()) {
-            revokeGrantOption = request.isRevokeGrantOption();
-          }
-          boolean result = revoke_privileges(request.getPrivileges(), revokeGrantOption);
-          response.setSuccess(result);
-          break;
-        }
-        default:
-          throw new MetaException("Unknown request type " + request.getRequestType());
-      }
-
-      return response;
-    }
-
-    @Override
-    public GrantRevokePrivilegeResponse refresh_privileges(HiveObjectRef objToRefresh, String authorizer,
-        GrantRevokePrivilegeRequest grantRequest)
-        throws TException {
-      incrementCounter("refresh_privileges");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      GrantRevokePrivilegeResponse response = new GrantRevokePrivilegeResponse();
-      try {
-        boolean result = getMS().refreshPrivileges(objToRefresh, authorizer, grantRequest.getPrivileges());
-        response.setSuccess(result);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-      return response;
-    }
-
-    @Override
-    public boolean revoke_privileges(final PrivilegeBag privileges) throws TException {
-      return revoke_privileges(privileges, false);
-    }
-
-    public boolean revoke_privileges(final PrivilegeBag privileges, boolean grantOption)
-        throws TException {
-      incrementCounter("revoke_privileges");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      Boolean ret;
-      try {
-        ret = getMS().revokePrivileges(privileges, grantOption);
-      } catch (MetaException e) {
-        throw e;
-      } catch (InvalidObjectException | NoSuchObjectException e) {
-        ret = false;
-        MetaStoreUtils.logAndThrowMetaException(e);
-      } catch (Exception e) {
-        throw new TException(e);
-      }
-      return ret;
-    }
-
-    private PrincipalPrivilegeSet get_user_privilege_set(final String userName,
-        final List<String> groupNames) throws TException {
-      incrementCounter("get_user_privilege_set");
-      PrincipalPrivilegeSet ret;
-      try {
-        ret = getMS().getUserPrivilegeSet(userName, groupNames);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-      return ret;
-    }
-
-    @Override
-    public List<HiveObjectPrivilege> list_privileges(String principalName,
-        PrincipalType principalType, HiveObjectRef hiveObject)
-        throws TException {
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      String catName = hiveObject.isSetCatName() ? hiveObject.getCatName() : getDefaultCatalog(conf);
-      if (hiveObject.getObjectType() == null) {
-        return getAllPrivileges(principalName, principalType, catName);
-      }
-      if (hiveObject.getObjectType() == HiveObjectType.GLOBAL) {
-        return list_global_privileges(principalName, principalType);
-      }
-      if (hiveObject.getObjectType() == HiveObjectType.DATABASE) {
-        return list_db_privileges(principalName, principalType, catName, hiveObject
-            .getDbName());
-      }
-      if (hiveObject.getObjectType() == HiveObjectType.TABLE) {
-        return list_table_privileges(principalName, principalType,
-            catName, hiveObject.getDbName(), hiveObject.getObjectName());
-      }
-      if (hiveObject.getObjectType() == HiveObjectType.PARTITION) {
-        return list_partition_privileges(principalName, principalType,
-            catName, hiveObject.getDbName(), hiveObject.getObjectName(), hiveObject
-            .getPartValues());
-      }
-      if (hiveObject.getObjectType() == HiveObjectType.COLUMN) {
-        if (hiveObject.getPartValues() == null || hiveObject.getPartValues().isEmpty()) {
-          return list_table_column_privileges(principalName, principalType,
-              catName, hiveObject.getDbName(), hiveObject.getObjectName(), hiveObject.getColumnName());
-        }
-        return list_partition_column_privileges(principalName, principalType,
-            catName, hiveObject.getDbName(), hiveObject.getObjectName(), hiveObject
-            .getPartValues(), hiveObject.getColumnName());
-      }
-      return null;
-    }
-
-    private List<HiveObjectPrivilege> getAllPrivileges(String principalName,
-        PrincipalType principalType, String catName) throws TException {
-      List<HiveObjectPrivilege> privs = new ArrayList<>();
-      privs.addAll(list_global_privileges(principalName, principalType));
-      privs.addAll(list_db_privileges(principalName, principalType, catName, null));
-      privs.addAll(list_table_privileges(principalName, principalType, catName, null, null));
-      privs.addAll(list_partition_privileges(principalName, principalType, catName, null, null, null));
-      privs.addAll(list_table_column_privileges(principalName, principalType, catName, null, null, null));
-      privs.addAll(list_partition_column_privileges(principalName, principalType,
-          catName, null, null, null, null));
-      return privs;
-    }
-
-    private List<HiveObjectPrivilege> list_table_column_privileges(
-        final String principalName, final PrincipalType principalType, String catName,
-        final String dbName, final String tableName, final String columnName) throws TException {
-      incrementCounter("list_table_column_privileges");
-
-      try {
-        if (dbName == null) {
-          return getMS().listPrincipalTableColumnGrantsAll(principalName, principalType);
-        }
-        if (principalName == null) {
-          return getMS().listTableColumnGrantsAll(catName, dbName, tableName, columnName);
-        }
-        return getMS().listPrincipalTableColumnGrants(principalName, principalType,
-                catName, dbName, tableName, columnName);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-    }
-
-    private List<HiveObjectPrivilege> list_partition_column_privileges(
-        final String principalName, final PrincipalType principalType,
-        String catName, final String dbName, final String tableName, final List<String> partValues,
-        final String columnName) throws TException {
-      incrementCounter("list_partition_column_privileges");
-
-      try {
-        if (dbName == null) {
-          return getMS().listPrincipalPartitionColumnGrantsAll(principalName, principalType);
-        }
-        Table tbl = get_table_core(catName, dbName, tableName);
-        String partName = Warehouse.makePartName(tbl.getPartitionKeys(), partValues);
-        if (principalName == null) {
-          return getMS().listPartitionColumnGrantsAll(catName, dbName, tableName, partName, columnName);
-        }
-
-        return getMS().listPrincipalPartitionColumnGrants(principalName, principalType, catName, dbName,
-                tableName, partValues, partName, columnName);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-    }
-
-    private List<HiveObjectPrivilege> list_db_privileges(final String principalName,
-        final PrincipalType principalType, String catName, final String dbName) throws TException {
-      incrementCounter("list_security_db_grant");
-
-      try {
-        if (dbName == null) {
-          return getMS().listPrincipalDBGrantsAll(principalName, principalType);
-        }
-        if (principalName == null) {
-          return getMS().listDBGrantsAll(catName, dbName);
-        } else {
-          return getMS().listPrincipalDBGrants(principalName, principalType, catName, dbName);
-        }
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-    }
-
-    private List<HiveObjectPrivilege> list_partition_privileges(
-        final String principalName, final PrincipalType principalType,
-        String catName, final String dbName, final String tableName, final List<String> partValues)
-        throws TException {
-      incrementCounter("list_security_partition_grant");
-
-      try {
-        if (dbName == null) {
-          return getMS().listPrincipalPartitionGrantsAll(principalName, principalType);
-        }
-        Table tbl = get_table_core(catName, dbName, tableName);
-        String partName = Warehouse.makePartName(tbl.getPartitionKeys(), partValues);
-        if (principalName == null) {
-          return getMS().listPartitionGrantsAll(catName, dbName, tableName, partName);
-        }
-        return getMS().listPrincipalPartitionGrants(
-            principalName, principalType, catName, dbName, tableName, partValues, partName);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-    }
-
-    private List<HiveObjectPrivilege> list_table_privileges(
-        final String principalName, final PrincipalType principalType,
-        String catName, final String dbName, final String tableName) throws TException {
-      incrementCounter("list_security_table_grant");
-
-      try {
-        if (dbName == null) {
-          return getMS().listPrincipalTableGrantsAll(principalName, principalType);
-        }
-        if (principalName == null) {
-          return getMS().listTableGrantsAll(catName, dbName, tableName);
-        }
-        return getMS().listAllTableGrants(principalName, principalType, catName, dbName, tableName);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-    }
-
-    private List<HiveObjectPrivilege> list_global_privileges(
-        final String principalName, final PrincipalType principalType) throws TException {
-      incrementCounter("list_security_user_grant");
-
-      try {
-        if (principalName == null) {
-          return getMS().listGlobalGrantsAll();
-        }
-        return getMS().listPrincipalGlobalGrants(principalName, principalType);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-    }
-
-    @Override
-    public void cancel_delegation_token(String token_str_form) throws TException {
-      startFunction("cancel_delegation_token");
-      boolean success = false;
-      Exception ex = null;
-      try {
-        HiveMetaStore.cancelDelegationToken(token_str_form);
-        success = true;
-      } catch (IOException e) {
-        ex = e;
-        throw new MetaException(e.getMessage());
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("cancel_delegation_token", success, ex);
-      }
-    }
-
-    @Override
-    public long renew_delegation_token(String token_str_form) throws TException {
-      startFunction("renew_delegation_token");
-      Long ret = null;
-      Exception ex = null;
-      try {
-        ret = HiveMetaStore.renewDelegationToken(token_str_form);
-      } catch (IOException e) {
-        ex = e;
-        throw new MetaException(e.getMessage());
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("renew_delegation_token", ret != null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public String get_delegation_token(String token_owner, String renewer_kerberos_principal_name)
-        throws TException {
-      startFunction("get_delegation_token");
-      String ret = null;
-      Exception ex = null;
-      try {
-        ret =
-            HiveMetaStore.getDelegationToken(token_owner,
-                renewer_kerberos_principal_name, getIPAddress());
-      } catch (IOException | InterruptedException e) {
-        ex = e;
-        throw new MetaException(e.getMessage());
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_delegation_token", ret != null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public boolean add_token(String token_identifier, String delegation_token) throws TException {
-      startFunction("add_token", ": " + token_identifier);
-      boolean ret = false;
-      Exception ex = null;
-      try {
-        ret = getMS().addToken(token_identifier, delegation_token);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("add_token", ret == true, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public boolean remove_token(String token_identifier) throws TException {
-      startFunction("remove_token", ": " + token_identifier);
-      boolean ret = false;
-      Exception ex = null;
-      try {
-        ret = getMS().removeToken(token_identifier);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("remove_token", ret == true, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public String get_token(String token_identifier) throws TException {
-      startFunction("get_token for", ": " + token_identifier);
-      String ret = null;
-      Exception ex = null;
-      try {
-        ret = getMS().getToken(token_identifier);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_token", ret != null, ex);
-      }
-      //Thrift cannot return null result
-      return ret == null ? "" : ret;
-    }
-
-    @Override
-    public List<String> get_all_token_identifiers() throws TException {
-      startFunction("get_all_token_identifiers.");
-      List<String> ret;
-      Exception ex = null;
-      try {
-        ret = getMS().getAllTokenIdentifiers();
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_all_token_identifiers.", ex == null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public int add_master_key(String key) throws TException {
-      startFunction("add_master_key.");
-      int ret;
-      Exception ex = null;
-      try {
-        ret = getMS().addMasterKey(key);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("add_master_key.", ex == null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public void update_master_key(int seq_number, String key) throws TException {
-      startFunction("update_master_key.");
-      Exception ex = null;
-      try {
-        getMS().updateMasterKey(seq_number, key);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("update_master_key.", ex == null, ex);
-      }
-    }
-
-    @Override
-    public boolean remove_master_key(int key_seq) throws TException {
-      startFunction("remove_master_key.");
-      Exception ex = null;
-      boolean ret;
-      try {
-        ret = getMS().removeMasterKey(key_seq);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("remove_master_key.", ex == null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public List<String> get_master_keys() throws TException {
-      startFunction("get_master_keys.");
-      Exception ex = null;
-      String [] ret = null;
-      try {
-        ret = getMS().getMasterKeys();
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_master_keys.", ret != null, ex);
-      }
-      return Arrays.asList(ret);
-    }
-
-    @Override
-    public void markPartitionForEvent(final String db_name, final String tbl_name,
-        final Map<String, String> partName, final PartitionEventType evtType) throws TException {
-
-      Table tbl = null;
-      Exception ex = null;
-      RawStore ms  = getMS();
-      boolean success = false;
-      try {
-        String[] parsedDbName = parseDbName(db_name, conf);
-        ms.openTransaction();
-        startPartitionFunction("markPartitionForEvent", parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tbl_name, partName);
-        firePreEvent(new PreLoadPartitionDoneEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tbl_name, partName, this));
-        tbl = ms.markPartitionForEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name,
-            partName, evtType);
-        if (null == tbl) {
-          throw new UnknownTableException("Table: " + tbl_name + " not found.");
-        }
-
-        if (transactionalListeners.size() > 0) {
-          LoadPartitionDoneEvent lpde = new LoadPartitionDoneEvent(true, tbl, partName, this);
-          for (MetaStoreEventListener transactionalListener : transactionalListeners) {
-            transactionalListener.onLoadPartitionDone(lpde);
-          }
-        }
-
-        success = ms.commitTransaction();
-        for (MetaStoreEventListener listener : listeners) {
-          listener.onLoadPartitionDone(new LoadPartitionDoneEvent(true, tbl, partName, this));
-        }
-      } catch (UnknownTableException | InvalidPartitionException | MetaException e) {
-        ex = e;
-        LOG.error("Exception caught in mark partition event ", e);
-        throw e;
-      } catch (Exception original) {
-        ex = original;
-        LOG.error("Exception caught in mark partition event ", original);
-        throw newMetaException(original);
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-
-        endFunction("markPartitionForEvent", tbl != null, ex, tbl_name);
-      }
-    }
-
-    @Override
-    public boolean isPartitionMarkedForEvent(final String db_name, final String tbl_name,
-        final Map<String, String> partName, final PartitionEventType evtType) throws TException {
-
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startPartitionFunction("isPartitionMarkedForEvent", parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-          tbl_name, partName);
-      Boolean ret = null;
-      Exception ex = null;
-      try {
-        ret = getMS().isPartitionMarkedForEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tbl_name, partName, evtType);
-      } catch (UnknownTableException | UnknownPartitionException | InvalidPartitionException | MetaException e) {
-        ex = e;
-        LOG.error("Exception caught for isPartitionMarkedForEvent ", e);
-        throw e;
-      } catch (Exception original) {
-        LOG.error("Exception caught for isPartitionMarkedForEvent ", original);
-        ex = original;
-        throw newMetaException(original);
-      } finally {
-                endFunction("isPartitionMarkedForEvent", ret != null, ex, tbl_name);
-      }
-
-      return ret;
-    }
-
-    @Override
-    public List<String> set_ugi(String username, List<String> groupNames) throws TException {
-      Collections.addAll(groupNames, username);
-      return groupNames;
-    }
-
-    @Override
-    public boolean partition_name_has_valid_characters(List<String> part_vals,
-        boolean throw_exception) throws TException {
-      startFunction("partition_name_has_valid_characters");
-      boolean ret;
-      Exception ex = null;
-      try {
-        if (throw_exception) {
-          MetaStoreServerUtils.validatePartitionNameCharacters(part_vals, partitionValidationPattern);
-          ret = true;
-        } else {
-          ret = MetaStoreServerUtils.partitionNameHasValidCharacters(part_vals,
-              partitionValidationPattern);
-        }
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("partition_name_has_valid_characters", true, ex);
-      }
-      return ret;
-    }
-
-    private static MetaException newMetaException(Exception e) {
-      if (e instanceof MetaException) {
-        return (MetaException)e;
-      }
-      MetaException me = new MetaException(e.toString());
-      me.initCause(e);
-      return me;
-    }
-
-    private void validateFunctionInfo(Function func) throws InvalidObjectException, MetaException {
-      if (func == null) {
-        throw new MetaException("Function cannot be null.");
-      }
-      if (func.getFunctionName() == null) {
-        throw new MetaException("Function name cannot be null.");
-      }
-      if (func.getDbName() == null) {
-        throw new MetaException("Database name in Function cannot be null.");
-      }
-      if (!MetaStoreUtils.validateName(func.getFunctionName(), null)) {
-        throw new InvalidObjectException(func.getFunctionName() + " is not a valid object name");
-      }
-      String className = func.getClassName();
-      if (className == null) {
-        throw new InvalidObjectException("Function class name cannot be null");
-      }
-      if (func.getOwnerType() == null) {
-        throw new MetaException("Function owner type cannot be null.");
-      }
-      if (func.getFunctionType() == null) {
-        throw new MetaException("Function type cannot be null.");
-      }
-    }
-
-    @Override
-    public void create_function(Function func) throws TException {
-      validateFunctionInfo(func);
-      boolean success = false;
-      RawStore ms = getMS();
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-      try {
-        String catName = func.isSetCatName() ? func.getCatName() : getDefaultCatalog(conf);
-        ms.openTransaction();
-        Database db = ms.getDatabase(catName, func.getDbName());
-        if (db == null) {
-          throw new NoSuchObjectException("The database " + func.getDbName() + " does not exist");
-        }
-
-        Function existingFunc = ms.getFunction(catName, func.getDbName(), func.getFunctionName());
-        if (existingFunc != null) {
-          throw new AlreadyExistsException(
-              "Function " + func.getFunctionName() + " already exists");
-        }
-
-        long time = System.currentTimeMillis() / 1000;
-        func.setCreateTime((int) time);
-        ms.createFunction(func);
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenerResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                    EventType.CREATE_FUNCTION,
-                                                    new CreateFunctionEvent(func, true, this));
-        }
-
-        success = ms.commitTransaction();
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.CREATE_FUNCTION,
-                                                new CreateFunctionEvent(func, success, this),
-                                                null,
-                                                transactionalListenerResponses, ms);
-        }
-      }
-    }
-
-    @Override
-    public void drop_function(String dbName, String funcName)
-        throws NoSuchObjectException, MetaException,
-        InvalidObjectException, InvalidInputException {
-      if (funcName == null) {
-        throw new MetaException("Function name cannot be null.");
-      }
-      boolean success = false;
-      Function func = null;
-      RawStore ms = getMS();
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-      String[] parsedDbName = parseDbName(dbName, conf);
-      if (parsedDbName[DB_NAME] == null) {
-        throw new MetaException("Database name cannot be null.");
-      }
-      try {
-        ms.openTransaction();
-        func = ms.getFunction(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], funcName);
-        if (func == null) {
-          throw new NoSuchObjectException("Function " + funcName + " does not exist");
-        }
-        Boolean needsCm =
-              ReplChangeManager.isSourceOfReplication(get_database_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]));
-
-        // if copy of jar to change management fails we fail the metastore transaction, since the
-        // user might delete the jars on HDFS externally after dropping the function, hence having
-        // a copy is required to allow incremental replication to work correctly.
-        if (func.getResourceUris() != null && !func.getResourceUris().isEmpty()) {
-          for (ResourceUri uri : func.getResourceUris()) {
-            if (uri.getUri().toLowerCase().startsWith("hdfs:") && needsCm) {
-              wh.addToChangeManagement(new Path(uri.getUri()));
-            }
-          }
-        }
-
-        // if the operation on metastore fails, we don't do anything in change management, but fail
-        // the metastore transaction, as having a copy of the jar in change management is not going
-        // to cause any problem, the cleaner thread will remove this when this jar expires.
-        ms.dropFunction(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], funcName);
-        if (transactionalListeners.size() > 0) {
-          transactionalListenerResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                    EventType.DROP_FUNCTION,
-                                                    new DropFunctionEvent(func, true, this));
-        }
-        success = ms.commitTransaction();
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-
-        if (listeners.size() > 0) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.DROP_FUNCTION,
-                                                new DropFunctionEvent(func, success, this),
-                                                null,
-                                                transactionalListenerResponses, ms);
-        }
-      }
-    }
-
-    @Override
-    public void alter_function(String dbName, String funcName, Function newFunc) throws TException {
-      String[] parsedDbName = parseDbName(dbName, conf);
-      validateForAlterFunction(parsedDbName[DB_NAME], funcName, newFunc);
-      boolean success = false;
-      RawStore ms = getMS();
-      try {
-        ms.openTransaction();
-        ms.alterFunction(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], funcName, newFunc);
-        success = ms.commitTransaction();
-      } catch (InvalidObjectException e) {
-        // Throwing MetaException instead of InvalidObjectException as the InvalidObjectException
-        // is not defined for the alter_function method in the Thrift interface.
-        throwMetaException(e);
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-      }
-    }
-
-    private void validateForAlterFunction(String dbName, String funcName, Function newFunc)
-        throws MetaException {
-      if (dbName == null || funcName == null) {
-        throw new MetaException("Database and function name cannot be null.");
-      }
-      try {
-        validateFunctionInfo(newFunc);
-      } catch (InvalidObjectException e) {
-        // The validateFunctionInfo method is used by the create and alter function methods as well
-        // and it can throw InvalidObjectException. But the InvalidObjectException is not defined
-        // for the alter_function method in the Thrift interface, therefore a TApplicationException
-        // will occur at the caller side. Re-throwing the InvalidObjectException as MetaException
-        // would eliminate the TApplicationException at caller side.
-        throw newMetaException(e);
-      }
-    }
-
-    @Override
-    public List<String> get_functions(String dbName, String pattern)
-        throws MetaException {
-      startFunction("get_functions", ": db=" + dbName + " pat=" + pattern);
-
-      RawStore ms = getMS();
-      Exception ex = null;
-      List<String> funcNames = null;
-      String[] parsedDbName = parseDbName(dbName, conf);
-
-      try {
-        funcNames = ms.getFunctions(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], pattern);
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_functions", funcNames != null, ex);
-      }
-
-      return funcNames;
-    }
-
-    @Override
-    public GetAllFunctionsResponse get_all_functions()
-            throws MetaException {
-      GetAllFunctionsResponse response = new GetAllFunctionsResponse();
-      startFunction("get_all_functions");
-      RawStore ms = getMS();
-      List<Function> allFunctions = null;
-      Exception ex = null;
-      try {
-        // Leaving this as the 'hive' catalog (rather than choosing the default from the
-        // configuration) because all the default UDFs are in that catalog, and I think that's
-        // would people really want here.
-        allFunctions = ms.getAllFunctions(DEFAULT_CATALOG_NAME);
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_all_functions", allFunctions != null, ex);
-      }
-      response.setFunctions(allFunctions);
-      return response;
-    }
-
-    @Override
-    public Function get_function(String dbName, String funcName) throws TException {
-      if (dbName == null || funcName == null) {
-        throw new MetaException("Database and function name cannot be null.");
-      }
-      startFunction("get_function", ": " + dbName + "." + funcName);
-
-      RawStore ms = getMS();
-      Function func = null;
-      Exception ex = null;
-      String[] parsedDbName = parseDbName(dbName, conf);
-
-      try {
-        func = ms.getFunction(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], funcName);
-        if (func == null) {
-          throw new NoSuchObjectException(
-              "Function " + dbName + "." + funcName + " does not exist");
-        }
-      } catch (NoSuchObjectException e) {
-        ex = e;
-        rethrowException(e);
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_function", func != null, ex);
-      }
-
-      return func;
-    }
-
-    // Transaction and locking methods
-    @Override
-    public GetOpenTxnsResponse get_open_txns() throws TException {
-      return getTxnHandler().getOpenTxns();
-    }
-
-    @Override
-    public GetOpenTxnsResponse get_open_txns_req(GetOpenTxnsRequest getOpenTxnsRequest) throws TException {
-      return getTxnHandler().getOpenTxns(getOpenTxnsRequest.getExcludeTxnTypes());
-    }
-
-    // Transaction and locking methods
-    @Override
-    public GetOpenTxnsInfoResponse get_open_txns_info() throws TException {
-      return getTxnHandler().getOpenTxnsInfo();
-    }
-
-    @Override
-    public OpenTxnsResponse open_txns(OpenTxnRequest rqst) throws TException {
-      OpenTxnsResponse response = getTxnHandler().openTxns(rqst);
-      List<Long> txnIds = response.getTxn_ids();
-      if (txnIds != null && listeners != null && !listeners.isEmpty()) {
-        MetaStoreListenerNotifier.notifyEvent(listeners, EventType.OPEN_TXN,
-            new OpenTxnEvent(txnIds, this));
-      }
-      return response;
-    }
-
-    @Override
-    public void abort_txn(AbortTxnRequest rqst) throws TException {
-      getTxnHandler().abortTxn(rqst);
-      if (listeners != null && !listeners.isEmpty()) {
-        MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ABORT_TXN,
-                new AbortTxnEvent(rqst.getTxnid(), this));
-      }
-    }
-
-    @Override
-    public void abort_txns(AbortTxnsRequest rqst) throws TException {
-      getTxnHandler().abortTxns(rqst);
-      if (listeners != null && !listeners.isEmpty()) {
-        for (Long txnId : rqst.getTxn_ids()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ABORT_TXN,
-                  new AbortTxnEvent(txnId, this));
-        }
-      }
-    }
-
-    @Override
-    public long get_latest_txnid_in_conflict(long txnId) throws MetaException {
-      return getTxnHandler().getLatestTxnIdInConflict(txnId);
-    }
-
-    @Override
-    public void commit_txn(CommitTxnRequest rqst) throws TException {
-      // in replication flow, the write notification log table will be updated here.
-      if (rqst.isSetWriteEventInfos()) {
-        long targetTxnId = getTxnHandler().getTargetTxnId(rqst.getReplPolicy(), rqst.getTxnid());
-        if (targetTxnId < 0) {
-          //looks like a retry
-          return;
-        }
-        for (WriteEventInfo writeEventInfo : rqst.getWriteEventInfos()) {
-          String[] filesAdded = ReplChangeManager.getListFromSeparatedString(writeEventInfo.getFiles());
-          List<String> partitionValue = null;
-          Partition ptnObj = null;
-          String root;
-          Table tbl = getTblObject(writeEventInfo.getDatabase(), writeEventInfo.getTable());
-
-          if (writeEventInfo.getPartition() != null && !writeEventInfo.getPartition().isEmpty()) {
-            partitionValue = Warehouse.getPartValuesFromPartName(writeEventInfo.getPartition());
-            ptnObj = getPartitionObj(writeEventInfo.getDatabase(), writeEventInfo.getTable(), partitionValue, tbl);
-            root = ptnObj.getSd().getLocation();
-          } else {
-            root = tbl.getSd().getLocation();
-          }
-
-          InsertEventRequestData insertData = new InsertEventRequestData();
-          insertData.setReplace(true);
-
-          // The files in the commit txn message during load will have files with path corresponding to source
-          // warehouse. Need to transform them to target warehouse using table or partition object location.
-          for (String file : filesAdded) {
-            String[] decodedPath = ReplChangeManager.decodeFileUri(file);
-            String name = (new Path(decodedPath[0])).getName();
-            Path newPath = FileUtils.getTransformedPath(name, decodedPath[3], root);
-            insertData.addToFilesAdded(newPath.toUri().toString());
-            insertData.addToSubDirectoryList(decodedPath[3]);
-            try {
-              insertData.addToFilesAddedChecksum(ReplChangeManager.checksumFor(newPath, newPath.getFileSystem(conf)));
-            } catch (IOException e) {
-              LOG.error("failed to get checksum for the file " + newPath + " with error: " + e.getMessage());
-              throw new TException(e.getMessage());
-            }
-          }
-
-          WriteNotificationLogRequest wnRqst = new WriteNotificationLogRequest(targetTxnId,
-                  writeEventInfo.getWriteId(), writeEventInfo.getDatabase(), writeEventInfo.getTable(), insertData);
-          if (partitionValue != null) {
-            wnRqst.setPartitionVals(partitionValue);
-          }
-          addTxnWriteNotificationLog(tbl, ptnObj, wnRqst);
-        }
-      }
-      getTxnHandler().commitTxn(rqst);
-      if (listeners != null && !listeners.isEmpty()) {
-        MetaStoreListenerNotifier.notifyEvent(listeners, EventType.COMMIT_TXN,
-                new CommitTxnEvent(rqst.getTxnid(), this));
-        Optional<CompactionInfo> compactionInfo = getTxnHandler().getCompactionByTxnId(rqst.getTxnid());
-        if (compactionInfo.isPresent()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners, EventType.COMMIT_COMPACTION,
-              new CommitCompactionEvent(rqst.getTxnid(), compactionInfo.get(), this));
-        }
-      }
-    }
-
-    @Override
-    public void repl_tbl_writeid_state(ReplTblWriteIdStateRequest rqst) throws TException {
-      getTxnHandler().replTableWriteIdState(rqst);
-    }
-
-    @Override
-    public GetValidWriteIdsResponse get_valid_write_ids(GetValidWriteIdsRequest rqst) throws TException {
-      return getTxnHandler().getValidWriteIds(rqst);
-    }
-
-    @Override
-    public void set_hadoop_jobid(String jobId, long cqId) {
-      getTxnHandler().setHadoopJobId(jobId, cqId);
-    }
-
-    @Override
-    public OptionalCompactionInfoStruct find_next_compact(String workerId) throws MetaException{
-      return CompactionInfo.compactionInfoToOptionalStruct(
-          getTxnHandler().findNextToCompact(workerId));
-    }
-
-    @Override
-    public void mark_cleaned(CompactionInfoStruct cr) throws MetaException {
-      getTxnHandler().markCleaned(CompactionInfo.compactionStructToInfo(cr));
-    }
-
-    @Override
-    public void mark_compacted(CompactionInfoStruct cr) throws MetaException {
-      getTxnHandler().markCompacted(CompactionInfo.compactionStructToInfo(cr));
-    }
-
-    @Override
-    public void mark_failed(CompactionInfoStruct cr) throws MetaException {
-      getTxnHandler().markFailed(CompactionInfo.compactionStructToInfo(cr));
-    }
-
-    @Override
-    public List<String> find_columns_with_stats(CompactionInfoStruct cr) throws MetaException {
-      return getTxnHandler().findColumnsWithStats(CompactionInfo.compactionStructToInfo(cr));
-    }
-
-    @Override
-    public void update_compactor_state(CompactionInfoStruct cr, long highWaterMark) throws MetaException {
-      getTxnHandler().updateCompactorState(
-          CompactionInfo.compactionStructToInfo(cr), highWaterMark);
-    }
-
-    @Override
-    public AllocateTableWriteIdsResponse allocate_table_write_ids(
-            AllocateTableWriteIdsRequest rqst) throws TException {
-      AllocateTableWriteIdsResponse response = getTxnHandler().allocateTableWriteIds(rqst);
-      if (listeners != null && !listeners.isEmpty()) {
-        MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ALLOC_WRITE_ID,
-                new AllocWriteIdEvent(response.getTxnToWriteIds(), rqst.getDbName(),
-                        rqst.getTableName(), this));
-      }
-      return response;
-    }
-
-    @Override
-    public MaxAllocatedTableWriteIdResponse get_max_allocated_table_write_id(MaxAllocatedTableWriteIdRequest rqst)
-        throws MetaException {
-      return getTxnHandler().getMaxAllocatedTableWrited(rqst);
-    }
-
-    @Override
-    public void seed_write_id(SeedTableWriteIdsRequest rqst) throws MetaException {
-      getTxnHandler().seedWriteId(rqst);
-    }
-
-    @Override
-    public void seed_txn_id(SeedTxnIdRequest rqst) throws MetaException {
-      getTxnHandler().seedTxnId(rqst);
-    }
-
-    private void addTxnWriteNotificationLog(Table tableObj, Partition ptnObj, WriteNotificationLogRequest rqst)
-            throws MetaException {
-      String partition = ""; //Empty string is an invalid partition name. Can be used for non partitioned table.
-      if (ptnObj != null) {
-        partition = Warehouse.makePartName(tableObj.getPartitionKeys(), rqst.getPartitionVals());
-      }
-      AcidWriteEvent event = new AcidWriteEvent(partition, tableObj, ptnObj, rqst);
-      getTxnHandler().addWriteNotificationLog(event);
-      if (listeners != null && !listeners.isEmpty()) {
-        MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ACID_WRITE, event);
-      }
-    }
-
-    private Table getTblObject(String db, String table) throws MetaException, NoSuchObjectException {
-      GetTableRequest req = new GetTableRequest(db, table);
-      req.setCapabilities(new ClientCapabilities(Lists.newArrayList(ClientCapability.TEST_CAPABILITY, ClientCapability.INSERT_ONLY_TABLES)));
-      return get_table_req(req).getTable();
-    }
-
-    private Partition getPartitionObj(String db, String table, List<String> partitionVals, Table tableObj)
-            throws MetaException, NoSuchObjectException {
-      if (tableObj.isSetPartitionKeys() && !tableObj.getPartitionKeys().isEmpty()) {
-        return get_partition(db, table, partitionVals);
-      }
-      return null;
-    }
-
-    @Override
-    public WriteNotificationLogResponse add_write_notification_log(WriteNotificationLogRequest rqst)
-            throws TException {
-      Table tableObj = getTblObject(rqst.getDb(), rqst.getTable());
-      Partition ptnObj = getPartitionObj(rqst.getDb(), rqst.getTable(), rqst.getPartitionVals(), tableObj);
-      addTxnWriteNotificationLog(tableObj, ptnObj, rqst);
-      return new WriteNotificationLogResponse();
-    }
-
-    @Override
-    public LockResponse lock(LockRequest rqst) throws TException {
-      return getTxnHandler().lock(rqst);
-    }
-
-    @Override
-    public LockResponse check_lock(CheckLockRequest rqst) throws TException {
-      return getTxnHandler().checkLock(rqst);
-    }
-
-    @Override
-    public void unlock(UnlockRequest rqst) throws TException {
-      getTxnHandler().unlock(rqst);
-    }
-
-    @Override
-    public ShowLocksResponse show_locks(ShowLocksRequest rqst) throws TException {
-      return getTxnHandler().showLocks(rqst);
-    }
-
-    @Override
-    public void heartbeat(HeartbeatRequest ids) throws TException {
-      getTxnHandler().heartbeat(ids);
-    }
-
-    @Override
-    public HeartbeatTxnRangeResponse heartbeat_txn_range(HeartbeatTxnRangeRequest rqst)
-      throws TException {
-      return getTxnHandler().heartbeatTxnRange(rqst);
-    }
-    @Deprecated
-    @Override
-    public void compact(CompactionRequest rqst) throws TException {
-      compact2(rqst);
-    }
-    @Override
-    public CompactionResponse compact2(CompactionRequest rqst) throws TException {
-      return getTxnHandler().compact(rqst);
-    }
-
-    @Override
-    public ShowCompactResponse show_compact(ShowCompactRequest rqst) throws TException {
-      ShowCompactResponse response = getTxnHandler().showCompact(rqst);
-      response.setCompacts(FilterUtils.filterCompactionsIfEnabled(isServerFilterEnabled,
-              filterHook, getDefaultCatalog(conf), response.getCompacts()));
-      return response;
-    }
-
-    @Override
-    public void flushCache() throws TException {
-      getMS().flushCache();
-    }
-
-    @Override
-    public void add_dynamic_partitions(AddDynamicPartitions rqst) throws TException {
-      getTxnHandler().addDynamicPartitions(rqst);
-    }
-
-    @Override
-    public GetPrincipalsInRoleResponse get_principals_in_role(GetPrincipalsInRoleRequest request)
-        throws TException {
-
-      incrementCounter("get_principals_in_role");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      Exception ex = null;
-      GetPrincipalsInRoleResponse response = null;
-      try {
-        response = new GetPrincipalsInRoleResponse(getMS().listRoleMembers(request.getRoleName()));
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_principals_in_role", ex == null, ex);
-      }
-      return response;
-    }
-
-    @Override
-    public GetRoleGrantsForPrincipalResponse get_role_grants_for_principal(
-        GetRoleGrantsForPrincipalRequest request) throws TException {
-
-      incrementCounter("get_role_grants_for_principal");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      Exception ex = null;
-      List<RolePrincipalGrant> roleMaps = null;
-      try {
-        roleMaps = getMS().listRolesWithGrants(request.getPrincipal_name(), request.getPrincipal_type());
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_role_grants_for_principal", ex == null, ex);
-      }
-
-      //List<RolePrincipalGrant> roleGrantsList = getRolePrincipalGrants(roleMaps);
-      return new GetRoleGrantsForPrincipalResponse(roleMaps);
-    }
-
-    @Override
-    public AggrStats get_aggr_stats_for(PartitionsStatsRequest request) throws TException {
-      String catName = request.isSetCatName() ? request.getCatName().toLowerCase() :
-          getDefaultCatalog(conf);
-      String dbName = request.getDbName().toLowerCase();
-      String tblName = request.getTblName().toLowerCase();
-      startFunction("get_aggr_stats_for", ": table=" +
-          TableName.getQualified(catName, dbName, tblName));
-
-      List<String> lowerCaseColNames = new ArrayList<>(request.getColNames().size());
-      for (String colName : request.getColNames()) {
-        lowerCaseColNames.add(colName.toLowerCase());
-      }
-      List<String> lowerCasePartNames = new ArrayList<>(request.getPartNames().size());
-      for (String partName : request.getPartNames()) {
-        lowerCasePartNames.add(lowerCaseConvertPartName(partName));
-      }
-      AggrStats aggrStats = null;
-
-      try {
-        aggrStats = getMS().get_aggr_stats_for(catName, dbName, tblName,
-            lowerCasePartNames, lowerCaseColNames, request.getEngine(), request.getValidWriteIdList());
-        return aggrStats;
-      } finally {
-          endFunction("get_aggr_stats_for", aggrStats == null, null, request.getTblName());
-      }
-
-    }
-
-    @Override
-    public boolean set_aggr_stats_for(SetPartitionsStatsRequest request) throws TException {
-      boolean ret = true;
-      List<ColumnStatistics> csNews = request.getColStats();
-      if (csNews == null || csNews.isEmpty()) {
-        return ret;
-      }
-      // figure out if it is table level or partition level
-      ColumnStatistics firstColStats = csNews.get(0);
-      ColumnStatisticsDesc statsDesc = firstColStats.getStatsDesc();
-      String catName = statsDesc.isSetCatName() ? statsDesc.getCatName() : getDefaultCatalog(conf);
-      String dbName = statsDesc.getDbName();
-      String tableName = statsDesc.getTableName();
-      List<String> colNames = new ArrayList<>();
-      for (ColumnStatisticsObj obj : firstColStats.getStatsObj()) {
-        colNames.add(obj.getColName());
-      }
-      if (statsDesc.isIsTblLevel()) {
-        // there should be only one ColumnStatistics
-        if (request.getColStatsSize() != 1) {
-          throw new MetaException(
-              "Expecting only 1 ColumnStatistics for table's column stats, but find "
-                  + request.getColStatsSize());
-        }
-        if (request.isSetNeedMerge() && request.isNeedMerge()) {
-          return updateTableColumnStatsWithMerge(catName, dbName, tableName, colNames, request);
-        } else {
-          // This is the overwrite case, we do not care about the accuracy.
-          return updateTableColumnStatsInternal(firstColStats,
-              request.getValidWriteIdList(), request.getWriteId());
-        }
-      } else {
-        // partition level column stats merging
-        // note that we may have two or more duplicate partition names.
-        // see autoColumnStats_2.q under TestMiniLlapLocalCliDriver
-        Map<String, ColumnStatistics> newStatsMap = new HashMap<>();
-        for (ColumnStatistics csNew : csNews) {
-          String partName = csNew.getStatsDesc().getPartName();
-          if (newStatsMap.containsKey(partName)) {
-            MetaStoreServerUtils.mergeColStats(csNew, newStatsMap.get(partName));
-          }
-          newStatsMap.put(partName, csNew);
-        }
-
-        if (request.isSetNeedMerge() && request.isNeedMerge()) {
-          ret = updatePartColumnStatsWithMerge(catName, dbName, tableName,
-              colNames, newStatsMap, request);
-        } else { // No merge.
-          Table t = getTable(catName, dbName, tableName);
-          for (Entry<String, ColumnStatistics> entry : newStatsMap.entrySet()) {
-            // We don't short-circuit on errors here anymore. That can leave acid stats invalid.
-            ret = updatePartitonColStatsInternal(t, entry.getValue(),
-                request.getValidWriteIdList(), request.getWriteId()) && ret;
-          }
-        }
-      }
-      return ret;
-    }
-
-    private boolean updatePartColumnStatsWithMerge(String catName, String dbName, String tableName,
-      List<String> colNames, Map<String, ColumnStatistics> newStatsMap, SetPartitionsStatsRequest request)
-          throws MetaException, NoSuchObjectException, InvalidObjectException, InvalidInputException {
-      RawStore ms = getMS();
-      ms.openTransaction();
-      boolean isCommitted = false, result = false;
-      try {
-        // a single call to get all column stats for all partitions
-        List<String> partitionNames = new ArrayList<>();
-        partitionNames.addAll(newStatsMap.keySet());
-        List<ColumnStatistics> csOlds = ms.getPartitionColumnStatistics(catName, dbName, tableName,
-            partitionNames, colNames, request.getEngine(), request.getValidWriteIdList());
-        if (newStatsMap.values().size() != csOlds.size()) {
-          // some of the partitions miss stats.
-          LOG.debug("Some of the partitions miss stats.");
-        }
-        Map<String, ColumnStatistics> oldStatsMap = new HashMap<>();
-        for (ColumnStatistics csOld : csOlds) {
-          oldStatsMap.put(csOld.getStatsDesc().getPartName(), csOld);
-        }
-
-        // another single call to get all the partition objects
-        List<Partition> partitions = ms.getPartitionsByNames(catName, dbName, tableName, partitionNames);
-        Map<String, Partition> mapToPart = new HashMap<>();
-        for (int index = 0; index < partitionNames.size(); index++) {
-          mapToPart.put(partitionNames.get(index), partitions.get(index));
-        }
-
-        Table t = getTable(catName, dbName, tableName);
-        for (Entry<String, ColumnStatistics> entry : newStatsMap.entrySet()) {
-          ColumnStatistics csNew = entry.getValue();
-          ColumnStatistics csOld = oldStatsMap.get(entry.getKey());
-          boolean isInvalidTxnStats = csOld != null
-              && csOld.isSetIsStatsCompliant() && !csOld.isIsStatsCompliant();
-          Partition part = mapToPart.get(entry.getKey());
-          if (isInvalidTxnStats) {
-            // No columns can be merged; a shortcut for getMergableCols.
-            csNew.setStatsObj(Lists.newArrayList());
-          } else {
-            // we first use getParameters() to prune the stats
-            MetaStoreServerUtils.getMergableCols(csNew, part.getParameters());
-            // we merge those that can be merged
-            if (csOld != null && csOld.getStatsObjSize() != 0 && !csNew.getStatsObj().isEmpty()) {
-              MetaStoreServerUtils.mergeColStats(csNew, csOld);
-            }
-          }
-
-          if (!csNew.getStatsObj().isEmpty()) {
-            // We don't short-circuit on errors here anymore. That can leave acid stats invalid.
-            result = updatePartitonColStatsInternal(t, csNew,
-                request.getValidWriteIdList(), request.getWriteId()) && result;
-          } else if (isInvalidTxnStats) {
-            // For now because the stats state is such as it is, we will invalidate everything.
-            // Overall the sematics here are not clear - we could invalide only some columns, but does
-            // that make any physical sense? Could query affect some columns but not others?
-            part.setWriteId(request.getWriteId());
-            StatsSetupConst.clearColumnStatsState(part.getParameters());
-            StatsSetupConst.setBasicStatsState(part.getParameters(), StatsSetupConst.FALSE);
-            ms.alterPartition(catName, dbName, tableName, part.getValues(), part,
-                request.getValidWriteIdList());
-            result = false;
-          } else {
-            // TODO: why doesn't the original call for non acid tables invalidate the stats?
-            LOG.debug("All the column stats " + csNew.getStatsDesc().getPartName()
-                + " are not accurate to merge.");
-          }
-        }
-        ms.commitTransaction();
-        isCommitted = true;
-      } finally {
-        if (!isCommitted) {
-          ms.rollbackTransaction();
-        }
-      }
-      return result;
-    }
-
-
-    private boolean updateTableColumnStatsWithMerge(String catName, String dbName, String tableName,
-        List<String> colNames, SetPartitionsStatsRequest request) throws MetaException,
-        NoSuchObjectException, InvalidObjectException, InvalidInputException {
-      ColumnStatistics firstColStats = request.getColStats().get(0);
-      RawStore ms = getMS();
-      ms.openTransaction();
-      boolean isCommitted = false, result = false;
-      try {
-        ColumnStatistics csOld = ms.getTableColumnStatistics(catName, dbName, tableName, colNames,
-            request.getEngine(), request.getValidWriteIdList());
-        // we first use the valid stats list to prune the stats
-        boolean isInvalidTxnStats = csOld != null
-            && csOld.isSetIsStatsCompliant() && !csOld.isIsStatsCompliant();
-        if (isInvalidTxnStats) {
-          // No columns can be merged; a shortcut for getMergableCols.
-          firstColStats.setStatsObj(Lists.newArrayList());
-        } else {
-          Table t = getTable(catName, dbName, tableName);
-          MetaStoreServerUtils.getMergableCols(firstColStats, t.getParameters());
-
-          // we merge those that can be merged
-          if (csOld != null && csOld.getStatsObjSize() != 0 && !firstColStats.getStatsObj().isEmpty()) {
-            MetaStoreServerUtils.mergeColStats(firstColStats, csOld);
-          }
-        }
-
-        if (!firstColStats.getStatsObj().isEmpty()) {
-          result = updateTableColumnStatsInternal(firstColStats,
-              request.getValidWriteIdList(), request.getWriteId());
-        } else if (isInvalidTxnStats) {
-          // For now because the stats state is such as it is, we will invalidate everything.
-          // Overall the sematics here are not clear - we could invalide only some columns, but does
-          // that make any physical sense? Could query affect some columns but not others?
-          Table t = getTable(catName, dbName, tableName);
-          t.setWriteId(request.getWriteId());
-          StatsSetupConst.clearColumnStatsState(t.getParameters());
-          StatsSetupConst.setBasicStatsState(t.getParameters(), StatsSetupConst.FALSE);
-          ms.alterTable(catName, dbName, tableName, t, request.getValidWriteIdList());
-        } else {
-          // TODO: why doesn't the original call for non acid tables invalidate the stats?
-          LOG.debug("All the column stats are not accurate to merge.");
-          result = true;
-        }
-
-        ms.commitTransaction();
-        isCommitted = true;
-      } finally {
-        if (!isCommitted) {
-          ms.rollbackTransaction();
-        }
-      }
-      return result;
-    }
-
-    private Table getTable(String catName, String dbName, String tableName)
-        throws MetaException, InvalidObjectException {
-      return getTable(catName, dbName, tableName, null);
-    }
-
-    private Table getTable(String catName, String dbName, String tableName,
-                           String writeIdList)
-        throws MetaException, InvalidObjectException {
-      Table t = getMS().getTable(catName, dbName, tableName, writeIdList);
-      if (t == null) {
-        throw new InvalidObjectException(TableName.getQualified(catName, dbName, tableName)
-            + " table not found");
-      }
-      return t;
-    }
-
-    @Override
-    public NotificationEventResponse get_next_notification(NotificationEventRequest rqst)
-        throws TException {
-      try {
-        authorizeProxyPrivilege();
-      } catch (Exception ex) {
-        LOG.error("Not authorized to make the get_next_notification call. You can try to disable " +
-            ConfVars.EVENT_DB_NOTIFICATION_API_AUTH.toString(), ex);
-        throw new TException(ex);
-      }
-
-      RawStore ms = getMS();
-      return ms.getNextNotification(rqst);
-    }
-
-    @Override
-    public CurrentNotificationEventId get_current_notificationEventId() throws TException {
-      try {
-        authorizeProxyPrivilege();
-      } catch (Exception ex) {
-        LOG.error("Not authorized to make the get_current_notificationEventId call. You can try to disable " +
-            ConfVars.EVENT_DB_NOTIFICATION_API_AUTH.toString(), ex);
-        throw new TException(ex);
-      }
-
-      RawStore ms = getMS();
-      return ms.getCurrentNotificationEventId();
-    }
-
-    @Override
-    public NotificationEventsCountResponse get_notification_events_count(NotificationEventsCountRequest rqst)
-            throws TException {
-      try {
-        authorizeProxyPrivilege();
-      } catch (Exception ex) {
-        LOG.error("Not authorized to make the get_notification_events_count call. You can try to disable " +
-            ConfVars.EVENT_DB_NOTIFICATION_API_AUTH.toString(), ex);
-        throw new TException(ex);
-      }
-
-      RawStore ms = getMS();
-      return ms.getNotificationEventsCount(rqst);
-    }
-
-    private void authorizeProxyPrivilege() throws Exception {
-      // Skip the auth in embedded mode or if the auth is disabled
-      if (!isMetaStoreRemote() ||
-          !MetastoreConf.getBoolVar(conf, ConfVars.EVENT_DB_NOTIFICATION_API_AUTH)) {
-        return;
-      }
-      String user = null;
-      try {
-        user = SecurityUtils.getUGI().getShortUserName();
-      } catch (Exception ex) {
-        LOG.error("Cannot obtain username", ex);
-        throw ex;
-      }
-      if (!MetaStoreServerUtils.checkUserHasHostProxyPrivileges(user, conf, getIPAddress())) {
-        throw new MetaException("User " + user + " is not allowed to perform this API call");
-      }
-    }
-
-    @Override
-    public FireEventResponse fire_listener_event(FireEventRequest rqst) throws TException {
-      switch (rqst.getData().getSetField()) {
-        case INSERT_DATA:
-        case INSERT_DATAS:
-        String catName =
-            rqst.isSetCatName() ? rqst.getCatName() : getDefaultCatalog(conf);
-        String dbName = rqst.getDbName();
-        String tblName = rqst.getTableName();
-        boolean isSuccessful = rqst.isSuccessful();
-        List<InsertEvent> events = new ArrayList<>();
-        if (rqst.getData().isSetInsertData()) {
-          events.add(new InsertEvent(catName, dbName, tblName,
-              rqst.getPartitionVals(),
-              rqst.getData().getInsertData(), isSuccessful, this));
-        } else {
-          // this is a bulk fire insert event operation
-          // we use the partition values field from the InsertEventRequestData object
-          // instead of the FireEventRequest object
-          for (InsertEventRequestData insertData : rqst.getData().getInsertDatas()) {
-            if (!insertData.isSetPartitionVal()) {
-              throw new MetaException(
-                  "Partition values must be set when firing multiple insert events");
-            }
-            events.add(new InsertEvent(catName, dbName, tblName,
-                insertData.getPartitionVal(),
-                insertData, isSuccessful, this));
-          }
-        }
-        FireEventResponse response = new FireEventResponse();
-        for (InsertEvent event : events) {
-          /*
-           * The transactional listener response will be set already on the event, so there is not need
-           * to pass the response to the non-transactional listener.
-           */
-          MetaStoreListenerNotifier
-              .notifyEvent(transactionalListeners, EventType.INSERT, event);
-          MetaStoreListenerNotifier.notifyEvent(listeners, EventType.INSERT, event);
-          if (event.getParameters() != null && event.getParameters()
-              .containsKey(
-                  MetaStoreEventListenerConstants.DB_NOTIFICATION_EVENT_ID_KEY_NAME)) {
-            response.addToEventIds(Long.valueOf(event.getParameters()
-                .get(MetaStoreEventListenerConstants.DB_NOTIFICATION_EVENT_ID_KEY_NAME)));
-          } else {
-            String msg = "Insert event id not generated for ";
-            if (event.getPartitionObj() != null) {
-              msg += "partition " + Arrays
-                  .toString(event.getPartitionObj().getValues().toArray()) + " of ";
-            }
-            msg +=
-                " of table " + event.getTableObj().getDbName() + "." + event.getTableObj()
-                    .getTableName();
-            LOG.warn(msg);
-          }
-        }
-        return response;
-        default:
-        throw new TException("Event type " + rqst.getData().getSetField().toString()
-            + " not currently supported.");
-      }
-
-    }
-
-    @Override
-    public GetFileMetadataByExprResult get_file_metadata_by_expr(GetFileMetadataByExprRequest req)
-        throws TException {
-      GetFileMetadataByExprResult result = new GetFileMetadataByExprResult();
-      RawStore ms = getMS();
-      if (!ms.isFileMetadataSupported()) {
-        result.setIsSupported(false);
-        result.setMetadata(Collections.emptyMap()); // Set the required field.
-        return result;
-      }
-      result.setIsSupported(true);
-
-      List<Long> fileIds = req.getFileIds();
-      boolean needMetadata = !req.isSetDoGetFooters() || req.isDoGetFooters();
-      FileMetadataExprType type = req.isSetType() ? req.getType() : FileMetadataExprType.ORC_SARG;
-
-      ByteBuffer[] metadatas = needMetadata ? new ByteBuffer[fileIds.size()] : null;
-      ByteBuffer[] ppdResults = new ByteBuffer[fileIds.size()];
-      boolean[] eliminated = new boolean[fileIds.size()];
-
-      getMS().getFileMetadataByExpr(fileIds, type, req.getExpr(), metadatas, ppdResults, eliminated);
-      for (int i = 0; i < fileIds.size(); ++i) {
-        if (!eliminated[i] && ppdResults[i] == null)
-         {
-          continue; // No metadata => no ppd.
-        }
-        MetadataPpdResult mpr = new MetadataPpdResult();
-        ByteBuffer ppdResult = eliminated[i] ? null : handleReadOnlyBufferForThrift(ppdResults[i]);
-        mpr.setIncludeBitset(ppdResult);
-        if (needMetadata) {
-          ByteBuffer metadata = eliminated[i] ? null : handleReadOnlyBufferForThrift(metadatas[i]);
-          mpr.setMetadata(metadata);
-        }
-        result.putToMetadata(fileIds.get(i), mpr);
-      }
-      if (!result.isSetMetadata()) {
-        result.setMetadata(Collections.emptyMap()); // Set the required field.
-      }
-      return result;
-    }
-
-    @Override
-    public GetFileMetadataResult get_file_metadata(GetFileMetadataRequest req) throws TException {
-      GetFileMetadataResult result = new GetFileMetadataResult();
-      RawStore ms = getMS();
-      if (!ms.isFileMetadataSupported()) {
-        result.setIsSupported(false);
-        result.setMetadata(Collections.emptyMap()); // Set the required field.
-        return result;
-      }
-      result.setIsSupported(true);
-      List<Long> fileIds = req.getFileIds();
-      ByteBuffer[] metadatas = ms.getFileMetadata(fileIds);
-      assert metadatas.length == fileIds.size();
-      for (int i = 0; i < metadatas.length; ++i) {
-        ByteBuffer bb = metadatas[i];
-        if (bb == null) {
-          continue;
-        }
-        bb = handleReadOnlyBufferForThrift(bb);
-        result.putToMetadata(fileIds.get(i), bb);
-      }
-      if (!result.isSetMetadata()) {
-        result.setMetadata(Collections.emptyMap()); // Set the required field.
-      }
-      return result;
-    }
-
-    private ByteBuffer handleReadOnlyBufferForThrift(ByteBuffer bb) {
-      if (!bb.isReadOnly()) {
-        return bb;
-      }
-      // Thrift cannot write read-only buffers... oh well.
-      // TODO: actually thrift never writes to the buffer, so we could use reflection to
-      //       unset the unnecessary read-only flag if allocation/copy perf becomes a problem.
-      ByteBuffer copy = ByteBuffer.allocate(bb.capacity());
-      copy.put(bb);
-      copy.flip();
-      return copy;
-    }
-
-    @Override
-    public PutFileMetadataResult put_file_metadata(PutFileMetadataRequest req) throws TException {
-      RawStore ms = getMS();
-      if (ms.isFileMetadataSupported()) {
-        ms.putFileMetadata(req.getFileIds(), req.getMetadata(), req.getType());
-      }
-      return new PutFileMetadataResult();
-    }
-
-    @Override
-    public ClearFileMetadataResult clear_file_metadata(ClearFileMetadataRequest req)
-        throws TException {
-      getMS().putFileMetadata(req.getFileIds(), null, null);
-      return new ClearFileMetadataResult();
-    }
-
-    @Override
-    public CacheFileMetadataResult cache_file_metadata(
-        CacheFileMetadataRequest req) throws TException {
-      RawStore ms = getMS();
-      if (!ms.isFileMetadataSupported()) {
-        return new CacheFileMetadataResult(false);
-      }
-      String dbName = req.getDbName(), tblName = req.getTblName(),
-          partName = req.isSetPartName() ? req.getPartName() : null;
-      boolean isAllPart = req.isSetIsAllParts() && req.isIsAllParts();
-      ms.openTransaction();
-      boolean success = false;
-      try {
-        Table tbl = ms.getTable(DEFAULT_CATALOG_NAME, dbName, tblName);
-        if (tbl == null) {
-          throw new NoSuchObjectException(dbName + "." + tblName + " not found");
-        }
-        boolean isPartitioned = tbl.isSetPartitionKeys() && tbl.getPartitionKeysSize() > 0;
-        String tableInputFormat = tbl.isSetSd() ? tbl.getSd().getInputFormat() : null;
-        if (!isPartitioned) {
-          if (partName != null || isAllPart) {
-            throw new MetaException("Table is not partitioned");
-          }
-          if (!tbl.isSetSd() || !tbl.getSd().isSetLocation()) {
-            throw new MetaException(
-                "Table does not have storage location; this operation is not supported on views");
-          }
-          FileMetadataExprType type = expressionProxy.getMetadataType(tableInputFormat);
-          if (type == null) {
-            throw new MetaException("The operation is not supported for " + tableInputFormat);
-          }
-          fileMetadataManager.queueCacheMetadata(tbl.getSd().getLocation(), type);
-          success = true;
-        } else {
-          List<String> partNames;
-          if (partName != null) {
-            partNames = Lists.newArrayList(partName);
-          } else if (isAllPart) {
-            partNames = ms.listPartitionNames(DEFAULT_CATALOG_NAME, dbName, tblName, (short)-1);
-          } else {
-            throw new MetaException("Table is partitioned");
-          }
-          int batchSize = MetastoreConf.getIntVar(
-              conf, ConfVars.BATCH_RETRIEVE_OBJECTS_MAX);
-          int index = 0;
-          int successCount = 0, failCount = 0;
-          HashSet<String> failFormats = null;
-          while (index < partNames.size()) {
-            int currentBatchSize = Math.min(batchSize, partNames.size() - index);
-            List<String> nameBatch = partNames.subList(index, index + currentBatchSize);
-            index += currentBatchSize;
-            List<Partition> parts = ms.getPartitionsByNames(DEFAULT_CATALOG_NAME, dbName, tblName, nameBatch);
-            for (Partition part : parts) {
-              if (!part.isSetSd() || !part.getSd().isSetLocation()) {
-                throw new MetaException("Partition does not have storage location;" +
-                    " this operation is not supported on views");
-              }
-              String inputFormat = part.getSd().isSetInputFormat()
-                  ? part.getSd().getInputFormat() : tableInputFormat;
-              FileMetadataExprType type = expressionProxy.getMetadataType(inputFormat);
-              if (type == null) {
-                ++failCount;
-                if (failFormats == null) {
-                  failFormats = new HashSet<>();
-                }
-                failFormats.add(inputFormat);
-              } else {
-                ++successCount;
-                fileMetadataManager.queueCacheMetadata(part.getSd().getLocation(), type);
-              }
-            }
-          }
-          success = true; // Regardless of the following exception
-          if (failCount > 0) {
-            String errorMsg = "The operation failed for " + failCount + " partitions and "
-                + "succeeded for " + successCount + " partitions; unsupported formats: ";
-            boolean isFirst = true;
-            for (String s : failFormats) {
-              if (!isFirst) {
-                errorMsg += ", ";
-              }
-              isFirst = false;
-              errorMsg += s;
-            }
-            throw new MetaException(errorMsg);
-          }
-        }
-      } finally {
-        if (success) {
-          if (!ms.commitTransaction()) {
-            throw new MetaException("Failed to commit");
-          }
-        } else {
-          ms.rollbackTransaction();
-        }
-      }
-      return new CacheFileMetadataResult(true);
-    }
-
-    @VisibleForTesting
-    void updateMetrics() throws MetaException {
-      if (databaseCount != null) {
-        tableCount.set(getMS().getTableCount());
-        partCount.set(getMS().getPartitionCount());
-        databaseCount.set(getMS().getDatabaseCount());
-      }
-    }
-
-    @Override
-    public PrimaryKeysResponse get_primary_keys(PrimaryKeysRequest request) throws TException {
-      String catName = request.isSetCatName() ? request.getCatName() : getDefaultCatalog(conf);
-      String db_name = request.getDb_name();
-      String tbl_name = request.getTbl_name();
-      startTableFunction("get_primary_keys", catName, db_name, tbl_name);
-      List<SQLPrimaryKey> ret = null;
-      Exception ex = null;
-      try {
-        ret = getMS().getPrimaryKeys(catName, db_name, tbl_name);
-      } catch (Exception e) {
-       ex = e;
-       throwMetaException(e);
-     } finally {
-       endFunction("get_primary_keys", ret != null, ex, tbl_name);
-     }
-     return new PrimaryKeysResponse(ret);
-    }
-
-    @Override
-    public ForeignKeysResponse get_foreign_keys(ForeignKeysRequest request) throws TException {
-      String catName = request.isSetCatName() ? request.getCatName() : getDefaultCatalog(conf);
-      String parent_db_name = request.getParent_db_name();
-      String parent_tbl_name = request.getParent_tbl_name();
-      String foreign_db_name = request.getForeign_db_name();
-      String foreign_tbl_name = request.getForeign_tbl_name();
-      startFunction("get_foreign_keys", " : parentdb=" + parent_db_name +
-        " parenttbl=" + parent_tbl_name + " foreigndb=" + foreign_db_name +
-        " foreigntbl=" + foreign_tbl_name);
-      List<SQLForeignKey> ret = null;
-      Exception ex = null;
-      try {
-        ret = getMS().getForeignKeys(catName, parent_db_name, parent_tbl_name,
-              foreign_db_name, foreign_tbl_name);
-      } catch (Exception e) {
-        ex = e;
-        throwMetaException(e);
-      } finally {
-        endFunction("get_foreign_keys", ret != null, ex, foreign_tbl_name);
-      }
-      return new ForeignKeysResponse(ret);
-    }
-
-    private void throwMetaException(Exception e) throws MetaException,
-        NoSuchObjectException {
-      if (e instanceof MetaException) {
-        throw (MetaException) e;
-      } else if (e instanceof NoSuchObjectException) {
-        throw (NoSuchObjectException) e;
-      } else {
-        throw newMetaException(e);
-      }
-    }
-
-    @Override
-    public UniqueConstraintsResponse get_unique_constraints(UniqueConstraintsRequest request)
-        throws TException {
-      String catName = request.isSetCatName() ? request.getCatName() : getDefaultCatalog(conf);
-      String db_name = request.getDb_name();
-      String tbl_name = request.getTbl_name();
-      startTableFunction("get_unique_constraints", catName, db_name, tbl_name);
-      List<SQLUniqueConstraint> ret = null;
-      Exception ex = null;
-      try {
-        ret = getMS().getUniqueConstraints(catName, db_name, tbl_name);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_unique_constraints", ret != null, ex, tbl_name);
-      }
-      return new UniqueConstraintsResponse(ret);
-    }
-
-    @Override
-    public NotNullConstraintsResponse get_not_null_constraints(NotNullConstraintsRequest request)
-        throws TException {
-      String catName = request.isSetCatName() ? request.getCatName() : getDefaultCatalog(conf);
-      String db_name = request.getDb_name();
-      String tbl_name = request.getTbl_name();
-      startTableFunction("get_not_null_constraints", catName, db_name, tbl_name);
-      List<SQLNotNullConstraint> ret = null;
-      Exception ex = null;
-      try {
-        ret = getMS().getNotNullConstraints(catName, db_name, tbl_name);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_not_null_constraints", ret != null, ex, tbl_name);
-      }
-      return new NotNullConstraintsResponse(ret);
-    }
-
-    @Override
-    public DefaultConstraintsResponse get_default_constraints(DefaultConstraintsRequest request)
-        throws TException {
-      String catName = request.isSetCatName() ? request.getCatName() : getDefaultCatalog(conf);
-      String db_name = request.getDb_name();
-      String tbl_name = request.getTbl_name();
-      startTableFunction("get_default_constraints", catName, db_name, tbl_name);
-      List<SQLDefaultConstraint> ret = null;
-      Exception ex = null;
-      try {
-        ret = getMS().getDefaultConstraints(catName, db_name, tbl_name);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_default_constraints", ret != null, ex, tbl_name);
-      }
-      return new DefaultConstraintsResponse(ret);
-    }
-
-    @Override
-    public CheckConstraintsResponse get_check_constraints(CheckConstraintsRequest request)
-        throws TException {
-      String catName = request.getCatName();
-      String db_name = request.getDb_name();
-      String tbl_name = request.getTbl_name();
-      startTableFunction("get_check_constraints", catName, db_name, tbl_name);
-      List<SQLCheckConstraint> ret = null;
-      Exception ex = null;
-      try {
-        ret = getMS().getCheckConstraints(catName, db_name, tbl_name);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_check_constraints", ret != null, ex, tbl_name);
-      }
-      return new CheckConstraintsResponse(ret);
-    }
-
-    /**
-     * Api to fetch all table constraints at once
-     * @param request it consist of catalog name, database name and table name to identify the table in metastore
-     * @return all constraints attached to given table
-     * @throws TException
-     */
-    @Override
-    public AllTableConstraintsResponse get_all_table_constraints(AllTableConstraintsRequest request)
-        throws TException, MetaException, NoSuchObjectException {
-      String catName = request.isSetCatName() ? request.getCatName() : getDefaultCatalog(conf);
-      String dbName = request.getDbName();
-      String tblName = request.getTblName();
-      startTableFunction("get_all_table_constraints", catName, dbName, tblName);
-      SQLAllTableConstraints ret = null;
-      Exception ex = null;
-      try {
-        ret = getMS().getAllTableConstraints(catName, dbName, tblName);
-      } catch (Exception e) {
-        ex = e;
-        throwMetaException(e);
-      } finally {
-        endFunction("get_all_table_constraints", ret != null, ex, tblName);
-      }
-      return new AllTableConstraintsResponse(ret);
-    }
-
-    @Override
-    public String get_metastore_db_uuid() throws TException {
-      try {
-        return getMS().getMetastoreDbUuid();
-      } catch (MetaException e) {
-        LOG.error("Exception thrown while querying metastore db uuid", e);
-        throw e;
-      }
-    }
-
-    @Override
-    public WMCreateResourcePlanResponse create_resource_plan(WMCreateResourcePlanRequest request)
-        throws AlreadyExistsException, InvalidObjectException, MetaException, TException {
-      int defaultPoolSize = MetastoreConf.getIntVar(
-          conf, MetastoreConf.ConfVars.WM_DEFAULT_POOL_SIZE);
-      WMResourcePlan plan = request.getResourcePlan();
-      if (defaultPoolSize > 0 && plan.isSetQueryParallelism()) {
-        // If the default pool is not disabled, override the size with the specified parallelism.
-        defaultPoolSize = plan.getQueryParallelism();
-      }
-      try {
-        getMS().createResourcePlan(plan, request.getCopyFrom(), defaultPoolSize);
-        return new WMCreateResourcePlanResponse();
-      } catch (MetaException e) {
-        LOG.error("Exception while trying to persist resource plan", e);
-        throw e;
-      }
-    }
-
-    @Override
-    public WMGetResourcePlanResponse get_resource_plan(WMGetResourcePlanRequest request)
-        throws NoSuchObjectException, MetaException, TException {
-      try {
-        WMFullResourcePlan rp = getMS().getResourcePlan(request.getResourcePlanName(), request.getNs());
-        WMGetResourcePlanResponse resp = new WMGetResourcePlanResponse();
-        resp.setResourcePlan(rp);
-        return resp;
-      } catch (MetaException e) {
-        LOG.error("Exception while trying to retrieve resource plan", e);
-        throw e;
-      }
-    }
-
-    @Override
-    public WMGetAllResourcePlanResponse get_all_resource_plans(WMGetAllResourcePlanRequest request)
-        throws MetaException, TException {
-      try {
-        WMGetAllResourcePlanResponse resp = new WMGetAllResourcePlanResponse();
-        resp.setResourcePlans(getMS().getAllResourcePlans(request.getNs()));
-        return resp;
-      } catch (MetaException e) {
-        LOG.error("Exception while trying to retrieve resource plans", e);
-        throw e;
-      }
-    }
-
-    @Override
-    public WMAlterResourcePlanResponse alter_resource_plan(WMAlterResourcePlanRequest request)
-        throws NoSuchObjectException, InvalidOperationException, MetaException, TException {
-      try {
-        if (((request.isIsEnableAndActivate() ? 1 : 0) + (request.isIsReplace() ? 1 : 0)
-           + (request.isIsForceDeactivate() ? 1 : 0)) > 1) {
-          throw new MetaException("Invalid request; multiple flags are set");
-        }
-        WMAlterResourcePlanResponse response = new WMAlterResourcePlanResponse();
-        // This method will only return full resource plan when activating one,
-        // to give the caller the result atomically with the activation.
-        WMFullResourcePlan fullPlanAfterAlter = getMS().alterResourcePlan(
-            request.getResourcePlanName(), request.getNs(), request.getResourcePlan(),
-            request.isIsEnableAndActivate(), request.isIsForceDeactivate(), request.isIsReplace());
-        if (fullPlanAfterAlter != null) {
-          response.setFullResourcePlan(fullPlanAfterAlter);
-        }
-        return response;
-      } catch (MetaException e) {
-        LOG.error("Exception while trying to alter resource plan", e);
-        throw e;
-      }
-    }
-
-    @Override
-    public WMGetActiveResourcePlanResponse get_active_resource_plan(
-        WMGetActiveResourcePlanRequest request) throws MetaException, TException {
-      try {
-        WMGetActiveResourcePlanResponse response = new WMGetActiveResourcePlanResponse();
-        response.setResourcePlan(getMS().getActiveResourcePlan(request.getNs()));
-        return response;
-      } catch (MetaException e) {
-        LOG.error("Exception while trying to get active resource plan", e);
-        throw e;
-      }
-    }
-
-    @Override
-    public WMValidateResourcePlanResponse validate_resource_plan(WMValidateResourcePlanRequest request)
-        throws NoSuchObjectException, MetaException, TException {
-      try {
-        return getMS().validateResourcePlan(request.getResourcePlanName(), request.getNs());
-      } catch (MetaException e) {
-        LOG.error("Exception while trying to validate resource plan", e);
-        throw e;
-      }
-    }
-
-    @Override
-    public WMDropResourcePlanResponse drop_resource_plan(WMDropResourcePlanRequest request)
-        throws NoSuchObjectException, InvalidOperationException, MetaException, TException {
-      try {
-        getMS().dropResourcePlan(request.getResourcePlanName(), request.getNs());
-        return new WMDropResourcePlanResponse();
-      } catch (MetaException e) {
-        LOG.error("Exception while trying to drop resource plan", e);
-        throw e;
-      }
-    }
-
-    @Override
-    public WMCreateTriggerResponse create_wm_trigger(WMCreateTriggerRequest request)
-        throws AlreadyExistsException, InvalidObjectException, MetaException, TException {
-      try {
-        getMS().createWMTrigger(request.getTrigger());
-        return new WMCreateTriggerResponse();
-      } catch (MetaException e) {
-        LOG.error("Exception while trying to create trigger", e);
-        throw e;
-      }
-    }
-
-    @Override
-    public WMAlterTriggerResponse alter_wm_trigger(WMAlterTriggerRequest request)
-        throws NoSuchObjectException, InvalidObjectException, MetaException, TException {
-      try {
-        getMS().alterWMTrigger(request.getTrigger());
-        return new WMAlterTriggerResponse();
-      } catch (MetaException e) {
-        LOG.error("Exception while trying to alter trigger", e);
-        throw e;
-      }
-    }
-
-    @Override
-    public WMDropTriggerResponse drop_wm_trigger(WMDropTriggerRequest request)
-        throws NoSuchObjectException, InvalidOperationException, MetaException, TException {
-      try {
-        getMS().dropWMTrigger(request.getResourcePlanName(), request.getTriggerName(), request.getNs());
-        return new WMDropTriggerResponse();
-      } catch (MetaException e) {
-        LOG.error("Exception while trying to drop trigger.", e);
-        throw e;
-      }
-    }
-
-    @Override
-    public WMGetTriggersForResourePlanResponse get_triggers_for_resourceplan(
-        WMGetTriggersForResourePlanRequest request)
-        throws NoSuchObjectException, MetaException, TException {
-      try {
-        List<WMTrigger> triggers =
-            getMS().getTriggersForResourcePlan(request.getResourcePlanName(), request.getNs());
-        WMGetTriggersForResourePlanResponse response = new WMGetTriggersForResourePlanResponse();
-        response.setTriggers(triggers);
-        return response;
-      } catch (MetaException e) {
-        LOG.error("Exception while trying to retrieve triggers plans", e);
-        throw e;
-      }
-    }
-
-    @Override
-    public WMAlterPoolResponse alter_wm_pool(WMAlterPoolRequest request)
-        throws AlreadyExistsException, NoSuchObjectException, InvalidObjectException, MetaException,
-        TException {
-      try {
-        getMS().alterPool(request.getPool(), request.getPoolPath());
-        return new WMAlterPoolResponse();
-      } catch (MetaException e) {
-        LOG.error("Exception while trying to alter WMPool", e);
-        throw e;
-      }
-    }
-
-    @Override
-    public WMCreatePoolResponse create_wm_pool(WMCreatePoolRequest request)
-        throws AlreadyExistsException, NoSuchObjectException, InvalidObjectException, MetaException,
-        TException {
-      try {
-        getMS().createPool(request.getPool());
-        return new WMCreatePoolResponse();
-      } catch (MetaException e) {
-        LOG.error("Exception while trying to create WMPool", e);
-        throw e;
-      }
-    }
-
-    @Override
-    public WMDropPoolResponse drop_wm_pool(WMDropPoolRequest request)
-        throws NoSuchObjectException, InvalidOperationException, MetaException, TException {
-      try {
-        getMS().dropWMPool(request.getResourcePlanName(), request.getPoolPath(), request.getNs());
-        return new WMDropPoolResponse();
-      } catch (MetaException e) {
-        LOG.error("Exception while trying to drop WMPool", e);
-        throw e;
-      }
-    }
-
-    @Override
-    public WMCreateOrUpdateMappingResponse create_or_update_wm_mapping(
-        WMCreateOrUpdateMappingRequest request) throws AlreadyExistsException,
-        NoSuchObjectException, InvalidObjectException, MetaException, TException {
-      try {
-        getMS().createOrUpdateWMMapping(request.getMapping(), request.isUpdate());
-        return new WMCreateOrUpdateMappingResponse();
-      } catch (MetaException e) {
-        LOG.error("Exception while trying to create or update WMMapping", e);
-        throw e;
-      }
-    }
-
-    @Override
-    public WMDropMappingResponse drop_wm_mapping(WMDropMappingRequest request)
-        throws NoSuchObjectException, InvalidOperationException, MetaException, TException {
-      try {
-        getMS().dropWMMapping(request.getMapping());
-        return new WMDropMappingResponse();
-      } catch (MetaException e) {
-        LOG.error("Exception while trying to drop WMMapping", e);
-        throw e;
-      }
-    }
-
-    @Override
-    public WMCreateOrDropTriggerToPoolMappingResponse create_or_drop_wm_trigger_to_pool_mapping(
-        WMCreateOrDropTriggerToPoolMappingRequest request) throws AlreadyExistsException,
-        NoSuchObjectException, InvalidObjectException, MetaException, TException {
-      try {
-        if (request.isDrop()) {
-          getMS().dropWMTriggerToPoolMapping(request.getResourcePlanName(),
-              request.getTriggerName(), request.getPoolPath(), request.getNs());
-        } else {
-          getMS().createWMTriggerToPoolMapping(request.getResourcePlanName(),
-              request.getTriggerName(), request.getPoolPath(), request.getNs());
-        }
-        return new WMCreateOrDropTriggerToPoolMappingResponse();
-      } catch (MetaException e) {
-        LOG.error("Exception while trying to create or drop pool mappings", e);
-        throw e;
-      }
-    }
-
-    @Override
-    public void create_ischema(ISchema schema) throws TException {
-      startFunction("create_ischema", ": " + schema.getName());
-      boolean success = false;
-      Exception ex = null;
-      RawStore ms = getMS();
-      try {
-        firePreEvent(new PreCreateISchemaEvent(this, schema));
-        Map<String, String> transactionalListenersResponses = Collections.emptyMap();
-        ms.openTransaction();
-        try {
-          ms.createISchema(schema);
-
-          if (!transactionalListeners.isEmpty()) {
-            transactionalListenersResponses =
-                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                    EventType.CREATE_ISCHEMA, new CreateISchemaEvent(true, this, schema));
-          }
-          success = ms.commitTransaction();
-        } finally {
-          if (!success) {
-            ms.rollbackTransaction();
-          }
-          if (!listeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.CREATE_ISCHEMA,
-                new CreateISchemaEvent(success, this, schema), null,
-                transactionalListenersResponses, ms);
-          }
-        }
-      } catch (MetaException|AlreadyExistsException e) {
-        LOG.error("Caught exception creating schema", e);
-        ex = e;
-        throw e;
-      } finally {
-        endFunction("create_ischema", success, ex);
-      }
-    }
-
-    @Override
-    public void alter_ischema(AlterISchemaRequest rqst) throws TException {
-      startFunction("alter_ischema", ": " + rqst);
-      boolean success = false;
-      Exception ex = null;
-      RawStore ms = getMS();
-      try {
-        ISchema oldSchema = ms.getISchema(rqst.getName());
-        if (oldSchema == null) {
-          throw new NoSuchObjectException("Could not find schema " + rqst.getName());
-        }
-        firePreEvent(new PreAlterISchemaEvent(this, oldSchema, rqst.getNewSchema()));
-        Map<String, String> transactionalListenersResponses = Collections.emptyMap();
-        ms.openTransaction();
-        try {
-          ms.alterISchema(rqst.getName(), rqst.getNewSchema());
-          if (!transactionalListeners.isEmpty()) {
-            transactionalListenersResponses =
-                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                    EventType.ALTER_ISCHEMA, new AlterISchemaEvent(true, this, oldSchema, rqst.getNewSchema()));
-          }
-          success = ms.commitTransaction();
-        } finally {
-          if (!success) {
-            ms.rollbackTransaction();
-          }
-          if (!listeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ALTER_ISCHEMA,
-                new AlterISchemaEvent(success, this, oldSchema, rqst.getNewSchema()), null,
-                transactionalListenersResponses, ms);
-          }
-        }
-      } catch (MetaException|NoSuchObjectException e) {
-        LOG.error("Caught exception altering schema", e);
-        ex = e;
-        throw e;
-      } finally {
-        endFunction("alter_ischema", success, ex);
-      }
-    }
-
-    @Override
-    public ISchema get_ischema(ISchemaName schemaName) throws TException {
-      startFunction("get_ischema", ": " + schemaName);
-      Exception ex = null;
-      ISchema schema = null;
-      try {
-        schema = getMS().getISchema(schemaName);
-        if (schema == null) {
-          throw new NoSuchObjectException("No schema named " + schemaName + " exists");
-        }
-        firePreEvent(new PreReadISchemaEvent(this, schema));
-        return schema;
-      } catch (MetaException e) {
-        LOG.error("Caught exception getting schema", e);
-        ex = e;
-        throw e;
-      } finally {
-        endFunction("get_ischema", schema != null, ex);
-      }
-    }
-
-    @Override
-    public void drop_ischema(ISchemaName schemaName) throws TException {
-      startFunction("drop_ischema", ": " + schemaName);
-      Exception ex = null;
-      boolean success = false;
-      RawStore ms = getMS();
-      try {
-        // look for any valid versions.  This will also throw NoSuchObjectException if the schema
-        // itself doesn't exist, which is what we want.
-        SchemaVersion latest = ms.getLatestSchemaVersion(schemaName);
-        if (latest != null) {
-          ex = new InvalidOperationException("Schema " + schemaName + " cannot be dropped, it has" +
-              " at least one valid version");
-          throw (InvalidObjectException)ex;
-        }
-        ISchema schema = ms.getISchema(schemaName);
-        firePreEvent(new PreDropISchemaEvent(this, schema));
-        Map<String, String> transactionalListenersResponses = Collections.emptyMap();
-        ms.openTransaction();
-        try {
-          ms.dropISchema(schemaName);
-          if (!transactionalListeners.isEmpty()) {
-            transactionalListenersResponses =
-                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                    EventType.DROP_ISCHEMA, new DropISchemaEvent(true, this, schema));
-          }
-          success = ms.commitTransaction();
-        } finally {
-          if (!success) {
-            ms.rollbackTransaction();
-          }
-          if (!listeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.DROP_ISCHEMA,
-                new DropISchemaEvent(success, this, schema), null,
-                transactionalListenersResponses, ms);
-          }
-        }
-      } catch (MetaException|NoSuchObjectException e) {
-        LOG.error("Caught exception dropping schema", e);
-        ex = e;
-        throw e;
-      } finally {
-        endFunction("drop_ischema", success, ex);
-      }
-    }
-
-    @Override
-    public void add_schema_version(SchemaVersion schemaVersion) throws TException {
-      startFunction("add_schema_version", ": " + schemaVersion);
-      boolean success = false;
-      Exception ex = null;
-      RawStore ms = getMS();
... 419 lines suppressed ...

[hive] 34/38: HIVE-24396: qtest failure (Naveen Gangam)

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 07ebf02bfe91fdac60299999503928f421cfce87
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Mon Mar 22 15:27:00 2021 -0400

    HIVE-24396: qtest failure (Naveen Gangam)
---
 ql/src/test/results/clientpositive/beeline/escape_comments.q.out | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ql/src/test/results/clientpositive/beeline/escape_comments.q.out b/ql/src/test/results/clientpositive/beeline/escape_comments.q.out
index 64b13f0..69fd771 100644
--- a/ql/src/test/results/clientpositive/beeline/escape_comments.q.out
+++ b/ql/src/test/results/clientpositive/beeline/escape_comments.q.out
@@ -42,14 +42,14 @@ PREHOOK: Input: database:escape_comments_db
 POSTHOOK: query: describe database extended escape_comments_db
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:escape_comments_db
-escape_comments_db	a\nb	location/in/test		user	USER	
+escape_comments_db	a\nb	location/in/test		user	USER			
 PREHOOK: query: describe database escape_comments_db
 PREHOOK: type: DESCDATABASE
 PREHOOK: Input: database:escape_comments_db
 POSTHOOK: query: describe database escape_comments_db
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:escape_comments_db
-escape_comments_db	a\nb	location/in/test		user	USER
+escape_comments_db	a\nb	location/in/test		user	USER		
 PREHOOK: query: show create table escape_comments_tbl1
 PREHOOK: type: SHOW_CREATETABLE
 PREHOOK: Input: escape_comments_db@escape_comments_tbl1

[hive] 03/38: Implemented getTable and getTableNames for MYSQL (working)

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit d65307d795ad6415de1e8714859fa0ce4bd07a87
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Thu Nov 12 00:12:55 2020 -0500

    Implemented getTable and getTableNames for MYSQL (working)
---
 .../database/create/CreateDatabaseAnalyzer.java    |  10 +-
 .../url/AlterDataConnectorSetUrlAnalyzer.java      |   4 +-
 .../create/CreateDataConnectorAnalyzer.java        |   2 +-
 .../apache/hadoop/hive/metastore/IHMSHandler.java  |  12 ++
 .../AbstractDataConnectorProvider.java             |   7 +-
 .../DataConnectorProviderFactory.java              |  39 ++++--
 .../dataconnector/IDataConnectorProvider.java      |   6 +
 .../dataconnector/jdbc/JDBCConnectorProvider.java  | 150 ++++++++++++++++++++-
 8 files changed, 198 insertions(+), 32 deletions(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseAnalyzer.java
index 42d7c79..d342db0 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseAnalyzer.java
@@ -75,12 +75,11 @@ public class CreateDatabaseAnalyzer extends BaseSemanticAnalyzer {
         break;
       case HiveParser.TOK_DATACONNECTOR:
         type = "REMOTE";
-        locationUri = "REMOTE_DATABASE"; // TODO
-        // i++;
+        // locationUri = "REMOTE_DATABASE"; // TODO
         ASTNode nextNode = (ASTNode) root.getChild(i);
         connectorName = ((ASTNode)nextNode).getChild(0).getText();
         outputs.add(toWriteEntity(connectorName));
-        outputs.remove(toWriteEntity(locationUri));
+        // outputs.remove(toWriteEntity(locationUri));
         if (managedLocationUri != null) {
           outputs.remove(toWriteEntity(managedLocationUri));
           managedLocationUri = null;
@@ -91,7 +90,6 @@ public class CreateDatabaseAnalyzer extends BaseSemanticAnalyzer {
       }
     }
 
-    // String remoteDbName = props.get("connector.remoteDbName");
     CreateDatabaseDesc desc = null;
     Database database = new Database(databaseName, comment, locationUri, props);
     if (type.equalsIgnoreCase("NATIVE")) {
@@ -103,7 +101,7 @@ public class CreateDatabaseAnalyzer extends BaseSemanticAnalyzer {
       }
     } else {
       String remoteDbName = databaseName;
-      if (props != null && props.get("connector.remoteDbName") != null) // TODO
+      if (props != null && props.get("connector.remoteDbName") != null) // TODO finalize the property name
         remoteDbName = props.get("connector.remoteDbName");
       desc = new CreateDatabaseDesc(databaseName, comment, locationUri, null, ifNotExists, props, type,
           connectorName, remoteDbName);
@@ -112,8 +110,6 @@ public class CreateDatabaseAnalyzer extends BaseSemanticAnalyzer {
       database.setRemote_dbname(remoteDbName);
     }
     rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc)));
-
-    // database = new Database(databaseName, comment, locationUri, props);
     outputs.add(new WriteEntity(database, WriteEntity.WriteType.DDL_NO_LOCK));
   }
 }
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlAnalyzer.java
index 217f702..c7b0af8 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlAnalyzer.java
@@ -38,9 +38,7 @@ public class AlterDataConnectorSetUrlAnalyzer extends AbstractAlterDataConnector
   public void analyzeInternal(ASTNode root) throws SemanticException {
     String connectorName = getUnescapedName((ASTNode) root.getChild(0));
     String newURL = unescapeSQLString(root.getChild(1).getText());
-
-    outputs.add(toWriteEntity(newURL));
-
+    // TODO add some validation for the URL?
     AlterDataConnectorSetUrlDesc desc = new AlterDataConnectorSetUrlDesc(connectorName, newURL);
     addAlterDataConnectorDesc(desc);
   }
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/create/CreateDataConnectorAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/create/CreateDataConnectorAnalyzer.java
index 5867108..a277baf 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/create/CreateDataConnectorAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/create/CreateDataConnectorAnalyzer.java
@@ -63,7 +63,7 @@ public class CreateDataConnectorAnalyzer extends BaseSemanticAnalyzer {
         break;
       case HiveParser.TOK_DATACONNECTORURL:
         url = unescapeSQLString(childNode.getChild(0).getText());
-        outputs.add(toWriteEntity(url));
+        // outputs.add(toWriteEntity(url));
         break;
       case HiveParser.TOK_DATACONNECTORTYPE:
         type = unescapeSQLString(childNode.getChild(0).getText());
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/IHMSHandler.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/IHMSHandler.java
index a969d5e..fbd8f87 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/IHMSHandler.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/IHMSHandler.java
@@ -23,6 +23,7 @@ import java.util.List;
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.conf.Configurable;
 import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.api.DataConnector;
 import org.apache.hadoop.hive.metastore.api.MetaException;
 import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
 import org.apache.hadoop.hive.metastore.api.Table;
@@ -105,4 +106,15 @@ public interface IHMSHandler extends ThriftHiveMetastore.Iface, Configurable {
    * @return list of non-transactional listeners.
    */
   List<MetaStoreEventListener> getListeners();
+
+  /**
+   * Equivalent to get_connector, but does not write to audit logs, or fire pre-event listeners.
+   * Meant to be used for internal hive classes that don't use the thrift interface.
+   * @param name connector name
+   * @return DataConnector object
+   * @throws NoSuchObjectException If the connector does not exist.
+   * @throws MetaException If another error occurs.
+   */
+  DataConnector get_dataconnector_core(final String name)
+      throws NoSuchObjectException, MetaException;
 }
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/AbstractDataConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/AbstractDataConnectorProvider.java
index bad1ecb..2a73236 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/AbstractDataConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/AbstractDataConnectorProvider.java
@@ -8,13 +8,8 @@ import java.net.ConnectException;
 import java.util.List;
 
 public abstract class AbstractDataConnectorProvider implements IDataConnectorProvider {
-  public static final String MYSQL_TYPE = "mysql";
-  public static final String POSTGRES_TYPE = "postgres";
-  public static final String ORACLE_TYPE = "oracle";
-  public static final String MSSQL_TYPE = "mssql";
-
   protected String scoped_db = null;
-  protected Object handle = null;
+  protected Object  handle = null;
   protected boolean isOpen = false;
   protected DataConnector connector = null;
 
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/DataConnectorProviderFactory.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/DataConnectorProviderFactory.java
index babe89b..ce43633 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/DataConnectorProviderFactory.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/DataConnectorProviderFactory.java
@@ -5,6 +5,13 @@ import org.apache.hadoop.hive.metastore.api.DataConnector;
 import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.metastore.api.DatabaseType;
 import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
+import static org.apache.hadoop.hive.metastore.dataconnector.IDataConnectorProvider.DERBY_TYPE;
+import static org.apache.hadoop.hive.metastore.dataconnector.IDataConnectorProvider.MSSQL_TYPE;
+import static org.apache.hadoop.hive.metastore.dataconnector.IDataConnectorProvider.MYSQL_TYPE;
+import static org.apache.hadoop.hive.metastore.dataconnector.IDataConnectorProvider.ORACLE_TYPE;
+import static org.apache.hadoop.hive.metastore.dataconnector.IDataConnectorProvider.POSTGRES_TYPE;
+import org.apache.hadoop.hive.metastore.dataconnector.jdbc.JDBCConnectorProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -32,33 +39,43 @@ public class DataConnectorProviderFactory {
 
   public static synchronized IDataConnectorProvider getDataConnectorProvider(Database db) throws MetaException {
     IDataConnectorProvider provider = null;
+    DataConnector connector = null;
     if (db.getType() == DatabaseType.NATIVE) {
       throw new MetaException("Database " + db.getName() + " is of type NATIVE, no connector available");
     }
 
-    // DataConnector connector = hmsHandler.getMS().getDataConnector(db.getConnector_name());
-
+    String scopedDb = (db.getRemote_dbname() != null) ? db.getRemote_dbname() : db.getName();
     if (cache.containsKey(db.getConnector_name().toLowerCase() != null)) {
       provider = cache.get(db.getConnector_name().toLowerCase());
-
       if (provider != null) {
-        provider.setScope(db.getName());
+        provider.setScope(scopedDb);
       }
-
       return provider;
     }
 
-    // String type = connector.getType();
-    String type = "mysql";
+    try {
+      connector = hmsHandler.get_dataconnector_core(db.getConnector_name());
+    } catch (NoSuchObjectException notexists) {
+      throw new MetaException("Data connector " + db.getConnector_name() + " associated with database "
+          + db.getName() + " does not exist");
+    }
+    String type = connector.getType();
     switch (type) {
-    case "mysql":
-
+    case DERBY_TYPE:
+    case MSSQL_TYPE:
+    case MYSQL_TYPE:
+    case ORACLE_TYPE:
+    case POSTGRES_TYPE:
+      try {
+        provider = new JDBCConnectorProvider(scopedDb, connector);
+      } catch (Exception e) {
+        throw new MetaException("Could not instantiate a provider for database " + db.getName());
+      }
         ;
     default:
       ;
     }
-
-    cache.put(db.getConnector_name().toLowerCase(), provider);
+    cache.put(connector.getName().toLowerCase(), provider);
     return provider;
   }
 
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/IDataConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/IDataConnectorProvider.java
index 2239939..73b3db9 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/IDataConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/IDataConnectorProvider.java
@@ -20,6 +20,12 @@ import java.util.Map;
 @InterfaceAudience.Public
 @InterfaceStability.Evolving
 public interface IDataConnectorProvider {
+  public static final String MYSQL_TYPE = "mysql";
+  public static final String POSTGRES_TYPE = "postgres";
+  public static final String ORACLE_TYPE = "oracle";
+  public static final String MSSQL_TYPE = "mssql";
+  public static final String DERBY_TYPE = "derby";
+
   DataConnector connector = null;
 
   /**
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/JDBCConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/JDBCConnectorProvider.java
index 2e92cc4..7e9d408 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/JDBCConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/JDBCConnectorProvider.java
@@ -10,14 +10,25 @@ import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.Date;
 
+import org.apache.hadoop.hive.conf.Constants;
+import org.apache.hadoop.hive.metastore.ColumnType;
+import org.apache.hadoop.hive.metastore.TableType;
+import org.apache.hadoop.hive.metastore.Warehouse;
 import org.apache.hadoop.hive.metastore.api.DataConnector;
+import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.Order;
+import org.apache.hadoop.hive.metastore.api.SerDeInfo;
+import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
 import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants;
 import org.apache.hadoop.hive.metastore.dataconnector.AbstractDataConnectorProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 public class JDBCConnectorProvider extends AbstractDataConnectorProvider {
   private static Logger LOG = LoggerFactory.getLogger(JDBCConnectorProvider.class);
@@ -30,7 +41,7 @@ public class JDBCConnectorProvider extends AbstractDataConnectorProvider {
 
   public JDBCConnectorProvider(String dbName, DataConnector dataConn) {
     super(dbName, dataConn);
-    this.type = connector.getType();
+    this.type = connector.getType().toUpperCase(); // TODO
     this.jdbcUrl = connector.getUrl();
     this.username = connector.getParameters().get("dataconnector.username");
     this.password = connector.getParameters().get("dataconnector.password");
@@ -52,7 +63,8 @@ public class JDBCConnectorProvider extends AbstractDataConnectorProvider {
         throw new ConnectException("Could not connect to remote datasource at " + jdbcUrl + ",cause:" + sqle.getMessage());
       }
       break;
-
+    case POSTGRES_TYPE:
+      
     default:
       throw new RuntimeException("Unsupported JDBC type");
     }
@@ -100,7 +112,7 @@ public class JDBCConnectorProvider extends AbstractDataConnectorProvider {
   @Override public List<String> getTableNames() throws MetaException {
     ResultSet rs = null;
     try {
-      rs = getConnection().getMetaData().getTables(null, scoped_db, "*", new String[] { "TABLE" });
+      rs = getConnection().getMetaData().getTables(scoped_db, null, null, new String[] { "TABLE" });
       if (rs != null) {
         List<String> tables = new ArrayList<String>();
         while(rs.next()) {
@@ -128,7 +140,137 @@ public class JDBCConnectorProvider extends AbstractDataConnectorProvider {
    * @param tableName
    */
   @Override public Table getTable(String tableName) throws MetaException {
-    return null;
+    try {
+      Statement stmt = getConnection().createStatement();
+      ResultSet rs = stmt.executeQuery(
+          "SELECT table_name, column_name, is_nullable, data_type, character_maximum_length FROM INFORMATION_SCHEMA.Columns where table_schema='"
+              + scoped_db + "' and table_name='" + tableName + "'");
+      List<FieldSchema> cols = new ArrayList<>();
+      // TODO throw exception is RS is empty
+      while (rs.next()) {
+        FieldSchema fs = new FieldSchema();
+        fs.setName(rs.getString("COLUMN_NAME"));
+        fs.setType(getDataType(rs.getString("DATA_TYPE"), rs.getInt("CHARACTER_MAXIMUM_LENGTH")));
+        fs.setComment("inferred column type");
+        cols.add(fs);
+      }
+
+      //Setting the storage descriptor.
+      StorageDescriptor sd = new StorageDescriptor();
+      sd.setCols(cols);
+      // sd.se
+      SerDeInfo serdeInfo = new SerDeInfo();
+      serdeInfo.setName(tableName);
+      serdeInfo.setSerializationLib("org.apache.hive.storage.jdbc.JdbcSerDe");
+      Map<String, String> serdeParams = new HashMap<String, String>();
+      serdeParams.put("serialization.format", "1");
+      serdeInfo.setParameters(serdeParams);
+
+      // StorageHandler
+
+      // serdeInfo.setDeserializerClass();
+      sd.setSerdeInfo(serdeInfo);
+      // sd.getSerdeInfo().setName(tableName);
+      sd.setInputFormat("org.apache.hive.storage.jdbc.JdbcInputFormat"); // TODO
+      sd.setOutputFormat("org.apache.hive.storage.jdbc.JdbcOutputFormat"); // TODO
+      sd.setLocation("/tmp/some_dummy_path"); // TODO
+      sd.setBucketCols(new ArrayList<String>());
+      sd.setSortCols(new ArrayList<Order>());
+
+      //Setting the table properties.
+      Map<String, String> tblProps = new HashMap<>();
+      tblProps.put(Constants.JDBC_DATABASE_TYPE, this.type);
+      tblProps.put(Constants.JDBC_DRIVER, this.driverClassName);
+      tblProps.put(Constants.JDBC_URL, this.jdbcUrl); // "jdbc://localhost:3306/hive"
+      tblProps.put(Constants.JDBC_USERNAME, this.username);
+      tblProps.put(Constants.JDBC_PASSWORD, this.password);
+      tblProps.put(Constants.JDBC_TABLE, tableName);
+      tblProps.put(hive_metastoreConstants.META_TABLE_STORAGE, Constants.JDBC_HIVE_STORAGE_HANDLER_ID);
+      tblProps.put("EXTERNAL", "TRUE");
+      // TODO: Need to include schema, catalog info in the paramters list.
+
+      //Setting the required table information
+      Table table = new Table();
+      table.setTableName(tableName);
+      table.setTableType(TableType.EXTERNAL_TABLE.toString());
+      table.setDbName(scoped_db);
+      table.setSd(sd);
+      table.setParameters(tblProps);
+      // set partition keys to empty
+      table.setPartitionKeys(new ArrayList<FieldSchema>());
+
+      return table;
+    } catch (Exception e) {
+      LOG.warn("Exception retrieving remote table " + scoped_db + "." + tableName + " via data connector "
+          + connector.getName());
+      throw new MetaException("Error retrieving remote table:" + e);
+    }
+  }
+
+  private String wrapSize(int size) {
+    return "(" + size + ")";
   }
 
+  private String getDataType(String mySqlType, int size) {
+    //TODO: Geomentric, network, bit, array data types of postgresql needs to be supported.
+    switch(mySqlType)
+    {
+    case "char":
+      return ColumnType.CHAR_TYPE_NAME + wrapSize(size);
+    case "varchar":
+    case "tinytext":
+      return ColumnType.VARCHAR_TYPE_NAME + wrapSize(size);
+    case "text":
+    case "mediumtext":
+    case "enum":
+    case "set":
+    case "tsvector":
+    case "tsquery":
+    case "uuid":
+    case "json":
+      return ColumnType.STRING_TYPE_NAME;
+    case "blob":
+    case "mediumblob":
+    case "longblob":
+    case "bytea":
+      return ColumnType.BINARY_TYPE_NAME;
+    case "tinyint":
+      return ColumnType.TINYINT_TYPE_NAME;
+    case "smallint":
+    case "smallserial":
+      return ColumnType.SMALLINT_TYPE_NAME;
+    case "mediumint":
+    case "int":
+    case "serial":
+      return ColumnType.INT_TYPE_NAME;
+    case "bigint":
+    case "bigserial":
+    case "money":
+      return ColumnType.BIGINT_TYPE_NAME;
+    case "float":
+    case "real":
+      return ColumnType.FLOAT_TYPE_NAME;
+    case "double":
+    case "double precision":
+      return ColumnType.DOUBLE_TYPE_NAME;
+    case "decimal":
+    case "numeric":
+      return ColumnType.DECIMAL_TYPE_NAME;
+    case "date":
+      return ColumnType.DATE_TYPE_NAME;
+    case "datetime":
+      return ColumnType.DATETIME_TYPE_NAME;
+    case "timestamp":
+    case "time":
+    case "interval":
+      return ColumnType.TIMESTAMP_TYPE_NAME;
+    case "timestampz":
+    case "timez":
+      return ColumnType.TIMESTAMPTZ_TYPE_NAME;
+    case "boolean":
+      return ColumnType.BOOLEAN_TYPE_NAME;
+    default:
+      return ColumnType.VOID_TYPE_NAME;
+    }
+  }
 }

[hive] 13/38: HIVE-24396: Fix for drop database for remote databases

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 750449185cc8cff874d9ba70897b9a702c30726e
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Fri Nov 20 20:32:53 2020 -0500

    HIVE-24396: Fix for drop database for remote databases
---
 .../org/apache/hadoop/hive/metastore/HiveMetaStore.java | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
index 696b89d..2eeb60a 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
@@ -1713,6 +1713,10 @@ public class HiveMetaStore extends ThriftHiveMetastore {
       try {
         ms.openTransaction();
         db = ms.getDatabase(catName, name);
+        if (db.getType() == DatabaseType.REMOTE) {
+          success = drop_remote_database_core(ms, db);
+          return;
+        }
         isReplicated = isDbReplicationTarget(db);
 
         if (!isInTest && ReplChangeManager.isSourceOfReplication(db)) {
@@ -1899,6 +1903,16 @@ public class HiveMetaStore extends ThriftHiveMetastore {
       }
     }
 
+    private boolean drop_remote_database_core(RawStore ms, final Database db) throws MetaException, NoSuchObjectException {
+      boolean success = false;
+      firePreEvent(new PreDropDatabaseEvent(db, this));
+
+      if (ms.dropDatabase(db.getCatalogName(), db.getName())) {
+        success = ms.commitTransaction();
+      }
+      return success;
+    }
+
     @Override
     public void drop_database(final String dbName, final boolean deleteData, final boolean cascade)
         throws NoSuchObjectException, InvalidOperationException, MetaException {
@@ -1983,14 +1997,12 @@ public class HiveMetaStore extends ThriftHiveMetastore {
       }
     }
 
-    // Assumes that the catalog has already been set.
     private void create_dataconnector_core(RawStore ms, final DataConnector connector)
         throws AlreadyExistsException, InvalidObjectException, MetaException {
       if (!MetaStoreUtils.validateName(connector.getName(), conf)) {
         throw new InvalidObjectException(connector.getName() + " is not a valid dataconnector name");
       }
 
-      // connector.setLocationUri(dbPath.toString());
       if (connector.getOwnerName() == null){
         try {
           connector.setOwnerName(SecurityUtils.getUGI().getShortUserName());
@@ -2001,7 +2013,6 @@ public class HiveMetaStore extends ThriftHiveMetastore {
       long time = System.currentTimeMillis()/1000;
       connector.setCreateTime((int) time);
       boolean success = false;
-      boolean madeDir = false;
       Map<String, String> transactionalListenersResponses = Collections.emptyMap();
       try {
         firePreEvent(new PreCreateDataConnectorEvent(connector, this));

[hive] 01/38: External metastore: clean after rebase

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 69e5417b9829433f487d8958d57ffc2aeea85059
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Thu Aug 13 00:10:27 2020 -0400

    External metastore: clean after rebase
---
 .../java/org/apache/hadoop/hive/ql/ErrorMsg.java   |     3 +
 .../hadoop/hive/ql/parse/AlterClauseParser.g       |    31 +
 .../apache/hadoop/hive/ql/parse/CreateDDLParser.g  |    35 +
 .../apache/hadoop/hive/ql/parse/HiveLexerParent.g  |     6 +
 .../org/apache/hadoop/hive/ql/parse/HiveParser.g   |    36 +-
 .../hadoop/hive/ql/parse/IdentifiersParser.g       |     4 +-
 pom.xml                                            |     3 +
 .../database/create/CreateDatabaseAnalyzer.java    |    43 +-
 .../ql/ddl/database/create/CreateDatabaseDesc.java |    54 +
 .../database/create/CreateDatabaseOperation.java   |    22 +-
 .../ql/ddl/database/desc/DescDatabaseDesc.java     |     6 +-
 .../ddl/database/desc/DescDatabaseOperation.java   |    23 +-
 .../org/apache/hadoop/hive/ql/hooks/Entity.java    |    33 +-
 .../apache/hadoop/hive/ql/hooks/ReadEntity.java    |     8 +
 .../apache/hadoop/hive/ql/hooks/WriteEntity.java   |     6 +
 .../org/apache/hadoop/hive/ql/metadata/Hive.java   |   105 +
 .../metadata/formatting/JsonMetaDataFormatter.java |   704 ++
 .../hadoop/hive/ql/parse/BaseSemanticAnalyzer.java |    18 +
 .../apache/hadoop/hive/ql/plan/HiveOperation.java  |     8 +
 .../hive/ql/security/authorization/Privilege.java  |     3 +
 standalone-metastore/metastore-common/pom.xml      |     1 +
 .../src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp |  7400 +++++++++--
 .../src/gen/thrift/gen-cpp/ThriftHiveMetastore.h   |   700 ++
 .../ThriftHiveMetastore_server.skeleton.cpp        |    25 +
 .../gen/thrift/gen-cpp/hive_metastore_types.cpp    |  8645 ++++++++-----
 .../src/gen/thrift/gen-cpp/hive_metastore_types.h  |   350 +-
 .../hive/metastore/api/AbortTxnsRequest.java       |    32 +-
 .../hive/metastore/api/AddDynamicPartitions.java   |    32 +-
 .../api/AllocateTableWriteIdsRequest.java          |    68 +-
 .../api/AllocateTableWriteIdsResponse.java         |    36 +-
 .../hive/metastore/api/AlterPartitionsRequest.java |    34 +
 .../hive/metastore/api/AlterTableRequest.java      |    32 +
 .../metastore/api/ClearFileMetadataRequest.java    |    32 +-
 .../hive/metastore/api/ClientCapabilities.java     |    36 +-
 .../hive/metastore/api/CommitTxnRequest.java       |    36 +-
 .../hive/metastore/api/CompactionRequest.java      |    44 +-
 ...sponse.java => CreateDataConnectorRequest.java} |   221 +-
 .../{Database.java => CreateDatabaseRequest.java}  |   555 +-
 .../hive/metastore/api/CreateTableRequest.java     |   236 +
 .../api/{Database.java => DataConnector.java}      |   753 +-
 .../apache/hadoop/hive/metastore/api/Database.java |   338 +-
 .../hadoop/hive/metastore/api/DatabaseType.java    |    43 +
 .../hive/metastore/api/ExtendedTableInfo.java      |    64 +
 .../hive/metastore/api/FindSchemasByColsResp.java  |    34 +
 .../hive/metastore/api/FireEventRequest.java       |    32 +-
 .../hive/metastore/api/FireEventRequestData.java   |    36 +-
 .../hive/metastore/api/FireEventResponse.java      |    32 +-
 .../apache/hadoop/hive/metastore/api/Function.java |    36 +-
 .../metastore/api/GetAllFunctionsResponse.java     |    36 +-
 ...lesResult.java => GetDataConnectorRequest.java} |   221 +-
 .../hive/metastore/api/GetDatabaseRequest.java     |    32 +
 .../hive/metastore/api/GetFieldsResponse.java      |    36 +-
 .../api/GetFileMetadataByExprRequest.java          |    32 +-
 .../metastore/api/GetFileMetadataByExprResult.java |    48 +-
 .../hive/metastore/api/GetFileMetadataRequest.java |    32 +-
 .../hive/metastore/api/GetFileMetadataResult.java  |    44 +-
 .../metastore/api/GetOpenTxnsInfoResponse.java     |    36 +-
 .../hive/metastore/api/GetOpenTxnsRequest.java     |    36 +-
 .../hive/metastore/api/GetOpenTxnsResponse.java    |    32 +-
 .../metastore/api/GetPartitionNamesPsRequest.java  |    32 +-
 .../metastore/api/GetPartitionNamesPsResponse.java |    32 +-
 .../hive/metastore/api/GetPartitionRequest.java    |    32 +-
 .../metastore/api/GetPartitionsFilterSpec.java     |    32 +-
 .../api/GetPartitionsPsWithAuthRequest.java        |    64 +-
 .../api/GetPartitionsPsWithAuthResponse.java       |    36 +-
 .../hive/metastore/api/GetPartitionsRequest.java   |    64 +-
 .../hive/metastore/api/GetPartitionsResponse.java  |    36 +-
 .../hive/metastore/api/GetProjectionsSpec.java     |    32 +
 .../hive/metastore/api/GetSchemaResponse.java      |    36 +-
 .../hadoop/hive/metastore/api/GetTableRequest.java |    32 +
 .../hive/metastore/api/GetTablesExtRequest.java    |    32 +
 .../hive/metastore/api/GetTablesRequest.java       |    64 +
 .../hadoop/hive/metastore/api/GetTablesResult.java |    34 +
 .../metastore/api/GetValidWriteIdsRequest.java     |    32 +-
 .../metastore/api/GetValidWriteIdsResponse.java    |    36 +-
 .../metastore/api/HeartbeatTxnRangeResponse.java   |    64 +-
 .../hive/metastore/api/InsertEventRequestData.java |   128 +-
 .../hadoop/hive/metastore/api/LockRequest.java     |    36 +-
 .../metastore/api/NotificationEventRequest.java    |    32 +-
 .../metastore/api/NotificationEventResponse.java   |    36 +-
 .../hadoop/hive/metastore/api/OpenTxnRequest.java  |    32 +-
 .../hive/metastore/api/OpenTxnsResponse.java       |    32 +-
 .../hive/metastore/api/PartitionsResponse.java     |    36 +-
 .../hive/metastore/api/PutFileMetadataRequest.java |    64 +-
 .../hive/metastore/api/RenamePartitionRequest.java |    32 +
 .../hadoop/hive/metastore/api/ReplLastIdInfo.java  |    32 +-
 .../metastore/api/ReplTblWriteIdStateRequest.java  |    32 +-
 .../hive/metastore/api/ReplicationMetricList.java  |    36 +-
 .../hadoop/hive/metastore/api/SchemaVersion.java   |    34 +
 .../hive/metastore/api/ShowCompactResponse.java    |    36 +-
 .../hive/metastore/api/ShowLocksResponse.java      |    36 +-
 .../hive/metastore/api/TableValidWriteIds.java     |    32 +-
 .../hive/metastore/api/ThriftHiveMetastore.java    | 12182 ++++++++++++++-----
 .../hive/metastore/api/WMFullResourcePlan.java     |   136 +
 .../api/WMGetAllResourcePlanResponse.java          |    34 +
 .../api/WMGetTriggersForResourePlanResponse.java   |    34 +
 .../api/WMValidateResourcePlanResponse.java        |    64 +
 .../metastore/api/WriteNotificationLogRequest.java |    32 +-
 .../thrift/gen-php/metastore/AbortTxnsRequest.php  |    18 +-
 .../gen-php/metastore/AddDynamicPartitions.php     |    18 +-
 .../metastore/AllocateTableWriteIdsRequest.php     |    38 +-
 .../metastore/AllocateTableWriteIdsResponse.php    |    20 +-
 .../gen-php/metastore/AlterPartitionsRequest.php   |    16 +
 .../thrift/gen-php/metastore/AlterTableRequest.php |    15 +
 .../gen-php/metastore/ClearFileMetadataRequest.php |    18 +-
 .../gen-php/metastore/ClientCapabilities.php       |    18 +-
 .../thrift/gen-php/metastore/CommitTxnRequest.php  |    20 +-
 .../thrift/gen-php/metastore/CompactionRequest.php |    26 +-
 ...Response.php => CreateDataConnectorRequest.php} |    49 +-
 .../{Database.php => CreateDatabaseRequest.php}    |    98 +-
 .../gen-php/metastore/CreateTableRequest.php       |   111 +
 .../metastore/{Database.php => DataConnector.php}  |   165 +-
 .../src/gen/thrift/gen-php/metastore/Database.php  |    72 +
 .../gen/thrift/gen-php/metastore/DatabaseType.php  |    30 +
 .../thrift/gen-php/metastore/ExtendedTableInfo.php |    30 +
 .../gen-php/metastore/FindSchemasByColsResp.php    |    16 +
 .../thrift/gen-php/metastore/FireEventRequest.php  |    18 +-
 .../gen-php/metastore/FireEventRequestData.php     |    20 +-
 .../thrift/gen-php/metastore/FireEventResponse.php |    18 +-
 .../src/gen/thrift/gen-php/metastore/Function.php  |    20 +-
 .../gen-php/metastore/GetAllFunctionsResponse.php  |    20 +-
 ...apabilities.php => GetDataConnectorRequest.php} |    48 +-
 .../gen-php/metastore/GetDatabaseRequest.php       |    15 +
 .../thrift/gen-php/metastore/GetFieldsResponse.php |    20 +-
 .../metastore/GetFileMetadataByExprRequest.php     |    18 +-
 .../metastore/GetFileMetadataByExprResult.php      |    28 +-
 .../gen-php/metastore/GetFileMetadataRequest.php   |    18 +-
 .../gen-php/metastore/GetFileMetadataResult.php    |    26 +-
 .../gen-php/metastore/GetOpenTxnsInfoResponse.php  |    20 +-
 .../gen-php/metastore/GetOpenTxnsRequest.php       |    18 +-
 .../gen-php/metastore/GetOpenTxnsResponse.php      |    18 +-
 .../metastore/GetPartitionNamesPsRequest.php       |    18 +-
 .../metastore/GetPartitionNamesPsResponse.php      |    18 +-
 .../gen-php/metastore/GetPartitionRequest.php      |    18 +-
 .../gen-php/metastore/GetPartitionsFilterSpec.php  |    18 +-
 .../metastore/GetPartitionsPsWithAuthRequest.php   |    36 +-
 .../metastore/GetPartitionsPsWithAuthResponse.php  |    20 +-
 .../gen-php/metastore/GetPartitionsRequest.php     |    36 +-
 .../gen-php/metastore/GetPartitionsResponse.php    |    20 +-
 .../gen-php/metastore/GetProjectionsSpec.php       |    15 +
 .../thrift/gen-php/metastore/GetSchemaResponse.php |    20 +-
 .../thrift/gen-php/metastore/GetTableRequest.php   |    15 +
 .../gen-php/metastore/GetTablesExtRequest.php      |    15 +
 .../thrift/gen-php/metastore/GetTablesRequest.php  |    30 +
 .../thrift/gen-php/metastore/GetTablesResult.php   |    16 +
 .../gen-php/metastore/GetValidWriteIdsRequest.php  |    18 +-
 .../gen-php/metastore/GetValidWriteIdsResponse.php |    20 +-
 .../metastore/HeartbeatTxnRangeResponse.php        |    36 +-
 .../gen-php/metastore/InsertEventRequestData.php   |    72 +-
 .../gen/thrift/gen-php/metastore/LockRequest.php   |    20 +-
 .../gen-php/metastore/NotificationEventRequest.php |    18 +-
 .../metastore/NotificationEventResponse.php        |    20 +-
 .../thrift/gen-php/metastore/OpenTxnRequest.php    |    18 +-
 .../thrift/gen-php/metastore/OpenTxnsResponse.php  |    18 +-
 .../gen-php/metastore/PartitionsResponse.php       |    20 +-
 .../gen-php/metastore/PutFileMetadataRequest.php   |    36 +-
 .../gen-php/metastore/RenamePartitionRequest.php   |    15 +
 .../thrift/gen-php/metastore/ReplLastIdInfo.php    |    18 +-
 .../metastore/ReplTblWriteIdStateRequest.php       |    18 +-
 .../gen-php/metastore/ReplicationMetricList.php    |    20 +-
 .../gen/thrift/gen-php/metastore/SchemaVersion.php |    16 +
 .../gen-php/metastore/ShowCompactResponse.php      |    20 +-
 .../thrift/gen-php/metastore/ShowLocksResponse.php |    20 +-
 .../gen-php/metastore/TableValidWriteIds.php       |    18 +-
 .../metastore/ThriftHiveMetastoreClient.php        |   321 +
 .../gen-php/metastore/ThriftHiveMetastoreIf.php    |    35 +
 .../ThriftHiveMetastore_add_partitions_args.php    |    20 +-
 ...riftHiveMetastore_add_partitions_pspec_args.php |    20 +-
 ...riftHiveMetastore_alter_dataconnector_args.php} |    65 +-
 ...ftHiveMetastore_alter_dataconnector_result.php} |    50 +-
 .../ThriftHiveMetastore_alter_partitions_args.php  |    20 +-
 ...er_partitions_with_environment_context_args.php |    20 +-
 .../ThriftHiveMetastore_append_partition_args.php  |    18 +-
 ...end_partition_with_environment_context_args.php |    18 +-
 ...iftHiveMetastore_create_dataconnector_args.php} |    49 +-
 ...tHiveMetastore_create_dataconnector_result.php} |    84 +-
 ...etastore_create_table_with_constraints_args.php |   120 +-
 ...hriftHiveMetastore_drop_dataconnector_args.php} |    92 +-
 ...iftHiveMetastore_drop_dataconnector_result.php} |    80 +-
 .../ThriftHiveMetastore_drop_partition_args.php    |    18 +-
 ...rop_partition_with_environment_context_args.php |    18 +-
 ...ThriftHiveMetastore_exchange_partition_args.php |    26 +-
 ...hriftHiveMetastore_exchange_partitions_args.php |    26 +-
 ...iftHiveMetastore_exchange_partitions_result.php |    20 +-
 ...iveMetastore_find_columns_with_stats_result.php |    18 +-
 ...hriftHiveMetastore_get_all_databases_result.php |    18 +-
 ...erialized_view_objects_for_rewriting_result.php |    20 +-
 ...eMetastore_get_all_stored_procedures_result.php |    18 +-
 .../ThriftHiveMetastore_get_all_tables_result.php  |    18 +-
 ...eMetastore_get_all_token_identifiers_result.php |    18 +-
 .../ThriftHiveMetastore_get_databases_result.php   |    18 +-
 ...ftHiveMetastore_get_dataconnector_req_args.php} |    49 +-
 ...HiveMetastore_get_dataconnector_req_result.php} |    39 +-
 ...ThriftHiveMetastore_get_dataconnectors_args.php |    68 +
 ...iftHiveMetastore_get_dataconnectors_result.php} |    24 +-
 .../ThriftHiveMetastore_get_fields_result.php      |    20 +-
 ..._get_fields_with_environment_context_result.php |    20 +-
 .../ThriftHiveMetastore_get_functions_result.php   |    18 +-
 .../ThriftHiveMetastore_get_master_keys_result.php |    18 +-
 ...get_materialized_views_for_rewriting_result.php |    18 +-
 ...veMetastore_get_part_specs_by_filter_result.php |    20 +-
 .../ThriftHiveMetastore_get_partition_args.php     |    18 +-
 ...ftHiveMetastore_get_partition_names_ps_args.php |    18 +-
 ...HiveMetastore_get_partition_names_ps_result.php |    18 +-
 ...iveMetastore_get_partition_names_req_result.php |    18 +-
 ...iftHiveMetastore_get_partition_names_result.php |    18 +-
 ...tHiveMetastore_get_partition_with_auth_args.php |    36 +-
 ...veMetastore_get_partitions_by_filter_result.php |    20 +-
 ...tHiveMetastore_get_partitions_by_names_args.php |    18 +-
 ...iveMetastore_get_partitions_by_names_result.php |    20 +-
 .../ThriftHiveMetastore_get_partitions_ps_args.php |    18 +-
 ...hriftHiveMetastore_get_partitions_ps_result.php |    20 +-
 ...eMetastore_get_partitions_ps_with_auth_args.php |    36 +-
 ...etastore_get_partitions_ps_with_auth_result.php |    20 +-
 ...ftHiveMetastore_get_partitions_pspec_result.php |    20 +-
 .../ThriftHiveMetastore_get_partitions_result.php  |    20 +-
 ...HiveMetastore_get_partitions_with_auth_args.php |    18 +-
 ...veMetastore_get_partitions_with_auth_result.php |    20 +-
 .../ThriftHiveMetastore_get_privilege_set_args.php |    18 +-
 .../ThriftHiveMetastore_get_role_names_result.php  |    18 +-
 ...hriftHiveMetastore_get_runtime_stats_result.php |    20 +-
 ...iveMetastore_get_schema_all_versions_result.php |    20 +-
 .../ThriftHiveMetastore_get_schema_result.php      |    20 +-
 ..._get_schema_with_environment_context_result.php |    20 +-
 .../ThriftHiveMetastore_get_table_meta_args.php    |    18 +-
 .../ThriftHiveMetastore_get_table_meta_result.php  |    20 +-
 ...eMetastore_get_table_names_by_filter_result.php |    18 +-
 ...iveMetastore_get_table_objects_by_name_args.php |    18 +-
 ...eMetastore_get_table_objects_by_name_result.php |    20 +-
 ...riftHiveMetastore_get_tables_by_type_result.php |    18 +-
 .../ThriftHiveMetastore_get_tables_ext_result.php  |    20 +-
 .../ThriftHiveMetastore_get_tables_result.php      |    18 +-
 .../ThriftHiveMetastore_get_type_all_result.php    |    28 +-
 ...iveMetastore_isPartitionMarkedForEvent_args.php |    26 +-
 .../ThriftHiveMetastore_list_privileges_result.php |    20 +-
 .../ThriftHiveMetastore_list_roles_result.php      |    20 +-
 ...iftHiveMetastore_markPartitionForEvent_args.php |    26 +-
 ...re_partition_name_has_valid_characters_args.php |    18 +-
 ...HiveMetastore_partition_name_to_spec_result.php |    26 +-
 ...HiveMetastore_partition_name_to_vals_result.php |    18 +-
 .../ThriftHiveMetastore_rename_partition_args.php  |    18 +-
 .../metastore/ThriftHiveMetastore_set_ugi_args.php |    18 +-
 .../ThriftHiveMetastore_set_ugi_result.php         |    18 +-
 .../ThriftHiveMetastore_truncate_table_args.php    |    18 +-
 .../gen-php/metastore/WMFullResourcePlan.php       |    64 +
 .../metastore/WMGetAllResourcePlanResponse.php     |    16 +
 .../WMGetTriggersForResourePlanResponse.php        |    16 +
 .../metastore/WMValidateResourcePlanResponse.php   |    30 +
 .../metastore/WriteNotificationLogRequest.php      |    18 +-
 .../hive_metastore/ThriftHiveMetastore-remote      |    35 +
 .../gen-py/hive_metastore/ThriftHiveMetastore.py   |  3054 +++--
 .../src/gen/thrift/gen-py/hive_metastore/ttypes.py |  1737 ++-
 .../src/gen/thrift/gen-rb/hive_metastore_types.rb  |   134 +-
 .../src/gen/thrift/gen-rb/thrift_hive_metastore.rb |   331 +
 .../hadoop/hive/metastore/HiveMetaStoreClient.java |    78 +-
 .../hadoop/hive/metastore/IMetaStoreClient.java    |    52 +
 .../apache/hadoop/hive/metastore/Warehouse.java    |     8 +
 .../hadoop/hive/metastore/utils/FilterUtils.java   |    20 +
 .../src/main/thrift/hive_metastore.thrift          |    54 +-
 standalone-metastore/metastore-server/pom.xml      |     1 +
 .../hadoop/hive/metastore/HiveMetaStore.java       | 10299 ++++++++++++++++
 .../hadoop/hive/metastore/MetaStoreDirectSql.java  |    14 +-
 .../hive/metastore/MetaStoreEventListener.java     |    16 +
 .../hive/metastore/MetaStoreListenerNotifier.java  |    15 +
 .../apache/hadoop/hive/metastore/ObjectStore.java  |   218 +-
 .../org/apache/hadoop/hive/metastore/RawStore.java |    46 +
 .../TransactionalMetaStoreEventListener.java       |    14 +
 .../hadoop/hive/metastore/cache/CachedStore.java   |    32 +
 .../AbstractDataConnectorProvider.java             |    76 +
 .../DataConnectorProviderFactory.java              |    86 +
 .../dataconnector/IDataConnectorProvider.java      |    63 +
 .../dataconnector/jdbc/JDBCConnectorProvider.java  |   134 +
 .../dataconnector/jdbc/MySQLConfigGenerator.java   |     4 +
 .../CreateDataConnectorEvent.java}                 |    32 +-
 .../metastore/events/DropDataConnectorEvent.java   |    26 +
 .../events/PreCreateDataConnectorEvent.java        |    24 +
 .../hive/metastore/events/PreEventContext.java     |     5 +-
 .../hive/metastore/messaging/EventMessage.java     |     3 +
 .../hive/metastore/messaging/MessageBuilder.java   |     3 +
 .../model/{MDatabase.java => MDataConnector.java}  |    85 +-
 .../hadoop/hive/metastore/model/MDatabase.java     |    62 +
 .../src/main/resources/package.jdo                 |    44 +-
 .../src/main/sql/derby/hive-schema-4.0.0.derby.sql |    10 +-
 .../sql/derby/upgrade-3.2.0-to-4.0.0.derby.sql     |     9 +
 .../metastore/DummyRawStoreControlledCommit.java   |    50 +-
 .../metastore/DummyRawStoreForJdoConnection.java   |    54 +-
 .../metastore/HiveMetaStoreClientPreCatalog.java   |    44 +-
 standalone-metastore/pom.xml                       |     1 +
 testutils/ptest2/pom.xml                           |     1 +
 289 files changed, 44122 insertions(+), 12710 deletions(-)

diff --git a/common/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java b/common/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java
index e606539..0af2383 100644
--- a/common/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java
+++ b/common/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java
@@ -472,6 +472,9 @@ public enum ErrorMsg {
   OFFSET_NOT_SUPPORTED_IN_SUBQUERY(10424, "OFFSET is not supported in subquery of exists", true),
   WITH_COL_LIST_NUM_OVERFLOW(10425, "WITH-clause query {0} returns {1} columns, but {2} labels were specified. The number of column labels must be smaller or equal to the number of expressions returned by the query.", true),
   NULL_TREATMENT_NOT_SUPPORTED(10426, "Function {0} does not support null treatment.", true),
+  DATACONNECTOR_ALREADY_EXISTS(10427, "Dataconnector {0} already exists", true),
+  DATACONNECTOR_NOT_EXISTS(10428, "Dataconnector does not exist:"),
+
 
   //========================== 20000 range starts here ========================//
 
diff --git a/parser/src/java/org/apache/hadoop/hive/ql/parse/AlterClauseParser.g b/parser/src/java/org/apache/hadoop/hive/ql/parse/AlterClauseParser.g
index cced8bb..c5074be 100644
--- a/parser/src/java/org/apache/hadoop/hive/ql/parse/AlterClauseParser.g
+++ b/parser/src/java/org/apache/hadoop/hive/ql/parse/AlterClauseParser.g
@@ -51,6 +51,7 @@ alterStatement
     | KW_ALTER KW_VIEW tableName KW_AS? alterViewStatementSuffix -> ^(TOK_ALTERVIEW tableName alterViewStatementSuffix)
     | KW_ALTER KW_MATERIALIZED KW_VIEW tableNameTree=tableName alterMaterializedViewStatementSuffix[$tableNameTree.tree] -> alterMaterializedViewStatementSuffix
     | KW_ALTER (KW_DATABASE|KW_SCHEMA) alterDatabaseStatementSuffix -> alterDatabaseStatementSuffix
+    | KW_ALTER KW_DATACONNECTOR alterDataConnectorStatementSuffix -> alterDataConnectorStatementSuffix
     ;
 
 alterTableStatementSuffix
@@ -450,3 +451,33 @@ fileFormat
       -> ^(TOK_TABLEFILEFORMAT $inFmt $outFmt $serdeCls $inDriver? $outDriver?)
     | genericSpec=identifier -> ^(TOK_FILEFORMAT_GENERIC $genericSpec)
     ;
+
+alterDataConnectorStatementSuffix
+@init { gParent.pushMsg("alter connector statement", state); }
+@after { gParent.popMsg(state); }
+    : alterDataConnectorSuffixProperties
+    | alterDataConnectorSuffixSetOwner
+    | alterDataConnectorSuffixSetUrl
+    ;
+
+alterDataConnectorSuffixProperties
+@init { gParent.pushMsg("alter connector set properties statement", state); }
+@after { gParent.popMsg(state); }
+    : name=identifier KW_SET KW_DBPROPERTIES dbProperties
+    -> ^(TOK_ALTERDATACONNECTOR_PROPERTIES $name dbProperties)
+    ;
+
+alterDataConnectorSuffixSetOwner
+@init { gParent.pushMsg("alter connector set owner", state); }
+@after { gParent.popMsg(state); }
+    : dcName=identifier KW_SET KW_OWNER principalName
+    -> ^(TOK_ALTERDATACONNECTOR_OWNER $dcName principalName)
+    ;
+
+alterDataConnectorSuffixSetUrl
+@init { gParent.pushMsg("alter connector set url", state); }
+@after { gParent.popMsg(state); }
+    : dcName=identifier KW_SET KW_URL newUri=StringLiteral
+    -> ^(TOK_ALTERDATACONNECTOR_URL $dcName $newUri)
+    ;
+
diff --git a/parser/src/java/org/apache/hadoop/hive/ql/parse/CreateDDLParser.g b/parser/src/java/org/apache/hadoop/hive/ql/parse/CreateDDLParser.g
index ce01aea..434ae57 100644
--- a/parser/src/java/org/apache/hadoop/hive/ql/parse/CreateDDLParser.g
+++ b/parser/src/java/org/apache/hadoop/hive/ql/parse/CreateDDLParser.g
@@ -108,3 +108,38 @@ createTableStatement
          selectStatementWithCTE?
         )
     ;
+
+createDataConnectorStatement
+@init { gParent.pushMsg("create connector statement", state); }
+@after { gParent.popMsg(state); }
+    : KW_CREATE KW_DATACONNECTOR ifNotExists? name=identifier dataConnectorType dataConnectorUrl dataConnectorComment? ( KW_WITH KW_PROPERTIES dcprops=dbProperties)?
+    -> ^(TOK_CREATEDATACONNECTOR $name ifNotExists? dataConnectorType dataConnectorUrl dataConnectorComment? $dcprops?)
+    ;
+
+dataConnectorComment
+@init { gParent.pushMsg("dataconnector comment", state); }
+@after { gParent.popMsg(state); }
+    : KW_COMMENT comment=StringLiteral
+    -> ^(TOK_DATACONNECTORCOMMENT $comment)
+    ;
+
+dataConnectorUrl
+@init { gParent.pushMsg("dataconnector URL", state); }
+@after { gParent.popMsg(state); }
+    : KW_URL url=StringLiteral
+    -> ^(TOK_DATACONNECTORURL $url)
+    ;
+
+dataConnectorType
+@init { gParent.pushMsg("dataconnector type", state); }
+@after { gParent.popMsg(state); }
+    : KW_TYPE dcType=StringLiteral
+    -> ^(TOK_DATACONNECTORTYPE $dcType)
+    ;
+
+dropDataConnectorStatement
+@init { gParent.pushMsg("drop connector statement", state); }
+@after { gParent.popMsg(state); }
+    : KW_DROP (KW_DATACONNECTOR) ifExists? identifier
+    -> ^(TOK_DROPDATACONNECTOR identifier ifExists?)
+    ;
diff --git a/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveLexerParent.g b/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveLexerParent.g
index 4009218..5c6df83 100644
--- a/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveLexerParent.g
+++ b/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveLexerParent.g
@@ -183,6 +183,7 @@ KW_WITH: 'WITH';
 KW_DEFERRED: 'DEFERRED';
 KW_SERDEPROPERTIES: 'SERDEPROPERTIES';
 KW_DBPROPERTIES: 'DBPROPERTIES';
+KW_DCPROPERTIES: 'DCPROPERTIES';
 KW_LIMIT: 'LIMIT';
 KW_OFFSET: 'OFFSET';
 KW_SET: 'SET';
@@ -378,6 +379,11 @@ KW_TRAILING: 'TRAILING';
 KW_TRIM: 'TRIM';
 KW_IGNORE: 'IGNORE';
 KW_RESPECT: 'RESPECT';
+KW_DATACONNECTOR: 'CONNECTOR';
+KW_DATACONNECTORS: 'CONNECTORS';
+KW_TYPE: 'TYPE';
+KW_URL: 'URL';
+KW_REMOTE: 'REMOTE';
 
 // Operators
 // NOTE: if you add a new function/operator, add it to sysFuncNames so that describe function _FUNC_ will work.
diff --git a/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g b/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
index 2cb7ea8..1375e4a 100644
--- a/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
+++ b/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
@@ -157,9 +157,17 @@ TOK_MAP;
 TOK_UNIONTYPE;
 TOK_COLTYPELIST;
 TOK_CREATEDATABASE;
+TOK_CREATEDATACONNECTOR;
 TOK_CREATETABLE;
 TOK_TRUNCATETABLE;
 TOK_LIKETABLE;
+TOK_DATACONNECTOR;
+TOK_DATACONNECTORCOMMENT;
+TOK_DATACONNECTORTYPE;
+TOK_DATACONNECTORURL;
+TOK_DATACONNECTOROWNER;
+TOK_DATACONNECTORPROPERTIES;
+TOK_DROPDATACONNECTOR;
 TOK_DESCTABLE;
 TOK_DESCFUNCTION;
 TOK_ALTERTABLE;
@@ -207,6 +215,7 @@ TOK_ALTERTABLE_UPDATECOLUMNS;
 TOK_ALTERTABLE_OWNER;
 TOK_MSCK;
 TOK_SHOWDATABASES;
+TOK_SHOWDATACONNECTORS;
 TOK_SHOWTABLES;
 TOK_SHOWCOLUMNS;
 TOK_SHOWFUNCTIONS;
@@ -355,6 +364,11 @@ TOK_ALTERDATABASE_PROPERTIES;
 TOK_ALTERDATABASE_OWNER;
 TOK_ALTERDATABASE_LOCATION;
 TOK_ALTERDATABASE_MANAGEDLOCATION;
+TOK_DATACONNECTORPROPERTIES;
+TOK_ALTERDATACONNECTOR_PROPERTIES;
+TOK_ALTERDATACONNECTOR_OWNER;
+TOK_ALTERDATACONNECTOR_URL;
+TOK_DESCDATACONNECTOR;
 TOK_DBNAME;
 TOK_TABNAME;
 TOK_TABSRC;
@@ -468,6 +482,7 @@ TOK_EXECUTED_AS;
 TOK_EXECUTE;
 TOK_SCHEDULE;
 TOK_EVERY;
+TOK_REMOTE;
 TOK_PARAMETER;
 TOK_PARAMETER_IDX;
 TOK_RESPECT_NULLS;
@@ -670,6 +685,10 @@ import org.apache.hadoop.hive.conf.HiveConf;
     xlateMap.put("KW_TRAILING", "TRAILING");
     xlateMap.put("KW_BOTH", "BOTH");
 
+    xlateMap.put("KW_TYPE", "TYPE");
+    xlateMap.put("KW_DATACONNECTOR", "CONNECTOR");
+    xlateMap.put("KW_DATACONNECTORS", "CONNECTORS");
+    xlateMap.put("KW_REMOTE", "REMOTE");
 
     // Operators
     xlateMap.put("DOT", ".");
@@ -1043,6 +1062,8 @@ ddlStatement
     | abortTransactionStatement
     | killQueryStatement
     | resourcePlanDdlStatements
+    | createDataConnectorStatement
+    | dropDataConnectorStatement
     ;
 
 ifExists
@@ -1106,14 +1127,16 @@ orReplace
 createDatabaseStatement
 @init { pushMsg("create database statement", state); }
 @after { popMsg(state); }
-    : KW_CREATE (KW_DATABASE|KW_SCHEMA)
+    : KW_CREATE (remote=KW_REMOTE)? (KW_DATABASE|KW_SCHEMA)
         ifNotExists?
         name=identifier
         databaseComment?
         dbLocation?
         dbManagedLocation?
+        dbConnectorName?
         (KW_WITH KW_DBPROPERTIES dbprops=dbProperties)?
-    -> ^(TOK_CREATEDATABASE $name ifNotExists? dbLocation? dbManagedLocation? databaseComment? $dbprops?)
+    -> {$remote != null}? ^(TOK_CREATEDATABASE $name ifNotExists? databaseComment? $dbprops? dbConnectorName?)
+    ->                    ^(TOK_CREATEDATABASE $name ifNotExists? dbLocation? dbManagedLocation? databaseComment? $dbprops?)
     ;
 
 dbLocation
@@ -1144,6 +1167,12 @@ dbPropertiesList
       keyValueProperty (COMMA keyValueProperty)* -> ^(TOK_DBPROPLIST keyValueProperty+)
     ;
 
+dbConnectorName
+@init { pushMsg("remote database using connector", state); }
+@after { popMsg(state); }
+    :
+      KW_USING dcName=identifier -> ^(TOK_DATACONNECTOR $dcName)
+    ;
 
 switchDatabaseStatement
 @init { pushMsg("switch database statement", state); }
@@ -1222,6 +1251,8 @@ descStatement
     (
     (KW_DATABASE|KW_SCHEMA) => (KW_DATABASE|KW_SCHEMA) KW_EXTENDED? (dbName=identifier) -> ^(TOK_DESCDATABASE $dbName KW_EXTENDED?)
     |
+    (KW_DATACONNECTOR) => (KW_DATACONNECTOR) KW_EXTENDED? (dcName=identifier) -> ^(TOK_DESCDATACONNECTOR $dcName KW_EXTENDED?)
+    |
     (KW_FUNCTION) => KW_FUNCTION KW_EXTENDED? (name=descFuncNames) -> ^(TOK_DESCFUNCTION $name KW_EXTENDED?)
     |
     (KW_FORMATTED|KW_EXTENDED) => ((descOptions=KW_FORMATTED|descOptions=KW_EXTENDED) parttype=tabPartColTypeExpr) -> ^(TOK_DESCTABLE $parttype $descOptions)
@@ -1277,6 +1308,7 @@ showStatement
         (KW_PLAN rp_name=identifier -> ^(TOK_SHOW_RP $rp_name))
         | (KW_PLANS -> ^(TOK_SHOW_RP))
       )
+    | KW_SHOW (KW_DATACONNECTORS) -> ^(TOK_SHOWDATACONNECTORS)
     ;
 
 showTablesFilterExpr
diff --git a/parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g b/parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
index 110b16c..9402471 100644
--- a/parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
+++ b/parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
@@ -922,11 +922,11 @@ nonReserved
     | KW_MANAGEDLOCATION | KW_MAPJOIN | KW_MATERIALIZED | KW_METADATA | KW_MINUTE | KW_MONTH | KW_MSCK | KW_NOSCAN | KW_NO_DROP | KW_NULLS | KW_OFFLINE
     | KW_OPTION | KW_OUTPUTDRIVER | KW_OUTPUTFORMAT | KW_OVERWRITE | KW_OWNER | KW_PARTITIONED | KW_PARTITIONS | KW_PLUS
     | KW_PRINCIPALS | KW_PROTECTION | KW_PURGE | KW_QUERY | KW_QUARTER | KW_READ | KW_READONLY | KW_REBUILD | KW_RECORDREADER | KW_RECORDWRITER
-    | KW_RELOAD | KW_RENAME | KW_REPAIR | KW_REPLACE | KW_REPLICATION | KW_RESTRICT | KW_REWRITE
+    | KW_RELOAD | KW_REMOTE | KW_RENAME | KW_REPAIR | KW_REPLACE | KW_REPLICATION | KW_RESTRICT | KW_REWRITE
     | KW_ROLE | KW_ROLES | KW_SCHEMA | KW_SCHEMAS | KW_SECOND | KW_SEMI | KW_SERDE | KW_SERDEPROPERTIES | KW_SERVER | KW_SETS | KW_SHARED
     | KW_SHOW | KW_SHOW_DATABASE | KW_SKEWED | KW_SORT | KW_SORTED | KW_SSL | KW_STATISTICS | KW_STORED | KW_AST
     | KW_STREAMTABLE | KW_STRING | KW_STRUCT | KW_TABLES | KW_TBLPROPERTIES | KW_TEMPORARY | KW_TERMINATED
-    | KW_TINYINT | KW_TOUCH | KW_TRANSACTIONAL | KW_TRANSACTIONS | KW_UNARCHIVE | KW_UNDO | KW_UNIONTYPE | KW_UNLOCK | KW_UNSET
+    | KW_TINYINT | KW_TOUCH | KW_TRANSACTIONAL | KW_TRANSACTIONS | KW_TYPE | KW_UNARCHIVE | KW_UNDO | KW_UNIONTYPE | KW_UNLOCK | KW_UNSET
     | KW_UNSIGNED | KW_URI | KW_USE | KW_UTC | KW_UTCTIMESTAMP | KW_VALUE_TYPE | KW_VIEW | KW_WEEK | KW_WHILE | KW_YEAR
     | KW_WORK
     | KW_TRANSACTION
diff --git a/pom.xml b/pom.xml
index e6293c3..449b71e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1571,6 +1571,7 @@
         </executions>
         <configuration>
 	  <excludes>
+	    <exclude>*.patch</exclude>
 	    <exclude>.github/**</exclude>
 	    <exclude>binary-package-licenses/**</exclude>
 	    <exclude>data/**</exclude>
@@ -1617,6 +1618,8 @@
             <exclude>**/patchprocess/**</exclude>
             <exclude>**/metastore_db/**</exclude>
             <exclude>**/test/resources/**/*.ldif</exclude>
+            <exclude>hcatalog/core/mapred/**/part-m*</exclude>
+            <exclude>hcatalog/core/mapred/**/*_SUCCESS*</exclude>
 	  </excludes>
 	</configuration>
       </plugin>
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseAnalyzer.java
index 0cf58ee..42d7c79 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseAnalyzer.java
@@ -21,6 +21,7 @@ package org.apache.hadoop.hive.ql.ddl.database.create;
 import java.util.Map;
 
 import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.api.DatabaseType;
 import org.apache.hadoop.hive.ql.QueryState;
 import org.apache.hadoop.hive.ql.exec.TaskFactory;
 import org.apache.hadoop.hive.ql.ddl.DDLSemanticAnalyzerFactory.DDLType;
@@ -48,6 +49,8 @@ public class CreateDatabaseAnalyzer extends BaseSemanticAnalyzer {
     String comment = null;
     String locationUri = null;
     String managedLocationUri = null;
+    String type = "NATIVE";
+    String connectorName = null;
     Map<String, String> props = null;
 
     for (int i = 1; i < root.getChildCount(); i++) {
@@ -70,19 +73,47 @@ public class CreateDatabaseAnalyzer extends BaseSemanticAnalyzer {
         managedLocationUri = unescapeSQLString(childNode.getChild(0).getText());
         outputs.add(toWriteEntity(managedLocationUri));
         break;
+      case HiveParser.TOK_DATACONNECTOR:
+        type = "REMOTE";
+        locationUri = "REMOTE_DATABASE"; // TODO
+        // i++;
+        ASTNode nextNode = (ASTNode) root.getChild(i);
+        connectorName = ((ASTNode)nextNode).getChild(0).getText();
+        outputs.add(toWriteEntity(connectorName));
+        outputs.remove(toWriteEntity(locationUri));
+        if (managedLocationUri != null) {
+          outputs.remove(toWriteEntity(managedLocationUri));
+          managedLocationUri = null;
+        }
+        break;
       default:
         throw new SemanticException("Unrecognized token in CREATE DATABASE statement");
       }
     }
 
-    CreateDatabaseDesc desc = new CreateDatabaseDesc(databaseName, comment, locationUri, managedLocationUri,
-        ifNotExists, props);
-    rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc)));
-
+    // String remoteDbName = props.get("connector.remoteDbName");
+    CreateDatabaseDesc desc = null;
     Database database = new Database(databaseName, comment, locationUri, props);
-    if (managedLocationUri != null) {
-      database.setManagedLocationUri(managedLocationUri);
+    if (type.equalsIgnoreCase("NATIVE")) {
+      desc = new CreateDatabaseDesc(databaseName, comment, locationUri, managedLocationUri, ifNotExists, props);
+      database.setType(DatabaseType.NATIVE);
+      // database = new Database(databaseName, comment, locationUri, props);
+      if (managedLocationUri != null) {
+        database.setManagedLocationUri(managedLocationUri);
+      }
+    } else {
+      String remoteDbName = databaseName;
+      if (props != null && props.get("connector.remoteDbName") != null) // TODO
+        remoteDbName = props.get("connector.remoteDbName");
+      desc = new CreateDatabaseDesc(databaseName, comment, locationUri, null, ifNotExists, props, type,
+          connectorName, remoteDbName);
+      database.setConnector_name(connectorName);
+      database.setType(DatabaseType.REMOTE);
+      database.setRemote_dbname(remoteDbName);
     }
+    rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc)));
+
+    // database = new Database(databaseName, comment, locationUri, props);
     outputs.add(new WriteEntity(database, WriteEntity.WriteType.DDL_NO_LOCK));
   }
 }
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseDesc.java
index 167672b..ef9d8c8 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseDesc.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseDesc.java
@@ -21,32 +21,64 @@ package org.apache.hadoop.hive.ql.ddl.database.create;
 import java.io.Serializable;
 import java.util.Map;
 
+import org.apache.hadoop.hive.metastore.api.DatabaseType;
 import org.apache.hadoop.hive.ql.ddl.DDLDesc;
 import org.apache.hadoop.hive.ql.plan.Explain;
 import org.apache.hadoop.hive.ql.plan.Explain.Level;
 
+import javax.xml.crypto.Data;
+
 /**
  * DDL task description for CREATE DATABASE commands.
  */
 @Explain(displayName = "Create Database", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
 public class CreateDatabaseDesc implements DDLDesc, Serializable {
   private static final long serialVersionUID = 1L;
+  public static final String REMOTEDB_LOCATION = "REMOTE_LOCATION".intern();
 
   private final String databaseName;
   private final String comment;
   private final String locationUri;
   private final String managedLocationUri;
   private final boolean ifNotExists;
+  private final DatabaseType dbType;
+  private final String connectorName;
+  private final String remoteDbName;
   private final Map<String, String> dbProperties;
 
   public CreateDatabaseDesc(String databaseName, String comment, String locationUri, String managedLocationUri,
       boolean ifNotExists, Map<String, String> dbProperties) {
+    this(databaseName, comment, locationUri, managedLocationUri, ifNotExists, dbProperties, "NATIVE", null, null);
+/*
     this.databaseName = databaseName;
     this.comment = comment;
     this.locationUri = locationUri;
     this.managedLocationUri = managedLocationUri;
     this.ifNotExists = ifNotExists;
     this.dbProperties = dbProperties;
+
+ */
+  }
+
+  public CreateDatabaseDesc(String databaseName, String comment, String locationUri, String managedLocationUri,
+      boolean ifNotExists, Map<String, String> dbProperties, String dbtype, String connectorName, String remoteDbName) {
+    this.databaseName = databaseName;
+    this.comment = comment;
+    if (dbtype != null && dbtype.equalsIgnoreCase("REMOTE")) {
+      this.dbType = DatabaseType.REMOTE;
+      this.locationUri = REMOTEDB_LOCATION; // this is non-null in the HMSDB
+      this.connectorName = connectorName;
+      this.remoteDbName = remoteDbName;
+      this.managedLocationUri = null;
+    } else {
+      this.dbType = DatabaseType.NATIVE;
+      this.locationUri = locationUri;
+      this.managedLocationUri = managedLocationUri;
+      this.connectorName = null;
+      this.remoteDbName = null;
+    }
+    this.ifNotExists = ifNotExists;
+    this.dbProperties = dbProperties;
   }
 
   @Explain(displayName="if not exists", displayOnlyOnTrue = true)
@@ -77,4 +109,26 @@ public class CreateDatabaseDesc implements DDLDesc, Serializable {
   public String getManagedLocationUri() {
     return managedLocationUri;
   }
+
+  @Explain(displayName="database type")
+  public DatabaseType getDatabaseType() {
+    return dbType;
+    /*
+    if (dbType == DatabaseType.NATIVE)
+      return "NATIVE";
+    else
+      return "REMOTE";
+
+     */
+  }
+
+  @Explain(displayName="connector name")
+  public String getConnectorName() {
+    return connectorName;
+  }
+
+  @Explain(displayName="remote database name")
+  public String getRemoteDbName() {
+    return remoteDbName;
+  }
 }
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseOperation.java
index db06161..97e318d 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseOperation.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseOperation.java
@@ -21,11 +21,13 @@ package org.apache.hadoop.hive.ql.ddl.database.create;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.metastore.api.AlreadyExistsException;
 import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.api.DatabaseType;
 import org.apache.hadoop.hive.metastore.api.PrincipalType;
 import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
 import org.apache.hadoop.hive.ql.ErrorMsg;
 import org.apache.hadoop.hive.ql.ddl.DDLOperation;
 import org.apache.hadoop.hive.ql.ddl.DDLOperationContext;
+import org.apache.hadoop.hive.ql.ddl.database.desc.DescDatabaseDesc;
 import org.apache.hadoop.hive.ql.exec.Utilities;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
 import org.apache.hadoop.hive.ql.session.SessionState;
@@ -46,14 +48,20 @@ public class CreateDatabaseOperation extends DDLOperation<CreateDatabaseDesc> {
         desc.getDatabaseProperties());
     database.setOwnerName(SessionState.getUserFromAuthenticator());
     database.setOwnerType(PrincipalType.USER);
-    if (desc.getManagedLocationUri() != null) {
-      database.setManagedLocationUri(desc.getManagedLocationUri());
-    }
-
+    database.setType(desc.getDatabaseType());
     try {
-      makeLocationQualified(database);
-      if (database.getLocationUri().equalsIgnoreCase(database.getManagedLocationUri())) {
-        throw new HiveException("Managed and external locations for database cannot be the same");
+      if (desc.getDatabaseType() == DatabaseType.NATIVE) {
+        if (desc.getManagedLocationUri() != null) {
+          database.setManagedLocationUri(desc.getManagedLocationUri());
+        }
+        makeLocationQualified(database);
+        if (database.getLocationUri().equalsIgnoreCase(database.getManagedLocationUri())) {
+          throw new HiveException("Managed and external locations for database cannot be the same");
+        }
+      } else {
+        database.setLocationUri(CreateDatabaseDesc.REMOTEDB_LOCATION);
+        database.setConnector_name(desc.getConnectorName());
+        database.setRemote_dbname(desc.getRemoteDbName());
       }
       context.getDb().createDatabase(database, desc.getIfNotExists());
     } catch (AlreadyExistsException ex) {
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseDesc.java
index 09751ee..aafa67f 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseDesc.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseDesc.java
@@ -33,11 +33,11 @@ public class DescDatabaseDesc implements DDLDesc, Serializable {
   private static final long serialVersionUID = 1L;
 
   public static final String DESC_DATABASE_SCHEMA =
-      "db_name,comment,location,managedLocation,owner_name,owner_type#string:string:string:string:string:string";
+      "db_name,comment,location,managedLocation,owner_name,owner_type,connector_name,remote_dbname#string:string:string:string:string:string,string,string";
 
   public static final String DESC_DATABASE_SCHEMA_EXTENDED =
-      "db_name,comment,location,managedLocation,owner_name,owner_type,parameters#" +
-      "string:string:string:string:string:string:string";
+      "db_name,comment,location,managedLocation,owner_name,owner_type,connector_name,remote_dbname,parameters#" +
+      "string:string:string:string:string:string:string,string,string";
 
   private final String resFile;
   private final String dbName;
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseOperation.java
index f516228..0a19ccc 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseOperation.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseOperation.java
@@ -25,6 +25,7 @@ import java.util.TreeMap;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.api.DatabaseType;
 import org.apache.hadoop.hive.ql.ErrorMsg;
 import org.apache.hadoop.hive.ql.ddl.DDLOperation;
 import org.apache.hadoop.hive.ql.ddl.DDLOperationContext;
@@ -52,14 +53,22 @@ public class DescDatabaseOperation extends DDLOperation<DescDatabaseDesc> {
         params = new TreeMap<>(database.getParameters());
       }
 
-      String location = database.getLocationUri();
-      if (HiveConf.getBoolVar(context.getConf(), HiveConf.ConfVars.HIVE_IN_TEST)) {
-        location = "location/in/test";
-      }
-
+      String location = "";
       DescDatabaseFormatter formatter = DescDatabaseFormatter.getFormatter(context.getConf());
-      formatter.showDatabaseDescription(outStream, database.getName(), database.getDescription(), location,
-          database.getManagedLocationUri(), database.getOwnerName(), database.getOwnerType(), params);
+      if (database.getType() == DatabaseType.NATIVE) {
+        location = database.getLocationUri();
+        if (HiveConf.getBoolVar(context.getConf(), HiveConf.ConfVars.HIVE_IN_TEST)) {
+          location = "location/in/test";
+        }
+        // database.setRemote_dbname("");
+        // database.setConnector_name("");
+
+        formatter.showDatabaseDescription(outStream, database.getName(), database.getDescription(), location,
+          database.getManagedLocationUri(), database.getOwnerName(), database.getOwnerType(), params, "", "");
+      } else {
+        formatter.showDatabaseDescription(outStream, database.getName(), database.getDescription(), "", "",
+          database.getOwnerName(), database.getOwnerType(), params, database.getConnector_name(), database.getRemote_dbname());
+      }
     } catch (Exception e) {
       throw new HiveException(e, ErrorMsg.GENERIC_ERROR);
     }
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/hooks/Entity.java b/ql/src/java/org/apache/hadoop/hive/ql/hooks/Entity.java
index f36b0f9..254605e 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/hooks/Entity.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/hooks/Entity.java
@@ -24,6 +24,7 @@ import java.util.Map;
 
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.api.DataConnector;
 import org.apache.hadoop.hive.ql.metadata.DummyPartition;
 import org.apache.hadoop.hive.ql.metadata.Partition;
 import org.apache.hadoop.hive.ql.metadata.Table;
@@ -41,7 +42,7 @@ public class Entity implements Serializable {
    * The type of the entity.
    */
   public static enum Type {
-    DATABASE, TABLE, PARTITION, DUMMYPARTITION, DFS_DIR, LOCAL_DIR, FUNCTION, SERVICE_NAME
+    DATABASE, TABLE, PARTITION, DUMMYPARTITION, DFS_DIR, LOCAL_DIR, FUNCTION, SERVICE_NAME, DATACONNECTOR
   }
 
   /**
@@ -50,6 +51,11 @@ public class Entity implements Serializable {
   private Database database;
 
   /**
+   * The dataconnector if this is a dataconnector.
+   */
+  private DataConnector connector;
+
+  /**
    * The type.
    */
   private Type typ;
@@ -112,6 +118,14 @@ public class Entity implements Serializable {
     this.database = database;
   }
 
+  public DataConnector getDataConnector() {
+    return connector;
+  }
+
+  public void setDataConnector(DataConnector connector) {
+    this.connector = connector;
+  }
+
   public Type getTyp() {
     return typ;
   }
@@ -197,6 +211,21 @@ public class Entity implements Serializable {
   }
 
   /**
+   * Constructor for a dataconnector.
+   *
+   * @param dataconnector
+   *          Database that is read or written to.
+   * @param complete
+   *          Means the dataconnector is target
+   */
+  public Entity(DataConnector dataconnector, boolean complete) {
+    this.connector = dataconnector;
+    this.typ = Type.DATACONNECTOR;
+    this.name = computeName();
+    this.complete = complete;
+  }
+
+  /**
    * Constructor for a entity with string object representation (eg SERVICE_NAME)
    *
    * @param name
@@ -384,6 +413,8 @@ public class Entity implements Serializable {
       return stringObject;
     case SERVICE_NAME:
       return stringObject;
+    case DATACONNECTOR:
+      return "connector:" + connector.getName();
     default:
       return d.toString();
     }
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/hooks/ReadEntity.java b/ql/src/java/org/apache/hadoop/hive/ql/hooks/ReadEntity.java
index 2678def..df4fe3c 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/hooks/ReadEntity.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/hooks/ReadEntity.java
@@ -25,6 +25,7 @@ import java.util.List;
 import java.util.Set;
 
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.metastore.api.DataConnector;
 import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.ql.metadata.Partition;
 import org.apache.hadoop.hive.ql.metadata.Table;
@@ -82,6 +83,13 @@ public class ReadEntity extends Entity implements Serializable {
   }
 
   /**
+   * Constructor for a dataconnector.
+   */
+  public ReadEntity(DataConnector connector) {
+    super(connector, true);
+  }
+
+  /**
    * Constructor.
    *
    * @param t
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/hooks/WriteEntity.java b/ql/src/java/org/apache/hadoop/hive/ql/hooks/WriteEntity.java
index 6ce74c8..f5a8d63 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/hooks/WriteEntity.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/hooks/WriteEntity.java
@@ -19,6 +19,7 @@
 package org.apache.hadoop.hive.ql.hooks;
 
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.metastore.api.DataConnector;
 import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.ql.ddl.table.AlterTableType;
 import org.apache.hadoop.hive.ql.metadata.DummyPartition;
@@ -65,6 +66,11 @@ public class WriteEntity extends Entity implements Serializable {
     setWriteTypeInternal(type);
   }
 
+  public WriteEntity(DataConnector connector, WriteType type) {
+    super(connector, true);
+    setWriteTypeInternal(type);
+  }
+
   /**
    * Constructor for a table.
    *
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
index 8f40eab..c2c6d7f 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
@@ -128,6 +128,7 @@ import org.apache.hadoop.hive.metastore.api.CompactionResponse;
 import org.apache.hadoop.hive.metastore.api.CompactionType;
 import org.apache.hadoop.hive.metastore.api.CreationMetadata;
 import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.api.DataConnector;
 import org.apache.hadoop.hive.metastore.api.DefaultConstraintsRequest;
 import org.apache.hadoop.hive.metastore.api.EnvironmentContext;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
@@ -846,6 +847,110 @@ public class Hive {
     }
   }
 
+  /**
+   * Create a dataconnector
+   * @param connector
+   * @param ifNotExist if true, will ignore AlreadyExistsException exception
+   * @throws AlreadyExistsException
+   * @throws HiveException
+   */
+  public void createDataConnector(DataConnector connector, boolean ifNotExist)
+      throws AlreadyExistsException, HiveException {
+    try {
+      getMSC().createDataConnector(connector);
+    } catch (AlreadyExistsException e) {
+      if (!ifNotExist) {
+        throw e;
+      }
+    } catch (Exception e) {
+      throw new HiveException(e);
+    }
+  }
+
+  /**
+   * Create a DataConnector. Raise an error if a dataconnector with the same name already exists.
+   * @param connector
+   * @throws AlreadyExistsException
+   * @throws HiveException
+   */
+  public void createDataConnector(DataConnector connector) throws AlreadyExistsException, HiveException {
+    createDataConnector(connector, false);
+  }
+
+  /**
+   * Drop a dataconnector.
+   * @param name
+   * @throws NoSuchObjectException
+   * @throws HiveException
+   * @see org.apache.hadoop.hive.metastore.HiveMetaStoreClient#dropDataConnector(java.lang.String, boolean, boolean)
+   */
+  public void dropDataConnector(String name, boolean ifNotExists) throws HiveException, NoSuchObjectException {
+    dropDataConnector(name, ifNotExists, true);
+  }
+
+  /**
+   * Drop a dataconnector
+   * @param name
+   * @param checkReferences drop only if there are no dbs referencing this connector
+   * @throws HiveException
+   * @throws NoSuchObjectException
+   */
+  public void dropDataConnector(String name, boolean ifNotExists, boolean checkReferences)
+      throws HiveException, NoSuchObjectException {
+    try {
+      getMSC().dropDataConnector(name, ifNotExists, checkReferences);
+    } catch (NoSuchObjectException e) {
+      if (!ifNotExists)
+        throw e;
+    } catch (Exception e) {
+      throw new HiveException(e);
+    }
+  }
+
+  /**
+   * Get the dataconnector by name.
+   * @param dcName the name of the dataconnector.
+   * @return a DataConnector object if this dataconnector exists, null otherwise.
+   * @throws HiveException
+   */
+  public DataConnector getDataConnector(String dcName) throws HiveException {
+    try {
+      return getMSC().getDataConnector(dcName);
+    } catch (NoSuchObjectException e) {
+      return null;
+    } catch (Exception e) {
+      throw new HiveException(e);
+    }
+  }
+
+  /**
+   * Get all dataconnector names.
+   * @return List of all dataconnector names.
+   * @throws HiveException
+   */
+  public List<String> getAllDataConnectors() throws HiveException {
+    try {
+      return getMSC().getAllDataConnectors();
+    } catch (NoSuchObjectException e) {
+      return null;
+    } catch (Exception e) {
+      throw new HiveException(e);
+    }
+  }
+
+  public void alterDataConnector(String dcName, DataConnector connector)
+      throws HiveException {
+    try {
+      getMSC().alterDataConnector(dcName, connector);
+    } catch (MetaException e) {
+      throw new HiveException("Unable to alter dataconnector " + dcName + ". " + e.getMessage(), e);
+    } catch (NoSuchObjectException e) {
+      throw new HiveException("DataConnector " + dcName + " does not exists.", e);
+    } catch (TException e) {
+      throw new HiveException("Unable to alter dataconnector " + dcName + ". " + e.getMessage(), e);
+    }
+  }
+
   public void updateCreationMetadata(String dbName, String tableName, CreationMetadata cm)
       throws HiveException {
     try {
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java
index 9a245c9..6a5234a 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java
@@ -66,6 +66,710 @@ public class JsonMetaDataFormatter implements MetaDataFormatter {
     asJson(out, mb.build());
   }
 
+  /**
+   * Show a list of tables.
+   */
+  @Override
+  public void showTables(DataOutputStream out, List<String> tables)
+      throws HiveException {
+    asJson(out, MapBuilder.create().put("tables", tables).build());
+  }
+
+  /**
+   * Show a list of tables including table types.
+   */
+  @Override
+  public void showTablesExtended(DataOutputStream out, List<Table> tables) throws HiveException {
+    if (tables.isEmpty()) {
+      return;
+    }
+
+    List<Map<String, Object>> tableDataList = new ArrayList<Map<String, Object>>();
+    for (Table table : tables) {
+      Map<String, Object> tableData = ImmutableMap.of(
+          "Table Name", table.getTableName(),
+          "Table Type", table.getTableType().toString());
+      tableDataList.add(tableData);
+    }
+    asJson(out, ImmutableMap.of("tables", tableDataList));
+  }
+
+  /**
+   * Show a list of materialized views.
+   */
+  @Override
+  public void showMaterializedViews(DataOutputStream out, List<Table> materializedViews) throws HiveException {
+    if (materializedViews.isEmpty()) {
+      return;
+    }
+
+    List<Map<String, Object>> materializedViewDataList = new ArrayList<Map<String, Object>>();
+    for (Table materializedView : materializedViews) {
+      // Currently, we only support manual refresh
+      // TODO: Update whenever we have other modes
+      String refreshMode = "Manual refresh";
+      String timeWindowString = materializedView.getProperty(MATERIALIZED_VIEW_REWRITING_TIME_WINDOW);
+      String mode;
+      if (!StringUtils.isEmpty(timeWindowString)) {
+        long time = HiveConf.toTime(timeWindowString,
+            HiveConf.getDefaultTimeUnit(HiveConf.ConfVars.HIVE_MATERIALIZED_VIEW_REWRITING_TIME_WINDOW),
+            TimeUnit.MINUTES);
+        if (time > 0L) {
+          mode = refreshMode + " (Valid for " + time + "min)";
+        } else if (time == 0L) {
+          mode = refreshMode + " (Valid until source tables modified)";
+        } else {
+          mode = refreshMode + " (Valid always)";
+        }
+      } else {
+        mode = refreshMode;
+      }
+
+      Map<String, Object> materializedViewData = ImmutableMap.of(
+          "MV Name", materializedView.getTableName(),
+          "Rewriting Enabled", materializedView.isRewriteEnabled() ? "Yes" : "No",
+          "Mode", mode);
+      materializedViewDataList.add(materializedViewData);
+    }
+    asJson(out, ImmutableMap.of("materialized views", materializedViewDataList));
+  }
+
+  /**
+   * Describe table.
+   */
+  @Override
+  public void describeTable(DataOutputStream out, String colPath, String tableName, Table tbl, Partition part,
+      List<FieldSchema> cols, boolean isFormatted, boolean isExt, boolean isOutputPadded,
+      List<ColumnStatisticsObj> colStats) throws HiveException {
+    MapBuilder builder = MapBuilder.create();
+    builder.put("columns", createColumnsInfo(cols, colStats));
+
+    if (isExt) {
+      if (part != null) {
+        builder.put("partitionInfo", part.getTPartition());
+      }
+      else {
+        builder.put("tableInfo", tbl.getTTable());
+      }
+      if (PrimaryKeyInfo.isPrimaryKeyInfoNotEmpty(tbl.getPrimaryKeyInfo())) {
+        builder.put("primaryKeyInfo", tbl.getPrimaryKeyInfo());
+      }
+      if (ForeignKeyInfo.isForeignKeyInfoNotEmpty(tbl.getForeignKeyInfo())) {
+        builder.put("foreignKeyInfo", tbl.getForeignKeyInfo());
+      }
+      if (UniqueConstraint.isUniqueConstraintNotEmpty(tbl.getUniqueKeyInfo())) {
+        builder.put("uniqueConstraintInfo", tbl.getUniqueKeyInfo());
+      }
+      if (NotNullConstraint.isNotNullConstraintNotEmpty(tbl.getNotNullConstraint())) {
+        builder.put("notNullConstraintInfo", tbl.getNotNullConstraint());
+      }
+      if (DefaultConstraint.isCheckConstraintNotEmpty(tbl.getDefaultConstraint())) {
+        builder.put("defaultConstraintInfo", tbl.getDefaultConstraint());
+      }
+      if (CheckConstraint.isCheckConstraintNotEmpty(tbl.getCheckConstraint())) {
+        builder.put("checkConstraintInfo", tbl.getCheckConstraint());
+      }
+      if (tbl.getStorageHandlerInfo() != null) {
+        builder.put("storageHandlerInfo", tbl.getStorageHandlerInfo().toString());
+      }
+    }
+
+    asJson(out, builder.build());
+  }
+
+  private List<Map<String, Object>> createColumnsInfo(List<FieldSchema> columns,
+      List<ColumnStatisticsObj> columnStatisticsList) {
+    ArrayList<Map<String, Object>> res = new ArrayList<Map<String, Object>>();
+    for (FieldSchema column : columns) {
+      ColumnStatisticsData statistics = getStatistics(column, columnStatisticsList);
+      res.add(createColumnInfo(column, statistics));
+    }
+    return res;
+  }
+
+  private ColumnStatisticsData getStatistics(FieldSchema column, List<ColumnStatisticsObj> columnStatisticsList) {
+    for (ColumnStatisticsObj columnStatistics : columnStatisticsList) {
+      if (column.getName().equals(columnStatistics.getColName())) {
+        return columnStatistics.getStatsData();
+      }
+    }
+
+    return null;
+  }
+
+  private Map<String, Object> createColumnInfo(FieldSchema column, ColumnStatisticsData statistics) {
+    Map<String, Object> result = MapBuilder.create()
+        .put(COLUMN_NAME, column.getName())
+        .put(COLUMN_TYPE, column.getType())
+        .put(COLUMN_COMMENT, column.getComment())
+        .build();
+
+    if (statistics != null) {
+      if (statistics.isSetBinaryStats()) {
+        if (statistics.getBinaryStats().isSetNumNulls()) {
+          result.put(COLUMN_NUM_NULLS, statistics.getBinaryStats().getNumNulls());
+        }
+        if (statistics.getBinaryStats().isSetAvgColLen()) {
+          result.put(COLUMN_AVG_LENGTH, statistics.getBinaryStats().getAvgColLen());
+        }
+        if (statistics.getBinaryStats().isSetMaxColLen()) {
+          result.put(COLUMN_MAX_LENGTH, statistics.getBinaryStats().getMaxColLen());
+        }
+      } else if (statistics.isSetStringStats()) {
+        if (statistics.getStringStats().isSetNumNulls()) {
+          result.put(COLUMN_NUM_NULLS, statistics.getStringStats().getNumNulls());
+        }
+        if (statistics.getStringStats().isSetNumDVs()) {
+          result.put(COLUMN_DISTINCT_COUNT, statistics.getStringStats().getNumDVs());
+        }
+        if (statistics.getStringStats().isSetAvgColLen()) {
+          result.put(COLUMN_AVG_LENGTH, statistics.getStringStats().getAvgColLen());
+        }
+        if (statistics.getStringStats().isSetMaxColLen()) {
+          result.put(COLUMN_MAX_LENGTH, statistics.getStringStats().getMaxColLen());
+        }
+      } else if (statistics.isSetBooleanStats()) {
+        if (statistics.getBooleanStats().isSetNumNulls()) {
+          result.put(COLUMN_NUM_NULLS, statistics.getBooleanStats().getNumNulls());
+        }
+        if (statistics.getBooleanStats().isSetNumTrues()) {
+          result.put(COLUMN_NUM_TRUES, statistics.getBooleanStats().getNumTrues());
+        }
+        if (statistics.getBooleanStats().isSetNumFalses()) {
+          result.put(COLUMN_NUM_FALSES, statistics.getBooleanStats().getNumFalses());
+        }
+      } else if (statistics.isSetDecimalStats()) {
+        if (statistics.getDecimalStats().isSetLowValue()) {
+          result.put(COLUMN_MIN, MetaDataFormatUtils.convertToString(statistics.getDecimalStats().getLowValue()));
+        }
+        if (statistics.getDecimalStats().isSetHighValue()) {
+          result.put(COLUMN_MAX, MetaDataFormatUtils.convertToString(statistics.getDecimalStats().getHighValue()));
+        }
+        if (statistics.getDecimalStats().isSetNumNulls()) {
+          result.put(COLUMN_NUM_NULLS, statistics.getDecimalStats().getNumNulls());
+        }
+        if (statistics.getDecimalStats().isSetNumDVs()) {
+          result.put(COLUMN_DISTINCT_COUNT, statistics.getDecimalStats().getNumDVs());
+        }
+      } else if (statistics.isSetDoubleStats()) {
+        if (statistics.getDoubleStats().isSetLowValue()) {
+          result.put(COLUMN_MIN, statistics.getDoubleStats().getLowValue());
+        }
+        if (statistics.getDoubleStats().isSetHighValue()) {
+          result.put(COLUMN_MAX, statistics.getDoubleStats().getHighValue());
+        }
+        if (statistics.getDoubleStats().isSetNumNulls()) {
+          result.put(COLUMN_NUM_NULLS, statistics.getDoubleStats().getNumNulls());
+        }
+        if (statistics.getDoubleStats().isSetNumDVs()) {
+          result.put(COLUMN_DISTINCT_COUNT, statistics.getDoubleStats().getNumDVs());
+        }
+      } else if (statistics.isSetLongStats()) {
+        if (statistics.getLongStats().isSetLowValue()) {
+          result.put(COLUMN_MIN, statistics.getLongStats().getLowValue());
+        }
+        if (statistics.getLongStats().isSetHighValue()) {
+          result.put(COLUMN_MAX, statistics.getLongStats().getHighValue());
+        }
+        if (statistics.getLongStats().isSetNumNulls()) {
+          result.put(COLUMN_NUM_NULLS, statistics.getLongStats().getNumNulls());
+        }
+        if (statistics.getLongStats().isSetNumDVs()) {
+          result.put(COLUMN_DISTINCT_COUNT, statistics.getLongStats().getNumDVs());
+        }
+      } else if (statistics.isSetDateStats()) {
+        if (statistics.getDateStats().isSetLowValue()) {
+          result.put(COLUMN_MIN, MetaDataFormatUtils.convertToString(statistics.getDateStats().getLowValue()));
+        }
+        if (statistics.getDateStats().isSetHighValue()) {
+          result.put(COLUMN_MAX, MetaDataFormatUtils.convertToString(statistics.getDateStats().getHighValue()));
+        }
+        if (statistics.getDateStats().isSetNumNulls()) {
+          result.put(COLUMN_NUM_NULLS, statistics.getDateStats().getNumNulls());
+        }
+        if (statistics.getDateStats().isSetNumDVs()) {
+          result.put(COLUMN_DISTINCT_COUNT, statistics.getDateStats().getNumDVs());
+        }
+      } else if (statistics.isSetTimestampStats()) {
+        if (statistics.getTimestampStats().isSetLowValue()) {
+          result.put(COLUMN_MIN, MetaDataFormatUtils.convertToString(statistics.getTimestampStats().getLowValue()));
+        }
+        if (statistics.getTimestampStats().isSetHighValue()) {
+          result.put(COLUMN_MAX, MetaDataFormatUtils.convertToString(statistics.getTimestampStats().getHighValue()));
+        }
+        if (statistics.getTimestampStats().isSetNumNulls()) {
+          result.put(COLUMN_NUM_NULLS, statistics.getTimestampStats().getNumNulls());
+        }
+        if (statistics.getTimestampStats().isSetNumDVs()) {
+          result.put(COLUMN_DISTINCT_COUNT, statistics.getTimestampStats().getNumDVs());
+        }
+      }
+    }
+
+    return result;
+  }
+
+  @Override
+  public void showTableStatus(DataOutputStream out, Hive db, HiveConf conf,
+      List<Table> tbls, Map<String, String> part, Partition par)
+          throws HiveException {
+    asJson(out, MapBuilder.create().put(
+        "tables", makeAllTableStatus(db, conf, tbls, part, par)).build());
+  }
+
+  private List<Map<String, Object>> makeAllTableStatus(Hive db, HiveConf conf,
+      List<Table> tbls, Map<String, String> part, Partition par)
+          throws HiveException {
+    try {
+      ArrayList<Map<String, Object>> res = new ArrayList<Map<String, Object>>();
+      for (Table tbl : tbls) {
+        res.add(makeOneTableStatus(tbl, db, conf, part, par));
+      }
+      return res;
+    } catch(IOException e) {
+      throw new HiveException(e);
+    }
+  }
+
+  private Map<String, Object> makeOneTableStatus(Table tbl, Hive db,
+      HiveConf conf, Map<String, String> part, Partition par)
+          throws HiveException, IOException {
+    String tblLoc = null;
+    String inputFormattCls = null;
+    String outputFormattCls = null;
+    if (part != null) {
+      if (par != null) {
+        if (par.getLocation() != null) {
+          tblLoc = par.getDataLocation().toString();
+        }
+        inputFormattCls = par.getInputFormatClass() == null ? null : par.getInputFormatClass().getName();
+        outputFormattCls = par.getOutputFormatClass() == null ? null : par.getOutputFormatClass().getName();
+      }
+    } else {
+      if (tbl.getPath() != null) {
+        tblLoc = tbl.getDataLocation().toString();
+      }
+      inputFormattCls = tbl.getInputFormatClass() == null ? null : tbl.getInputFormatClass().getName();
+      outputFormattCls = tbl.getOutputFormatClass() == null ? null : tbl.getOutputFormatClass().getName();
+    }
+
+    MapBuilder builder = MapBuilder.create();
+
+    builder.put("tableName", tbl.getTableName());
+    builder.put("ownerType", (tbl.getOwnerType() != null) ? tbl.getOwnerType().name() : "null");
+    builder.put("owner", tbl.getOwner());
+    builder.put("location", tblLoc);
+    builder.put("inputFormat", inputFormattCls);
+    builder.put("outputFormat", outputFormattCls);
+    builder.put("columns", createColumnsInfo(tbl.getCols(), new ArrayList<ColumnStatisticsObj>()));
+
+    builder.put("partitioned", tbl.isPartitioned());
+    if (tbl.isPartitioned()) {
+      builder.put("partitionColumns", createColumnsInfo(tbl.getPartCols(), new ArrayList<ColumnStatisticsObj>()));
+    }
+    if(tbl.getTableType() != TableType.VIRTUAL_VIEW) {
+      //tbl.getPath() is null for views
+      putFileSystemsStats(builder, makeTableStatusLocations(tbl, db, par),
+        conf, tbl.getPath());
+    }
+
+    return builder.build();
+  }
+
+  private List<Path> makeTableStatusLocations(Table tbl, Hive db, Partition par)
+      throws HiveException {
+    // output file system information
+    Path tblPath = tbl.getPath();
+    List<Path> locations = new ArrayList<Path>();
+    if (tbl.isPartitioned()) {
+      if (par == null) {
+        for (Partition curPart : db.getPartitions(tbl)) {
+          if (curPart.getLocation() != null) {
+            locations.add(new Path(curPart.getLocation()));
+          }
+        }
+      } else {
+        if (par.getLocation() != null) {
+          locations.add(new Path(par.getLocation()));
+        }
+      }
+    } else {
+      if (tblPath != null) {
+        locations.add(tblPath);
+      }
+    }
+
+    return locations;
+  }
+
+  /**
+   * @param tblPath not NULL
+   * @throws IOException
+   */
+  // Duplicates logic in TextMetaDataFormatter
+  private void putFileSystemsStats(MapBuilder builder, List<Path> locations,
+      HiveConf conf, Path tblPath)
+          throws IOException {
+    long totalFileSize = 0;
+    long maxFileSize = 0;
+    long minFileSize = Long.MAX_VALUE;
+    long lastAccessTime = 0;
+    long lastUpdateTime = 0;
+    int numOfFiles = 0;
+
+    boolean unknown = false;
+    FileSystem fs = tblPath.getFileSystem(conf);
+    // in case all files in locations do not exist
+    try {
+      FileStatus tmpStatus = fs.getFileStatus(tblPath);
+      lastAccessTime = tmpStatus.getAccessTime();
+      lastUpdateTime = tmpStatus.getModificationTime();
+    } catch (IOException e) {
+      LOG.warn(
+          "Cannot access File System. File System status will be unknown: ", e);
+      unknown = true;
+    }
+
+    if (!unknown) {
+      for (Path loc : locations) {
+        try {
+          FileStatus status = fs.getFileStatus(tblPath);
+          FileStatus[] files = fs.listStatus(loc);
+          long accessTime = status.getAccessTime();
+          long updateTime = status.getModificationTime();
+          // no matter loc is the table location or part location, it must be a
+          // directory.
+          if (!status.isDir()) {
+            continue;
+          }
+          if (accessTime > lastAccessTime) {
+            lastAccessTime = accessTime;
+          }
+          if (updateTime > lastUpdateTime) {
+            lastUpdateTime = updateTime;
+          }
+          for (FileStatus currentStatus : files) {
+            if (currentStatus.isDir()) {
+              continue;
+            }
+            numOfFiles++;
+            long fileLen = currentStatus.getLen();
+            totalFileSize += fileLen;
+            if (fileLen > maxFileSize) {
+              maxFileSize = fileLen;
+            }
+            if (fileLen < minFileSize) {
+              minFileSize = fileLen;
+            }
+            accessTime = currentStatus.getAccessTime();
+            updateTime = currentStatus.getModificationTime();
+            if (accessTime > lastAccessTime) {
+              lastAccessTime = accessTime;
+            }
+            if (updateTime > lastUpdateTime) {
+              lastUpdateTime = updateTime;
+            }
+          }
+        } catch (IOException e) {
+          // ignore
+        }
+      }
+    }
+
+    builder
+    .put("totalNumberFiles", numOfFiles, ! unknown)
+    .put("totalFileSize",    totalFileSize, ! unknown)
+    .put("maxFileSize",      maxFileSize, ! unknown)
+    .put("minFileSize",      numOfFiles > 0 ? minFileSize : 0, ! unknown)
+    .put("lastAccessTime",   lastAccessTime, ! (unknown  || lastAccessTime < 0))
+    .put("lastUpdateTime",   lastUpdateTime, ! unknown);
+  }
+
+  /**
+   * Show the table partitions.
+   */
+  @Override
+  public void showTablePartitions(DataOutputStream out, List<String> parts)
+      throws HiveException {
+    asJson(out, MapBuilder.create().put("partitions",
+        makeTablePartions(parts)).build());
+  }
+
+  private List<Map<String, Object>> makeTablePartions(List<String> parts) {
+    ArrayList<Map<String, Object>> res =
+        new ArrayList<Map<String, Object>>(parts.size());
+    for (String part : parts) {
+      res.add(makeOneTablePartition(part));
+    }
+    return res;
+  }
+
+  // This seems like a very wrong implementation.
+  private Map<String, Object> makeOneTablePartition(String partIdent) {
+    ArrayList<Map<String, Object>> res = new ArrayList<Map<String, Object>>();
+
+    ArrayList<String> names = new ArrayList<String>();
+    for (String part : StringUtils.split(partIdent, "/")) {
+      String name = part;
+      String val = null;
+      String[] kv = StringUtils.split(part, "=", 2);
+      if (kv != null) {
+        name = kv[0];
+        if (kv.length > 1) {
+          try {
+            val = URLDecoder.decode(kv[1], StandardCharsets.UTF_8.name());
+          } catch (UnsupportedEncodingException e) {
+          }
+        }
+      }
+      if (val != null) {
+        names.add(name + "='" + val + "'");
+      }
+      else {
+        names.add(name);
+      }
+
+      res.add(MapBuilder.create()
+          .put("columnName", name)
+          .put("columnValue", val)
+          .build());
+    }
+
+    return MapBuilder.create()
+        .put("name", StringUtils.join(names, ","))
+        .put("values", res)
+        .build();
+  }
+
+  /**
+   * Show a list of databases
+   */
+  @Override
+  public void showDatabases(DataOutputStream out, List<String> databases)
+      throws HiveException {
+    asJson(out, MapBuilder.create().put("databases", databases).build());
+  }
+
+  /**
+   * Show the description of a database
+   */
+  @Override
+  public void showDatabaseDescription(DataOutputStream out, String database, String comment,
+      String location, String managedLocation, String ownerName, PrincipalType ownerType, String connectorName, String remoteDbName, Map<String, String> params)
+          throws HiveException {
+    MapBuilder builder = MapBuilder.create().put("database", database).put("comment", comment)
+        .put("location", location);
+    if (null != managedLocation) {
+      builder.put("managedLocation", managedLocation);
+    }
+    if (null != ownerName) {
+      builder.put("owner", ownerName);
+    }
+    if (null != ownerType) {
+      builder.put("ownerType", ownerType.name());
+    }
+    if (null != connectorName) {
+      builder.put("connector_name", connectorName);
+    }
+    if (null != remoteDbName) {
+      builder.put("remote_dbname", remoteDbName);
+    }
+    if (null != params && !params.isEmpty()) {
+      builder.put("params", params);
+    }
+    asJson(out, builder.build());
+  }
+
+  /**
+   * Show a list of dataconnectors
+   */
+  @Override
+  public void showDataConnectors(DataOutputStream out, List<String> connectors)
+      throws HiveException {
+    asJson(out, MapBuilder.create().put("connectors", connectors).build());
+  }
+
+  /**
+   * Show the description of a dataconnector
+   */
+  @Override
+  public void showDataConnectorDescription(DataOutputStream out, String dcName, String type,
+      String url, String ownerName, PrincipalType ownerType, String comment, Map<String, String> params)
+          throws HiveException {
+    MapBuilder builder = MapBuilder.create().put("connector", dcName).put("type", type)
+        .put("url", url);
+    if (null != ownerName) {
+      builder.put("owner", ownerName);
+    }
+    if (null != ownerType) {
+      builder.put("ownerType", ownerType.name());
+    }
+    if (null != comment) {
+      builder.put("comment", comment);
+    }
+    if (null != params && !params.isEmpty()) {
+      builder.put("params", params);
+    }
+    asJson(out, builder.build());
+  }
+
+  @Override
+  public void showResourcePlans(DataOutputStream out, List<WMResourcePlan> resourcePlans)
+      throws HiveException {
+    JsonGenerator generator = null;
+    try {
+      generator = new ObjectMapper().getJsonFactory().createJsonGenerator(out);
+      generator.writeStartArray();
+      for (WMResourcePlan plan : resourcePlans) {
+        generator.writeStartObject();
+        generator.writeStringField("name", plan.getName());
+        generator.writeStringField("status", plan.getStatus().name());
+        if (plan.isSetQueryParallelism()) {
+          generator.writeNumberField("queryParallelism", plan.getQueryParallelism());
+        }
+        if (plan.isSetDefaultPoolPath()) {
+          generator.writeStringField("defaultPoolPath", plan.getDefaultPoolPath());
+        }
+        generator.writeEndObject();
+      }
+      generator.writeEndArray();
+      generator.close();
+    } catch (IOException e) {
+      throw new HiveException(e);
+    } finally {
+      if (generator != null) {
+        IOUtils.closeQuietly(generator);
+      }
+    }
+  }
+
+  /**
+   * Formats a resource plan into a json object, the structure is as follows:
+   * {
+   *    name: "<rp_name>",
+   *    parallelism: "<parallelism>",
+   *    defaultQueue: "<defaultQueue>",
+   *    pools : [
+   *      {
+   *        name: "<pool_name>",
+   *        parallelism: "<parallelism>",
+   *        schedulingPolicy: "<policy>",
+   *        triggers: [
+   *          { name: "<triggerName>", trigger: "<trigExpression>", action: "<actionExpr">}
+   *          ...
+   *        ]
+   *      }
+   *      ...
+   *    ]
+   * }
+   */
+  private static class JsonRPFormatter implements MetaDataFormatUtils.RPFormatter, Closeable {
+    private final JsonGenerator generator;
+
+    JsonRPFormatter(DataOutputStream out) throws IOException {
+      generator = new ObjectMapper().getJsonFactory().createJsonGenerator(out);
+    }
+
+    private void writeNameAndFields(String name, Object ... kvPairs) throws IOException {
+      if (kvPairs.length % 2 != 0) {
+        throw new IllegalArgumentException("Expected pairs");
+      }
+      generator.writeStringField("name", name);
+      for (int i = 0; i < kvPairs.length; i += 2) {
+        generator.writeObjectField(kvPairs[i].toString(), kvPairs[i + 1]);
+      }
+    }
+
+    @Override
+    public void startRP(String rpName, Object ... kvPairs) throws IOException {
+      generator.writeStartObject();
+      writeNameAndFields(rpName, kvPairs);
+    }
+
+    @Override
+    public void endRP() throws IOException {
+      // End the root rp object.
+      generator.writeEndObject();
+    }
+
+    @Override
+    public void startPools() throws IOException {
+      generator.writeArrayFieldStart("pools");
+    }
+
+    @Override
+    public void endPools() throws IOException {
+      // End the pools array.
+      generator.writeEndArray();
+    }
+
+    @Override
+    public void startPool(String poolName, Object ... kvPairs) throws IOException {
+      generator.writeStartObject();
+      writeNameAndFields(poolName, kvPairs);
+    }
+
+    @Override
+    public void startTriggers() throws IOException {
+      generator.writeArrayFieldStart("triggers");
+    }
+
+    @Override
+    public void endTriggers() throws IOException {
+      generator.writeEndArray();
+    }
+
+    @Override
+    public void startMappings() throws IOException {
+      generator.writeArrayFieldStart("mappings");
+    }
+
+    @Override
+    public void endMappings() throws IOException {
+      generator.writeEndArray();
+    }
+
+    @Override
+    public void endPool() throws IOException {
+      generator.writeEndObject();
+    }
+
+    @Override
+    public void formatTrigger(String triggerName, String actionExpression,
+        String triggerExpression) throws IOException {
+      generator.writeStartObject();
+      writeNameAndFields(triggerName, "action", actionExpression, "trigger", triggerExpression);
+      generator.writeEndObject();
+    }
+
+    @Override
+    public void formatMappingType(String type, List<String> names) throws IOException {
+      generator.writeStartObject();
+      generator.writeStringField("type", type);
+      generator.writeArrayFieldStart("values");
+      for (String name : names) {
+        generator.writeString(name);
+      }
+      generator.writeEndArray();
+      generator.writeEndObject();
+    }
+
+    @Override
+    public void close() throws IOException {
+      generator.close();
+    }
+  }
+
+  public void showFullResourcePlan(DataOutputStream out, WMFullResourcePlan resourcePlan)
+      throws HiveException {
+    try (JsonRPFormatter formatter = new JsonRPFormatter(out)) {
+      MetaDataFormatUtils.formatFullRP(formatter, resourcePlan);
+    } catch (IOException e) {
+      throw new HiveException(e);
+    }
+>>>>>>> External metastore: clean after rebase
+  }
+
   @Override
   public void showErrors(DataOutputStream out, WMValidateResourcePlanResponse response) throws HiveException {
     try (JsonGenerator generator = new ObjectMapper().getJsonFactory().createJsonGenerator(out)) {
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java
index 6769f49..3f58661 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java
@@ -45,6 +45,7 @@ import org.apache.hadoop.hive.common.TableName;
 import org.apache.hadoop.hive.common.type.Date;
 import org.apache.hadoop.hive.conf.Constants;
 import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.api.DataConnector;
 import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.metastore.api.Order;
@@ -1719,6 +1720,23 @@ public abstract class BaseSemanticAnalyzer {
     return database;
   }
 
+  protected DataConnector getDataConnector(String dbName) throws SemanticException {
+    return getDataConnector(dbName, true);
+  }
+
+  protected DataConnector getDataConnector(String dcName, boolean throwException) throws SemanticException {
+    DataConnector connector;
+    try {
+      connector = db.getDataConnector(dcName);
+    } catch (Exception e) {
+      throw new SemanticException(e.getMessage(), e);
+    }
+    if (connector == null && throwException) {
+      throw new SemanticException(ErrorMsg.DATACONNECTOR_NOT_EXISTS.getMsg(dcName));
+    }
+    return connector;
+  }
+
   protected Table getTable(TableName tn) throws SemanticException {
     return getTable(tn, true);
   }
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/HiveOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/HiveOperation.java
index 7bbbf2b..c25b189 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/plan/HiveOperation.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/HiveOperation.java
@@ -33,7 +33,9 @@ public enum HiveOperation {
   REPLLOAD("REPLLOAD", HiveParser.TOK_REPL_LOAD, null, new Privilege[]{Privilege.ALL}),
   REPLSTATUS("REPLSTATUS", HiveParser.TOK_REPL_STATUS, new Privilege[]{Privilege.SELECT}, null),
   CREATEDATABASE("CREATEDATABASE", HiveParser.TOK_CREATEDATABASE, null, new Privilege[]{Privilege.CREATE}),
+  CREATEDATACONNECTOR("CREATEDATACONNECTOR", HiveParser.TOK_CREATEDATACONNECTOR, null, new Privilege[]{Privilege.CREATE}),
   DROPDATABASE("DROPDATABASE", HiveParser.TOK_DROPDATABASE, null, new Privilege[]{Privilege.DROP}),
+  DROPDATACONNECTOR("DROPDATACONNECTOR", HiveParser.TOK_DROPDATACONNECTOR, null, new Privilege[]{Privilege.DROP}),
   SWITCHDATABASE("SWITCHDATABASE", HiveParser.TOK_SWITCHDATABASE, null, null, true, false),
   LOCKDB("LOCKDATABASE", HiveParser.TOK_LOCKDB, new Privilege[]{Privilege.LOCK}, null),
   UNLOCKDB("UNLOCKDATABASE", HiveParser.TOK_UNLOCKDB, new Privilege[]{Privilege.LOCK}, null),
@@ -93,6 +95,8 @@ public enum HiveOperation {
       new Privilege[]{Privilege.ALTER_METADATA}, null),
   SHOWDATABASES("SHOWDATABASES", HiveParser.TOK_SHOWDATABASES, new Privilege[]{Privilege.SHOW_DATABASE}, null, true,
       false),
+  SHOWDATACONNECTORS("SHOWDATACONNECTORS", HiveParser.TOK_SHOWDATACONNECTORS, new Privilege[]{Privilege.SHOW_DATABASE}, null, true,
+      false),
   SHOWTABLES("SHOWTABLES", HiveParser.TOK_SHOWTABLES, null, null, true, false),
   SHOWCOLUMNS("SHOWCOLUMNS", HiveParser.TOK_SHOWCOLUMNS, null, null, true, false),
   SHOW_TABLESTATUS("SHOW_TABLESTATUS", HiveParser.TOK_SHOW_TABLESTATUS, null, null, true, false),
@@ -158,6 +162,10 @@ public enum HiveOperation {
       new int[] {HiveParser.TOK_ALTERDATABASE_LOCATION, HiveParser.TOK_ALTERDATABASE_MANAGEDLOCATION},
       new Privilege[]{Privilege.ALTER_DATA}, null),
   DESCDATABASE("DESCDATABASE", HiveParser.TOK_DESCDATABASE, null, null),
+  ALTERDATACONNECTOR("ALTERDATACONNECTOR", HiveParser.TOK_ALTERDATACONNECTOR_PROPERTIES, null, null),
+  ALTERDATACONNECTOR_OWNER("ALTERDATABASE_OWNER", HiveParser.TOK_ALTERDATACONNECTOR_OWNER, null, null),
+  ALTERDATACONNECTOR_URL("ALTERDATACONNECTOR_", HiveParser.TOK_ALTERDATACONNECTOR_URL, null, null),
+  DESCDATACONNECTOR("DESCDATACONNECTOR", HiveParser.TOK_DESCDATACONNECTOR, null, null),
   ALTERTABLE_MERGEFILES("ALTER_TABLE_MERGE", HiveParser.TOK_ALTERTABLE_MERGEFILES, new Privilege[] {Privilege.SELECT},
       new Privilege[] {Privilege.ALTER_DATA}),
   ALTERPARTITION_MERGEFILES("ALTER_PARTITION_MERGE", HiveParser.TOK_ALTERPARTITION_MERGEFILES,
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/Privilege.java b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/Privilege.java
index a8afcd6..9ce8b07 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/Privilege.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/Privilege.java
@@ -120,4 +120,7 @@ public class Privilege {
   public static Privilege SHOW_DATABASE = new Privilege(PrivilegeType.SHOW_DATABASE,
       EnumSet.of(PrivilegeScope.USER_LEVEL_SCOPE));
 
+  public static Privilege SHOW_DATACONNECTOR = new Privilege(PrivilegeType.SHOW_DATABASE,
+      EnumSet.of(PrivilegeScope.USER_LEVEL_SCOPE));
+
 }
diff --git a/standalone-metastore/metastore-common/pom.xml b/standalone-metastore/metastore-common/pom.xml
index 4119a10..4af0495 100644
--- a/standalone-metastore/metastore-common/pom.xml
+++ b/standalone-metastore/metastore-common/pom.xml
@@ -589,6 +589,7 @@
         <artifactId>apache-rat-plugin</artifactId>
         <configuration>
           <excludes>
+            <exclude>*.patch</exclude>
             <exclude>binary-package-licenses/**</exclude>
             <exclude>DEV-README</exclude>
             <exclude>**/src/main/sql/**</exclude>
diff --git a/standalone-metastore/metastore-common/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp b/standalone-metastore/metastore-common/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp
index 1544437..4cd965e 100644
--- a/standalone-metastore/metastore-common/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp
+++ b/standalone-metastore/metastore-common/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp
@@ -2561,6 +2561,7 @@ uint32_t ThriftHiveMetastore_get_databases_result::read(::apache::thrift::protoc
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size1651;
             ::apache::thrift::protocol::TType _etype1654;
             xfer += iprot->readListBegin(_etype1654, _size1651);
@@ -2569,6 +2570,16 @@ uint32_t ThriftHiveMetastore_get_databases_result::read(::apache::thrift::protoc
             for (_i1655 = 0; _i1655 < _size1651; ++_i1655)
             {
               xfer += iprot->readString(this->success[_i1655]);
+=======
+            uint32_t _size1668;
+            ::apache::thrift::protocol::TType _etype1671;
+            xfer += iprot->readListBegin(_etype1671, _size1668);
+            this->success.resize(_size1668);
+            uint32_t _i1672;
+            for (_i1672 = 0; _i1672 < _size1668; ++_i1672)
+            {
+              xfer += iprot->readString(this->success[_i1672]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -2607,10 +2618,17 @@ uint32_t ThriftHiveMetastore_get_databases_result::write(::apache::thrift::proto
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<std::string> ::const_iterator _iter1656;
       for (_iter1656 = this->success.begin(); _iter1656 != this->success.end(); ++_iter1656)
       {
         xfer += oprot->writeString((*_iter1656));
+=======
+      std::vector<std::string> ::const_iterator _iter1673;
+      for (_iter1673 = this->success.begin(); _iter1673 != this->success.end(); ++_iter1673)
+      {
+        xfer += oprot->writeString((*_iter1673));
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -2655,6 +2673,7 @@ uint32_t ThriftHiveMetastore_get_databases_presult::read(::apache::thrift::proto
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size1657;
             ::apache::thrift::protocol::TType _etype1660;
             xfer += iprot->readListBegin(_etype1660, _size1657);
@@ -2663,6 +2682,16 @@ uint32_t ThriftHiveMetastore_get_databases_presult::read(::apache::thrift::proto
             for (_i1661 = 0; _i1661 < _size1657; ++_i1661)
             {
               xfer += iprot->readString((*(this->success))[_i1661]);
+=======
+            uint32_t _size1674;
+            ::apache::thrift::protocol::TType _etype1677;
+            xfer += iprot->readListBegin(_etype1677, _size1674);
+            (*(this->success)).resize(_size1674);
+            uint32_t _i1678;
+            for (_i1678 = 0; _i1678 < _size1674; ++_i1678)
+            {
+              xfer += iprot->readString((*(this->success))[_i1678]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -2779,6 +2808,7 @@ uint32_t ThriftHiveMetastore_get_all_databases_result::read(::apache::thrift::pr
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size1662;
             ::apache::thrift::protocol::TType _etype1665;
             xfer += iprot->readListBegin(_etype1665, _size1662);
@@ -2787,6 +2817,16 @@ uint32_t ThriftHiveMetastore_get_all_databases_result::read(::apache::thrift::pr
             for (_i1666 = 0; _i1666 < _size1662; ++_i1666)
             {
               xfer += iprot->readString(this->success[_i1666]);
+=======
+            uint32_t _size1679;
+            ::apache::thrift::protocol::TType _etype1682;
+            xfer += iprot->readListBegin(_etype1682, _size1679);
+            this->success.resize(_size1679);
+            uint32_t _i1683;
+            for (_i1683 = 0; _i1683 < _size1679; ++_i1683)
+            {
+              xfer += iprot->readString(this->success[_i1683]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -2825,10 +2865,17 @@ uint32_t ThriftHiveMetastore_get_all_databases_result::write(::apache::thrift::p
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<std::string> ::const_iterator _iter1667;
       for (_iter1667 = this->success.begin(); _iter1667 != this->success.end(); ++_iter1667)
       {
         xfer += oprot->writeString((*_iter1667));
+=======
+      std::vector<std::string> ::const_iterator _iter1684;
+      for (_iter1684 = this->success.begin(); _iter1684 != this->success.end(); ++_iter1684)
+      {
+        xfer += oprot->writeString((*_iter1684));
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -2873,6 +2920,7 @@ uint32_t ThriftHiveMetastore_get_all_databases_presult::read(::apache::thrift::p
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size1668;
             ::apache::thrift::protocol::TType _etype1671;
             xfer += iprot->readListBegin(_etype1671, _size1668);
@@ -2881,6 +2929,16 @@ uint32_t ThriftHiveMetastore_get_all_databases_presult::read(::apache::thrift::p
             for (_i1672 = 0; _i1672 < _size1668; ++_i1672)
             {
               xfer += iprot->readString((*(this->success))[_i1672]);
+=======
+            uint32_t _size1685;
+            ::apache::thrift::protocol::TType _etype1688;
+            xfer += iprot->readListBegin(_etype1688, _size1685);
+            (*(this->success)).resize(_size1685);
+            uint32_t _i1689;
+            for (_i1689 = 0; _i1689 < _size1685; ++_i1689)
+            {
+              xfer += iprot->readString((*(this->success))[_i1689]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -3133,11 +3191,11 @@ uint32_t ThriftHiveMetastore_alter_database_presult::read(::apache::thrift::prot
 }
 
 
-ThriftHiveMetastore_get_type_args::~ThriftHiveMetastore_get_type_args() noexcept {
+ThriftHiveMetastore_create_dataconnector_args::~ThriftHiveMetastore_create_dataconnector_args() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_type_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_create_dataconnector_args::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -3159,104 +3217,9 @@ uint32_t ThriftHiveMetastore_get_type_args::read(::apache::thrift::protocol::TPr
     switch (fid)
     {
       case 1:
-        if (ftype == ::apache::thrift::protocol::T_STRING) {
-          xfer += iprot->readString(this->name);
-          this->__isset.name = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      default:
-        xfer += iprot->skip(ftype);
-        break;
-    }
-    xfer += iprot->readFieldEnd();
-  }
-
-  xfer += iprot->readStructEnd();
-
-  return xfer;
-}
-
-uint32_t ThriftHiveMetastore_get_type_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
-  uint32_t xfer = 0;
-  ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_type_args");
-
-  xfer += oprot->writeFieldBegin("name", ::apache::thrift::protocol::T_STRING, 1);
-  xfer += oprot->writeString(this->name);
-  xfer += oprot->writeFieldEnd();
-
-  xfer += oprot->writeFieldStop();
-  xfer += oprot->writeStructEnd();
-  return xfer;
-}
-
-
-ThriftHiveMetastore_get_type_pargs::~ThriftHiveMetastore_get_type_pargs() noexcept {
-}
-
-
-uint32_t ThriftHiveMetastore_get_type_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
-  uint32_t xfer = 0;
-  ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_type_pargs");
-
-  xfer += oprot->writeFieldBegin("name", ::apache::thrift::protocol::T_STRING, 1);
-  xfer += oprot->writeString((*(this->name)));
-  xfer += oprot->writeFieldEnd();
-
-  xfer += oprot->writeFieldStop();
-  xfer += oprot->writeStructEnd();
-  return xfer;
-}
-
-
-ThriftHiveMetastore_get_type_result::~ThriftHiveMetastore_get_type_result() noexcept {
-}
-
-
-uint32_t ThriftHiveMetastore_get_type_result::read(::apache::thrift::protocol::TProtocol* iprot) {
-
-  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
-  uint32_t xfer = 0;
-  std::string fname;
-  ::apache::thrift::protocol::TType ftype;
-  int16_t fid;
-
-  xfer += iprot->readStructBegin(fname);
-
-  using ::apache::thrift::protocol::TProtocolException;
-
-
-  while (true)
-  {
-    xfer += iprot->readFieldBegin(fname, ftype, fid);
-    if (ftype == ::apache::thrift::protocol::T_STOP) {
-      break;
-    }
-    switch (fid)
-    {
-      case 0:
         if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->success.read(iprot);
-          this->__isset.success = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 1:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o1.read(iprot);
-          this->__isset.o1 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 2:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o2.read(iprot);
-          this->__isset.o2 = true;
+          xfer += this->connector.read(iprot);
+          this->__isset.connector = true;
         } else {
           xfer += iprot->skip(ftype);
         }
@@ -3273,145 +3236,13 @@ uint32_t ThriftHiveMetastore_get_type_result::read(::apache::thrift::protocol::T
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_get_type_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
-
-  uint32_t xfer = 0;
-
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_type_result");
-
-  if (this->__isset.success) {
-    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0);
-    xfer += this->success.write(oprot);
-    xfer += oprot->writeFieldEnd();
-  } else if (this->__isset.o1) {
-    xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
-    xfer += this->o1.write(oprot);
-    xfer += oprot->writeFieldEnd();
-  } else if (this->__isset.o2) {
-    xfer += oprot->writeFieldBegin("o2", ::apache::thrift::protocol::T_STRUCT, 2);
-    xfer += this->o2.write(oprot);
-    xfer += oprot->writeFieldEnd();
-  }
-  xfer += oprot->writeFieldStop();
-  xfer += oprot->writeStructEnd();
-  return xfer;
-}
-
-
-ThriftHiveMetastore_get_type_presult::~ThriftHiveMetastore_get_type_presult() noexcept {
-}
-
-
-uint32_t ThriftHiveMetastore_get_type_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
-
-  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
-  uint32_t xfer = 0;
-  std::string fname;
-  ::apache::thrift::protocol::TType ftype;
-  int16_t fid;
-
-  xfer += iprot->readStructBegin(fname);
-
-  using ::apache::thrift::protocol::TProtocolException;
-
-
-  while (true)
-  {
-    xfer += iprot->readFieldBegin(fname, ftype, fid);
-    if (ftype == ::apache::thrift::protocol::T_STOP) {
-      break;
-    }
-    switch (fid)
-    {
-      case 0:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += (*(this->success)).read(iprot);
-          this->__isset.success = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 1:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o1.read(iprot);
-          this->__isset.o1 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 2:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o2.read(iprot);
-          this->__isset.o2 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      default:
-        xfer += iprot->skip(ftype);
-        break;
-    }
-    xfer += iprot->readFieldEnd();
-  }
-
-  xfer += iprot->readStructEnd();
-
-  return xfer;
-}
-
-
-ThriftHiveMetastore_create_type_args::~ThriftHiveMetastore_create_type_args() noexcept {
-}
-
-
-uint32_t ThriftHiveMetastore_create_type_args::read(::apache::thrift::protocol::TProtocol* iprot) {
-
-  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
-  uint32_t xfer = 0;
-  std::string fname;
-  ::apache::thrift::protocol::TType ftype;
-  int16_t fid;
-
-  xfer += iprot->readStructBegin(fname);
-
-  using ::apache::thrift::protocol::TProtocolException;
-
-
-  while (true)
-  {
-    xfer += iprot->readFieldBegin(fname, ftype, fid);
-    if (ftype == ::apache::thrift::protocol::T_STOP) {
-      break;
-    }
-    switch (fid)
-    {
-      case 1:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->type.read(iprot);
-          this->__isset.type = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      default:
-        xfer += iprot->skip(ftype);
-        break;
-    }
-    xfer += iprot->readFieldEnd();
-  }
-
-  xfer += iprot->readStructEnd();
-
-  return xfer;
-}
-
-uint32_t ThriftHiveMetastore_create_type_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_create_dataconnector_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_type_args");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_dataconnector_args");
 
-  xfer += oprot->writeFieldBegin("type", ::apache::thrift::protocol::T_STRUCT, 1);
-  xfer += this->type.write(oprot);
+  xfer += oprot->writeFieldBegin("connector", ::apache::thrift::protocol::T_STRUCT, 1);
+  xfer += this->connector.write(oprot);
   xfer += oprot->writeFieldEnd();
 
   xfer += oprot->writeFieldStop();
@@ -3420,17 +3251,17 @@ uint32_t ThriftHiveMetastore_create_type_args::write(::apache::thrift::protocol:
 }
 
 
-ThriftHiveMetastore_create_type_pargs::~ThriftHiveMetastore_create_type_pargs() noexcept {
+ThriftHiveMetastore_create_dataconnector_pargs::~ThriftHiveMetastore_create_dataconnector_pargs() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_create_type_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_create_dataconnector_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_type_pargs");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_dataconnector_pargs");
 
-  xfer += oprot->writeFieldBegin("type", ::apache::thrift::protocol::T_STRUCT, 1);
-  xfer += (*(this->type)).write(oprot);
+  xfer += oprot->writeFieldBegin("connector", ::apache::thrift::protocol::T_STRUCT, 1);
+  xfer += (*(this->connector)).write(oprot);
   xfer += oprot->writeFieldEnd();
 
   xfer += oprot->writeFieldStop();
@@ -3439,11 +3270,11 @@ uint32_t ThriftHiveMetastore_create_type_pargs::write(::apache::thrift::protocol
 }
 
 
-ThriftHiveMetastore_create_type_result::~ThriftHiveMetastore_create_type_result() noexcept {
+ThriftHiveMetastore_create_dataconnector_result::~ThriftHiveMetastore_create_dataconnector_result() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_create_type_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_create_dataconnector_result::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -3464,14 +3295,6 @@ uint32_t ThriftHiveMetastore_create_type_result::read(::apache::thrift::protocol
     }
     switch (fid)
     {
-      case 0:
-        if (ftype == ::apache::thrift::protocol::T_BOOL) {
-          xfer += iprot->readBool(this->success);
-          this->__isset.success = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
       case 1:
         if (ftype == ::apache::thrift::protocol::T_STRUCT) {
           xfer += this->o1.read(iprot);
@@ -3508,17 +3331,13 @@ uint32_t ThriftHiveMetastore_create_type_result::read(::apache::thrift::protocol
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_create_type_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_create_dataconnector_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
 
   uint32_t xfer = 0;
 
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_type_result");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_dataconnector_result");
 
-  if (this->__isset.success) {
-    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_BOOL, 0);
-    xfer += oprot->writeBool(this->success);
-    xfer += oprot->writeFieldEnd();
-  } else if (this->__isset.o1) {
+  if (this->__isset.o1) {
     xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
     xfer += this->o1.write(oprot);
     xfer += oprot->writeFieldEnd();
@@ -3537,11 +3356,11 @@ uint32_t ThriftHiveMetastore_create_type_result::write(::apache::thrift::protoco
 }
 
 
-ThriftHiveMetastore_create_type_presult::~ThriftHiveMetastore_create_type_presult() noexcept {
+ThriftHiveMetastore_create_dataconnector_presult::~ThriftHiveMetastore_create_dataconnector_presult() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_create_type_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_create_dataconnector_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -3562,14 +3381,6 @@ uint32_t ThriftHiveMetastore_create_type_presult::read(::apache::thrift::protoco
     }
     switch (fid)
     {
-      case 0:
-        if (ftype == ::apache::thrift::protocol::T_BOOL) {
-          xfer += iprot->readBool((*(this->success)));
-          this->__isset.success = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
       case 1:
         if (ftype == ::apache::thrift::protocol::T_STRUCT) {
           xfer += this->o1.read(iprot);
@@ -3607,11 +3418,11 @@ uint32_t ThriftHiveMetastore_create_type_presult::read(::apache::thrift::protoco
 }
 
 
-ThriftHiveMetastore_drop_type_args::~ThriftHiveMetastore_drop_type_args() noexcept {
+ThriftHiveMetastore_get_dataconnector_req_args::~ThriftHiveMetastore_get_dataconnector_req_args() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_drop_type_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_get_dataconnector_req_args::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -3633,9 +3444,9 @@ uint32_t ThriftHiveMetastore_drop_type_args::read(::apache::thrift::protocol::TP
     switch (fid)
     {
       case 1:
-        if (ftype == ::apache::thrift::protocol::T_STRING) {
-          xfer += iprot->readString(this->type);
-          this->__isset.type = true;
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->request.read(iprot);
+          this->__isset.request = true;
         } else {
           xfer += iprot->skip(ftype);
         }
@@ -3652,13 +3463,13 @@ uint32_t ThriftHiveMetastore_drop_type_args::read(::apache::thrift::protocol::TP
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_drop_type_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_get_dataconnector_req_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_drop_type_args");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_dataconnector_req_args");
 
-  xfer += oprot->writeFieldBegin("type", ::apache::thrift::protocol::T_STRING, 1);
-  xfer += oprot->writeString(this->type);
+  xfer += oprot->writeFieldBegin("request", ::apache::thrift::protocol::T_STRUCT, 1);
+  xfer += this->request.write(oprot);
   xfer += oprot->writeFieldEnd();
 
   xfer += oprot->writeFieldStop();
@@ -3667,17 +3478,17 @@ uint32_t ThriftHiveMetastore_drop_type_args::write(::apache::thrift::protocol::T
 }
 
 
-ThriftHiveMetastore_drop_type_pargs::~ThriftHiveMetastore_drop_type_pargs() noexcept {
+ThriftHiveMetastore_get_dataconnector_req_pargs::~ThriftHiveMetastore_get_dataconnector_req_pargs() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_drop_type_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_get_dataconnector_req_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_drop_type_pargs");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_dataconnector_req_pargs");
 
-  xfer += oprot->writeFieldBegin("type", ::apache::thrift::protocol::T_STRING, 1);
-  xfer += oprot->writeString((*(this->type)));
+  xfer += oprot->writeFieldBegin("request", ::apache::thrift::protocol::T_STRUCT, 1);
+  xfer += (*(this->request)).write(oprot);
   xfer += oprot->writeFieldEnd();
 
   xfer += oprot->writeFieldStop();
@@ -3686,11 +3497,11 @@ uint32_t ThriftHiveMetastore_drop_type_pargs::write(::apache::thrift::protocol::
 }
 
 
-ThriftHiveMetastore_drop_type_result::~ThriftHiveMetastore_drop_type_result() noexcept {
+ThriftHiveMetastore_get_dataconnector_req_result::~ThriftHiveMetastore_get_dataconnector_req_result() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_drop_type_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_get_dataconnector_req_result::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -3712,8 +3523,8 @@ uint32_t ThriftHiveMetastore_drop_type_result::read(::apache::thrift::protocol::
     switch (fid)
     {
       case 0:
-        if (ftype == ::apache::thrift::protocol::T_BOOL) {
-          xfer += iprot->readBool(this->success);
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->success.read(iprot);
           this->__isset.success = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -3747,15 +3558,15 @@ uint32_t ThriftHiveMetastore_drop_type_result::read(::apache::thrift::protocol::
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_drop_type_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_get_dataconnector_req_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
 
   uint32_t xfer = 0;
 
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_drop_type_result");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_dataconnector_req_result");
 
   if (this->__isset.success) {
-    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_BOOL, 0);
-    xfer += oprot->writeBool(this->success);
+    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0);
+    xfer += this->success.write(oprot);
     xfer += oprot->writeFieldEnd();
   } else if (this->__isset.o1) {
     xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
@@ -3772,11 +3583,11 @@ uint32_t ThriftHiveMetastore_drop_type_result::write(::apache::thrift::protocol:
 }
 
 
-ThriftHiveMetastore_drop_type_presult::~ThriftHiveMetastore_drop_type_presult() noexcept {
+ThriftHiveMetastore_get_dataconnector_req_presult::~ThriftHiveMetastore_get_dataconnector_req_presult() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_drop_type_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_get_dataconnector_req_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -3798,8 +3609,8 @@ uint32_t ThriftHiveMetastore_drop_type_presult::read(::apache::thrift::protocol:
     switch (fid)
     {
       case 0:
-        if (ftype == ::apache::thrift::protocol::T_BOOL) {
-          xfer += iprot->readBool((*(this->success)));
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += (*(this->success)).read(iprot);
           this->__isset.success = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -3834,11 +3645,11 @@ uint32_t ThriftHiveMetastore_drop_type_presult::read(::apache::thrift::protocol:
 }
 
 
-ThriftHiveMetastore_get_type_all_args::~ThriftHiveMetastore_get_type_all_args() noexcept {
+ThriftHiveMetastore_drop_dataconnector_args::~ThriftHiveMetastore_drop_dataconnector_args() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_type_all_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_drop_dataconnector_args::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -3867,6 +3678,22 @@ uint32_t ThriftHiveMetastore_get_type_all_args::read(::apache::thrift::protocol:
           xfer += iprot->skip(ftype);
         }
         break;
+      case -1:
+        if (ftype == ::apache::thrift::protocol::T_BOOL) {
+          xfer += iprot->readBool(this->ifNotExists);
+          this->__isset.ifNotExists = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case -2:
+        if (ftype == ::apache::thrift::protocol::T_BOOL) {
+          xfer += iprot->readBool(this->checkReferences);
+          this->__isset.checkReferences = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
       default:
         xfer += iprot->skip(ftype);
         break;
@@ -3879,10 +3706,18 @@ uint32_t ThriftHiveMetastore_get_type_all_args::read(::apache::thrift::protocol:
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_get_type_all_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_drop_dataconnector_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_type_all_args");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_drop_dataconnector_args");
+
+  xfer += oprot->writeFieldBegin("checkReferences", ::apache::thrift::protocol::T_BOOL, -2);
+  xfer += oprot->writeBool(this->checkReferences);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldBegin("ifNotExists", ::apache::thrift::protocol::T_BOOL, -1);
+  xfer += oprot->writeBool(this->ifNotExists);
+  xfer += oprot->writeFieldEnd();
 
   xfer += oprot->writeFieldBegin("name", ::apache::thrift::protocol::T_STRING, 1);
   xfer += oprot->writeString(this->name);
@@ -3894,14 +3729,22 @@ uint32_t ThriftHiveMetastore_get_type_all_args::write(::apache::thrift::protocol
 }
 
 
-ThriftHiveMetastore_get_type_all_pargs::~ThriftHiveMetastore_get_type_all_pargs() noexcept {
+ThriftHiveMetastore_drop_dataconnector_pargs::~ThriftHiveMetastore_drop_dataconnector_pargs() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_type_all_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_drop_dataconnector_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_type_all_pargs");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_drop_dataconnector_pargs");
+
+  xfer += oprot->writeFieldBegin("checkReferences", ::apache::thrift::protocol::T_BOOL, -2);
+  xfer += oprot->writeBool((*(this->checkReferences)));
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldBegin("ifNotExists", ::apache::thrift::protocol::T_BOOL, -1);
+  xfer += oprot->writeBool((*(this->ifNotExists)));
+  xfer += oprot->writeFieldEnd();
 
   xfer += oprot->writeFieldBegin("name", ::apache::thrift::protocol::T_STRING, 1);
   xfer += oprot->writeString((*(this->name)));
@@ -3913,11 +3756,11 @@ uint32_t ThriftHiveMetastore_get_type_all_pargs::write(::apache::thrift::protoco
 }
 
 
-ThriftHiveMetastore_get_type_all_result::~ThriftHiveMetastore_get_type_all_result() noexcept {
+ThriftHiveMetastore_drop_dataconnector_result::~ThriftHiveMetastore_drop_dataconnector_result() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_type_all_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_drop_dataconnector_result::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -3938,30 +3781,15 @@ uint32_t ThriftHiveMetastore_get_type_all_result::read(::apache::thrift::protoco
     }
     switch (fid)
     {
-      case 0:
-        if (ftype == ::apache::thrift::protocol::T_MAP) {
-          {
-            this->success.clear();
-            uint32_t _size1673;
-            ::apache::thrift::protocol::TType _ktype1674;
-            ::apache::thrift::protocol::TType _vtype1675;
-            xfer += iprot->readMapBegin(_ktype1674, _vtype1675, _size1673);
-            uint32_t _i1677;
-            for (_i1677 = 0; _i1677 < _size1673; ++_i1677)
-            {
-              std::string _key1678;
-              xfer += iprot->readString(_key1678);
-              Type& _val1679 = this->success[_key1678];
-              xfer += _val1679.read(iprot);
-            }
-            xfer += iprot->readMapEnd();
-          }
-          this->__isset.success = true;
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o1.read(iprot);
+          this->__isset.o1 = true;
         } else {
           xfer += iprot->skip(ftype);
         }
         break;
-      case 1:
+      case 2:
         if (ftype == ::apache::thrift::protocol::T_STRUCT) {
           xfer += this->o2.read(iprot);
           this->__isset.o2 = true;
@@ -3969,6 +3797,14 @@ uint32_t ThriftHiveMetastore_get_type_all_result::read(::apache::thrift::protoco
           xfer += iprot->skip(ftype);
         }
         break;
+      case 3:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o3.read(iprot);
+          this->__isset.o3 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
       default:
         xfer += iprot->skip(ftype);
         break;
@@ -3981,29 +3817,24 @@ uint32_t ThriftHiveMetastore_get_type_all_result::read(::apache::thrift::protoco
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_get_type_all_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_drop_dataconnector_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
 
   uint32_t xfer = 0;
 
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_type_all_result");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_drop_dataconnector_result");
 
-  if (this->__isset.success) {
-    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_MAP, 0);
-    {
-      xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-      std::map<std::string, Type> ::const_iterator _iter1680;
-      for (_iter1680 = this->success.begin(); _iter1680 != this->success.end(); ++_iter1680)
-      {
-        xfer += oprot->writeString(_iter1680->first);
-        xfer += _iter1680->second.write(oprot);
-      }
-      xfer += oprot->writeMapEnd();
-    }
+  if (this->__isset.o1) {
+    xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
+    xfer += this->o1.write(oprot);
     xfer += oprot->writeFieldEnd();
   } else if (this->__isset.o2) {
-    xfer += oprot->writeFieldBegin("o2", ::apache::thrift::protocol::T_STRUCT, 1);
+    xfer += oprot->writeFieldBegin("o2", ::apache::thrift::protocol::T_STRUCT, 2);
     xfer += this->o2.write(oprot);
     xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o3) {
+    xfer += oprot->writeFieldBegin("o3", ::apache::thrift::protocol::T_STRUCT, 3);
+    xfer += this->o3.write(oprot);
+    xfer += oprot->writeFieldEnd();
   }
   xfer += oprot->writeFieldStop();
   xfer += oprot->writeStructEnd();
@@ -4011,11 +3842,11 @@ uint32_t ThriftHiveMetastore_get_type_all_result::write(::apache::thrift::protoc
 }
 
 
-ThriftHiveMetastore_get_type_all_presult::~ThriftHiveMetastore_get_type_all_presult() noexcept {
+ThriftHiveMetastore_drop_dataconnector_presult::~ThriftHiveMetastore_drop_dataconnector_presult() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_type_all_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_drop_dataconnector_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -4036,30 +3867,15 @@ uint32_t ThriftHiveMetastore_get_type_all_presult::read(::apache::thrift::protoc
     }
     switch (fid)
     {
-      case 0:
-        if (ftype == ::apache::thrift::protocol::T_MAP) {
-          {
-            (*(this->success)).clear();
-            uint32_t _size1681;
-            ::apache::thrift::protocol::TType _ktype1682;
-            ::apache::thrift::protocol::TType _vtype1683;
-            xfer += iprot->readMapBegin(_ktype1682, _vtype1683, _size1681);
-            uint32_t _i1685;
-            for (_i1685 = 0; _i1685 < _size1681; ++_i1685)
-            {
-              std::string _key1686;
-              xfer += iprot->readString(_key1686);
-              Type& _val1687 = (*(this->success))[_key1686];
-              xfer += _val1687.read(iprot);
-            }
-            xfer += iprot->readMapEnd();
-          }
-          this->__isset.success = true;
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o1.read(iprot);
+          this->__isset.o1 = true;
         } else {
           xfer += iprot->skip(ftype);
         }
         break;
-      case 1:
+      case 2:
         if (ftype == ::apache::thrift::protocol::T_STRUCT) {
           xfer += this->o2.read(iprot);
           this->__isset.o2 = true;
@@ -4067,6 +3883,14 @@ uint32_t ThriftHiveMetastore_get_type_all_presult::read(::apache::thrift::protoc
           xfer += iprot->skip(ftype);
         }
         break;
+      case 3:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o3.read(iprot);
+          this->__isset.o3 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
       default:
         xfer += iprot->skip(ftype);
         break;
@@ -4080,11 +3904,11 @@ uint32_t ThriftHiveMetastore_get_type_all_presult::read(::apache::thrift::protoc
 }
 
 
-ThriftHiveMetastore_get_fields_args::~ThriftHiveMetastore_get_fields_args() noexcept {
+ThriftHiveMetastore_get_dataconnectors_args::~ThriftHiveMetastore_get_dataconnectors_args() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_fields_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_get_dataconnectors_args::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -4103,28 +3927,7 @@ uint32_t ThriftHiveMetastore_get_fields_args::read(::apache::thrift::protocol::T
     if (ftype == ::apache::thrift::protocol::T_STOP) {
       break;
     }
-    switch (fid)
-    {
-      case 1:
-        if (ftype == ::apache::thrift::protocol::T_STRING) {
-          xfer += iprot->readString(this->db_name);
-          this->__isset.db_name = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 2:
-        if (ftype == ::apache::thrift::protocol::T_STRING) {
-          xfer += iprot->readString(this->table_name);
-          this->__isset.table_name = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      default:
-        xfer += iprot->skip(ftype);
-        break;
-    }
+    xfer += iprot->skip(ftype);
     xfer += iprot->readFieldEnd();
   }
 
@@ -4133,18 +3936,10 @@ uint32_t ThriftHiveMetastore_get_fields_args::read(::apache::thrift::protocol::T
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_get_fields_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_get_dataconnectors_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_fields_args");
-
-  xfer += oprot->writeFieldBegin("db_name", ::apache::thrift::protocol::T_STRING, 1);
-  xfer += oprot->writeString(this->db_name);
-  xfer += oprot->writeFieldEnd();
-
-  xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2);
-  xfer += oprot->writeString(this->table_name);
-  xfer += oprot->writeFieldEnd();
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_dataconnectors_args");
 
   xfer += oprot->writeFieldStop();
   xfer += oprot->writeStructEnd();
@@ -4152,22 +3947,14 @@ uint32_t ThriftHiveMetastore_get_fields_args::write(::apache::thrift::protocol::
 }
 
 
-ThriftHiveMetastore_get_fields_pargs::~ThriftHiveMetastore_get_fields_pargs() noexcept {
+ThriftHiveMetastore_get_dataconnectors_pargs::~ThriftHiveMetastore_get_dataconnectors_pargs() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_fields_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_get_dataconnectors_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_fields_pargs");
-
-  xfer += oprot->writeFieldBegin("db_name", ::apache::thrift::protocol::T_STRING, 1);
-  xfer += oprot->writeString((*(this->db_name)));
-  xfer += oprot->writeFieldEnd();
-
-  xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2);
-  xfer += oprot->writeString((*(this->table_name)));
-  xfer += oprot->writeFieldEnd();
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_dataconnectors_pargs");
 
   xfer += oprot->writeFieldStop();
   xfer += oprot->writeStructEnd();
@@ -4175,11 +3962,11 @@ uint32_t ThriftHiveMetastore_get_fields_pargs::write(::apache::thrift::protocol:
 }
 
 
-ThriftHiveMetastore_get_fields_result::~ThriftHiveMetastore_get_fields_result() noexcept {
+ThriftHiveMetastore_get_dataconnectors_result::~ThriftHiveMetastore_get_dataconnectors_result() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_fields_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_get_dataconnectors_result::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -4204,14 +3991,28 @@ uint32_t ThriftHiveMetastore_get_fields_result::read(::apache::thrift::protocol:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-            uint32_t _size1688;
-            ::apache::thrift::protocol::TType _etype1691;
-            xfer += iprot->readListBegin(_etype1691, _size1688);
-            this->success.resize(_size1688);
-            uint32_t _i1692;
-            for (_i1692 = 0; _i1692 < _size1688; ++_i1692)
+<<<<<<< HEAD
+            uint32_t _size1673;
+            ::apache::thrift::protocol::TType _ktype1674;
+            ::apache::thrift::protocol::TType _vtype1675;
+            xfer += iprot->readMapBegin(_ktype1674, _vtype1675, _size1673);
+            uint32_t _i1677;
+            for (_i1677 = 0; _i1677 < _size1673; ++_i1677)
             {
-              xfer += this->success[_i1692].read(iprot);
+              std::string _key1678;
+              xfer += iprot->readString(_key1678);
+              Type& _val1679 = this->success[_key1678];
+              xfer += _val1679.read(iprot);
+=======
+            uint32_t _size1690;
+            ::apache::thrift::protocol::TType _etype1693;
+            xfer += iprot->readListBegin(_etype1693, _size1690);
+            this->success.resize(_size1690);
+            uint32_t _i1694;
+            for (_i1694 = 0; _i1694 < _size1690; ++_i1694)
+            {
+              xfer += iprot->readString(this->success[_i1694]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -4228,22 +4029,6 @@ uint32_t ThriftHiveMetastore_get_fields_result::read(::apache::thrift::protocol:
           xfer += iprot->skip(ftype);
         }
         break;
-      case 2:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o2.read(iprot);
-          this->__isset.o2 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 3:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o3.read(iprot);
-          this->__isset.o3 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
       default:
         xfer += iprot->skip(ftype);
         break;
@@ -4256,20 +4041,29 @@ uint32_t ThriftHiveMetastore_get_fields_result::read(::apache::thrift::protocol:
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_get_fields_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_get_dataconnectors_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
 
   uint32_t xfer = 0;
 
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_fields_result");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_dataconnectors_result");
 
   if (this->__isset.success) {
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
-      xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-      std::vector<FieldSchema> ::const_iterator _iter1693;
-      for (_iter1693 = this->success.begin(); _iter1693 != this->success.end(); ++_iter1693)
+<<<<<<< HEAD
+      xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+      std::map<std::string, Type> ::const_iterator _iter1680;
+      for (_iter1680 = this->success.begin(); _iter1680 != this->success.end(); ++_iter1680)
       {
-        xfer += (*_iter1693).write(oprot);
+        xfer += oprot->writeString(_iter1680->first);
+        xfer += _iter1680->second.write(oprot);
+=======
+      xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
+      std::vector<std::string> ::const_iterator _iter1695;
+      for (_iter1695 = this->success.begin(); _iter1695 != this->success.end(); ++_iter1695)
+      {
+        xfer += oprot->writeString((*_iter1695));
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -4278,14 +4072,6 @@ uint32_t ThriftHiveMetastore_get_fields_result::write(::apache::thrift::protocol
     xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
     xfer += this->o1.write(oprot);
     xfer += oprot->writeFieldEnd();
-  } else if (this->__isset.o2) {
-    xfer += oprot->writeFieldBegin("o2", ::apache::thrift::protocol::T_STRUCT, 2);
-    xfer += this->o2.write(oprot);
-    xfer += oprot->writeFieldEnd();
-  } else if (this->__isset.o3) {
-    xfer += oprot->writeFieldBegin("o3", ::apache::thrift::protocol::T_STRUCT, 3);
-    xfer += this->o3.write(oprot);
-    xfer += oprot->writeFieldEnd();
   }
   xfer += oprot->writeFieldStop();
   xfer += oprot->writeStructEnd();
@@ -4293,11 +4079,11 @@ uint32_t ThriftHiveMetastore_get_fields_result::write(::apache::thrift::protocol
 }
 
 
-ThriftHiveMetastore_get_fields_presult::~ThriftHiveMetastore_get_fields_presult() noexcept {
+ThriftHiveMetastore_get_dataconnectors_presult::~ThriftHiveMetastore_get_dataconnectors_presult() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_fields_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_get_dataconnectors_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -4322,14 +4108,28 @@ uint32_t ThriftHiveMetastore_get_fields_presult::read(::apache::thrift::protocol
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-            uint32_t _size1694;
-            ::apache::thrift::protocol::TType _etype1697;
-            xfer += iprot->readListBegin(_etype1697, _size1694);
-            (*(this->success)).resize(_size1694);
-            uint32_t _i1698;
-            for (_i1698 = 0; _i1698 < _size1694; ++_i1698)
+<<<<<<< HEAD
+            uint32_t _size1681;
+            ::apache::thrift::protocol::TType _ktype1682;
+            ::apache::thrift::protocol::TType _vtype1683;
+            xfer += iprot->readMapBegin(_ktype1682, _vtype1683, _size1681);
+            uint32_t _i1685;
+            for (_i1685 = 0; _i1685 < _size1681; ++_i1685)
             {
-              xfer += (*(this->success))[_i1698].read(iprot);
+              std::string _key1686;
+              xfer += iprot->readString(_key1686);
+              Type& _val1687 = (*(this->success))[_key1686];
+              xfer += _val1687.read(iprot);
+=======
+            uint32_t _size1696;
+            ::apache::thrift::protocol::TType _etype1699;
+            xfer += iprot->readListBegin(_etype1699, _size1696);
+            (*(this->success)).resize(_size1696);
+            uint32_t _i1700;
+            for (_i1700 = 0; _i1700 < _size1696; ++_i1700)
+            {
+              xfer += iprot->readString((*(this->success))[_i1700]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -4346,22 +4146,6 @@ uint32_t ThriftHiveMetastore_get_fields_presult::read(::apache::thrift::protocol
           xfer += iprot->skip(ftype);
         }
         break;
-      case 2:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o2.read(iprot);
-          this->__isset.o2 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 3:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o3.read(iprot);
-          this->__isset.o3 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
       default:
         xfer += iprot->skip(ftype);
         break;
@@ -4375,11 +4159,11 @@ uint32_t ThriftHiveMetastore_get_fields_presult::read(::apache::thrift::protocol
 }
 
 
-ThriftHiveMetastore_get_fields_with_environment_context_args::~ThriftHiveMetastore_get_fields_with_environment_context_args() noexcept {
+ThriftHiveMetastore_alter_dataconnector_args::~ThriftHiveMetastore_alter_dataconnector_args() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_fields_with_environment_context_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_alter_dataconnector_args::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -4402,24 +4186,16 @@ uint32_t ThriftHiveMetastore_get_fields_with_environment_context_args::read(::ap
     {
       case 1:
         if (ftype == ::apache::thrift::protocol::T_STRING) {
-          xfer += iprot->readString(this->db_name);
-          this->__isset.db_name = true;
+          xfer += iprot->readString(this->name);
+          this->__isset.name = true;
         } else {
           xfer += iprot->skip(ftype);
         }
         break;
       case 2:
-        if (ftype == ::apache::thrift::protocol::T_STRING) {
-          xfer += iprot->readString(this->table_name);
-          this->__isset.table_name = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 3:
         if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->environment_context.read(iprot);
-          this->__isset.environment_context = true;
+          xfer += this->connector.read(iprot);
+          this->__isset.connector = true;
         } else {
           xfer += iprot->skip(ftype);
         }
@@ -4436,21 +4212,17 @@ uint32_t ThriftHiveMetastore_get_fields_with_environment_context_args::read(::ap
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_get_fields_with_environment_context_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_alter_dataconnector_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_fields_with_environment_context_args");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_alter_dataconnector_args");
 
-  xfer += oprot->writeFieldBegin("db_name", ::apache::thrift::protocol::T_STRING, 1);
-  xfer += oprot->writeString(this->db_name);
-  xfer += oprot->writeFieldEnd();
-
-  xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2);
-  xfer += oprot->writeString(this->table_name);
+  xfer += oprot->writeFieldBegin("name", ::apache::thrift::protocol::T_STRING, 1);
+  xfer += oprot->writeString(this->name);
   xfer += oprot->writeFieldEnd();
 
-  xfer += oprot->writeFieldBegin("environment_context", ::apache::thrift::protocol::T_STRUCT, 3);
-  xfer += this->environment_context.write(oprot);
+  xfer += oprot->writeFieldBegin("connector", ::apache::thrift::protocol::T_STRUCT, 2);
+  xfer += this->connector.write(oprot);
   xfer += oprot->writeFieldEnd();
 
   xfer += oprot->writeFieldStop();
@@ -4459,25 +4231,21 @@ uint32_t ThriftHiveMetastore_get_fields_with_environment_context_args::write(::a
 }
 
 
-ThriftHiveMetastore_get_fields_with_environment_context_pargs::~ThriftHiveMetastore_get_fields_with_environment_context_pargs() noexcept {
+ThriftHiveMetastore_alter_dataconnector_pargs::~ThriftHiveMetastore_alter_dataconnector_pargs() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_fields_with_environment_context_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_alter_dataconnector_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_fields_with_environment_context_pargs");
-
-  xfer += oprot->writeFieldBegin("db_name", ::apache::thrift::protocol::T_STRING, 1);
-  xfer += oprot->writeString((*(this->db_name)));
-  xfer += oprot->writeFieldEnd();
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_alter_dataconnector_pargs");
 
-  xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2);
-  xfer += oprot->writeString((*(this->table_name)));
+  xfer += oprot->writeFieldBegin("name", ::apache::thrift::protocol::T_STRING, 1);
+  xfer += oprot->writeString((*(this->name)));
   xfer += oprot->writeFieldEnd();
 
-  xfer += oprot->writeFieldBegin("environment_context", ::apache::thrift::protocol::T_STRUCT, 3);
-  xfer += (*(this->environment_context)).write(oprot);
+  xfer += oprot->writeFieldBegin("connector", ::apache::thrift::protocol::T_STRUCT, 2);
+  xfer += (*(this->connector)).write(oprot);
   xfer += oprot->writeFieldEnd();
 
   xfer += oprot->writeFieldStop();
@@ -4486,11 +4254,11 @@ uint32_t ThriftHiveMetastore_get_fields_with_environment_context_pargs::write(::
 }
 
 
-ThriftHiveMetastore_get_fields_with_environment_context_result::~ThriftHiveMetastore_get_fields_with_environment_context_result() noexcept {
+ThriftHiveMetastore_alter_dataconnector_result::~ThriftHiveMetastore_alter_dataconnector_result() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_fields_with_environment_context_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_alter_dataconnector_result::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -4511,18 +4279,19 @@ uint32_t ThriftHiveMetastore_get_fields_with_environment_context_result::read(::
     }
     switch (fid)
     {
+<<<<<<< HEAD
       case 0:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-            uint32_t _size1699;
-            ::apache::thrift::protocol::TType _etype1702;
-            xfer += iprot->readListBegin(_etype1702, _size1699);
-            this->success.resize(_size1699);
-            uint32_t _i1703;
-            for (_i1703 = 0; _i1703 < _size1699; ++_i1703)
+            uint32_t _size1688;
+            ::apache::thrift::protocol::TType _etype1691;
+            xfer += iprot->readListBegin(_etype1691, _size1688);
+            this->success.resize(_size1688);
+            uint32_t _i1692;
+            for (_i1692 = 0; _i1692 < _size1688; ++_i1692)
             {
-              xfer += this->success[_i1703].read(iprot);
+              xfer += this->success[_i1692].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -4531,6 +4300,8 @@ uint32_t ThriftHiveMetastore_get_fields_with_environment_context_result::read(::
           xfer += iprot->skip(ftype);
         }
         break;
+=======
+>>>>>>> External metastore: clean after rebase
       case 1:
         if (ftype == ::apache::thrift::protocol::T_STRUCT) {
           xfer += this->o1.read(iprot);
@@ -4547,14 +4318,6 @@ uint32_t ThriftHiveMetastore_get_fields_with_environment_context_result::read(::
           xfer += iprot->skip(ftype);
         }
         break;
-      case 3:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o3.read(iprot);
-          this->__isset.o3 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
       default:
         xfer += iprot->skip(ftype);
         break;
@@ -4567,25 +4330,29 @@ uint32_t ThriftHiveMetastore_get_fields_with_environment_context_result::read(::
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_get_fields_with_environment_context_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_alter_dataconnector_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
 
   uint32_t xfer = 0;
 
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_fields_with_environment_context_result");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_alter_dataconnector_result");
 
+<<<<<<< HEAD
   if (this->__isset.success) {
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-      std::vector<FieldSchema> ::const_iterator _iter1704;
-      for (_iter1704 = this->success.begin(); _iter1704 != this->success.end(); ++_iter1704)
+      std::vector<FieldSchema> ::const_iterator _iter1693;
+      for (_iter1693 = this->success.begin(); _iter1693 != this->success.end(); ++_iter1693)
       {
-        xfer += (*_iter1704).write(oprot);
+        xfer += (*_iter1693).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
     xfer += oprot->writeFieldEnd();
   } else if (this->__isset.o1) {
+=======
+  if (this->__isset.o1) {
+>>>>>>> External metastore: clean after rebase
     xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
     xfer += this->o1.write(oprot);
     xfer += oprot->writeFieldEnd();
@@ -4593,10 +4360,6 @@ uint32_t ThriftHiveMetastore_get_fields_with_environment_context_result::write(:
     xfer += oprot->writeFieldBegin("o2", ::apache::thrift::protocol::T_STRUCT, 2);
     xfer += this->o2.write(oprot);
     xfer += oprot->writeFieldEnd();
-  } else if (this->__isset.o3) {
-    xfer += oprot->writeFieldBegin("o3", ::apache::thrift::protocol::T_STRUCT, 3);
-    xfer += this->o3.write(oprot);
-    xfer += oprot->writeFieldEnd();
   }
   xfer += oprot->writeFieldStop();
   xfer += oprot->writeStructEnd();
@@ -4604,11 +4367,11 @@ uint32_t ThriftHiveMetastore_get_fields_with_environment_context_result::write(:
 }
 
 
-ThriftHiveMetastore_get_fields_with_environment_context_presult::~ThriftHiveMetastore_get_fields_with_environment_context_presult() noexcept {
+ThriftHiveMetastore_alter_dataconnector_presult::~ThriftHiveMetastore_alter_dataconnector_presult() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_fields_with_environment_context_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_alter_dataconnector_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -4629,18 +4392,19 @@ uint32_t ThriftHiveMetastore_get_fields_with_environment_context_presult::read(:
     }
     switch (fid)
     {
+<<<<<<< HEAD
       case 0:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-            uint32_t _size1705;
-            ::apache::thrift::protocol::TType _etype1708;
-            xfer += iprot->readListBegin(_etype1708, _size1705);
-            (*(this->success)).resize(_size1705);
-            uint32_t _i1709;
-            for (_i1709 = 0; _i1709 < _size1705; ++_i1709)
+            uint32_t _size1694;
+            ::apache::thrift::protocol::TType _etype1697;
+            xfer += iprot->readListBegin(_etype1697, _size1694);
+            (*(this->success)).resize(_size1694);
+            uint32_t _i1698;
+            for (_i1698 = 0; _i1698 < _size1694; ++_i1698)
             {
-              xfer += (*(this->success))[_i1709].read(iprot);
+              xfer += (*(this->success))[_i1698].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -4649,6 +4413,8 @@ uint32_t ThriftHiveMetastore_get_fields_with_environment_context_presult::read(:
           xfer += iprot->skip(ftype);
         }
         break;
+=======
+>>>>>>> External metastore: clean after rebase
       case 1:
         if (ftype == ::apache::thrift::protocol::T_STRUCT) {
           xfer += this->o1.read(iprot);
@@ -4665,14 +4431,6 @@ uint32_t ThriftHiveMetastore_get_fields_with_environment_context_presult::read(:
           xfer += iprot->skip(ftype);
         }
         break;
-      case 3:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o3.read(iprot);
-          this->__isset.o3 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
       default:
         xfer += iprot->skip(ftype);
         break;
@@ -4686,11 +4444,11 @@ uint32_t ThriftHiveMetastore_get_fields_with_environment_context_presult::read(:
 }
 
 
-ThriftHiveMetastore_get_fields_req_args::~ThriftHiveMetastore_get_fields_req_args() noexcept {
+ThriftHiveMetastore_get_type_args::~ThriftHiveMetastore_get_type_args() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_fields_req_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_get_type_args::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -4712,9 +4470,9 @@ uint32_t ThriftHiveMetastore_get_fields_req_args::read(::apache::thrift::protoco
     switch (fid)
     {
       case 1:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->req.read(iprot);
-          this->__isset.req = true;
+        if (ftype == ::apache::thrift::protocol::T_STRING) {
+          xfer += iprot->readString(this->name);
+          this->__isset.name = true;
         } else {
           xfer += iprot->skip(ftype);
         }
@@ -4731,13 +4489,13 @@ uint32_t ThriftHiveMetastore_get_fields_req_args::read(::apache::thrift::protoco
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_get_fields_req_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_get_type_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_fields_req_args");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_type_args");
 
-  xfer += oprot->writeFieldBegin("req", ::apache::thrift::protocol::T_STRUCT, 1);
-  xfer += this->req.write(oprot);
+  xfer += oprot->writeFieldBegin("name", ::apache::thrift::protocol::T_STRING, 1);
+  xfer += oprot->writeString(this->name);
   xfer += oprot->writeFieldEnd();
 
   xfer += oprot->writeFieldStop();
@@ -4746,17 +4504,17 @@ uint32_t ThriftHiveMetastore_get_fields_req_args::write(::apache::thrift::protoc
 }
 
 
-ThriftHiveMetastore_get_fields_req_pargs::~ThriftHiveMetastore_get_fields_req_pargs() noexcept {
+ThriftHiveMetastore_get_type_pargs::~ThriftHiveMetastore_get_type_pargs() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_fields_req_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_get_type_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_fields_req_pargs");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_type_pargs");
 
-  xfer += oprot->writeFieldBegin("req", ::apache::thrift::protocol::T_STRUCT, 1);
-  xfer += (*(this->req)).write(oprot);
+  xfer += oprot->writeFieldBegin("name", ::apache::thrift::protocol::T_STRING, 1);
+  xfer += oprot->writeString((*(this->name)));
   xfer += oprot->writeFieldEnd();
 
   xfer += oprot->writeFieldStop();
@@ -4765,11 +4523,11 @@ uint32_t ThriftHiveMetastore_get_fields_req_pargs::write(::apache::thrift::proto
 }
 
 
-ThriftHiveMetastore_get_fields_req_result::~ThriftHiveMetastore_get_fields_req_result() noexcept {
+ThriftHiveMetastore_get_type_result::~ThriftHiveMetastore_get_type_result() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_fields_req_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_get_type_result::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -4791,8 +4549,25 @@ uint32_t ThriftHiveMetastore_get_fields_req_result::read(::apache::thrift::proto
     switch (fid)
     {
       case 0:
+<<<<<<< HEAD
+        if (ftype == ::apache::thrift::protocol::T_LIST) {
+          {
+            this->success.clear();
+            uint32_t _size1699;
+            ::apache::thrift::protocol::TType _etype1702;
+            xfer += iprot->readListBegin(_etype1702, _size1699);
+            this->success.resize(_size1699);
+            uint32_t _i1703;
+            for (_i1703 = 0; _i1703 < _size1699; ++_i1703)
+            {
+              xfer += this->success[_i1703].read(iprot);
+            }
+            xfer += iprot->readListEnd();
+          }
+=======
         if (ftype == ::apache::thrift::protocol::T_STRUCT) {
           xfer += this->success.read(iprot);
+>>>>>>> External metastore: clean after rebase
           this->__isset.success = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -4814,14 +4589,6 @@ uint32_t ThriftHiveMetastore_get_fields_req_result::read(::apache::thrift::proto
           xfer += iprot->skip(ftype);
         }
         break;
-      case 3:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o3.read(iprot);
-          this->__isset.o3 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
       default:
         xfer += iprot->skip(ftype);
         break;
@@ -4834,15 +4601,28 @@ uint32_t ThriftHiveMetastore_get_fields_req_result::read(::apache::thrift::proto
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_get_fields_req_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_get_type_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
 
   uint32_t xfer = 0;
 
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_fields_req_result");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_type_result");
 
   if (this->__isset.success) {
+<<<<<<< HEAD
+    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
+    {
+      xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+      std::vector<FieldSchema> ::const_iterator _iter1704;
+      for (_iter1704 = this->success.begin(); _iter1704 != this->success.end(); ++_iter1704)
+      {
+        xfer += (*_iter1704).write(oprot);
+      }
+      xfer += oprot->writeListEnd();
+    }
+=======
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0);
     xfer += this->success.write(oprot);
+>>>>>>> External metastore: clean after rebase
     xfer += oprot->writeFieldEnd();
   } else if (this->__isset.o1) {
     xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
@@ -4852,10 +4632,6 @@ uint32_t ThriftHiveMetastore_get_fields_req_result::write(::apache::thrift::prot
     xfer += oprot->writeFieldBegin("o2", ::apache::thrift::protocol::T_STRUCT, 2);
     xfer += this->o2.write(oprot);
     xfer += oprot->writeFieldEnd();
-  } else if (this->__isset.o3) {
-    xfer += oprot->writeFieldBegin("o3", ::apache::thrift::protocol::T_STRUCT, 3);
-    xfer += this->o3.write(oprot);
-    xfer += oprot->writeFieldEnd();
   }
   xfer += oprot->writeFieldStop();
   xfer += oprot->writeStructEnd();
@@ -4863,11 +4639,11 @@ uint32_t ThriftHiveMetastore_get_fields_req_result::write(::apache::thrift::prot
 }
 
 
-ThriftHiveMetastore_get_fields_req_presult::~ThriftHiveMetastore_get_fields_req_presult() noexcept {
+ThriftHiveMetastore_get_type_presult::~ThriftHiveMetastore_get_type_presult() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_fields_req_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_get_type_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -4889,8 +4665,25 @@ uint32_t ThriftHiveMetastore_get_fields_req_presult::read(::apache::thrift::prot
     switch (fid)
     {
       case 0:
+<<<<<<< HEAD
+        if (ftype == ::apache::thrift::protocol::T_LIST) {
+          {
+            (*(this->success)).clear();
+            uint32_t _size1705;
+            ::apache::thrift::protocol::TType _etype1708;
+            xfer += iprot->readListBegin(_etype1708, _size1705);
+            (*(this->success)).resize(_size1705);
+            uint32_t _i1709;
+            for (_i1709 = 0; _i1709 < _size1705; ++_i1709)
+            {
+              xfer += (*(this->success))[_i1709].read(iprot);
+            }
+            xfer += iprot->readListEnd();
+          }
+=======
         if (ftype == ::apache::thrift::protocol::T_STRUCT) {
           xfer += (*(this->success)).read(iprot);
+>>>>>>> External metastore: clean after rebase
           this->__isset.success = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -4912,14 +4705,6 @@ uint32_t ThriftHiveMetastore_get_fields_req_presult::read(::apache::thrift::prot
           xfer += iprot->skip(ftype);
         }
         break;
-      case 3:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o3.read(iprot);
-          this->__isset.o3 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
       default:
         xfer += iprot->skip(ftype);
         break;
@@ -4933,11 +4718,11 @@ uint32_t ThriftHiveMetastore_get_fields_req_presult::read(::apache::thrift::prot
 }
 
 
-ThriftHiveMetastore_get_schema_args::~ThriftHiveMetastore_get_schema_args() noexcept {
+ThriftHiveMetastore_create_type_args::~ThriftHiveMetastore_create_type_args() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_schema_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_create_type_args::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -4959,17 +4744,9 @@ uint32_t ThriftHiveMetastore_get_schema_args::read(::apache::thrift::protocol::T
     switch (fid)
     {
       case 1:
-        if (ftype == ::apache::thrift::protocol::T_STRING) {
-          xfer += iprot->readString(this->db_name);
-          this->__isset.db_name = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 2:
-        if (ftype == ::apache::thrift::protocol::T_STRING) {
-          xfer += iprot->readString(this->table_name);
-          this->__isset.table_name = true;
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->type.read(iprot);
+          this->__isset.type = true;
         } else {
           xfer += iprot->skip(ftype);
         }
@@ -4986,17 +4763,13 @@ uint32_t ThriftHiveMetastore_get_schema_args::read(::apache::thrift::protocol::T
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_get_schema_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_create_type_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_schema_args");
-
-  xfer += oprot->writeFieldBegin("db_name", ::apache::thrift::protocol::T_STRING, 1);
-  xfer += oprot->writeString(this->db_name);
-  xfer += oprot->writeFieldEnd();
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_type_args");
 
-  xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2);
-  xfer += oprot->writeString(this->table_name);
+  xfer += oprot->writeFieldBegin("type", ::apache::thrift::protocol::T_STRUCT, 1);
+  xfer += this->type.write(oprot);
   xfer += oprot->writeFieldEnd();
 
   xfer += oprot->writeFieldStop();
@@ -5005,21 +4778,17 @@ uint32_t ThriftHiveMetastore_get_schema_args::write(::apache::thrift::protocol::
 }
 
 
-ThriftHiveMetastore_get_schema_pargs::~ThriftHiveMetastore_get_schema_pargs() noexcept {
+ThriftHiveMetastore_create_type_pargs::~ThriftHiveMetastore_create_type_pargs() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_schema_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_create_type_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_schema_pargs");
-
-  xfer += oprot->writeFieldBegin("db_name", ::apache::thrift::protocol::T_STRING, 1);
-  xfer += oprot->writeString((*(this->db_name)));
-  xfer += oprot->writeFieldEnd();
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_type_pargs");
 
-  xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2);
-  xfer += oprot->writeString((*(this->table_name)));
+  xfer += oprot->writeFieldBegin("type", ::apache::thrift::protocol::T_STRUCT, 1);
+  xfer += (*(this->type)).write(oprot);
   xfer += oprot->writeFieldEnd();
 
   xfer += oprot->writeFieldStop();
@@ -5028,11 +4797,11 @@ uint32_t ThriftHiveMetastore_get_schema_pargs::write(::apache::thrift::protocol:
 }
 
 
-ThriftHiveMetastore_get_schema_result::~ThriftHiveMetastore_get_schema_result() noexcept {
+ThriftHiveMetastore_create_type_result::~ThriftHiveMetastore_create_type_result() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_schema_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_create_type_result::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -5054,20 +4823,8 @@ uint32_t ThriftHiveMetastore_get_schema_result::read(::apache::thrift::protocol:
     switch (fid)
     {
       case 0:
-        if (ftype == ::apache::thrift::protocol::T_LIST) {
-          {
-            this->success.clear();
-            uint32_t _size1710;
-            ::apache::thrift::protocol::TType _etype1713;
-            xfer += iprot->readListBegin(_etype1713, _size1710);
-            this->success.resize(_size1710);
-            uint32_t _i1714;
-            for (_i1714 = 0; _i1714 < _size1710; ++_i1714)
-            {
-              xfer += this->success[_i1714].read(iprot);
-            }
-            xfer += iprot->readListEnd();
-          }
+        if (ftype == ::apache::thrift::protocol::T_BOOL) {
+          xfer += iprot->readBool(this->success);
           this->__isset.success = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -5109,23 +4866,15 @@ uint32_t ThriftHiveMetastore_get_schema_result::read(::apache::thrift::protocol:
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_get_schema_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_create_type_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
 
   uint32_t xfer = 0;
 
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_schema_result");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_type_result");
 
   if (this->__isset.success) {
-    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
-    {
-      xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-      std::vector<FieldSchema> ::const_iterator _iter1715;
-      for (_iter1715 = this->success.begin(); _iter1715 != this->success.end(); ++_iter1715)
-      {
-        xfer += (*_iter1715).write(oprot);
-      }
-      xfer += oprot->writeListEnd();
-    }
+    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_BOOL, 0);
+    xfer += oprot->writeBool(this->success);
     xfer += oprot->writeFieldEnd();
   } else if (this->__isset.o1) {
     xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
@@ -5146,11 +4895,11 @@ uint32_t ThriftHiveMetastore_get_schema_result::write(::apache::thrift::protocol
 }
 
 
-ThriftHiveMetastore_get_schema_presult::~ThriftHiveMetastore_get_schema_presult() noexcept {
+ThriftHiveMetastore_create_type_presult::~ThriftHiveMetastore_create_type_presult() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_schema_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_create_type_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -5172,20 +4921,8 @@ uint32_t ThriftHiveMetastore_get_schema_presult::read(::apache::thrift::protocol
     switch (fid)
     {
       case 0:
-        if (ftype == ::apache::thrift::protocol::T_LIST) {
-          {
-            (*(this->success)).clear();
-            uint32_t _size1716;
-            ::apache::thrift::protocol::TType _etype1719;
-            xfer += iprot->readListBegin(_etype1719, _size1716);
-            (*(this->success)).resize(_size1716);
-            uint32_t _i1720;
-            for (_i1720 = 0; _i1720 < _size1716; ++_i1720)
-            {
-              xfer += (*(this->success))[_i1720].read(iprot);
-            }
-            xfer += iprot->readListEnd();
-          }
+        if (ftype == ::apache::thrift::protocol::T_BOOL) {
+          xfer += iprot->readBool((*(this->success)));
           this->__isset.success = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -5228,11 +4965,11 @@ uint32_t ThriftHiveMetastore_get_schema_presult::read(::apache::thrift::protocol
 }
 
 
-ThriftHiveMetastore_get_schema_with_environment_context_args::~ThriftHiveMetastore_get_schema_with_environment_context_args() noexcept {
+ThriftHiveMetastore_drop_type_args::~ThriftHiveMetastore_drop_type_args() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_schema_with_environment_context_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_drop_type_args::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -5255,24 +4992,8 @@ uint32_t ThriftHiveMetastore_get_schema_with_environment_context_args::read(::ap
     {
       case 1:
         if (ftype == ::apache::thrift::protocol::T_STRING) {
-          xfer += iprot->readString(this->db_name);
-          this->__isset.db_name = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 2:
-        if (ftype == ::apache::thrift::protocol::T_STRING) {
-          xfer += iprot->readString(this->table_name);
-          this->__isset.table_name = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 3:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->environment_context.read(iprot);
-          this->__isset.environment_context = true;
+          xfer += iprot->readString(this->type);
+          this->__isset.type = true;
         } else {
           xfer += iprot->skip(ftype);
         }
@@ -5289,21 +5010,13 @@ uint32_t ThriftHiveMetastore_get_schema_with_environment_context_args::read(::ap
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_get_schema_with_environment_context_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_drop_type_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_schema_with_environment_context_args");
-
-  xfer += oprot->writeFieldBegin("db_name", ::apache::thrift::protocol::T_STRING, 1);
-  xfer += oprot->writeString(this->db_name);
-  xfer += oprot->writeFieldEnd();
-
-  xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2);
-  xfer += oprot->writeString(this->table_name);
-  xfer += oprot->writeFieldEnd();
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_drop_type_args");
 
-  xfer += oprot->writeFieldBegin("environment_context", ::apache::thrift::protocol::T_STRUCT, 3);
-  xfer += this->environment_context.write(oprot);
+  xfer += oprot->writeFieldBegin("type", ::apache::thrift::protocol::T_STRING, 1);
+  xfer += oprot->writeString(this->type);
   xfer += oprot->writeFieldEnd();
 
   xfer += oprot->writeFieldStop();
@@ -5312,25 +5025,17 @@ uint32_t ThriftHiveMetastore_get_schema_with_environment_context_args::write(::a
 }
 
 
-ThriftHiveMetastore_get_schema_with_environment_context_pargs::~ThriftHiveMetastore_get_schema_with_environment_context_pargs() noexcept {
+ThriftHiveMetastore_drop_type_pargs::~ThriftHiveMetastore_drop_type_pargs() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_schema_with_environment_context_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_drop_type_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_schema_with_environment_context_pargs");
-
-  xfer += oprot->writeFieldBegin("db_name", ::apache::thrift::protocol::T_STRING, 1);
-  xfer += oprot->writeString((*(this->db_name)));
-  xfer += oprot->writeFieldEnd();
-
-  xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2);
-  xfer += oprot->writeString((*(this->table_name)));
-  xfer += oprot->writeFieldEnd();
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_drop_type_pargs");
 
-  xfer += oprot->writeFieldBegin("environment_context", ::apache::thrift::protocol::T_STRUCT, 3);
-  xfer += (*(this->environment_context)).write(oprot);
+  xfer += oprot->writeFieldBegin("type", ::apache::thrift::protocol::T_STRING, 1);
+  xfer += oprot->writeString((*(this->type)));
   xfer += oprot->writeFieldEnd();
 
   xfer += oprot->writeFieldStop();
@@ -5339,11 +5044,11 @@ uint32_t ThriftHiveMetastore_get_schema_with_environment_context_pargs::write(::
 }
 
 
-ThriftHiveMetastore_get_schema_with_environment_context_result::~ThriftHiveMetastore_get_schema_with_environment_context_result() noexcept {
+ThriftHiveMetastore_drop_type_result::~ThriftHiveMetastore_drop_type_result() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_schema_with_environment_context_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_drop_type_result::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -5365,20 +5070,25 @@ uint32_t ThriftHiveMetastore_get_schema_with_environment_context_result::read(::
     switch (fid)
     {
       case 0:
+<<<<<<< HEAD
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-            uint32_t _size1721;
-            ::apache::thrift::protocol::TType _etype1724;
-            xfer += iprot->readListBegin(_etype1724, _size1721);
-            this->success.resize(_size1721);
-            uint32_t _i1725;
-            for (_i1725 = 0; _i1725 < _size1721; ++_i1725)
+            uint32_t _size1710;
+            ::apache::thrift::protocol::TType _etype1713;
+            xfer += iprot->readListBegin(_etype1713, _size1710);
+            this->success.resize(_size1710);
+            uint32_t _i1714;
+            for (_i1714 = 0; _i1714 < _size1710; ++_i1714)
             {
-              xfer += this->success[_i1725].read(iprot);
+              xfer += this->success[_i1714].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
+=======
+        if (ftype == ::apache::thrift::protocol::T_BOOL) {
+          xfer += iprot->readBool(this->success);
+>>>>>>> External metastore: clean after rebase
           this->__isset.success = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -5400,14 +5110,6 @@ uint32_t ThriftHiveMetastore_get_schema_with_environment_context_result::read(::
           xfer += iprot->skip(ftype);
         }
         break;
-      case 3:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o3.read(iprot);
-          this->__isset.o3 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
       default:
         xfer += iprot->skip(ftype);
         break;
@@ -5420,23 +5122,28 @@ uint32_t ThriftHiveMetastore_get_schema_with_environment_context_result::read(::
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_get_schema_with_environment_context_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_drop_type_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
 
   uint32_t xfer = 0;
 
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_schema_with_environment_context_result");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_drop_type_result");
 
   if (this->__isset.success) {
+<<<<<<< HEAD
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-      std::vector<FieldSchema> ::const_iterator _iter1726;
-      for (_iter1726 = this->success.begin(); _iter1726 != this->success.end(); ++_iter1726)
+      std::vector<FieldSchema> ::const_iterator _iter1715;
+      for (_iter1715 = this->success.begin(); _iter1715 != this->success.end(); ++_iter1715)
       {
-        xfer += (*_iter1726).write(oprot);
+        xfer += (*_iter1715).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
+=======
+    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_BOOL, 0);
+    xfer += oprot->writeBool(this->success);
+>>>>>>> External metastore: clean after rebase
     xfer += oprot->writeFieldEnd();
   } else if (this->__isset.o1) {
     xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
@@ -5446,10 +5153,6 @@ uint32_t ThriftHiveMetastore_get_schema_with_environment_context_result::write(:
     xfer += oprot->writeFieldBegin("o2", ::apache::thrift::protocol::T_STRUCT, 2);
     xfer += this->o2.write(oprot);
     xfer += oprot->writeFieldEnd();
-  } else if (this->__isset.o3) {
-    xfer += oprot->writeFieldBegin("o3", ::apache::thrift::protocol::T_STRUCT, 3);
-    xfer += this->o3.write(oprot);
-    xfer += oprot->writeFieldEnd();
   }
   xfer += oprot->writeFieldStop();
   xfer += oprot->writeStructEnd();
@@ -5457,11 +5160,11 @@ uint32_t ThriftHiveMetastore_get_schema_with_environment_context_result::write(:
 }
 
 
-ThriftHiveMetastore_get_schema_with_environment_context_presult::~ThriftHiveMetastore_get_schema_with_environment_context_presult() noexcept {
+ThriftHiveMetastore_drop_type_presult::~ThriftHiveMetastore_drop_type_presult() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_schema_with_environment_context_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_drop_type_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -5483,20 +5186,25 @@ uint32_t ThriftHiveMetastore_get_schema_with_environment_context_presult::read(:
     switch (fid)
     {
       case 0:
+<<<<<<< HEAD
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-            uint32_t _size1727;
-            ::apache::thrift::protocol::TType _etype1730;
-            xfer += iprot->readListBegin(_etype1730, _size1727);
-            (*(this->success)).resize(_size1727);
-            uint32_t _i1731;
-            for (_i1731 = 0; _i1731 < _size1727; ++_i1731)
+            uint32_t _size1716;
+            ::apache::thrift::protocol::TType _etype1719;
+            xfer += iprot->readListBegin(_etype1719, _size1716);
+            (*(this->success)).resize(_size1716);
+            uint32_t _i1720;
+            for (_i1720 = 0; _i1720 < _size1716; ++_i1720)
             {
-              xfer += (*(this->success))[_i1731].read(iprot);
+              xfer += (*(this->success))[_i1720].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
+=======
+        if (ftype == ::apache::thrift::protocol::T_BOOL) {
+          xfer += iprot->readBool((*(this->success)));
+>>>>>>> External metastore: clean after rebase
           this->__isset.success = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -5518,14 +5226,6 @@ uint32_t ThriftHiveMetastore_get_schema_with_environment_context_presult::read(:
           xfer += iprot->skip(ftype);
         }
         break;
-      case 3:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o3.read(iprot);
-          this->__isset.o3 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
       default:
         xfer += iprot->skip(ftype);
         break;
@@ -5539,11 +5239,11 @@ uint32_t ThriftHiveMetastore_get_schema_with_environment_context_presult::read(:
 }
 
 
-ThriftHiveMetastore_get_schema_req_args::~ThriftHiveMetastore_get_schema_req_args() noexcept {
+ThriftHiveMetastore_get_type_all_args::~ThriftHiveMetastore_get_type_all_args() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_schema_req_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_get_type_all_args::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -5565,9 +5265,9 @@ uint32_t ThriftHiveMetastore_get_schema_req_args::read(::apache::thrift::protoco
     switch (fid)
     {
       case 1:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->req.read(iprot);
-          this->__isset.req = true;
+        if (ftype == ::apache::thrift::protocol::T_STRING) {
+          xfer += iprot->readString(this->name);
+          this->__isset.name = true;
         } else {
           xfer += iprot->skip(ftype);
         }
@@ -5584,13 +5284,13 @@ uint32_t ThriftHiveMetastore_get_schema_req_args::read(::apache::thrift::protoco
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_get_schema_req_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_get_type_all_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_schema_req_args");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_type_all_args");
 
-  xfer += oprot->writeFieldBegin("req", ::apache::thrift::protocol::T_STRUCT, 1);
-  xfer += this->req.write(oprot);
+  xfer += oprot->writeFieldBegin("name", ::apache::thrift::protocol::T_STRING, 1);
+  xfer += oprot->writeString(this->name);
   xfer += oprot->writeFieldEnd();
 
   xfer += oprot->writeFieldStop();
@@ -5599,17 +5299,17 @@ uint32_t ThriftHiveMetastore_get_schema_req_args::write(::apache::thrift::protoc
 }
 
 
-ThriftHiveMetastore_get_schema_req_pargs::~ThriftHiveMetastore_get_schema_req_pargs() noexcept {
+ThriftHiveMetastore_get_type_all_pargs::~ThriftHiveMetastore_get_type_all_pargs() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_schema_req_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_get_type_all_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_schema_req_pargs");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_type_all_pargs");
 
-  xfer += oprot->writeFieldBegin("req", ::apache::thrift::protocol::T_STRUCT, 1);
-  xfer += (*(this->req)).write(oprot);
+  xfer += oprot->writeFieldBegin("name", ::apache::thrift::protocol::T_STRING, 1);
+  xfer += oprot->writeString((*(this->name)));
   xfer += oprot->writeFieldEnd();
 
   xfer += oprot->writeFieldStop();
@@ -5618,11 +5318,11 @@ uint32_t ThriftHiveMetastore_get_schema_req_pargs::write(::apache::thrift::proto
 }
 
 
-ThriftHiveMetastore_get_schema_req_result::~ThriftHiveMetastore_get_schema_req_result() noexcept {
+ThriftHiveMetastore_get_type_all_result::~ThriftHiveMetastore_get_type_all_result() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_schema_req_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_get_type_all_result::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -5644,8 +5344,34 @@ uint32_t ThriftHiveMetastore_get_schema_req_result::read(::apache::thrift::proto
     switch (fid)
     {
       case 0:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->success.read(iprot);
+        if (ftype == ::apache::thrift::protocol::T_MAP) {
+          {
+            this->success.clear();
+<<<<<<< HEAD
+            uint32_t _size1721;
+            ::apache::thrift::protocol::TType _etype1724;
+            xfer += iprot->readListBegin(_etype1724, _size1721);
+            this->success.resize(_size1721);
+            uint32_t _i1725;
+            for (_i1725 = 0; _i1725 < _size1721; ++_i1725)
+            {
+              xfer += this->success[_i1725].read(iprot);
+=======
+            uint32_t _size1701;
+            ::apache::thrift::protocol::TType _ktype1702;
+            ::apache::thrift::protocol::TType _vtype1703;
+            xfer += iprot->readMapBegin(_ktype1702, _vtype1703, _size1701);
+            uint32_t _i1705;
+            for (_i1705 = 0; _i1705 < _size1701; ++_i1705)
+            {
+              std::string _key1706;
+              xfer += iprot->readString(_key1706);
+              Type& _val1707 = this->success[_key1706];
+              xfer += _val1707.read(iprot);
+>>>>>>> External metastore: clean after rebase
+            }
+            xfer += iprot->readMapEnd();
+          }
           this->__isset.success = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -5653,28 +5379,12 @@ uint32_t ThriftHiveMetastore_get_schema_req_result::read(::apache::thrift::proto
         break;
       case 1:
         if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o1.read(iprot);
-          this->__isset.o1 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 2:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
           xfer += this->o2.read(iprot);
           this->__isset.o2 = true;
         } else {
           xfer += iprot->skip(ftype);
         }
         break;
-      case 3:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o3.read(iprot);
-          this->__isset.o3 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
       default:
         xfer += iprot->skip(ftype);
         break;
@@ -5687,28 +5397,37 @@ uint32_t ThriftHiveMetastore_get_schema_req_result::read(::apache::thrift::proto
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_get_schema_req_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_get_type_all_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
 
   uint32_t xfer = 0;
 
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_schema_req_result");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_type_all_result");
 
   if (this->__isset.success) {
-    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0);
-    xfer += this->success.write(oprot);
-    xfer += oprot->writeFieldEnd();
-  } else if (this->__isset.o1) {
-    xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
-    xfer += this->o1.write(oprot);
+    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_MAP, 0);
+    {
+<<<<<<< HEAD
+      xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+      std::vector<FieldSchema> ::const_iterator _iter1726;
+      for (_iter1726 = this->success.begin(); _iter1726 != this->success.end(); ++_iter1726)
+      {
+        xfer += (*_iter1726).write(oprot);
+=======
+      xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+      std::map<std::string, Type> ::const_iterator _iter1708;
+      for (_iter1708 = this->success.begin(); _iter1708 != this->success.end(); ++_iter1708)
+      {
+        xfer += oprot->writeString(_iter1708->first);
+        xfer += _iter1708->second.write(oprot);
+>>>>>>> External metastore: clean after rebase
+      }
+      xfer += oprot->writeMapEnd();
+    }
     xfer += oprot->writeFieldEnd();
   } else if (this->__isset.o2) {
-    xfer += oprot->writeFieldBegin("o2", ::apache::thrift::protocol::T_STRUCT, 2);
+    xfer += oprot->writeFieldBegin("o2", ::apache::thrift::protocol::T_STRUCT, 1);
     xfer += this->o2.write(oprot);
     xfer += oprot->writeFieldEnd();
-  } else if (this->__isset.o3) {
-    xfer += oprot->writeFieldBegin("o3", ::apache::thrift::protocol::T_STRUCT, 3);
-    xfer += this->o3.write(oprot);
-    xfer += oprot->writeFieldEnd();
   }
   xfer += oprot->writeFieldStop();
   xfer += oprot->writeStructEnd();
@@ -5716,11 +5435,11 @@ uint32_t ThriftHiveMetastore_get_schema_req_result::write(::apache::thrift::prot
 }
 
 
-ThriftHiveMetastore_get_schema_req_presult::~ThriftHiveMetastore_get_schema_req_presult() noexcept {
+ThriftHiveMetastore_get_type_all_presult::~ThriftHiveMetastore_get_type_all_presult() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_get_schema_req_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_get_type_all_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -5742,8 +5461,34 @@ uint32_t ThriftHiveMetastore_get_schema_req_presult::read(::apache::thrift::prot
     switch (fid)
     {
       case 0:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += (*(this->success)).read(iprot);
+        if (ftype == ::apache::thrift::protocol::T_MAP) {
+          {
+            (*(this->success)).clear();
+<<<<<<< HEAD
+            uint32_t _size1727;
+            ::apache::thrift::protocol::TType _etype1730;
+            xfer += iprot->readListBegin(_etype1730, _size1727);
+            (*(this->success)).resize(_size1727);
+            uint32_t _i1731;
+            for (_i1731 = 0; _i1731 < _size1727; ++_i1731)
+            {
+              xfer += (*(this->success))[_i1731].read(iprot);
+=======
+            uint32_t _size1709;
+            ::apache::thrift::protocol::TType _ktype1710;
+            ::apache::thrift::protocol::TType _vtype1711;
+            xfer += iprot->readMapBegin(_ktype1710, _vtype1711, _size1709);
+            uint32_t _i1713;
+            for (_i1713 = 0; _i1713 < _size1709; ++_i1713)
+            {
+              std::string _key1714;
+              xfer += iprot->readString(_key1714);
+              Type& _val1715 = (*(this->success))[_key1714];
+              xfer += _val1715.read(iprot);
+>>>>>>> External metastore: clean after rebase
+            }
+            xfer += iprot->readMapEnd();
+          }
           this->__isset.success = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -5751,28 +5496,12 @@ uint32_t ThriftHiveMetastore_get_schema_req_presult::read(::apache::thrift::prot
         break;
       case 1:
         if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o1.read(iprot);
-          this->__isset.o1 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 2:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
           xfer += this->o2.read(iprot);
           this->__isset.o2 = true;
         } else {
           xfer += iprot->skip(ftype);
         }
         break;
-      case 3:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o3.read(iprot);
-          this->__isset.o3 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
       default:
         xfer += iprot->skip(ftype);
         break;
@@ -5786,11 +5515,11 @@ uint32_t ThriftHiveMetastore_get_schema_req_presult::read(::apache::thrift::prot
 }
 
 
-ThriftHiveMetastore_create_table_args::~ThriftHiveMetastore_create_table_args() noexcept {
+ThriftHiveMetastore_get_fields_args::~ThriftHiveMetastore_get_fields_args() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_create_table_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_get_fields_args::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -5812,9 +5541,17 @@ uint32_t ThriftHiveMetastore_create_table_args::read(::apache::thrift::protocol:
     switch (fid)
     {
       case 1:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->tbl.read(iprot);
-          this->__isset.tbl = true;
+        if (ftype == ::apache::thrift::protocol::T_STRING) {
+          xfer += iprot->readString(this->db_name);
+          this->__isset.db_name = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 2:
+        if (ftype == ::apache::thrift::protocol::T_STRING) {
+          xfer += iprot->readString(this->table_name);
+          this->__isset.table_name = true;
         } else {
           xfer += iprot->skip(ftype);
         }
@@ -5831,13 +5568,17 @@ uint32_t ThriftHiveMetastore_create_table_args::read(::apache::thrift::protocol:
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_create_table_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_get_fields_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_table_args");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_fields_args");
 
-  xfer += oprot->writeFieldBegin("tbl", ::apache::thrift::protocol::T_STRUCT, 1);
-  xfer += this->tbl.write(oprot);
+  xfer += oprot->writeFieldBegin("db_name", ::apache::thrift::protocol::T_STRING, 1);
+  xfer += oprot->writeString(this->db_name);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2);
+  xfer += oprot->writeString(this->table_name);
   xfer += oprot->writeFieldEnd();
 
   xfer += oprot->writeFieldStop();
@@ -5846,17 +5587,21 @@ uint32_t ThriftHiveMetastore_create_table_args::write(::apache::thrift::protocol
 }
 
 
-ThriftHiveMetastore_create_table_pargs::~ThriftHiveMetastore_create_table_pargs() noexcept {
+ThriftHiveMetastore_get_fields_pargs::~ThriftHiveMetastore_get_fields_pargs() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_create_table_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_get_fields_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_table_pargs");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_fields_pargs");
 
-  xfer += oprot->writeFieldBegin("tbl", ::apache::thrift::protocol::T_STRUCT, 1);
-  xfer += (*(this->tbl)).write(oprot);
+  xfer += oprot->writeFieldBegin("db_name", ::apache::thrift::protocol::T_STRING, 1);
+  xfer += oprot->writeString((*(this->db_name)));
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2);
+  xfer += oprot->writeString((*(this->table_name)));
   xfer += oprot->writeFieldEnd();
 
   xfer += oprot->writeFieldStop();
@@ -5865,11 +5610,11 @@ uint32_t ThriftHiveMetastore_create_table_pargs::write(::apache::thrift::protoco
 }
 
 
-ThriftHiveMetastore_create_table_result::~ThriftHiveMetastore_create_table_result() noexcept {
+ThriftHiveMetastore_get_fields_result::~ThriftHiveMetastore_get_fields_result() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_create_table_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_get_fields_result::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -5890,6 +5635,26 @@ uint32_t ThriftHiveMetastore_create_table_result::read(::apache::thrift::protoco
     }
     switch (fid)
     {
+      case 0:
+        if (ftype == ::apache::thrift::protocol::T_LIST) {
+          {
+            this->success.clear();
+            uint32_t _size1716;
+            ::apache::thrift::protocol::TType _etype1719;
+            xfer += iprot->readListBegin(_etype1719, _size1716);
+            this->success.resize(_size1716);
+            uint32_t _i1720;
+            for (_i1720 = 0; _i1720 < _size1716; ++_i1720)
+            {
+              xfer += this->success[_i1720].read(iprot);
+            }
+            xfer += iprot->readListEnd();
+          }
+          this->__isset.success = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
       case 1:
         if (ftype == ::apache::thrift::protocol::T_STRUCT) {
           xfer += this->o1.read(iprot);
@@ -5914,14 +5679,6 @@ uint32_t ThriftHiveMetastore_create_table_result::read(::apache::thrift::protoco
           xfer += iprot->skip(ftype);
         }
         break;
-      case 4:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o4.read(iprot);
-          this->__isset.o4 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
       default:
         xfer += iprot->skip(ftype);
         break;
@@ -5934,13 +5691,25 @@ uint32_t ThriftHiveMetastore_create_table_result::read(::apache::thrift::protoco
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_create_table_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_get_fields_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
 
   uint32_t xfer = 0;
 
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_table_result");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_fields_result");
 
-  if (this->__isset.o1) {
+  if (this->__isset.success) {
+    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
+    {
+      xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+      std::vector<FieldSchema> ::const_iterator _iter1721;
+      for (_iter1721 = this->success.begin(); _iter1721 != this->success.end(); ++_iter1721)
+      {
+        xfer += (*_iter1721).write(oprot);
+      }
+      xfer += oprot->writeListEnd();
+    }
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o1) {
     xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
     xfer += this->o1.write(oprot);
     xfer += oprot->writeFieldEnd();
@@ -5952,10 +5721,6 @@ uint32_t ThriftHiveMetastore_create_table_result::write(::apache::thrift::protoc
     xfer += oprot->writeFieldBegin("o3", ::apache::thrift::protocol::T_STRUCT, 3);
     xfer += this->o3.write(oprot);
     xfer += oprot->writeFieldEnd();
-  } else if (this->__isset.o4) {
-    xfer += oprot->writeFieldBegin("o4", ::apache::thrift::protocol::T_STRUCT, 4);
-    xfer += this->o4.write(oprot);
-    xfer += oprot->writeFieldEnd();
   }
   xfer += oprot->writeFieldStop();
   xfer += oprot->writeStructEnd();
@@ -5963,11 +5728,11 @@ uint32_t ThriftHiveMetastore_create_table_result::write(::apache::thrift::protoc
 }
 
 
-ThriftHiveMetastore_create_table_presult::~ThriftHiveMetastore_create_table_presult() noexcept {
+ThriftHiveMetastore_get_fields_presult::~ThriftHiveMetastore_get_fields_presult() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_create_table_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_get_fields_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -5988,6 +5753,26 @@ uint32_t ThriftHiveMetastore_create_table_presult::read(::apache::thrift::protoc
     }
     switch (fid)
     {
+      case 0:
+        if (ftype == ::apache::thrift::protocol::T_LIST) {
+          {
+            (*(this->success)).clear();
+            uint32_t _size1722;
+            ::apache::thrift::protocol::TType _etype1725;
+            xfer += iprot->readListBegin(_etype1725, _size1722);
+            (*(this->success)).resize(_size1722);
+            uint32_t _i1726;
+            for (_i1726 = 0; _i1726 < _size1722; ++_i1726)
+            {
+              xfer += (*(this->success))[_i1726].read(iprot);
+            }
+            xfer += iprot->readListEnd();
+          }
+          this->__isset.success = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
       case 1:
         if (ftype == ::apache::thrift::protocol::T_STRUCT) {
           xfer += this->o1.read(iprot);
@@ -6012,14 +5797,6 @@ uint32_t ThriftHiveMetastore_create_table_presult::read(::apache::thrift::protoc
           xfer += iprot->skip(ftype);
         }
         break;
-      case 4:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o4.read(iprot);
-          this->__isset.o4 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
       default:
         xfer += iprot->skip(ftype);
         break;
@@ -6033,11 +5810,11 @@ uint32_t ThriftHiveMetastore_create_table_presult::read(::apache::thrift::protoc
 }
 
 
-ThriftHiveMetastore_create_table_with_environment_context_args::~ThriftHiveMetastore_create_table_with_environment_context_args() noexcept {
+ThriftHiveMetastore_get_fields_with_environment_context_args::~ThriftHiveMetastore_get_fields_with_environment_context_args() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_create_table_with_environment_context_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_get_fields_with_environment_context_args::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -6059,14 +5836,22 @@ uint32_t ThriftHiveMetastore_create_table_with_environment_context_args::read(::
     switch (fid)
     {
       case 1:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->tbl.read(iprot);
-          this->__isset.tbl = true;
+        if (ftype == ::apache::thrift::protocol::T_STRING) {
+          xfer += iprot->readString(this->db_name);
+          this->__isset.db_name = true;
         } else {
           xfer += iprot->skip(ftype);
         }
         break;
       case 2:
+        if (ftype == ::apache::thrift::protocol::T_STRING) {
+          xfer += iprot->readString(this->table_name);
+          this->__isset.table_name = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 3:
         if (ftype == ::apache::thrift::protocol::T_STRUCT) {
           xfer += this->environment_context.read(iprot);
           this->__isset.environment_context = true;
@@ -6086,16 +5871,20 @@ uint32_t ThriftHiveMetastore_create_table_with_environment_context_args::read(::
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_create_table_with_environment_context_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_get_fields_with_environment_context_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_table_with_environment_context_args");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_fields_with_environment_context_args");
 
-  xfer += oprot->writeFieldBegin("tbl", ::apache::thrift::protocol::T_STRUCT, 1);
-  xfer += this->tbl.write(oprot);
+  xfer += oprot->writeFieldBegin("db_name", ::apache::thrift::protocol::T_STRING, 1);
+  xfer += oprot->writeString(this->db_name);
   xfer += oprot->writeFieldEnd();
 
-  xfer += oprot->writeFieldBegin("environment_context", ::apache::thrift::protocol::T_STRUCT, 2);
+  xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2);
+  xfer += oprot->writeString(this->table_name);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldBegin("environment_context", ::apache::thrift::protocol::T_STRUCT, 3);
   xfer += this->environment_context.write(oprot);
   xfer += oprot->writeFieldEnd();
 
@@ -6105,20 +5894,24 @@ uint32_t ThriftHiveMetastore_create_table_with_environment_context_args::write(:
 }
 
 
-ThriftHiveMetastore_create_table_with_environment_context_pargs::~ThriftHiveMetastore_create_table_with_environment_context_pargs() noexcept {
+ThriftHiveMetastore_get_fields_with_environment_context_pargs::~ThriftHiveMetastore_get_fields_with_environment_context_pargs() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_create_table_with_environment_context_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_get_fields_with_environment_context_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
   uint32_t xfer = 0;
   ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_table_with_environment_context_pargs");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_fields_with_environment_context_pargs");
 
-  xfer += oprot->writeFieldBegin("tbl", ::apache::thrift::protocol::T_STRUCT, 1);
-  xfer += (*(this->tbl)).write(oprot);
+  xfer += oprot->writeFieldBegin("db_name", ::apache::thrift::protocol::T_STRING, 1);
+  xfer += oprot->writeString((*(this->db_name)));
   xfer += oprot->writeFieldEnd();
 
-  xfer += oprot->writeFieldBegin("environment_context", ::apache::thrift::protocol::T_STRUCT, 2);
+  xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2);
+  xfer += oprot->writeString((*(this->table_name)));
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldBegin("environment_context", ::apache::thrift::protocol::T_STRUCT, 3);
   xfer += (*(this->environment_context)).write(oprot);
   xfer += oprot->writeFieldEnd();
 
@@ -6128,11 +5921,11 @@ uint32_t ThriftHiveMetastore_create_table_with_environment_context_pargs::write(
 }
 
 
-ThriftHiveMetastore_create_table_with_environment_context_result::~ThriftHiveMetastore_create_table_with_environment_context_result() noexcept {
+ThriftHiveMetastore_get_fields_with_environment_context_result::~ThriftHiveMetastore_get_fields_with_environment_context_result() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_create_table_with_environment_context_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_get_fields_with_environment_context_result::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -6153,6 +5946,26 @@ uint32_t ThriftHiveMetastore_create_table_with_environment_context_result::read(
     }
     switch (fid)
     {
+      case 0:
+        if (ftype == ::apache::thrift::protocol::T_LIST) {
+          {
+            this->success.clear();
+            uint32_t _size1727;
+            ::apache::thrift::protocol::TType _etype1730;
+            xfer += iprot->readListBegin(_etype1730, _size1727);
+            this->success.resize(_size1727);
+            uint32_t _i1731;
+            for (_i1731 = 0; _i1731 < _size1727; ++_i1731)
+            {
+              xfer += this->success[_i1731].read(iprot);
+            }
+            xfer += iprot->readListEnd();
+          }
+          this->__isset.success = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
       case 1:
         if (ftype == ::apache::thrift::protocol::T_STRUCT) {
           xfer += this->o1.read(iprot);
@@ -6177,14 +5990,6 @@ uint32_t ThriftHiveMetastore_create_table_with_environment_context_result::read(
           xfer += iprot->skip(ftype);
         }
         break;
-      case 4:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o4.read(iprot);
-          this->__isset.o4 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
       default:
         xfer += iprot->skip(ftype);
         break;
@@ -6197,13 +6002,25 @@ uint32_t ThriftHiveMetastore_create_table_with_environment_context_result::read(
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_create_table_with_environment_context_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+uint32_t ThriftHiveMetastore_get_fields_with_environment_context_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
 
   uint32_t xfer = 0;
 
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_table_with_environment_context_result");
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_fields_with_environment_context_result");
 
-  if (this->__isset.o1) {
+  if (this->__isset.success) {
+    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
+    {
+      xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+      std::vector<FieldSchema> ::const_iterator _iter1732;
+      for (_iter1732 = this->success.begin(); _iter1732 != this->success.end(); ++_iter1732)
+      {
+        xfer += (*_iter1732).write(oprot);
+      }
+      xfer += oprot->writeListEnd();
+    }
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o1) {
     xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
     xfer += this->o1.write(oprot);
     xfer += oprot->writeFieldEnd();
@@ -6215,10 +6032,6 @@ uint32_t ThriftHiveMetastore_create_table_with_environment_context_result::write
     xfer += oprot->writeFieldBegin("o3", ::apache::thrift::protocol::T_STRUCT, 3);
     xfer += this->o3.write(oprot);
     xfer += oprot->writeFieldEnd();
-  } else if (this->__isset.o4) {
-    xfer += oprot->writeFieldBegin("o4", ::apache::thrift::protocol::T_STRUCT, 4);
-    xfer += this->o4.write(oprot);
-    xfer += oprot->writeFieldEnd();
   }
   xfer += oprot->writeFieldStop();
   xfer += oprot->writeStructEnd();
@@ -6226,11 +6039,1633 @@ uint32_t ThriftHiveMetastore_create_table_with_environment_context_result::write
 }
 
 
-ThriftHiveMetastore_create_table_with_environment_context_presult::~ThriftHiveMetastore_create_table_with_environment_context_presult() noexcept {
+ThriftHiveMetastore_get_fields_with_environment_context_presult::~ThriftHiveMetastore_get_fields_with_environment_context_presult() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_create_table_with_environment_context_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_get_fields_with_environment_context_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 0:
+        if (ftype == ::apache::thrift::protocol::T_LIST) {
+          {
+            (*(this->success)).clear();
+            uint32_t _size1733;
+            ::apache::thrift::protocol::TType _etype1736;
+            xfer += iprot->readListBegin(_etype1736, _size1733);
+            (*(this->success)).resize(_size1733);
+            uint32_t _i1737;
+            for (_i1737 = 0; _i1737 < _size1733; ++_i1737)
+            {
+              xfer += (*(this->success))[_i1737].read(iprot);
+            }
+            xfer += iprot->readListEnd();
+          }
+          this->__isset.success = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o1.read(iprot);
+          this->__isset.o1 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 2:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o2.read(iprot);
+          this->__isset.o2 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 3:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o3.read(iprot);
+          this->__isset.o3 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+
+ThriftHiveMetastore_get_fields_req_args::~ThriftHiveMetastore_get_fields_req_args() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_get_fields_req_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->req.read(iprot);
+          this->__isset.req = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+uint32_t ThriftHiveMetastore_get_fields_req_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+  uint32_t xfer = 0;
+  ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_fields_req_args");
+
+  xfer += oprot->writeFieldBegin("req", ::apache::thrift::protocol::T_STRUCT, 1);
+  xfer += this->req.write(oprot);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+ThriftHiveMetastore_get_fields_req_pargs::~ThriftHiveMetastore_get_fields_req_pargs() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_get_fields_req_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+  uint32_t xfer = 0;
+  ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_fields_req_pargs");
+
+  xfer += oprot->writeFieldBegin("req", ::apache::thrift::protocol::T_STRUCT, 1);
+  xfer += (*(this->req)).write(oprot);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+ThriftHiveMetastore_get_fields_req_result::~ThriftHiveMetastore_get_fields_req_result() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_get_fields_req_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 0:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->success.read(iprot);
+          this->__isset.success = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o1.read(iprot);
+          this->__isset.o1 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 2:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o2.read(iprot);
+          this->__isset.o2 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 3:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o3.read(iprot);
+          this->__isset.o3 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+uint32_t ThriftHiveMetastore_get_fields_req_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+
+  uint32_t xfer = 0;
+
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_fields_req_result");
+
+  if (this->__isset.success) {
+    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0);
+    xfer += this->success.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o1) {
+    xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
+    xfer += this->o1.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o2) {
+    xfer += oprot->writeFieldBegin("o2", ::apache::thrift::protocol::T_STRUCT, 2);
+    xfer += this->o2.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o3) {
+    xfer += oprot->writeFieldBegin("o3", ::apache::thrift::protocol::T_STRUCT, 3);
+    xfer += this->o3.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  }
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+ThriftHiveMetastore_get_fields_req_presult::~ThriftHiveMetastore_get_fields_req_presult() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_get_fields_req_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 0:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += (*(this->success)).read(iprot);
+          this->__isset.success = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o1.read(iprot);
+          this->__isset.o1 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 2:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o2.read(iprot);
+          this->__isset.o2 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 3:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o3.read(iprot);
+          this->__isset.o3 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+
+ThriftHiveMetastore_get_schema_args::~ThriftHiveMetastore_get_schema_args() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_get_schema_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRING) {
+          xfer += iprot->readString(this->db_name);
+          this->__isset.db_name = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 2:
+        if (ftype == ::apache::thrift::protocol::T_STRING) {
+          xfer += iprot->readString(this->table_name);
+          this->__isset.table_name = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+uint32_t ThriftHiveMetastore_get_schema_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+  uint32_t xfer = 0;
+  ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_schema_args");
+
+  xfer += oprot->writeFieldBegin("db_name", ::apache::thrift::protocol::T_STRING, 1);
+  xfer += oprot->writeString(this->db_name);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2);
+  xfer += oprot->writeString(this->table_name);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+ThriftHiveMetastore_get_schema_pargs::~ThriftHiveMetastore_get_schema_pargs() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_get_schema_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+  uint32_t xfer = 0;
+  ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_schema_pargs");
+
+  xfer += oprot->writeFieldBegin("db_name", ::apache::thrift::protocol::T_STRING, 1);
+  xfer += oprot->writeString((*(this->db_name)));
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2);
+  xfer += oprot->writeString((*(this->table_name)));
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+ThriftHiveMetastore_get_schema_result::~ThriftHiveMetastore_get_schema_result() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_get_schema_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 0:
+        if (ftype == ::apache::thrift::protocol::T_LIST) {
+          {
+            this->success.clear();
+            uint32_t _size1738;
+            ::apache::thrift::protocol::TType _etype1741;
+            xfer += iprot->readListBegin(_etype1741, _size1738);
+            this->success.resize(_size1738);
+            uint32_t _i1742;
+            for (_i1742 = 0; _i1742 < _size1738; ++_i1742)
+            {
+              xfer += this->success[_i1742].read(iprot);
+            }
+            xfer += iprot->readListEnd();
+          }
+          this->__isset.success = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o1.read(iprot);
+          this->__isset.o1 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 2:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o2.read(iprot);
+          this->__isset.o2 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 3:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o3.read(iprot);
+          this->__isset.o3 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+uint32_t ThriftHiveMetastore_get_schema_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+
+  uint32_t xfer = 0;
+
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_schema_result");
+
+  if (this->__isset.success) {
+    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
+    {
+      xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+      std::vector<FieldSchema> ::const_iterator _iter1743;
+      for (_iter1743 = this->success.begin(); _iter1743 != this->success.end(); ++_iter1743)
+      {
+        xfer += (*_iter1743).write(oprot);
+      }
+      xfer += oprot->writeListEnd();
+    }
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o1) {
+    xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
+    xfer += this->o1.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o2) {
+    xfer += oprot->writeFieldBegin("o2", ::apache::thrift::protocol::T_STRUCT, 2);
+    xfer += this->o2.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o3) {
+    xfer += oprot->writeFieldBegin("o3", ::apache::thrift::protocol::T_STRUCT, 3);
+    xfer += this->o3.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  }
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+ThriftHiveMetastore_get_schema_presult::~ThriftHiveMetastore_get_schema_presult() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_get_schema_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 0:
+        if (ftype == ::apache::thrift::protocol::T_LIST) {
+          {
+            (*(this->success)).clear();
+            uint32_t _size1744;
+            ::apache::thrift::protocol::TType _etype1747;
+            xfer += iprot->readListBegin(_etype1747, _size1744);
+            (*(this->success)).resize(_size1744);
+            uint32_t _i1748;
+            for (_i1748 = 0; _i1748 < _size1744; ++_i1748)
+            {
+              xfer += (*(this->success))[_i1748].read(iprot);
+            }
+            xfer += iprot->readListEnd();
+          }
+          this->__isset.success = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o1.read(iprot);
+          this->__isset.o1 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 2:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o2.read(iprot);
+          this->__isset.o2 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 3:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o3.read(iprot);
+          this->__isset.o3 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+
+ThriftHiveMetastore_get_schema_with_environment_context_args::~ThriftHiveMetastore_get_schema_with_environment_context_args() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_get_schema_with_environment_context_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRING) {
+          xfer += iprot->readString(this->db_name);
+          this->__isset.db_name = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 2:
+        if (ftype == ::apache::thrift::protocol::T_STRING) {
+          xfer += iprot->readString(this->table_name);
+          this->__isset.table_name = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 3:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->environment_context.read(iprot);
+          this->__isset.environment_context = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+uint32_t ThriftHiveMetastore_get_schema_with_environment_context_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+  uint32_t xfer = 0;
+  ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_schema_with_environment_context_args");
+
+  xfer += oprot->writeFieldBegin("db_name", ::apache::thrift::protocol::T_STRING, 1);
+  xfer += oprot->writeString(this->db_name);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2);
+  xfer += oprot->writeString(this->table_name);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldBegin("environment_context", ::apache::thrift::protocol::T_STRUCT, 3);
+  xfer += this->environment_context.write(oprot);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+ThriftHiveMetastore_get_schema_with_environment_context_pargs::~ThriftHiveMetastore_get_schema_with_environment_context_pargs() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_get_schema_with_environment_context_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+  uint32_t xfer = 0;
+  ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_schema_with_environment_context_pargs");
+
+  xfer += oprot->writeFieldBegin("db_name", ::apache::thrift::protocol::T_STRING, 1);
+  xfer += oprot->writeString((*(this->db_name)));
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2);
+  xfer += oprot->writeString((*(this->table_name)));
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldBegin("environment_context", ::apache::thrift::protocol::T_STRUCT, 3);
+  xfer += (*(this->environment_context)).write(oprot);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+ThriftHiveMetastore_get_schema_with_environment_context_result::~ThriftHiveMetastore_get_schema_with_environment_context_result() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_get_schema_with_environment_context_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 0:
+        if (ftype == ::apache::thrift::protocol::T_LIST) {
+          {
+            this->success.clear();
+            uint32_t _size1749;
+            ::apache::thrift::protocol::TType _etype1752;
+            xfer += iprot->readListBegin(_etype1752, _size1749);
+            this->success.resize(_size1749);
+            uint32_t _i1753;
+            for (_i1753 = 0; _i1753 < _size1749; ++_i1753)
+            {
+              xfer += this->success[_i1753].read(iprot);
+            }
+            xfer += iprot->readListEnd();
+          }
+          this->__isset.success = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o1.read(iprot);
+          this->__isset.o1 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 2:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o2.read(iprot);
+          this->__isset.o2 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 3:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o3.read(iprot);
+          this->__isset.o3 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+uint32_t ThriftHiveMetastore_get_schema_with_environment_context_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+
+  uint32_t xfer = 0;
+
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_schema_with_environment_context_result");
+
+  if (this->__isset.success) {
+    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
+    {
+      xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+      std::vector<FieldSchema> ::const_iterator _iter1754;
+      for (_iter1754 = this->success.begin(); _iter1754 != this->success.end(); ++_iter1754)
+      {
+        xfer += (*_iter1754).write(oprot);
+      }
+      xfer += oprot->writeListEnd();
+    }
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o1) {
+    xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
+    xfer += this->o1.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o2) {
+    xfer += oprot->writeFieldBegin("o2", ::apache::thrift::protocol::T_STRUCT, 2);
+    xfer += this->o2.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o3) {
+    xfer += oprot->writeFieldBegin("o3", ::apache::thrift::protocol::T_STRUCT, 3);
+    xfer += this->o3.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  }
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+ThriftHiveMetastore_get_schema_with_environment_context_presult::~ThriftHiveMetastore_get_schema_with_environment_context_presult() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_get_schema_with_environment_context_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 0:
+        if (ftype == ::apache::thrift::protocol::T_LIST) {
+          {
+            (*(this->success)).clear();
+            uint32_t _size1755;
+            ::apache::thrift::protocol::TType _etype1758;
+            xfer += iprot->readListBegin(_etype1758, _size1755);
+            (*(this->success)).resize(_size1755);
+            uint32_t _i1759;
+            for (_i1759 = 0; _i1759 < _size1755; ++_i1759)
+            {
+              xfer += (*(this->success))[_i1759].read(iprot);
+            }
+            xfer += iprot->readListEnd();
+          }
+          this->__isset.success = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o1.read(iprot);
+          this->__isset.o1 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 2:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o2.read(iprot);
+          this->__isset.o2 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 3:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o3.read(iprot);
+          this->__isset.o3 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+
+ThriftHiveMetastore_get_schema_req_args::~ThriftHiveMetastore_get_schema_req_args() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_get_schema_req_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->req.read(iprot);
+          this->__isset.req = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+uint32_t ThriftHiveMetastore_get_schema_req_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+  uint32_t xfer = 0;
+  ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_schema_req_args");
+
+  xfer += oprot->writeFieldBegin("req", ::apache::thrift::protocol::T_STRUCT, 1);
+  xfer += this->req.write(oprot);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+ThriftHiveMetastore_get_schema_req_pargs::~ThriftHiveMetastore_get_schema_req_pargs() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_get_schema_req_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+  uint32_t xfer = 0;
+  ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_schema_req_pargs");
+
+  xfer += oprot->writeFieldBegin("req", ::apache::thrift::protocol::T_STRUCT, 1);
+  xfer += (*(this->req)).write(oprot);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+ThriftHiveMetastore_get_schema_req_result::~ThriftHiveMetastore_get_schema_req_result() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_get_schema_req_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 0:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->success.read(iprot);
+          this->__isset.success = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o1.read(iprot);
+          this->__isset.o1 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 2:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o2.read(iprot);
+          this->__isset.o2 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 3:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o3.read(iprot);
+          this->__isset.o3 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+uint32_t ThriftHiveMetastore_get_schema_req_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+
+  uint32_t xfer = 0;
+
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_schema_req_result");
+
+  if (this->__isset.success) {
+    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0);
+    xfer += this->success.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o1) {
+    xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
+    xfer += this->o1.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o2) {
+    xfer += oprot->writeFieldBegin("o2", ::apache::thrift::protocol::T_STRUCT, 2);
+    xfer += this->o2.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o3) {
+    xfer += oprot->writeFieldBegin("o3", ::apache::thrift::protocol::T_STRUCT, 3);
+    xfer += this->o3.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  }
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+ThriftHiveMetastore_get_schema_req_presult::~ThriftHiveMetastore_get_schema_req_presult() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_get_schema_req_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 0:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += (*(this->success)).read(iprot);
+          this->__isset.success = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o1.read(iprot);
+          this->__isset.o1 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 2:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o2.read(iprot);
+          this->__isset.o2 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 3:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o3.read(iprot);
+          this->__isset.o3 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+
+ThriftHiveMetastore_create_table_args::~ThriftHiveMetastore_create_table_args() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_create_table_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->tbl.read(iprot);
+          this->__isset.tbl = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+uint32_t ThriftHiveMetastore_create_table_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+  uint32_t xfer = 0;
+  ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_table_args");
+
+  xfer += oprot->writeFieldBegin("tbl", ::apache::thrift::protocol::T_STRUCT, 1);
+  xfer += this->tbl.write(oprot);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+ThriftHiveMetastore_create_table_pargs::~ThriftHiveMetastore_create_table_pargs() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_create_table_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+  uint32_t xfer = 0;
+  ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_table_pargs");
+
+  xfer += oprot->writeFieldBegin("tbl", ::apache::thrift::protocol::T_STRUCT, 1);
+  xfer += (*(this->tbl)).write(oprot);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+ThriftHiveMetastore_create_table_result::~ThriftHiveMetastore_create_table_result() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_create_table_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o1.read(iprot);
+          this->__isset.o1 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 2:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o2.read(iprot);
+          this->__isset.o2 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 3:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o3.read(iprot);
+          this->__isset.o3 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 4:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o4.read(iprot);
+          this->__isset.o4 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+uint32_t ThriftHiveMetastore_create_table_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+
+  uint32_t xfer = 0;
+
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_table_result");
+
+  if (this->__isset.o1) {
+    xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
+    xfer += this->o1.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o2) {
+    xfer += oprot->writeFieldBegin("o2", ::apache::thrift::protocol::T_STRUCT, 2);
+    xfer += this->o2.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o3) {
+    xfer += oprot->writeFieldBegin("o3", ::apache::thrift::protocol::T_STRUCT, 3);
+    xfer += this->o3.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o4) {
+    xfer += oprot->writeFieldBegin("o4", ::apache::thrift::protocol::T_STRUCT, 4);
+    xfer += this->o4.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  }
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+ThriftHiveMetastore_create_table_presult::~ThriftHiveMetastore_create_table_presult() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_create_table_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o1.read(iprot);
+          this->__isset.o1 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 2:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o2.read(iprot);
+          this->__isset.o2 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 3:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o3.read(iprot);
+          this->__isset.o3 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 4:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o4.read(iprot);
+          this->__isset.o4 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+
+ThriftHiveMetastore_create_table_with_environment_context_args::~ThriftHiveMetastore_create_table_with_environment_context_args() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_create_table_with_environment_context_args::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->tbl.read(iprot);
+          this->__isset.tbl = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 2:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->environment_context.read(iprot);
+          this->__isset.environment_context = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+uint32_t ThriftHiveMetastore_create_table_with_environment_context_args::write(::apache::thrift::protocol::TProtocol* oprot) const {
+  uint32_t xfer = 0;
+  ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_table_with_environment_context_args");
+
+  xfer += oprot->writeFieldBegin("tbl", ::apache::thrift::protocol::T_STRUCT, 1);
+  xfer += this->tbl.write(oprot);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldBegin("environment_context", ::apache::thrift::protocol::T_STRUCT, 2);
+  xfer += this->environment_context.write(oprot);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+ThriftHiveMetastore_create_table_with_environment_context_pargs::~ThriftHiveMetastore_create_table_with_environment_context_pargs() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_create_table_with_environment_context_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const {
+  uint32_t xfer = 0;
+  ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_table_with_environment_context_pargs");
+
+  xfer += oprot->writeFieldBegin("tbl", ::apache::thrift::protocol::T_STRUCT, 1);
+  xfer += (*(this->tbl)).write(oprot);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldBegin("environment_context", ::apache::thrift::protocol::T_STRUCT, 2);
+  xfer += (*(this->environment_context)).write(oprot);
+  xfer += oprot->writeFieldEnd();
+
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+ThriftHiveMetastore_create_table_with_environment_context_result::~ThriftHiveMetastore_create_table_with_environment_context_result() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_create_table_with_environment_context_result::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o1.read(iprot);
+          this->__isset.o1 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 2:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o2.read(iprot);
+          this->__isset.o2 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 3:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o3.read(iprot);
+          this->__isset.o3 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 4:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o4.read(iprot);
+          this->__isset.o4 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+uint32_t ThriftHiveMetastore_create_table_with_environment_context_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+
+  uint32_t xfer = 0;
+
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_create_table_with_environment_context_result");
+
+  if (this->__isset.o1) {
+    xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
+    xfer += this->o1.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o2) {
+    xfer += oprot->writeFieldBegin("o2", ::apache::thrift::protocol::T_STRUCT, 2);
+    xfer += this->o2.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o3) {
+    xfer += oprot->writeFieldBegin("o3", ::apache::thrift::protocol::T_STRUCT, 3);
+    xfer += this->o3.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o4) {
+    xfer += oprot->writeFieldBegin("o4", ::apache::thrift::protocol::T_STRUCT, 4);
+    xfer += this->o4.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  }
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+ThriftHiveMetastore_create_table_with_environment_context_presult::~ThriftHiveMetastore_create_table_with_environment_context_presult() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_create_table_with_environment_context_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -6333,6 +7768,7 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::read(::apache::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->primaryKeys.clear();
+<<<<<<< HEAD
             uint32_t _size1732;
             ::apache::thrift::protocol::TType _etype1735;
             xfer += iprot->readListBegin(_etype1735, _size1732);
@@ -6341,6 +7777,16 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::read(::apache::
             for (_i1736 = 0; _i1736 < _size1732; ++_i1736)
             {
               xfer += this->primaryKeys[_i1736].read(iprot);
+=======
+            uint32_t _size1760;
+            ::apache::thrift::protocol::TType _etype1763;
+            xfer += iprot->readListBegin(_etype1763, _size1760);
+            this->primaryKeys.resize(_size1760);
+            uint32_t _i1764;
+            for (_i1764 = 0; _i1764 < _size1760; ++_i1764)
+            {
+              xfer += this->primaryKeys[_i1764].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -6353,6 +7799,7 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::read(::apache::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->foreignKeys.clear();
+<<<<<<< HEAD
             uint32_t _size1737;
             ::apache::thrift::protocol::TType _etype1740;
             xfer += iprot->readListBegin(_etype1740, _size1737);
@@ -6361,6 +7808,16 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::read(::apache::
             for (_i1741 = 0; _i1741 < _size1737; ++_i1741)
             {
               xfer += this->foreignKeys[_i1741].read(iprot);
+=======
+            uint32_t _size1765;
+            ::apache::thrift::protocol::TType _etype1768;
+            xfer += iprot->readListBegin(_etype1768, _size1765);
+            this->foreignKeys.resize(_size1765);
+            uint32_t _i1769;
+            for (_i1769 = 0; _i1769 < _size1765; ++_i1769)
+            {
+              xfer += this->foreignKeys[_i1769].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -6373,6 +7830,7 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::read(::apache::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->uniqueConstraints.clear();
+<<<<<<< HEAD
             uint32_t _size1742;
             ::apache::thrift::protocol::TType _etype1745;
             xfer += iprot->readListBegin(_etype1745, _size1742);
@@ -6381,6 +7839,16 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::read(::apache::
             for (_i1746 = 0; _i1746 < _size1742; ++_i1746)
             {
               xfer += this->uniqueConstraints[_i1746].read(iprot);
+=======
+            uint32_t _size1770;
+            ::apache::thrift::protocol::TType _etype1773;
+            xfer += iprot->readListBegin(_etype1773, _size1770);
+            this->uniqueConstraints.resize(_size1770);
+            uint32_t _i1774;
+            for (_i1774 = 0; _i1774 < _size1770; ++_i1774)
+            {
+              xfer += this->uniqueConstraints[_i1774].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -6393,6 +7861,7 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::read(::apache::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->notNullConstraints.clear();
+<<<<<<< HEAD
             uint32_t _size1747;
             ::apache::thrift::protocol::TType _etype1750;
             xfer += iprot->readListBegin(_etype1750, _size1747);
@@ -6401,6 +7870,16 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::read(::apache::
             for (_i1751 = 0; _i1751 < _size1747; ++_i1751)
             {
               xfer += this->notNullConstraints[_i1751].read(iprot);
+=======
+            uint32_t _size1775;
+            ::apache::thrift::protocol::TType _etype1778;
+            xfer += iprot->readListBegin(_etype1778, _size1775);
+            this->notNullConstraints.resize(_size1775);
+            uint32_t _i1779;
+            for (_i1779 = 0; _i1779 < _size1775; ++_i1779)
+            {
+              xfer += this->notNullConstraints[_i1779].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -6413,6 +7892,7 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::read(::apache::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->defaultConstraints.clear();
+<<<<<<< HEAD
             uint32_t _size1752;
             ::apache::thrift::protocol::TType _etype1755;
             xfer += iprot->readListBegin(_etype1755, _size1752);
@@ -6421,6 +7901,16 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::read(::apache::
             for (_i1756 = 0; _i1756 < _size1752; ++_i1756)
             {
               xfer += this->defaultConstraints[_i1756].read(iprot);
+=======
+            uint32_t _size1780;
+            ::apache::thrift::protocol::TType _etype1783;
+            xfer += iprot->readListBegin(_etype1783, _size1780);
+            this->defaultConstraints.resize(_size1780);
+            uint32_t _i1784;
+            for (_i1784 = 0; _i1784 < _size1780; ++_i1784)
+            {
+              xfer += this->defaultConstraints[_i1784].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -6433,6 +7923,7 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::read(::apache::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->checkConstraints.clear();
+<<<<<<< HEAD
             uint32_t _size1757;
             ::apache::thrift::protocol::TType _etype1760;
             xfer += iprot->readListBegin(_etype1760, _size1757);
@@ -6441,6 +7932,16 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::read(::apache::
             for (_i1761 = 0; _i1761 < _size1757; ++_i1761)
             {
               xfer += this->checkConstraints[_i1761].read(iprot);
+=======
+            uint32_t _size1785;
+            ::apache::thrift::protocol::TType _etype1788;
+            xfer += iprot->readListBegin(_etype1788, _size1785);
+            this->checkConstraints.resize(_size1785);
+            uint32_t _i1789;
+            for (_i1789 = 0; _i1789 < _size1785; ++_i1789)
+            {
+              xfer += this->checkConstraints[_i1789].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -6473,10 +7974,17 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::write(::apache:
   xfer += oprot->writeFieldBegin("primaryKeys", ::apache::thrift::protocol::T_LIST, 2);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->primaryKeys.size()));
+<<<<<<< HEAD
     std::vector<SQLPrimaryKey> ::const_iterator _iter1762;
     for (_iter1762 = this->primaryKeys.begin(); _iter1762 != this->primaryKeys.end(); ++_iter1762)
     {
       xfer += (*_iter1762).write(oprot);
+=======
+    std::vector<SQLPrimaryKey> ::const_iterator _iter1790;
+    for (_iter1790 = this->primaryKeys.begin(); _iter1790 != this->primaryKeys.end(); ++_iter1790)
+    {
+      xfer += (*_iter1790).write(oprot);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -6485,10 +7993,17 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::write(::apache:
   xfer += oprot->writeFieldBegin("foreignKeys", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->foreignKeys.size()));
+<<<<<<< HEAD
     std::vector<SQLForeignKey> ::const_iterator _iter1763;
     for (_iter1763 = this->foreignKeys.begin(); _iter1763 != this->foreignKeys.end(); ++_iter1763)
     {
       xfer += (*_iter1763).write(oprot);
+=======
+    std::vector<SQLForeignKey> ::const_iterator _iter1791;
+    for (_iter1791 = this->foreignKeys.begin(); _iter1791 != this->foreignKeys.end(); ++_iter1791)
+    {
+      xfer += (*_iter1791).write(oprot);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -6497,10 +8012,17 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::write(::apache:
   xfer += oprot->writeFieldBegin("uniqueConstraints", ::apache::thrift::protocol::T_LIST, 4);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->uniqueConstraints.size()));
+<<<<<<< HEAD
     std::vector<SQLUniqueConstraint> ::const_iterator _iter1764;
     for (_iter1764 = this->uniqueConstraints.begin(); _iter1764 != this->uniqueConstraints.end(); ++_iter1764)
     {
       xfer += (*_iter1764).write(oprot);
+=======
+    std::vector<SQLUniqueConstraint> ::const_iterator _iter1792;
+    for (_iter1792 = this->uniqueConstraints.begin(); _iter1792 != this->uniqueConstraints.end(); ++_iter1792)
+    {
+      xfer += (*_iter1792).write(oprot);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -6509,10 +8031,17 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::write(::apache:
   xfer += oprot->writeFieldBegin("notNullConstraints", ::apache::thrift::protocol::T_LIST, 5);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->notNullConstraints.size()));
+<<<<<<< HEAD
     std::vector<SQLNotNullConstraint> ::const_iterator _iter1765;
     for (_iter1765 = this->notNullConstraints.begin(); _iter1765 != this->notNullConstraints.end(); ++_iter1765)
     {
       xfer += (*_iter1765).write(oprot);
+=======
+    std::vector<SQLNotNullConstraint> ::const_iterator _iter1793;
+    for (_iter1793 = this->notNullConstraints.begin(); _iter1793 != this->notNullConstraints.end(); ++_iter1793)
+    {
+      xfer += (*_iter1793).write(oprot);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -6521,10 +8050,17 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::write(::apache:
   xfer += oprot->writeFieldBegin("defaultConstraints", ::apache::thrift::protocol::T_LIST, 6);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->defaultConstraints.size()));
+<<<<<<< HEAD
     std::vector<SQLDefaultConstraint> ::const_iterator _iter1766;
     for (_iter1766 = this->defaultConstraints.begin(); _iter1766 != this->defaultConstraints.end(); ++_iter1766)
     {
       xfer += (*_iter1766).write(oprot);
+=======
+    std::vector<SQLDefaultConstraint> ::const_iterator _iter1794;
+    for (_iter1794 = this->defaultConstraints.begin(); _iter1794 != this->defaultConstraints.end(); ++_iter1794)
+    {
+      xfer += (*_iter1794).write(oprot);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -6533,10 +8069,17 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::write(::apache:
   xfer += oprot->writeFieldBegin("checkConstraints", ::apache::thrift::protocol::T_LIST, 7);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->checkConstraints.size()));
+<<<<<<< HEAD
     std::vector<SQLCheckConstraint> ::const_iterator _iter1767;
     for (_iter1767 = this->checkConstraints.begin(); _iter1767 != this->checkConstraints.end(); ++_iter1767)
     {
       xfer += (*_iter1767).write(oprot);
+=======
+    std::vector<SQLCheckConstraint> ::const_iterator _iter1795;
+    for (_iter1795 = this->checkConstraints.begin(); _iter1795 != this->checkConstraints.end(); ++_iter1795)
+    {
+      xfer += (*_iter1795).write(oprot);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -6564,10 +8107,17 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_pargs::write(::apache
   xfer += oprot->writeFieldBegin("primaryKeys", ::apache::thrift::protocol::T_LIST, 2);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->primaryKeys)).size()));
+<<<<<<< HEAD
     std::vector<SQLPrimaryKey> ::const_iterator _iter1768;
     for (_iter1768 = (*(this->primaryKeys)).begin(); _iter1768 != (*(this->primaryKeys)).end(); ++_iter1768)
     {
       xfer += (*_iter1768).write(oprot);
+=======
+    std::vector<SQLPrimaryKey> ::const_iterator _iter1796;
+    for (_iter1796 = (*(this->primaryKeys)).begin(); _iter1796 != (*(this->primaryKeys)).end(); ++_iter1796)
+    {
+      xfer += (*_iter1796).write(oprot);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -6576,10 +8126,17 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_pargs::write(::apache
   xfer += oprot->writeFieldBegin("foreignKeys", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->foreignKeys)).size()));
+<<<<<<< HEAD
     std::vector<SQLForeignKey> ::const_iterator _iter1769;
     for (_iter1769 = (*(this->foreignKeys)).begin(); _iter1769 != (*(this->foreignKeys)).end(); ++_iter1769)
     {
       xfer += (*_iter1769).write(oprot);
+=======
+    std::vector<SQLForeignKey> ::const_iterator _iter1797;
+    for (_iter1797 = (*(this->foreignKeys)).begin(); _iter1797 != (*(this->foreignKeys)).end(); ++_iter1797)
+    {
+      xfer += (*_iter1797).write(oprot);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -6588,10 +8145,17 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_pargs::write(::apache
   xfer += oprot->writeFieldBegin("uniqueConstraints", ::apache::thrift::protocol::T_LIST, 4);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->uniqueConstraints)).size()));
+<<<<<<< HEAD
     std::vector<SQLUniqueConstraint> ::const_iterator _iter1770;
     for (_iter1770 = (*(this->uniqueConstraints)).begin(); _iter1770 != (*(this->uniqueConstraints)).end(); ++_iter1770)
     {
       xfer += (*_iter1770).write(oprot);
+=======
+    std::vector<SQLUniqueConstraint> ::const_iterator _iter1798;
+    for (_iter1798 = (*(this->uniqueConstraints)).begin(); _iter1798 != (*(this->uniqueConstraints)).end(); ++_iter1798)
+    {
+      xfer += (*_iter1798).write(oprot);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -6600,10 +8164,17 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_pargs::write(::apache
   xfer += oprot->writeFieldBegin("notNullConstraints", ::apache::thrift::protocol::T_LIST, 5);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->notNullConstraints)).size()));
+<<<<<<< HEAD
     std::vector<SQLNotNullConstraint> ::const_iterator _iter1771;
     for (_iter1771 = (*(this->notNullConstraints)).begin(); _iter1771 != (*(this->notNullConstraints)).end(); ++_iter1771)
     {
       xfer += (*_iter1771).write(oprot);
+=======
+    std::vector<SQLNotNullConstraint> ::const_iterator _iter1799;
+    for (_iter1799 = (*(this->notNullConstraints)).begin(); _iter1799 != (*(this->notNullConstraints)).end(); ++_iter1799)
+    {
+      xfer += (*_iter1799).write(oprot);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -6612,10 +8183,17 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_pargs::write(::apache
   xfer += oprot->writeFieldBegin("defaultConstraints", ::apache::thrift::protocol::T_LIST, 6);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->defaultConstraints)).size()));
+<<<<<<< HEAD
     std::vector<SQLDefaultConstraint> ::const_iterator _iter1772;
     for (_iter1772 = (*(this->defaultConstraints)).begin(); _iter1772 != (*(this->defaultConstraints)).end(); ++_iter1772)
     {
       xfer += (*_iter1772).write(oprot);
+=======
+    std::vector<SQLDefaultConstraint> ::const_iterator _iter1800;
+    for (_iter1800 = (*(this->defaultConstraints)).begin(); _iter1800 != (*(this->defaultConstraints)).end(); ++_iter1800)
+    {
+      xfer += (*_iter1800).write(oprot);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -6624,10 +8202,17 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_pargs::write(::apache
   xfer += oprot->writeFieldBegin("checkConstraints", ::apache::thrift::protocol::T_LIST, 7);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->checkConstraints)).size()));
+<<<<<<< HEAD
     std::vector<SQLCheckConstraint> ::const_iterator _iter1773;
     for (_iter1773 = (*(this->checkConstraints)).begin(); _iter1773 != (*(this->checkConstraints)).end(); ++_iter1773)
     {
       xfer += (*_iter1773).write(oprot);
+=======
+    std::vector<SQLCheckConstraint> ::const_iterator _iter1801;
+    for (_iter1801 = (*(this->checkConstraints)).begin(); _iter1801 != (*(this->checkConstraints)).end(); ++_iter1801)
+    {
+      xfer += (*_iter1801).write(oprot);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -9042,6 +10627,7 @@ uint32_t ThriftHiveMetastore_truncate_table_args::read(::apache::thrift::protoco
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->partNames.clear();
+<<<<<<< HEAD
             uint32_t _size1774;
             ::apache::thrift::protocol::TType _etype1777;
             xfer += iprot->readListBegin(_etype1777, _size1774);
@@ -9050,6 +10636,16 @@ uint32_t ThriftHiveMetastore_truncate_table_args::read(::apache::thrift::protoco
             for (_i1778 = 0; _i1778 < _size1774; ++_i1778)
             {
               xfer += iprot->readString(this->partNames[_i1778]);
+=======
+            uint32_t _size1802;
+            ::apache::thrift::protocol::TType _etype1805;
+            xfer += iprot->readListBegin(_etype1805, _size1802);
+            this->partNames.resize(_size1802);
+            uint32_t _i1806;
+            for (_i1806 = 0; _i1806 < _size1802; ++_i1806)
+            {
+              xfer += iprot->readString(this->partNames[_i1806]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -9086,10 +10682,17 @@ uint32_t ThriftHiveMetastore_truncate_table_args::write(::apache::thrift::protoc
   xfer += oprot->writeFieldBegin("partNames", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->partNames.size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter1779;
     for (_iter1779 = this->partNames.begin(); _iter1779 != this->partNames.end(); ++_iter1779)
     {
       xfer += oprot->writeString((*_iter1779));
+=======
+    std::vector<std::string> ::const_iterator _iter1807;
+    for (_iter1807 = this->partNames.begin(); _iter1807 != this->partNames.end(); ++_iter1807)
+    {
+      xfer += oprot->writeString((*_iter1807));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -9121,10 +10724,17 @@ uint32_t ThriftHiveMetastore_truncate_table_pargs::write(::apache::thrift::proto
   xfer += oprot->writeFieldBegin("partNames", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->partNames)).size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter1780;
     for (_iter1780 = (*(this->partNames)).begin(); _iter1780 != (*(this->partNames)).end(); ++_iter1780)
     {
       xfer += oprot->writeString((*_iter1780));
+=======
+    std::vector<std::string> ::const_iterator _iter1808;
+    for (_iter1808 = (*(this->partNames)).begin(); _iter1808 != (*(this->partNames)).end(); ++_iter1808)
+    {
+      xfer += oprot->writeString((*_iter1808));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -9575,6 +11185,7 @@ uint32_t ThriftHiveMetastore_get_tables_result::read(::apache::thrift::protocol:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size1781;
             ::apache::thrift::protocol::TType _etype1784;
             xfer += iprot->readListBegin(_etype1784, _size1781);
@@ -9583,6 +11194,16 @@ uint32_t ThriftHiveMetastore_get_tables_result::read(::apache::thrift::protocol:
             for (_i1785 = 0; _i1785 < _size1781; ++_i1785)
             {
               xfer += iprot->readString(this->success[_i1785]);
+=======
+            uint32_t _size1809;
+            ::apache::thrift::protocol::TType _etype1812;
+            xfer += iprot->readListBegin(_etype1812, _size1809);
+            this->success.resize(_size1809);
+            uint32_t _i1813;
+            for (_i1813 = 0; _i1813 < _size1809; ++_i1813)
+            {
+              xfer += iprot->readString(this->success[_i1813]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -9621,10 +11242,17 @@ uint32_t ThriftHiveMetastore_get_tables_result::write(::apache::thrift::protocol
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<std::string> ::const_iterator _iter1786;
       for (_iter1786 = this->success.begin(); _iter1786 != this->success.end(); ++_iter1786)
       {
         xfer += oprot->writeString((*_iter1786));
+=======
+      std::vector<std::string> ::const_iterator _iter1814;
+      for (_iter1814 = this->success.begin(); _iter1814 != this->success.end(); ++_iter1814)
+      {
+        xfer += oprot->writeString((*_iter1814));
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -9669,6 +11297,7 @@ uint32_t ThriftHiveMetastore_get_tables_presult::read(::apache::thrift::protocol
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size1787;
             ::apache::thrift::protocol::TType _etype1790;
             xfer += iprot->readListBegin(_etype1790, _size1787);
@@ -9677,6 +11306,16 @@ uint32_t ThriftHiveMetastore_get_tables_presult::read(::apache::thrift::protocol
             for (_i1791 = 0; _i1791 < _size1787; ++_i1791)
             {
               xfer += iprot->readString((*(this->success))[_i1791]);
+=======
+            uint32_t _size1815;
+            ::apache::thrift::protocol::TType _etype1818;
+            xfer += iprot->readListBegin(_etype1818, _size1815);
+            (*(this->success)).resize(_size1815);
+            uint32_t _i1819;
+            for (_i1819 = 0; _i1819 < _size1815; ++_i1819)
+            {
+              xfer += iprot->readString((*(this->success))[_i1819]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -9846,6 +11485,7 @@ uint32_t ThriftHiveMetastore_get_tables_by_type_result::read(::apache::thrift::p
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size1792;
             ::apache::thrift::protocol::TType _etype1795;
             xfer += iprot->readListBegin(_etype1795, _size1792);
@@ -9854,6 +11494,16 @@ uint32_t ThriftHiveMetastore_get_tables_by_type_result::read(::apache::thrift::p
             for (_i1796 = 0; _i1796 < _size1792; ++_i1796)
             {
               xfer += iprot->readString(this->success[_i1796]);
+=======
+            uint32_t _size1820;
+            ::apache::thrift::protocol::TType _etype1823;
+            xfer += iprot->readListBegin(_etype1823, _size1820);
+            this->success.resize(_size1820);
+            uint32_t _i1824;
+            for (_i1824 = 0; _i1824 < _size1820; ++_i1824)
+            {
+              xfer += iprot->readString(this->success[_i1824]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -9892,10 +11542,17 @@ uint32_t ThriftHiveMetastore_get_tables_by_type_result::write(::apache::thrift::
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<std::string> ::const_iterator _iter1797;
       for (_iter1797 = this->success.begin(); _iter1797 != this->success.end(); ++_iter1797)
       {
         xfer += oprot->writeString((*_iter1797));
+=======
+      std::vector<std::string> ::const_iterator _iter1825;
+      for (_iter1825 = this->success.begin(); _iter1825 != this->success.end(); ++_iter1825)
+      {
+        xfer += oprot->writeString((*_iter1825));
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -9940,6 +11597,7 @@ uint32_t ThriftHiveMetastore_get_tables_by_type_presult::read(::apache::thrift::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size1798;
             ::apache::thrift::protocol::TType _etype1801;
             xfer += iprot->readListBegin(_etype1801, _size1798);
@@ -9948,6 +11606,16 @@ uint32_t ThriftHiveMetastore_get_tables_by_type_presult::read(::apache::thrift::
             for (_i1802 = 0; _i1802 < _size1798; ++_i1802)
             {
               xfer += iprot->readString((*(this->success))[_i1802]);
+=======
+            uint32_t _size1826;
+            ::apache::thrift::protocol::TType _etype1829;
+            xfer += iprot->readListBegin(_etype1829, _size1826);
+            (*(this->success)).resize(_size1826);
+            uint32_t _i1830;
+            for (_i1830 = 0; _i1830 < _size1826; ++_i1830)
+            {
+              xfer += iprot->readString((*(this->success))[_i1830]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -10064,6 +11732,7 @@ uint32_t ThriftHiveMetastore_get_all_materialized_view_objects_for_rewriting_res
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size1803;
             ::apache::thrift::protocol::TType _etype1806;
             xfer += iprot->readListBegin(_etype1806, _size1803);
@@ -10072,6 +11741,16 @@ uint32_t ThriftHiveMetastore_get_all_materialized_view_objects_for_rewriting_res
             for (_i1807 = 0; _i1807 < _size1803; ++_i1807)
             {
               xfer += this->success[_i1807].read(iprot);
+=======
+            uint32_t _size1831;
+            ::apache::thrift::protocol::TType _etype1834;
+            xfer += iprot->readListBegin(_etype1834, _size1831);
+            this->success.resize(_size1831);
+            uint32_t _i1835;
+            for (_i1835 = 0; _i1835 < _size1831; ++_i1835)
+            {
+              xfer += this->success[_i1835].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -10110,10 +11789,17 @@ uint32_t ThriftHiveMetastore_get_all_materialized_view_objects_for_rewriting_res
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<Table> ::const_iterator _iter1808;
       for (_iter1808 = this->success.begin(); _iter1808 != this->success.end(); ++_iter1808)
       {
         xfer += (*_iter1808).write(oprot);
+=======
+      std::vector<Table> ::const_iterator _iter1836;
+      for (_iter1836 = this->success.begin(); _iter1836 != this->success.end(); ++_iter1836)
+      {
+        xfer += (*_iter1836).write(oprot);
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -10158,6 +11844,7 @@ uint32_t ThriftHiveMetastore_get_all_materialized_view_objects_for_rewriting_pre
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size1809;
             ::apache::thrift::protocol::TType _etype1812;
             xfer += iprot->readListBegin(_etype1812, _size1809);
@@ -10166,6 +11853,16 @@ uint32_t ThriftHiveMetastore_get_all_materialized_view_objects_for_rewriting_pre
             for (_i1813 = 0; _i1813 < _size1809; ++_i1813)
             {
               xfer += (*(this->success))[_i1813].read(iprot);
+=======
+            uint32_t _size1837;
+            ::apache::thrift::protocol::TType _etype1840;
+            xfer += iprot->readListBegin(_etype1840, _size1837);
+            (*(this->success)).resize(_size1837);
+            uint32_t _i1841;
+            for (_i1841 = 0; _i1841 < _size1837; ++_i1841)
+            {
+              xfer += (*(this->success))[_i1841].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -10303,6 +12000,7 @@ uint32_t ThriftHiveMetastore_get_materialized_views_for_rewriting_result::read(:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size1814;
             ::apache::thrift::protocol::TType _etype1817;
             xfer += iprot->readListBegin(_etype1817, _size1814);
@@ -10311,6 +12009,16 @@ uint32_t ThriftHiveMetastore_get_materialized_views_for_rewriting_result::read(:
             for (_i1818 = 0; _i1818 < _size1814; ++_i1818)
             {
               xfer += iprot->readString(this->success[_i1818]);
+=======
+            uint32_t _size1842;
+            ::apache::thrift::protocol::TType _etype1845;
+            xfer += iprot->readListBegin(_etype1845, _size1842);
+            this->success.resize(_size1842);
+            uint32_t _i1846;
+            for (_i1846 = 0; _i1846 < _size1842; ++_i1846)
+            {
+              xfer += iprot->readString(this->success[_i1846]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -10349,10 +12057,17 @@ uint32_t ThriftHiveMetastore_get_materialized_views_for_rewriting_result::write(
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<std::string> ::const_iterator _iter1819;
       for (_iter1819 = this->success.begin(); _iter1819 != this->success.end(); ++_iter1819)
       {
         xfer += oprot->writeString((*_iter1819));
+=======
+      std::vector<std::string> ::const_iterator _iter1847;
+      for (_iter1847 = this->success.begin(); _iter1847 != this->success.end(); ++_iter1847)
+      {
+        xfer += oprot->writeString((*_iter1847));
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -10397,6 +12112,7 @@ uint32_t ThriftHiveMetastore_get_materialized_views_for_rewriting_presult::read(
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size1820;
             ::apache::thrift::protocol::TType _etype1823;
             xfer += iprot->readListBegin(_etype1823, _size1820);
@@ -10405,6 +12121,16 @@ uint32_t ThriftHiveMetastore_get_materialized_views_for_rewriting_presult::read(
             for (_i1824 = 0; _i1824 < _size1820; ++_i1824)
             {
               xfer += iprot->readString((*(this->success))[_i1824]);
+=======
+            uint32_t _size1848;
+            ::apache::thrift::protocol::TType _etype1851;
+            xfer += iprot->readListBegin(_etype1851, _size1848);
+            (*(this->success)).resize(_size1848);
+            uint32_t _i1852;
+            for (_i1852 = 0; _i1852 < _size1848; ++_i1852)
+            {
+              xfer += iprot->readString((*(this->success))[_i1852]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -10479,6 +12205,7 @@ uint32_t ThriftHiveMetastore_get_table_meta_args::read(::apache::thrift::protoco
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->tbl_types.clear();
+<<<<<<< HEAD
             uint32_t _size1825;
             ::apache::thrift::protocol::TType _etype1828;
             xfer += iprot->readListBegin(_etype1828, _size1825);
@@ -10487,6 +12214,16 @@ uint32_t ThriftHiveMetastore_get_table_meta_args::read(::apache::thrift::protoco
             for (_i1829 = 0; _i1829 < _size1825; ++_i1829)
             {
               xfer += iprot->readString(this->tbl_types[_i1829]);
+=======
+            uint32_t _size1853;
+            ::apache::thrift::protocol::TType _etype1856;
+            xfer += iprot->readListBegin(_etype1856, _size1853);
+            this->tbl_types.resize(_size1853);
+            uint32_t _i1857;
+            for (_i1857 = 0; _i1857 < _size1853; ++_i1857)
+            {
+              xfer += iprot->readString(this->tbl_types[_i1857]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -10523,10 +12260,17 @@ uint32_t ThriftHiveMetastore_get_table_meta_args::write(::apache::thrift::protoc
   xfer += oprot->writeFieldBegin("tbl_types", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->tbl_types.size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter1830;
     for (_iter1830 = this->tbl_types.begin(); _iter1830 != this->tbl_types.end(); ++_iter1830)
     {
       xfer += oprot->writeString((*_iter1830));
+=======
+    std::vector<std::string> ::const_iterator _iter1858;
+    for (_iter1858 = this->tbl_types.begin(); _iter1858 != this->tbl_types.end(); ++_iter1858)
+    {
+      xfer += oprot->writeString((*_iter1858));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -10558,10 +12302,17 @@ uint32_t ThriftHiveMetastore_get_table_meta_pargs::write(::apache::thrift::proto
   xfer += oprot->writeFieldBegin("tbl_types", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->tbl_types)).size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter1831;
     for (_iter1831 = (*(this->tbl_types)).begin(); _iter1831 != (*(this->tbl_types)).end(); ++_iter1831)
     {
       xfer += oprot->writeString((*_iter1831));
+=======
+    std::vector<std::string> ::const_iterator _iter1859;
+    for (_iter1859 = (*(this->tbl_types)).begin(); _iter1859 != (*(this->tbl_types)).end(); ++_iter1859)
+    {
+      xfer += oprot->writeString((*_iter1859));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -10602,6 +12353,7 @@ uint32_t ThriftHiveMetastore_get_table_meta_result::read(::apache::thrift::proto
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size1832;
             ::apache::thrift::protocol::TType _etype1835;
             xfer += iprot->readListBegin(_etype1835, _size1832);
@@ -10610,6 +12362,16 @@ uint32_t ThriftHiveMetastore_get_table_meta_result::read(::apache::thrift::proto
             for (_i1836 = 0; _i1836 < _size1832; ++_i1836)
             {
               xfer += this->success[_i1836].read(iprot);
+=======
+            uint32_t _size1860;
+            ::apache::thrift::protocol::TType _etype1863;
+            xfer += iprot->readListBegin(_etype1863, _size1860);
+            this->success.resize(_size1860);
+            uint32_t _i1864;
+            for (_i1864 = 0; _i1864 < _size1860; ++_i1864)
+            {
+              xfer += this->success[_i1864].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -10648,10 +12410,17 @@ uint32_t ThriftHiveMetastore_get_table_meta_result::write(::apache::thrift::prot
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<TableMeta> ::const_iterator _iter1837;
       for (_iter1837 = this->success.begin(); _iter1837 != this->success.end(); ++_iter1837)
       {
         xfer += (*_iter1837).write(oprot);
+=======
+      std::vector<TableMeta> ::const_iterator _iter1865;
+      for (_iter1865 = this->success.begin(); _iter1865 != this->success.end(); ++_iter1865)
+      {
+        xfer += (*_iter1865).write(oprot);
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -10696,6 +12465,7 @@ uint32_t ThriftHiveMetastore_get_table_meta_presult::read(::apache::thrift::prot
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size1838;
             ::apache::thrift::protocol::TType _etype1841;
             xfer += iprot->readListBegin(_etype1841, _size1838);
@@ -10704,6 +12474,16 @@ uint32_t ThriftHiveMetastore_get_table_meta_presult::read(::apache::thrift::prot
             for (_i1842 = 0; _i1842 < _size1838; ++_i1842)
             {
               xfer += (*(this->success))[_i1842].read(iprot);
+=======
+            uint32_t _size1866;
+            ::apache::thrift::protocol::TType _etype1869;
+            xfer += iprot->readListBegin(_etype1869, _size1866);
+            (*(this->success)).resize(_size1866);
+            uint32_t _i1870;
+            for (_i1870 = 0; _i1870 < _size1866; ++_i1870)
+            {
+              xfer += (*(this->success))[_i1870].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -10841,6 +12621,7 @@ uint32_t ThriftHiveMetastore_get_all_tables_result::read(::apache::thrift::proto
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size1843;
             ::apache::thrift::protocol::TType _etype1846;
             xfer += iprot->readListBegin(_etype1846, _size1843);
@@ -10849,6 +12630,16 @@ uint32_t ThriftHiveMetastore_get_all_tables_result::read(::apache::thrift::proto
             for (_i1847 = 0; _i1847 < _size1843; ++_i1847)
             {
               xfer += iprot->readString(this->success[_i1847]);
+=======
+            uint32_t _size1871;
+            ::apache::thrift::protocol::TType _etype1874;
+            xfer += iprot->readListBegin(_etype1874, _size1871);
+            this->success.resize(_size1871);
+            uint32_t _i1875;
+            for (_i1875 = 0; _i1875 < _size1871; ++_i1875)
+            {
+              xfer += iprot->readString(this->success[_i1875]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -10887,10 +12678,17 @@ uint32_t ThriftHiveMetastore_get_all_tables_result::write(::apache::thrift::prot
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<std::string> ::const_iterator _iter1848;
       for (_iter1848 = this->success.begin(); _iter1848 != this->success.end(); ++_iter1848)
       {
         xfer += oprot->writeString((*_iter1848));
+=======
+      std::vector<std::string> ::const_iterator _iter1876;
+      for (_iter1876 = this->success.begin(); _iter1876 != this->success.end(); ++_iter1876)
+      {
+        xfer += oprot->writeString((*_iter1876));
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -10935,6 +12733,7 @@ uint32_t ThriftHiveMetastore_get_all_tables_presult::read(::apache::thrift::prot
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size1849;
             ::apache::thrift::protocol::TType _etype1852;
             xfer += iprot->readListBegin(_etype1852, _size1849);
@@ -10943,6 +12742,16 @@ uint32_t ThriftHiveMetastore_get_all_tables_presult::read(::apache::thrift::prot
             for (_i1853 = 0; _i1853 < _size1849; ++_i1853)
             {
               xfer += iprot->readString((*(this->success))[_i1853]);
+=======
+            uint32_t _size1877;
+            ::apache::thrift::protocol::TType _etype1880;
+            xfer += iprot->readListBegin(_etype1880, _size1877);
+            (*(this->success)).resize(_size1877);
+            uint32_t _i1881;
+            for (_i1881 = 0; _i1881 < _size1877; ++_i1881)
+            {
+              xfer += iprot->readString((*(this->success))[_i1881]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -11252,6 +13061,7 @@ uint32_t ThriftHiveMetastore_get_table_objects_by_name_args::read(::apache::thri
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->tbl_names.clear();
+<<<<<<< HEAD
             uint32_t _size1854;
             ::apache::thrift::protocol::TType _etype1857;
             xfer += iprot->readListBegin(_etype1857, _size1854);
@@ -11260,6 +13070,16 @@ uint32_t ThriftHiveMetastore_get_table_objects_by_name_args::read(::apache::thri
             for (_i1858 = 0; _i1858 < _size1854; ++_i1858)
             {
               xfer += iprot->readString(this->tbl_names[_i1858]);
+=======
+            uint32_t _size1882;
+            ::apache::thrift::protocol::TType _etype1885;
+            xfer += iprot->readListBegin(_etype1885, _size1882);
+            this->tbl_names.resize(_size1882);
+            uint32_t _i1886;
+            for (_i1886 = 0; _i1886 < _size1882; ++_i1886)
+            {
+              xfer += iprot->readString(this->tbl_names[_i1886]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -11292,10 +13112,17 @@ uint32_t ThriftHiveMetastore_get_table_objects_by_name_args::write(::apache::thr
   xfer += oprot->writeFieldBegin("tbl_names", ::apache::thrift::protocol::T_LIST, 2);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->tbl_names.size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter1859;
     for (_iter1859 = this->tbl_names.begin(); _iter1859 != this->tbl_names.end(); ++_iter1859)
     {
       xfer += oprot->writeString((*_iter1859));
+=======
+    std::vector<std::string> ::const_iterator _iter1887;
+    for (_iter1887 = this->tbl_names.begin(); _iter1887 != this->tbl_names.end(); ++_iter1887)
+    {
+      xfer += oprot->writeString((*_iter1887));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -11323,10 +13150,17 @@ uint32_t ThriftHiveMetastore_get_table_objects_by_name_pargs::write(::apache::th
   xfer += oprot->writeFieldBegin("tbl_names", ::apache::thrift::protocol::T_LIST, 2);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->tbl_names)).size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter1860;
     for (_iter1860 = (*(this->tbl_names)).begin(); _iter1860 != (*(this->tbl_names)).end(); ++_iter1860)
     {
       xfer += oprot->writeString((*_iter1860));
+=======
+    std::vector<std::string> ::const_iterator _iter1888;
+    for (_iter1888 = (*(this->tbl_names)).begin(); _iter1888 != (*(this->tbl_names)).end(); ++_iter1888)
+    {
+      xfer += oprot->writeString((*_iter1888));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -11367,6 +13201,7 @@ uint32_t ThriftHiveMetastore_get_table_objects_by_name_result::read(::apache::th
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size1861;
             ::apache::thrift::protocol::TType _etype1864;
             xfer += iprot->readListBegin(_etype1864, _size1861);
@@ -11375,6 +13210,16 @@ uint32_t ThriftHiveMetastore_get_table_objects_by_name_result::read(::apache::th
             for (_i1865 = 0; _i1865 < _size1861; ++_i1865)
             {
               xfer += this->success[_i1865].read(iprot);
+=======
+            uint32_t _size1889;
+            ::apache::thrift::protocol::TType _etype1892;
+            xfer += iprot->readListBegin(_etype1892, _size1889);
+            this->success.resize(_size1889);
+            uint32_t _i1893;
+            for (_i1893 = 0; _i1893 < _size1889; ++_i1893)
+            {
+              xfer += this->success[_i1893].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -11405,10 +13250,17 @@ uint32_t ThriftHiveMetastore_get_table_objects_by_name_result::write(::apache::t
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<Table> ::const_iterator _iter1866;
       for (_iter1866 = this->success.begin(); _iter1866 != this->success.end(); ++_iter1866)
       {
         xfer += (*_iter1866).write(oprot);
+=======
+      std::vector<Table> ::const_iterator _iter1894;
+      for (_iter1894 = this->success.begin(); _iter1894 != this->success.end(); ++_iter1894)
+      {
+        xfer += (*_iter1894).write(oprot);
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -11449,6 +13301,7 @@ uint32_t ThriftHiveMetastore_get_table_objects_by_name_presult::read(::apache::t
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size1867;
             ::apache::thrift::protocol::TType _etype1870;
             xfer += iprot->readListBegin(_etype1870, _size1867);
@@ -11457,6 +13310,16 @@ uint32_t ThriftHiveMetastore_get_table_objects_by_name_presult::read(::apache::t
             for (_i1871 = 0; _i1871 < _size1867; ++_i1871)
             {
               xfer += (*(this->success))[_i1871].read(iprot);
+=======
+            uint32_t _size1895;
+            ::apache::thrift::protocol::TType _etype1898;
+            xfer += iprot->readListBegin(_etype1898, _size1895);
+            (*(this->success)).resize(_size1895);
+            uint32_t _i1899;
+            for (_i1899 = 0; _i1899 < _size1895; ++_i1899)
+            {
+              xfer += (*(this->success))[_i1899].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -11586,6 +13449,7 @@ uint32_t ThriftHiveMetastore_get_tables_ext_result::read(::apache::thrift::proto
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size1872;
             ::apache::thrift::protocol::TType _etype1875;
             xfer += iprot->readListBegin(_etype1875, _size1872);
@@ -11594,6 +13458,16 @@ uint32_t ThriftHiveMetastore_get_tables_ext_result::read(::apache::thrift::proto
             for (_i1876 = 0; _i1876 < _size1872; ++_i1876)
             {
               xfer += this->success[_i1876].read(iprot);
+=======
+            uint32_t _size1900;
+            ::apache::thrift::protocol::TType _etype1903;
+            xfer += iprot->readListBegin(_etype1903, _size1900);
+            this->success.resize(_size1900);
+            uint32_t _i1904;
+            for (_i1904 = 0; _i1904 < _size1900; ++_i1904)
+            {
+              xfer += this->success[_i1904].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -11632,10 +13506,17 @@ uint32_t ThriftHiveMetastore_get_tables_ext_result::write(::apache::thrift::prot
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<ExtendedTableInfo> ::const_iterator _iter1877;
       for (_iter1877 = this->success.begin(); _iter1877 != this->success.end(); ++_iter1877)
       {
         xfer += (*_iter1877).write(oprot);
+=======
+      std::vector<ExtendedTableInfo> ::const_iterator _iter1905;
+      for (_iter1905 = this->success.begin(); _iter1905 != this->success.end(); ++_iter1905)
+      {
+        xfer += (*_iter1905).write(oprot);
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -11680,6 +13561,7 @@ uint32_t ThriftHiveMetastore_get_tables_ext_presult::read(::apache::thrift::prot
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size1878;
             ::apache::thrift::protocol::TType _etype1881;
             xfer += iprot->readListBegin(_etype1881, _size1878);
@@ -11688,6 +13570,16 @@ uint32_t ThriftHiveMetastore_get_tables_ext_presult::read(::apache::thrift::prot
             for (_i1882 = 0; _i1882 < _size1878; ++_i1882)
             {
               xfer += (*(this->success))[_i1882].read(iprot);
+=======
+            uint32_t _size1906;
+            ::apache::thrift::protocol::TType _etype1909;
+            xfer += iprot->readListBegin(_etype1909, _size1906);
+            (*(this->success)).resize(_size1906);
+            uint32_t _i1910;
+            for (_i1910 = 0; _i1910 < _size1906; ++_i1910)
+            {
+              xfer += (*(this->success))[_i1910].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -12869,6 +14761,7 @@ uint32_t ThriftHiveMetastore_get_table_names_by_filter_result::read(::apache::th
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size1883;
             ::apache::thrift::protocol::TType _etype1886;
             xfer += iprot->readListBegin(_etype1886, _size1883);
@@ -12877,6 +14770,16 @@ uint32_t ThriftHiveMetastore_get_table_names_by_filter_result::read(::apache::th
             for (_i1887 = 0; _i1887 < _size1883; ++_i1887)
             {
               xfer += iprot->readString(this->success[_i1887]);
+=======
+            uint32_t _size1911;
+            ::apache::thrift::protocol::TType _etype1914;
+            xfer += iprot->readListBegin(_etype1914, _size1911);
+            this->success.resize(_size1911);
+            uint32_t _i1915;
+            for (_i1915 = 0; _i1915 < _size1911; ++_i1915)
+            {
+              xfer += iprot->readString(this->success[_i1915]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -12931,10 +14834,17 @@ uint32_t ThriftHiveMetastore_get_table_names_by_filter_result::write(::apache::t
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<std::string> ::const_iterator _iter1888;
       for (_iter1888 = this->success.begin(); _iter1888 != this->success.end(); ++_iter1888)
       {
         xfer += oprot->writeString((*_iter1888));
+=======
+      std::vector<std::string> ::const_iterator _iter1916;
+      for (_iter1916 = this->success.begin(); _iter1916 != this->success.end(); ++_iter1916)
+      {
+        xfer += oprot->writeString((*_iter1916));
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -12987,6 +14897,7 @@ uint32_t ThriftHiveMetastore_get_table_names_by_filter_presult::read(::apache::t
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size1889;
             ::apache::thrift::protocol::TType _etype1892;
             xfer += iprot->readListBegin(_etype1892, _size1889);
@@ -12995,6 +14906,16 @@ uint32_t ThriftHiveMetastore_get_table_names_by_filter_presult::read(::apache::t
             for (_i1893 = 0; _i1893 < _size1889; ++_i1893)
             {
               xfer += iprot->readString((*(this->success))[_i1893]);
+=======
+            uint32_t _size1917;
+            ::apache::thrift::protocol::TType _etype1920;
+            xfer += iprot->readListBegin(_etype1920, _size1917);
+            (*(this->success)).resize(_size1917);
+            uint32_t _i1921;
+            for (_i1921 = 0; _i1921 < _size1917; ++_i1921)
+            {
+              xfer += iprot->readString((*(this->success))[_i1921]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -14555,6 +16476,7 @@ uint32_t ThriftHiveMetastore_add_partitions_args::read(::apache::thrift::protoco
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->new_parts.clear();
+<<<<<<< HEAD
             uint32_t _size1894;
             ::apache::thrift::protocol::TType _etype1897;
             xfer += iprot->readListBegin(_etype1897, _size1894);
@@ -14563,6 +16485,16 @@ uint32_t ThriftHiveMetastore_add_partitions_args::read(::apache::thrift::protoco
             for (_i1898 = 0; _i1898 < _size1894; ++_i1898)
             {
               xfer += this->new_parts[_i1898].read(iprot);
+=======
+            uint32_t _size1922;
+            ::apache::thrift::protocol::TType _etype1925;
+            xfer += iprot->readListBegin(_etype1925, _size1922);
+            this->new_parts.resize(_size1922);
+            uint32_t _i1926;
+            for (_i1926 = 0; _i1926 < _size1922; ++_i1926)
+            {
+              xfer += this->new_parts[_i1926].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -14591,10 +16523,17 @@ uint32_t ThriftHiveMetastore_add_partitions_args::write(::apache::thrift::protoc
   xfer += oprot->writeFieldBegin("new_parts", ::apache::thrift::protocol::T_LIST, 1);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->new_parts.size()));
+<<<<<<< HEAD
     std::vector<Partition> ::const_iterator _iter1899;
     for (_iter1899 = this->new_parts.begin(); _iter1899 != this->new_parts.end(); ++_iter1899)
     {
       xfer += (*_iter1899).write(oprot);
+=======
+    std::vector<Partition> ::const_iterator _iter1927;
+    for (_iter1927 = this->new_parts.begin(); _iter1927 != this->new_parts.end(); ++_iter1927)
+    {
+      xfer += (*_iter1927).write(oprot);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -14618,10 +16557,17 @@ uint32_t ThriftHiveMetastore_add_partitions_pargs::write(::apache::thrift::proto
   xfer += oprot->writeFieldBegin("new_parts", ::apache::thrift::protocol::T_LIST, 1);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->new_parts)).size()));
+<<<<<<< HEAD
     std::vector<Partition> ::const_iterator _iter1900;
     for (_iter1900 = (*(this->new_parts)).begin(); _iter1900 != (*(this->new_parts)).end(); ++_iter1900)
     {
       xfer += (*_iter1900).write(oprot);
+=======
+    std::vector<Partition> ::const_iterator _iter1928;
+    for (_iter1928 = (*(this->new_parts)).begin(); _iter1928 != (*(this->new_parts)).end(); ++_iter1928)
+    {
+      xfer += (*_iter1928).write(oprot);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -14830,6 +16776,7 @@ uint32_t ThriftHiveMetastore_add_partitions_pspec_args::read(::apache::thrift::p
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->new_parts.clear();
+<<<<<<< HEAD
             uint32_t _size1901;
             ::apache::thrift::protocol::TType _etype1904;
             xfer += iprot->readListBegin(_etype1904, _size1901);
@@ -14838,6 +16785,16 @@ uint32_t ThriftHiveMetastore_add_partitions_pspec_args::read(::apache::thrift::p
             for (_i1905 = 0; _i1905 < _size1901; ++_i1905)
             {
               xfer += this->new_parts[_i1905].read(iprot);
+=======
+            uint32_t _size1929;
+            ::apache::thrift::protocol::TType _etype1932;
+            xfer += iprot->readListBegin(_etype1932, _size1929);
+            this->new_parts.resize(_size1929);
+            uint32_t _i1933;
+            for (_i1933 = 0; _i1933 < _size1929; ++_i1933)
+            {
+              xfer += this->new_parts[_i1933].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -14866,10 +16823,17 @@ uint32_t ThriftHiveMetastore_add_partitions_pspec_args::write(::apache::thrift::
   xfer += oprot->writeFieldBegin("new_parts", ::apache::thrift::protocol::T_LIST, 1);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->new_parts.size()));
+<<<<<<< HEAD
     std::vector<PartitionSpec> ::const_iterator _iter1906;
     for (_iter1906 = this->new_parts.begin(); _iter1906 != this->new_parts.end(); ++_iter1906)
     {
       xfer += (*_iter1906).write(oprot);
+=======
+    std::vector<PartitionSpec> ::const_iterator _iter1934;
+    for (_iter1934 = this->new_parts.begin(); _iter1934 != this->new_parts.end(); ++_iter1934)
+    {
+      xfer += (*_iter1934).write(oprot);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -14893,10 +16857,17 @@ uint32_t ThriftHiveMetastore_add_partitions_pspec_pargs::write(::apache::thrift:
   xfer += oprot->writeFieldBegin("new_parts", ::apache::thrift::protocol::T_LIST, 1);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->new_parts)).size()));
+<<<<<<< HEAD
     std::vector<PartitionSpec> ::const_iterator _iter1907;
     for (_iter1907 = (*(this->new_parts)).begin(); _iter1907 != (*(this->new_parts)).end(); ++_iter1907)
     {
       xfer += (*_iter1907).write(oprot);
+=======
+    std::vector<PartitionSpec> ::const_iterator _iter1935;
+    for (_iter1935 = (*(this->new_parts)).begin(); _iter1935 != (*(this->new_parts)).end(); ++_iter1935)
+    {
+      xfer += (*_iter1935).write(oprot);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -15121,6 +17092,7 @@ uint32_t ThriftHiveMetastore_append_partition_args::read(::apache::thrift::proto
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
+<<<<<<< HEAD
             uint32_t _size1908;
             ::apache::thrift::protocol::TType _etype1911;
             xfer += iprot->readListBegin(_etype1911, _size1908);
@@ -15129,6 +17101,16 @@ uint32_t ThriftHiveMetastore_append_partition_args::read(::apache::thrift::proto
             for (_i1912 = 0; _i1912 < _size1908; ++_i1912)
             {
               xfer += iprot->readString(this->part_vals[_i1912]);
+=======
+            uint32_t _size1936;
+            ::apache::thrift::protocol::TType _etype1939;
+            xfer += iprot->readListBegin(_etype1939, _size1936);
+            this->part_vals.resize(_size1936);
+            uint32_t _i1940;
+            for (_i1940 = 0; _i1940 < _size1936; ++_i1940)
+            {
+              xfer += iprot->readString(this->part_vals[_i1940]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -15165,10 +17147,17 @@ uint32_t ThriftHiveMetastore_append_partition_args::write(::apache::thrift::prot
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter1913;
     for (_iter1913 = this->part_vals.begin(); _iter1913 != this->part_vals.end(); ++_iter1913)
     {
       xfer += oprot->writeString((*_iter1913));
+=======
+    std::vector<std::string> ::const_iterator _iter1941;
+    for (_iter1941 = this->part_vals.begin(); _iter1941 != this->part_vals.end(); ++_iter1941)
+    {
+      xfer += oprot->writeString((*_iter1941));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -15200,10 +17189,17 @@ uint32_t ThriftHiveMetastore_append_partition_pargs::write(::apache::thrift::pro
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter1914;
     for (_iter1914 = (*(this->part_vals)).begin(); _iter1914 != (*(this->part_vals)).end(); ++_iter1914)
     {
       xfer += oprot->writeString((*_iter1914));
+=======
+    std::vector<std::string> ::const_iterator _iter1942;
+    for (_iter1942 = (*(this->part_vals)).begin(); _iter1942 != (*(this->part_vals)).end(); ++_iter1942)
+    {
+      xfer += oprot->writeString((*_iter1942));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -15675,6 +17671,7 @@ uint32_t ThriftHiveMetastore_append_partition_with_environment_context_args::rea
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
+<<<<<<< HEAD
             uint32_t _size1915;
             ::apache::thrift::protocol::TType _etype1918;
             xfer += iprot->readListBegin(_etype1918, _size1915);
@@ -15683,6 +17680,16 @@ uint32_t ThriftHiveMetastore_append_partition_with_environment_context_args::rea
             for (_i1919 = 0; _i1919 < _size1915; ++_i1919)
             {
               xfer += iprot->readString(this->part_vals[_i1919]);
+=======
+            uint32_t _size1943;
+            ::apache::thrift::protocol::TType _etype1946;
+            xfer += iprot->readListBegin(_etype1946, _size1943);
+            this->part_vals.resize(_size1943);
+            uint32_t _i1947;
+            for (_i1947 = 0; _i1947 < _size1943; ++_i1947)
+            {
+              xfer += iprot->readString(this->part_vals[_i1947]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -15727,10 +17734,17 @@ uint32_t ThriftHiveMetastore_append_partition_with_environment_context_args::wri
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter1920;
     for (_iter1920 = this->part_vals.begin(); _iter1920 != this->part_vals.end(); ++_iter1920)
     {
       xfer += oprot->writeString((*_iter1920));
+=======
+    std::vector<std::string> ::const_iterator _iter1948;
+    for (_iter1948 = this->part_vals.begin(); _iter1948 != this->part_vals.end(); ++_iter1948)
+    {
+      xfer += oprot->writeString((*_iter1948));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -15766,10 +17780,17 @@ uint32_t ThriftHiveMetastore_append_partition_with_environment_context_pargs::wr
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter1921;
     for (_iter1921 = (*(this->part_vals)).begin(); _iter1921 != (*(this->part_vals)).end(); ++_iter1921)
     {
       xfer += oprot->writeString((*_iter1921));
+=======
+    std::vector<std::string> ::const_iterator _iter1949;
+    for (_iter1949 = (*(this->part_vals)).begin(); _iter1949 != (*(this->part_vals)).end(); ++_iter1949)
+    {
+      xfer += oprot->writeString((*_iter1949));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -16572,6 +18593,7 @@ uint32_t ThriftHiveMetastore_drop_partition_args::read(::apache::thrift::protoco
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
+<<<<<<< HEAD
             uint32_t _size1922;
             ::apache::thrift::protocol::TType _etype1925;
             xfer += iprot->readListBegin(_etype1925, _size1922);
@@ -16580,6 +18602,16 @@ uint32_t ThriftHiveMetastore_drop_partition_args::read(::apache::thrift::protoco
             for (_i1926 = 0; _i1926 < _size1922; ++_i1926)
             {
               xfer += iprot->readString(this->part_vals[_i1926]);
+=======
+            uint32_t _size1950;
+            ::apache::thrift::protocol::TType _etype1953;
+            xfer += iprot->readListBegin(_etype1953, _size1950);
+            this->part_vals.resize(_size1950);
+            uint32_t _i1954;
+            for (_i1954 = 0; _i1954 < _size1950; ++_i1954)
+            {
+              xfer += iprot->readString(this->part_vals[_i1954]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -16624,10 +18656,17 @@ uint32_t ThriftHiveMetastore_drop_partition_args::write(::apache::thrift::protoc
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter1927;
     for (_iter1927 = this->part_vals.begin(); _iter1927 != this->part_vals.end(); ++_iter1927)
     {
       xfer += oprot->writeString((*_iter1927));
+=======
+    std::vector<std::string> ::const_iterator _iter1955;
+    for (_iter1955 = this->part_vals.begin(); _iter1955 != this->part_vals.end(); ++_iter1955)
+    {
+      xfer += oprot->writeString((*_iter1955));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -16663,10 +18702,17 @@ uint32_t ThriftHiveMetastore_drop_partition_pargs::write(::apache::thrift::proto
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter1928;
     for (_iter1928 = (*(this->part_vals)).begin(); _iter1928 != (*(this->part_vals)).end(); ++_iter1928)
     {
       xfer += oprot->writeString((*_iter1928));
+=======
+    std::vector<std::string> ::const_iterator _iter1956;
+    for (_iter1956 = (*(this->part_vals)).begin(); _iter1956 != (*(this->part_vals)).end(); ++_iter1956)
+    {
+      xfer += oprot->writeString((*_iter1956));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -16875,6 +18921,7 @@ uint32_t ThriftHiveMetastore_drop_partition_with_environment_context_args::read(
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
+<<<<<<< HEAD
             uint32_t _size1929;
             ::apache::thrift::protocol::TType _etype1932;
             xfer += iprot->readListBegin(_etype1932, _size1929);
@@ -16883,6 +18930,16 @@ uint32_t ThriftHiveMetastore_drop_partition_with_environment_context_args::read(
             for (_i1933 = 0; _i1933 < _size1929; ++_i1933)
             {
               xfer += iprot->readString(this->part_vals[_i1933]);
+=======
+            uint32_t _size1957;
+            ::apache::thrift::protocol::TType _etype1960;
+            xfer += iprot->readListBegin(_etype1960, _size1957);
+            this->part_vals.resize(_size1957);
+            uint32_t _i1961;
+            for (_i1961 = 0; _i1961 < _size1957; ++_i1961)
+            {
+              xfer += iprot->readString(this->part_vals[_i1961]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -16935,10 +18992,17 @@ uint32_t ThriftHiveMetastore_drop_partition_with_environment_context_args::write
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter1934;
     for (_iter1934 = this->part_vals.begin(); _iter1934 != this->part_vals.end(); ++_iter1934)
     {
       xfer += oprot->writeString((*_iter1934));
+=======
+    std::vector<std::string> ::const_iterator _iter1962;
+    for (_iter1962 = this->part_vals.begin(); _iter1962 != this->part_vals.end(); ++_iter1962)
+    {
+      xfer += oprot->writeString((*_iter1962));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -16978,10 +19042,17 @@ uint32_t ThriftHiveMetastore_drop_partition_with_environment_context_pargs::writ
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter1935;
     for (_iter1935 = (*(this->part_vals)).begin(); _iter1935 != (*(this->part_vals)).end(); ++_iter1935)
     {
       xfer += oprot->writeString((*_iter1935));
+=======
+    std::vector<std::string> ::const_iterator _iter1963;
+    for (_iter1963 = (*(this->part_vals)).begin(); _iter1963 != (*(this->part_vals)).end(); ++_iter1963)
+    {
+      xfer += oprot->writeString((*_iter1963));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -17987,6 +20058,7 @@ uint32_t ThriftHiveMetastore_get_partition_args::read(::apache::thrift::protocol
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
+<<<<<<< HEAD
             uint32_t _size1936;
             ::apache::thrift::protocol::TType _etype1939;
             xfer += iprot->readListBegin(_etype1939, _size1936);
@@ -17995,6 +20067,16 @@ uint32_t ThriftHiveMetastore_get_partition_args::read(::apache::thrift::protocol
             for (_i1940 = 0; _i1940 < _size1936; ++_i1940)
             {
               xfer += iprot->readString(this->part_vals[_i1940]);
+=======
+            uint32_t _size1964;
+            ::apache::thrift::protocol::TType _etype1967;
+            xfer += iprot->readListBegin(_etype1967, _size1964);
+            this->part_vals.resize(_size1964);
+            uint32_t _i1968;
+            for (_i1968 = 0; _i1968 < _size1964; ++_i1968)
+            {
+              xfer += iprot->readString(this->part_vals[_i1968]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -18031,10 +20113,17 @@ uint32_t ThriftHiveMetastore_get_partition_args::write(::apache::thrift::protoco
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter1941;
     for (_iter1941 = this->part_vals.begin(); _iter1941 != this->part_vals.end(); ++_iter1941)
     {
       xfer += oprot->writeString((*_iter1941));
+=======
+    std::vector<std::string> ::const_iterator _iter1969;
+    for (_iter1969 = this->part_vals.begin(); _iter1969 != this->part_vals.end(); ++_iter1969)
+    {
+      xfer += oprot->writeString((*_iter1969));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -18066,10 +20155,17 @@ uint32_t ThriftHiveMetastore_get_partition_pargs::write(::apache::thrift::protoc
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter1942;
     for (_iter1942 = (*(this->part_vals)).begin(); _iter1942 != (*(this->part_vals)).end(); ++_iter1942)
     {
       xfer += oprot->writeString((*_iter1942));
+=======
+    std::vector<std::string> ::const_iterator _iter1970;
+    for (_iter1970 = (*(this->part_vals)).begin(); _iter1970 != (*(this->part_vals)).end(); ++_iter1970)
+    {
+      xfer += oprot->writeString((*_iter1970));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -18485,6 +20581,7 @@ uint32_t ThriftHiveMetastore_exchange_partition_args::read(::apache::thrift::pro
         if (ftype == ::apache::thrift::protocol::T_MAP) {
           {
             this->partitionSpecs.clear();
+<<<<<<< HEAD
             uint32_t _size1943;
             ::apache::thrift::protocol::TType _ktype1944;
             ::apache::thrift::protocol::TType _vtype1945;
@@ -18496,6 +20593,19 @@ uint32_t ThriftHiveMetastore_exchange_partition_args::read(::apache::thrift::pro
               xfer += iprot->readString(_key1948);
               std::string& _val1949 = this->partitionSpecs[_key1948];
               xfer += iprot->readString(_val1949);
+=======
+            uint32_t _size1971;
+            ::apache::thrift::protocol::TType _ktype1972;
+            ::apache::thrift::protocol::TType _vtype1973;
+            xfer += iprot->readMapBegin(_ktype1972, _vtype1973, _size1971);
+            uint32_t _i1975;
+            for (_i1975 = 0; _i1975 < _size1971; ++_i1975)
+            {
+              std::string _key1976;
+              xfer += iprot->readString(_key1976);
+              std::string& _val1977 = this->partitionSpecs[_key1976];
+              xfer += iprot->readString(_val1977);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readMapEnd();
           }
@@ -18556,11 +20666,19 @@ uint32_t ThriftHiveMetastore_exchange_partition_args::write(::apache::thrift::pr
   xfer += oprot->writeFieldBegin("partitionSpecs", ::apache::thrift::protocol::T_MAP, 1);
   {
     xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->partitionSpecs.size()));
+<<<<<<< HEAD
     std::map<std::string, std::string> ::const_iterator _iter1950;
     for (_iter1950 = this->partitionSpecs.begin(); _iter1950 != this->partitionSpecs.end(); ++_iter1950)
     {
       xfer += oprot->writeString(_iter1950->first);
       xfer += oprot->writeString(_iter1950->second);
+=======
+    std::map<std::string, std::string> ::const_iterator _iter1978;
+    for (_iter1978 = this->partitionSpecs.begin(); _iter1978 != this->partitionSpecs.end(); ++_iter1978)
+    {
+      xfer += oprot->writeString(_iter1978->first);
+      xfer += oprot->writeString(_iter1978->second);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeMapEnd();
   }
@@ -18600,11 +20718,19 @@ uint32_t ThriftHiveMetastore_exchange_partition_pargs::write(::apache::thrift::p
   xfer += oprot->writeFieldBegin("partitionSpecs", ::apache::thrift::protocol::T_MAP, 1);
   {
     xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->partitionSpecs)).size()));
+<<<<<<< HEAD
     std::map<std::string, std::string> ::const_iterator _iter1951;
     for (_iter1951 = (*(this->partitionSpecs)).begin(); _iter1951 != (*(this->partitionSpecs)).end(); ++_iter1951)
     {
       xfer += oprot->writeString(_iter1951->first);
       xfer += oprot->writeString(_iter1951->second);
+=======
+    std::map<std::string, std::string> ::const_iterator _iter1979;
+    for (_iter1979 = (*(this->partitionSpecs)).begin(); _iter1979 != (*(this->partitionSpecs)).end(); ++_iter1979)
+    {
+      xfer += oprot->writeString(_iter1979->first);
+      xfer += oprot->writeString(_iter1979->second);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeMapEnd();
   }
@@ -18849,6 +20975,7 @@ uint32_t ThriftHiveMetastore_exchange_partitions_args::read(::apache::thrift::pr
         if (ftype == ::apache::thrift::protocol::T_MAP) {
           {
             this->partitionSpecs.clear();
+<<<<<<< HEAD
             uint32_t _size1952;
             ::apache::thrift::protocol::TType _ktype1953;
             ::apache::thrift::protocol::TType _vtype1954;
@@ -18860,6 +20987,19 @@ uint32_t ThriftHiveMetastore_exchange_partitions_args::read(::apache::thrift::pr
               xfer += iprot->readString(_key1957);
               std::string& _val1958 = this->partitionSpecs[_key1957];
               xfer += iprot->readString(_val1958);
+=======
+            uint32_t _size1980;
+            ::apache::thrift::protocol::TType _ktype1981;
+            ::apache::thrift::protocol::TType _vtype1982;
+            xfer += iprot->readMapBegin(_ktype1981, _vtype1982, _size1980);
+            uint32_t _i1984;
+            for (_i1984 = 0; _i1984 < _size1980; ++_i1984)
+            {
+              std::string _key1985;
+              xfer += iprot->readString(_key1985);
+              std::string& _val1986 = this->partitionSpecs[_key1985];
+              xfer += iprot->readString(_val1986);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readMapEnd();
           }
@@ -18920,11 +21060,19 @@ uint32_t ThriftHiveMetastore_exchange_partitions_args::write(::apache::thrift::p
   xfer += oprot->writeFieldBegin("partitionSpecs", ::apache::thrift::protocol::T_MAP, 1);
   {
     xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->partitionSpecs.size()));
+<<<<<<< HEAD
     std::map<std::string, std::string> ::const_iterator _iter1959;
     for (_iter1959 = this->partitionSpecs.begin(); _iter1959 != this->partitionSpecs.end(); ++_iter1959)
     {
       xfer += oprot->writeString(_iter1959->first);
       xfer += oprot->writeString(_iter1959->second);
+=======
+    std::map<std::string, std::string> ::const_iterator _iter1987;
+    for (_iter1987 = this->partitionSpecs.begin(); _iter1987 != this->partitionSpecs.end(); ++_iter1987)
+    {
+      xfer += oprot->writeString(_iter1987->first);
+      xfer += oprot->writeString(_iter1987->second);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeMapEnd();
   }
@@ -18964,11 +21112,19 @@ uint32_t ThriftHiveMetastore_exchange_partitions_pargs::write(::apache::thrift::
   xfer += oprot->writeFieldBegin("partitionSpecs", ::apache::thrift::protocol::T_MAP, 1);
   {
     xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->partitionSpecs)).size()));
+<<<<<<< HEAD
     std::map<std::string, std::string> ::const_iterator _iter1960;
     for (_iter1960 = (*(this->partitionSpecs)).begin(); _iter1960 != (*(this->partitionSpecs)).end(); ++_iter1960)
     {
       xfer += oprot->writeString(_iter1960->first);
       xfer += oprot->writeString(_iter1960->second);
+=======
+    std::map<std::string, std::string> ::const_iterator _iter1988;
+    for (_iter1988 = (*(this->partitionSpecs)).begin(); _iter1988 != (*(this->partitionSpecs)).end(); ++_iter1988)
+    {
+      xfer += oprot->writeString(_iter1988->first);
+      xfer += oprot->writeString(_iter1988->second);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeMapEnd();
   }
@@ -19025,6 +21181,7 @@ uint32_t ThriftHiveMetastore_exchange_partitions_result::read(::apache::thrift::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size1961;
             ::apache::thrift::protocol::TType _etype1964;
             xfer += iprot->readListBegin(_etype1964, _size1961);
@@ -19033,6 +21190,154 @@ uint32_t ThriftHiveMetastore_exchange_partitions_result::read(::apache::thrift::
             for (_i1965 = 0; _i1965 < _size1961; ++_i1965)
             {
               xfer += this->success[_i1965].read(iprot);
+=======
+            uint32_t _size1989;
+            ::apache::thrift::protocol::TType _etype1992;
+            xfer += iprot->readListBegin(_etype1992, _size1989);
+            this->success.resize(_size1989);
+            uint32_t _i1993;
+            for (_i1993 = 0; _i1993 < _size1989; ++_i1993)
+            {
+              xfer += this->success[_i1993].read(iprot);
+>>>>>>> External metastore: clean after rebase
+            }
+            xfer += iprot->readListEnd();
+          }
+          this->__isset.success = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o1.read(iprot);
+          this->__isset.o1 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 2:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o2.read(iprot);
+          this->__isset.o2 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 3:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o3.read(iprot);
+          this->__isset.o3 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 4:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o4.read(iprot);
+          this->__isset.o4 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+uint32_t ThriftHiveMetastore_exchange_partitions_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+
+  uint32_t xfer = 0;
+
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_exchange_partitions_result");
+
+  if (this->__isset.success) {
+    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
+    {
+      xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
+      std::vector<Partition> ::const_iterator _iter1966;
+      for (_iter1966 = this->success.begin(); _iter1966 != this->success.end(); ++_iter1966)
+      {
+        xfer += (*_iter1966).write(oprot);
+=======
+      std::vector<Partition> ::const_iterator _iter1994;
+      for (_iter1994 = this->success.begin(); _iter1994 != this->success.end(); ++_iter1994)
+      {
+        xfer += (*_iter1994).write(oprot);
+>>>>>>> External metastore: clean after rebase
+      }
+      xfer += oprot->writeListEnd();
+    }
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o1) {
+    xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
+    xfer += this->o1.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o2) {
+    xfer += oprot->writeFieldBegin("o2", ::apache::thrift::protocol::T_STRUCT, 2);
+    xfer += this->o2.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o3) {
+    xfer += oprot->writeFieldBegin("o3", ::apache::thrift::protocol::T_STRUCT, 3);
+    xfer += this->o3.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o4) {
+    xfer += oprot->writeFieldBegin("o4", ::apache::thrift::protocol::T_STRUCT, 4);
+    xfer += this->o4.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  }
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+ThriftHiveMetastore_exchange_partitions_presult::~ThriftHiveMetastore_exchange_partitions_presult() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_exchange_partitions_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 0:
+        if (ftype == ::apache::thrift::protocol::T_LIST) {
+          {
+            (*(this->success)).clear();
+<<<<<<< HEAD
+            uint32_t _size1967;
+            ::apache::thrift::protocol::TType _etype1970;
+            xfer += iprot->readListBegin(_etype1970, _size1967);
+            (*(this->success)).resize(_size1967);
+            uint32_t _i1971;
+            for (_i1971 = 0; _i1971 < _size1967; ++_i1971)
+            {
+              xfer += (*(this->success))[_i1971].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -19085,52 +21390,12 @@ uint32_t ThriftHiveMetastore_exchange_partitions_result::read(::apache::thrift::
   return xfer;
 }
 
-uint32_t ThriftHiveMetastore_exchange_partitions_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
-
-  uint32_t xfer = 0;
-
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_exchange_partitions_result");
-
-  if (this->__isset.success) {
-    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
-    {
-      xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-      std::vector<Partition> ::const_iterator _iter1966;
-      for (_iter1966 = this->success.begin(); _iter1966 != this->success.end(); ++_iter1966)
-      {
-        xfer += (*_iter1966).write(oprot);
-      }
-      xfer += oprot->writeListEnd();
-    }
-    xfer += oprot->writeFieldEnd();
-  } else if (this->__isset.o1) {
-    xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
-    xfer += this->o1.write(oprot);
-    xfer += oprot->writeFieldEnd();
-  } else if (this->__isset.o2) {
-    xfer += oprot->writeFieldBegin("o2", ::apache::thrift::protocol::T_STRUCT, 2);
-    xfer += this->o2.write(oprot);
-    xfer += oprot->writeFieldEnd();
-  } else if (this->__isset.o3) {
-    xfer += oprot->writeFieldBegin("o3", ::apache::thrift::protocol::T_STRUCT, 3);
-    xfer += this->o3.write(oprot);
-    xfer += oprot->writeFieldEnd();
-  } else if (this->__isset.o4) {
-    xfer += oprot->writeFieldBegin("o4", ::apache::thrift::protocol::T_STRUCT, 4);
-    xfer += this->o4.write(oprot);
-    xfer += oprot->writeFieldEnd();
-  }
-  xfer += oprot->writeFieldStop();
-  xfer += oprot->writeStructEnd();
-  return xfer;
-}
-
 
-ThriftHiveMetastore_exchange_partitions_presult::~ThriftHiveMetastore_exchange_partitions_presult() noexcept {
+ThriftHiveMetastore_get_partition_with_auth_args::~ThriftHiveMetastore_get_partition_with_auth_args() noexcept {
 }
 
 
-uint32_t ThriftHiveMetastore_exchange_partitions_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+uint32_t ThriftHiveMetastore_get_partition_with_auth_args::read(::apache::thrift::protocol::TProtocol* iprot) {
 
   ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
   uint32_t xfer = 0;
@@ -19151,18 +21416,74 @@ uint32_t ThriftHiveMetastore_exchange_partitions_presult::read(::apache::thrift:
     }
     switch (fid)
     {
-      case 0:
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRING) {
+          xfer += iprot->readString(this->db_name);
+          this->__isset.db_name = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 2:
+        if (ftype == ::apache::thrift::protocol::T_STRING) {
+          xfer += iprot->readString(this->tbl_name);
+          this->__isset.tbl_name = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 3:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
-            (*(this->success)).clear();
-            uint32_t _size1967;
-            ::apache::thrift::protocol::TType _etype1970;
-            xfer += iprot->readListBegin(_etype1970, _size1967);
-            (*(this->success)).resize(_size1967);
-            uint32_t _i1971;
-            for (_i1971 = 0; _i1971 < _size1967; ++_i1971)
+            this->part_vals.clear();
+            uint32_t _size1972;
+            ::apache::thrift::protocol::TType _etype1975;
+            xfer += iprot->readListBegin(_etype1975, _size1972);
+            this->part_vals.resize(_size1972);
+            uint32_t _i1976;
+            for (_i1976 = 0; _i1976 < _size1972; ++_i1976)
             {
-              xfer += (*(this->success))[_i1971].read(iprot);
+              xfer += iprot->readString(this->part_vals[_i1976]);
+            }
+            xfer += iprot->readListEnd();
+          }
+          this->__isset.part_vals = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 4:
+        if (ftype == ::apache::thrift::protocol::T_STRING) {
+          xfer += iprot->readString(this->user_name);
+          this->__isset.user_name = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 5:
+        if (ftype == ::apache::thrift::protocol::T_LIST) {
+          {
+            this->group_names.clear();
+            uint32_t _size1977;
+            ::apache::thrift::protocol::TType _etype1980;
+            xfer += iprot->readListBegin(_etype1980, _size1977);
+            this->group_names.resize(_size1977);
+            uint32_t _i1981;
+            for (_i1981 = 0; _i1981 < _size1977; ++_i1981)
+            {
+              xfer += iprot->readString(this->group_names[_i1981]);
+            }
+            xfer += iprot->readListEnd();
+          }
+=======
+            uint32_t _size1995;
+            ::apache::thrift::protocol::TType _etype1998;
+            xfer += iprot->readListBegin(_etype1998, _size1995);
+            (*(this->success)).resize(_size1995);
+            uint32_t _i1999;
+            for (_i1999 = 0; _i1999 < _size1995; ++_i1999)
+            {
+              xfer += (*(this->success))[_i1999].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -19261,14 +21582,14 @@ uint32_t ThriftHiveMetastore_get_partition_with_auth_args::read(::apache::thrift
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
-            uint32_t _size1972;
-            ::apache::thrift::protocol::TType _etype1975;
-            xfer += iprot->readListBegin(_etype1975, _size1972);
-            this->part_vals.resize(_size1972);
-            uint32_t _i1976;
-            for (_i1976 = 0; _i1976 < _size1972; ++_i1976)
+            uint32_t _size2000;
+            ::apache::thrift::protocol::TType _etype2003;
+            xfer += iprot->readListBegin(_etype2003, _size2000);
+            this->part_vals.resize(_size2000);
+            uint32_t _i2004;
+            for (_i2004 = 0; _i2004 < _size2000; ++_i2004)
             {
-              xfer += iprot->readString(this->part_vals[_i1976]);
+              xfer += iprot->readString(this->part_vals[_i2004]);
             }
             xfer += iprot->readListEnd();
           }
@@ -19289,17 +21610,18 @@ uint32_t ThriftHiveMetastore_get_partition_with_auth_args::read(::apache::thrift
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->group_names.clear();
-            uint32_t _size1977;
-            ::apache::thrift::protocol::TType _etype1980;
-            xfer += iprot->readListBegin(_etype1980, _size1977);
-            this->group_names.resize(_size1977);
-            uint32_t _i1981;
-            for (_i1981 = 0; _i1981 < _size1977; ++_i1981)
+            uint32_t _size2005;
+            ::apache::thrift::protocol::TType _etype2008;
+            xfer += iprot->readListBegin(_etype2008, _size2005);
+            this->group_names.resize(_size2005);
+            uint32_t _i2009;
+            for (_i2009 = 0; _i2009 < _size2005; ++_i2009)
             {
-              xfer += iprot->readString(this->group_names[_i1981]);
+              xfer += iprot->readString(this->group_names[_i2009]);
             }
             xfer += iprot->readListEnd();
           }
+>>>>>>> External metastore: clean after rebase
           this->__isset.group_names = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -19333,10 +21655,17 @@ uint32_t ThriftHiveMetastore_get_partition_with_auth_args::write(::apache::thrif
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter1982;
     for (_iter1982 = this->part_vals.begin(); _iter1982 != this->part_vals.end(); ++_iter1982)
     {
       xfer += oprot->writeString((*_iter1982));
+=======
+    std::vector<std::string> ::const_iterator _iter2010;
+    for (_iter2010 = this->part_vals.begin(); _iter2010 != this->part_vals.end(); ++_iter2010)
+    {
+      xfer += oprot->writeString((*_iter2010));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -19349,10 +21678,17 @@ uint32_t ThriftHiveMetastore_get_partition_with_auth_args::write(::apache::thrif
   xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 5);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->group_names.size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter1983;
     for (_iter1983 = this->group_names.begin(); _iter1983 != this->group_names.end(); ++_iter1983)
     {
       xfer += oprot->writeString((*_iter1983));
+=======
+    std::vector<std::string> ::const_iterator _iter2011;
+    for (_iter2011 = this->group_names.begin(); _iter2011 != this->group_names.end(); ++_iter2011)
+    {
+      xfer += oprot->writeString((*_iter2011));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -19384,10 +21720,17 @@ uint32_t ThriftHiveMetastore_get_partition_with_auth_pargs::write(::apache::thri
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter1984;
     for (_iter1984 = (*(this->part_vals)).begin(); _iter1984 != (*(this->part_vals)).end(); ++_iter1984)
     {
       xfer += oprot->writeString((*_iter1984));
+=======
+    std::vector<std::string> ::const_iterator _iter2012;
+    for (_iter2012 = (*(this->part_vals)).begin(); _iter2012 != (*(this->part_vals)).end(); ++_iter2012)
+    {
+      xfer += oprot->writeString((*_iter2012));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -19400,10 +21743,17 @@ uint32_t ThriftHiveMetastore_get_partition_with_auth_pargs::write(::apache::thri
   xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 5);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->group_names)).size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter1985;
     for (_iter1985 = (*(this->group_names)).begin(); _iter1985 != (*(this->group_names)).end(); ++_iter1985)
     {
       xfer += oprot->writeString((*_iter1985));
+=======
+    std::vector<std::string> ::const_iterator _iter2013;
+    for (_iter2013 = (*(this->group_names)).begin(); _iter2013 != (*(this->group_names)).end(); ++_iter2013)
+    {
+      xfer += oprot->writeString((*_iter2013));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -19962,6 +22312,7 @@ uint32_t ThriftHiveMetastore_get_partitions_result::read(::apache::thrift::proto
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size1986;
             ::apache::thrift::protocol::TType _etype1989;
             xfer += iprot->readListBegin(_etype1989, _size1986);
@@ -19970,6 +22321,16 @@ uint32_t ThriftHiveMetastore_get_partitions_result::read(::apache::thrift::proto
             for (_i1990 = 0; _i1990 < _size1986; ++_i1990)
             {
               xfer += this->success[_i1990].read(iprot);
+=======
+            uint32_t _size2014;
+            ::apache::thrift::protocol::TType _etype2017;
+            xfer += iprot->readListBegin(_etype2017, _size2014);
+            this->success.resize(_size2014);
+            uint32_t _i2018;
+            for (_i2018 = 0; _i2018 < _size2014; ++_i2018)
+            {
+              xfer += this->success[_i2018].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -20016,10 +22377,17 @@ uint32_t ThriftHiveMetastore_get_partitions_result::write(::apache::thrift::prot
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<Partition> ::const_iterator _iter1991;
       for (_iter1991 = this->success.begin(); _iter1991 != this->success.end(); ++_iter1991)
       {
         xfer += (*_iter1991).write(oprot);
+=======
+      std::vector<Partition> ::const_iterator _iter2019;
+      for (_iter2019 = this->success.begin(); _iter2019 != this->success.end(); ++_iter2019)
+      {
+        xfer += (*_iter2019).write(oprot);
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -20068,6 +22436,7 @@ uint32_t ThriftHiveMetastore_get_partitions_presult::read(::apache::thrift::prot
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size1992;
             ::apache::thrift::protocol::TType _etype1995;
             xfer += iprot->readListBegin(_etype1995, _size1992);
@@ -20076,6 +22445,16 @@ uint32_t ThriftHiveMetastore_get_partitions_presult::read(::apache::thrift::prot
             for (_i1996 = 0; _i1996 < _size1992; ++_i1996)
             {
               xfer += (*(this->success))[_i1996].read(iprot);
+=======
+            uint32_t _size2020;
+            ::apache::thrift::protocol::TType _etype2023;
+            xfer += iprot->readListBegin(_etype2023, _size2020);
+            (*(this->success)).resize(_size2020);
+            uint32_t _i2024;
+            for (_i2024 = 0; _i2024 < _size2020; ++_i2024)
+            {
+              xfer += (*(this->success))[_i2024].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -20401,6 +22780,7 @@ uint32_t ThriftHiveMetastore_get_partitions_with_auth_args::read(::apache::thrif
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->group_names.clear();
+<<<<<<< HEAD
             uint32_t _size1997;
             ::apache::thrift::protocol::TType _etype2000;
             xfer += iprot->readListBegin(_etype2000, _size1997);
@@ -20409,6 +22789,16 @@ uint32_t ThriftHiveMetastore_get_partitions_with_auth_args::read(::apache::thrif
             for (_i2001 = 0; _i2001 < _size1997; ++_i2001)
             {
               xfer += iprot->readString(this->group_names[_i2001]);
+=======
+            uint32_t _size2025;
+            ::apache::thrift::protocol::TType _etype2028;
+            xfer += iprot->readListBegin(_etype2028, _size2025);
+            this->group_names.resize(_size2025);
+            uint32_t _i2029;
+            for (_i2029 = 0; _i2029 < _size2025; ++_i2029)
+            {
+              xfer += iprot->readString(this->group_names[_i2029]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -20453,10 +22843,17 @@ uint32_t ThriftHiveMetastore_get_partitions_with_auth_args::write(::apache::thri
   xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 5);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->group_names.size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter2002;
     for (_iter2002 = this->group_names.begin(); _iter2002 != this->group_names.end(); ++_iter2002)
     {
       xfer += oprot->writeString((*_iter2002));
+=======
+    std::vector<std::string> ::const_iterator _iter2030;
+    for (_iter2030 = this->group_names.begin(); _iter2030 != this->group_names.end(); ++_iter2030)
+    {
+      xfer += oprot->writeString((*_iter2030));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -20496,10 +22893,17 @@ uint32_t ThriftHiveMetastore_get_partitions_with_auth_pargs::write(::apache::thr
   xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 5);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->group_names)).size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter2003;
     for (_iter2003 = (*(this->group_names)).begin(); _iter2003 != (*(this->group_names)).end(); ++_iter2003)
     {
       xfer += oprot->writeString((*_iter2003));
+=======
+    std::vector<std::string> ::const_iterator _iter2031;
+    for (_iter2031 = (*(this->group_names)).begin(); _iter2031 != (*(this->group_names)).end(); ++_iter2031)
+    {
+      xfer += oprot->writeString((*_iter2031));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -20540,6 +22944,7 @@ uint32_t ThriftHiveMetastore_get_partitions_with_auth_result::read(::apache::thr
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size2004;
             ::apache::thrift::protocol::TType _etype2007;
             xfer += iprot->readListBegin(_etype2007, _size2004);
@@ -20548,6 +22953,16 @@ uint32_t ThriftHiveMetastore_get_partitions_with_auth_result::read(::apache::thr
             for (_i2008 = 0; _i2008 < _size2004; ++_i2008)
             {
               xfer += this->success[_i2008].read(iprot);
+=======
+            uint32_t _size2032;
+            ::apache::thrift::protocol::TType _etype2035;
+            xfer += iprot->readListBegin(_etype2035, _size2032);
+            this->success.resize(_size2032);
+            uint32_t _i2036;
+            for (_i2036 = 0; _i2036 < _size2032; ++_i2036)
+            {
+              xfer += this->success[_i2036].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -20594,10 +23009,17 @@ uint32_t ThriftHiveMetastore_get_partitions_with_auth_result::write(::apache::th
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<Partition> ::const_iterator _iter2009;
       for (_iter2009 = this->success.begin(); _iter2009 != this->success.end(); ++_iter2009)
       {
         xfer += (*_iter2009).write(oprot);
+=======
+      std::vector<Partition> ::const_iterator _iter2037;
+      for (_iter2037 = this->success.begin(); _iter2037 != this->success.end(); ++_iter2037)
+      {
+        xfer += (*_iter2037).write(oprot);
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -20646,6 +23068,7 @@ uint32_t ThriftHiveMetastore_get_partitions_with_auth_presult::read(::apache::th
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size2010;
             ::apache::thrift::protocol::TType _etype2013;
             xfer += iprot->readListBegin(_etype2013, _size2010);
@@ -20654,6 +23077,16 @@ uint32_t ThriftHiveMetastore_get_partitions_with_auth_presult::read(::apache::th
             for (_i2014 = 0; _i2014 < _size2010; ++_i2014)
             {
               xfer += (*(this->success))[_i2014].read(iprot);
+=======
+            uint32_t _size2038;
+            ::apache::thrift::protocol::TType _etype2041;
+            xfer += iprot->readListBegin(_etype2041, _size2038);
+            (*(this->success)).resize(_size2038);
+            uint32_t _i2042;
+            for (_i2042 = 0; _i2042 < _size2038; ++_i2042)
+            {
+              xfer += (*(this->success))[_i2042].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -20831,6 +23264,7 @@ uint32_t ThriftHiveMetastore_get_partitions_pspec_result::read(::apache::thrift:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size2015;
             ::apache::thrift::protocol::TType _etype2018;
             xfer += iprot->readListBegin(_etype2018, _size2015);
@@ -20839,6 +23273,16 @@ uint32_t ThriftHiveMetastore_get_partitions_pspec_result::read(::apache::thrift:
             for (_i2019 = 0; _i2019 < _size2015; ++_i2019)
             {
               xfer += this->success[_i2019].read(iprot);
+=======
+            uint32_t _size2043;
+            ::apache::thrift::protocol::TType _etype2046;
+            xfer += iprot->readListBegin(_etype2046, _size2043);
+            this->success.resize(_size2043);
+            uint32_t _i2047;
+            for (_i2047 = 0; _i2047 < _size2043; ++_i2047)
+            {
+              xfer += this->success[_i2047].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -20885,10 +23329,17 @@ uint32_t ThriftHiveMetastore_get_partitions_pspec_result::write(::apache::thrift
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<PartitionSpec> ::const_iterator _iter2020;
       for (_iter2020 = this->success.begin(); _iter2020 != this->success.end(); ++_iter2020)
       {
         xfer += (*_iter2020).write(oprot);
+=======
+      std::vector<PartitionSpec> ::const_iterator _iter2048;
+      for (_iter2048 = this->success.begin(); _iter2048 != this->success.end(); ++_iter2048)
+      {
+        xfer += (*_iter2048).write(oprot);
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -20937,6 +23388,7 @@ uint32_t ThriftHiveMetastore_get_partitions_pspec_presult::read(::apache::thrift
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size2021;
             ::apache::thrift::protocol::TType _etype2024;
             xfer += iprot->readListBegin(_etype2024, _size2021);
@@ -20945,6 +23397,16 @@ uint32_t ThriftHiveMetastore_get_partitions_pspec_presult::read(::apache::thrift
             for (_i2025 = 0; _i2025 < _size2021; ++_i2025)
             {
               xfer += (*(this->success))[_i2025].read(iprot);
+=======
+            uint32_t _size2049;
+            ::apache::thrift::protocol::TType _etype2052;
+            xfer += iprot->readListBegin(_etype2052, _size2049);
+            (*(this->success)).resize(_size2049);
+            uint32_t _i2053;
+            for (_i2053 = 0; _i2053 < _size2049; ++_i2053)
+            {
+              xfer += (*(this->success))[_i2053].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -21122,6 +23584,7 @@ uint32_t ThriftHiveMetastore_get_partition_names_result::read(::apache::thrift::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size2026;
             ::apache::thrift::protocol::TType _etype2029;
             xfer += iprot->readListBegin(_etype2029, _size2026);
@@ -21130,6 +23593,16 @@ uint32_t ThriftHiveMetastore_get_partition_names_result::read(::apache::thrift::
             for (_i2030 = 0; _i2030 < _size2026; ++_i2030)
             {
               xfer += iprot->readString(this->success[_i2030]);
+=======
+            uint32_t _size2054;
+            ::apache::thrift::protocol::TType _etype2057;
+            xfer += iprot->readListBegin(_etype2057, _size2054);
+            this->success.resize(_size2054);
+            uint32_t _i2058;
+            for (_i2058 = 0; _i2058 < _size2054; ++_i2058)
+            {
+              xfer += iprot->readString(this->success[_i2058]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -21176,10 +23649,17 @@ uint32_t ThriftHiveMetastore_get_partition_names_result::write(::apache::thrift:
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<std::string> ::const_iterator _iter2031;
       for (_iter2031 = this->success.begin(); _iter2031 != this->success.end(); ++_iter2031)
       {
         xfer += oprot->writeString((*_iter2031));
+=======
+      std::vector<std::string> ::const_iterator _iter2059;
+      for (_iter2059 = this->success.begin(); _iter2059 != this->success.end(); ++_iter2059)
+      {
+        xfer += oprot->writeString((*_iter2059));
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -21228,6 +23708,7 @@ uint32_t ThriftHiveMetastore_get_partition_names_presult::read(::apache::thrift:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size2032;
             ::apache::thrift::protocol::TType _etype2035;
             xfer += iprot->readListBegin(_etype2035, _size2032);
@@ -21236,6 +23717,16 @@ uint32_t ThriftHiveMetastore_get_partition_names_presult::read(::apache::thrift:
             for (_i2036 = 0; _i2036 < _size2032; ++_i2036)
             {
               xfer += iprot->readString((*(this->success))[_i2036]);
+=======
+            uint32_t _size2060;
+            ::apache::thrift::protocol::TType _etype2063;
+            xfer += iprot->readListBegin(_etype2063, _size2060);
+            (*(this->success)).resize(_size2060);
+            uint32_t _i2064;
+            for (_i2064 = 0; _i2064 < _size2060; ++_i2064)
+            {
+              xfer += iprot->readString((*(this->success))[_i2064]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -21545,6 +24036,7 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_args::read(::apache::thrift::prot
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
+<<<<<<< HEAD
             uint32_t _size2037;
             ::apache::thrift::protocol::TType _etype2040;
             xfer += iprot->readListBegin(_etype2040, _size2037);
@@ -21553,6 +24045,16 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_args::read(::apache::thrift::prot
             for (_i2041 = 0; _i2041 < _size2037; ++_i2041)
             {
               xfer += iprot->readString(this->part_vals[_i2041]);
+=======
+            uint32_t _size2065;
+            ::apache::thrift::protocol::TType _etype2068;
+            xfer += iprot->readListBegin(_etype2068, _size2065);
+            this->part_vals.resize(_size2065);
+            uint32_t _i2069;
+            for (_i2069 = 0; _i2069 < _size2065; ++_i2069)
+            {
+              xfer += iprot->readString(this->part_vals[_i2069]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -21597,10 +24099,17 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_args::write(::apache::thrift::pro
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter2042;
     for (_iter2042 = this->part_vals.begin(); _iter2042 != this->part_vals.end(); ++_iter2042)
     {
       xfer += oprot->writeString((*_iter2042));
+=======
+    std::vector<std::string> ::const_iterator _iter2070;
+    for (_iter2070 = this->part_vals.begin(); _iter2070 != this->part_vals.end(); ++_iter2070)
+    {
+      xfer += oprot->writeString((*_iter2070));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -21636,10 +24145,17 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_pargs::write(::apache::thrift::pr
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter2043;
     for (_iter2043 = (*(this->part_vals)).begin(); _iter2043 != (*(this->part_vals)).end(); ++_iter2043)
     {
       xfer += oprot->writeString((*_iter2043));
+=======
+    std::vector<std::string> ::const_iterator _iter2071;
+    for (_iter2071 = (*(this->part_vals)).begin(); _iter2071 != (*(this->part_vals)).end(); ++_iter2071)
+    {
+      xfer += oprot->writeString((*_iter2071));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -21684,6 +24200,7 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_result::read(::apache::thrift::pr
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size2044;
             ::apache::thrift::protocol::TType _etype2047;
             xfer += iprot->readListBegin(_etype2047, _size2044);
@@ -21692,6 +24209,16 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_result::read(::apache::thrift::pr
             for (_i2048 = 0; _i2048 < _size2044; ++_i2048)
             {
               xfer += this->success[_i2048].read(iprot);
+=======
+            uint32_t _size2072;
+            ::apache::thrift::protocol::TType _etype2075;
+            xfer += iprot->readListBegin(_etype2075, _size2072);
+            this->success.resize(_size2072);
+            uint32_t _i2076;
+            for (_i2076 = 0; _i2076 < _size2072; ++_i2076)
+            {
+              xfer += this->success[_i2076].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -21738,10 +24265,17 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_result::write(::apache::thrift::p
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<Partition> ::const_iterator _iter2049;
       for (_iter2049 = this->success.begin(); _iter2049 != this->success.end(); ++_iter2049)
       {
         xfer += (*_iter2049).write(oprot);
+=======
+      std::vector<Partition> ::const_iterator _iter2077;
+      for (_iter2077 = this->success.begin(); _iter2077 != this->success.end(); ++_iter2077)
+      {
+        xfer += (*_iter2077).write(oprot);
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -21790,6 +24324,7 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_presult::read(::apache::thrift::p
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size2050;
             ::apache::thrift::protocol::TType _etype2053;
             xfer += iprot->readListBegin(_etype2053, _size2050);
@@ -21798,6 +24333,16 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_presult::read(::apache::thrift::p
             for (_i2054 = 0; _i2054 < _size2050; ++_i2054)
             {
               xfer += (*(this->success))[_i2054].read(iprot);
+=======
+            uint32_t _size2078;
+            ::apache::thrift::protocol::TType _etype2081;
+            xfer += iprot->readListBegin(_etype2081, _size2078);
+            (*(this->success)).resize(_size2078);
+            uint32_t _i2082;
+            for (_i2082 = 0; _i2082 < _size2078; ++_i2082)
+            {
+              xfer += (*(this->success))[_i2082].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -21880,6 +24425,7 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_args::read(::apache::th
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
+<<<<<<< HEAD
             uint32_t _size2055;
             ::apache::thrift::protocol::TType _etype2058;
             xfer += iprot->readListBegin(_etype2058, _size2055);
@@ -21888,6 +24434,16 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_args::read(::apache::th
             for (_i2059 = 0; _i2059 < _size2055; ++_i2059)
             {
               xfer += iprot->readString(this->part_vals[_i2059]);
+=======
+            uint32_t _size2083;
+            ::apache::thrift::protocol::TType _etype2086;
+            xfer += iprot->readListBegin(_etype2086, _size2083);
+            this->part_vals.resize(_size2083);
+            uint32_t _i2087;
+            for (_i2087 = 0; _i2087 < _size2083; ++_i2087)
+            {
+              xfer += iprot->readString(this->part_vals[_i2087]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -21916,6 +24472,7 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_args::read(::apache::th
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->group_names.clear();
+<<<<<<< HEAD
             uint32_t _size2060;
             ::apache::thrift::protocol::TType _etype2063;
             xfer += iprot->readListBegin(_etype2063, _size2060);
@@ -21924,6 +24481,16 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_args::read(::apache::th
             for (_i2064 = 0; _i2064 < _size2060; ++_i2064)
             {
               xfer += iprot->readString(this->group_names[_i2064]);
+=======
+            uint32_t _size2088;
+            ::apache::thrift::protocol::TType _etype2091;
+            xfer += iprot->readListBegin(_etype2091, _size2088);
+            this->group_names.resize(_size2088);
+            uint32_t _i2092;
+            for (_i2092 = 0; _i2092 < _size2088; ++_i2092)
+            {
+              xfer += iprot->readString(this->group_names[_i2092]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -21960,10 +24527,17 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_args::write(::apache::t
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter2065;
     for (_iter2065 = this->part_vals.begin(); _iter2065 != this->part_vals.end(); ++_iter2065)
     {
       xfer += oprot->writeString((*_iter2065));
+=======
+    std::vector<std::string> ::const_iterator _iter2093;
+    for (_iter2093 = this->part_vals.begin(); _iter2093 != this->part_vals.end(); ++_iter2093)
+    {
+      xfer += oprot->writeString((*_iter2093));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -21980,10 +24554,17 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_args::write(::apache::t
   xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 6);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->group_names.size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter2066;
     for (_iter2066 = this->group_names.begin(); _iter2066 != this->group_names.end(); ++_iter2066)
     {
       xfer += oprot->writeString((*_iter2066));
+=======
+    std::vector<std::string> ::const_iterator _iter2094;
+    for (_iter2094 = this->group_names.begin(); _iter2094 != this->group_names.end(); ++_iter2094)
+    {
+      xfer += oprot->writeString((*_iter2094));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -22015,10 +24596,17 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_pargs::write(::apache::
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter2067;
     for (_iter2067 = (*(this->part_vals)).begin(); _iter2067 != (*(this->part_vals)).end(); ++_iter2067)
     {
       xfer += oprot->writeString((*_iter2067));
+=======
+    std::vector<std::string> ::const_iterator _iter2095;
+    for (_iter2095 = (*(this->part_vals)).begin(); _iter2095 != (*(this->part_vals)).end(); ++_iter2095)
+    {
+      xfer += oprot->writeString((*_iter2095));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -22035,10 +24623,17 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_pargs::write(::apache::
   xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 6);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->group_names)).size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter2068;
     for (_iter2068 = (*(this->group_names)).begin(); _iter2068 != (*(this->group_names)).end(); ++_iter2068)
     {
       xfer += oprot->writeString((*_iter2068));
+=======
+    std::vector<std::string> ::const_iterator _iter2096;
+    for (_iter2096 = (*(this->group_names)).begin(); _iter2096 != (*(this->group_names)).end(); ++_iter2096)
+    {
+      xfer += oprot->writeString((*_iter2096));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -22079,6 +24674,7 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_result::read(::apache::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size2069;
             ::apache::thrift::protocol::TType _etype2072;
             xfer += iprot->readListBegin(_etype2072, _size2069);
@@ -22087,6 +24683,16 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_result::read(::apache::
             for (_i2073 = 0; _i2073 < _size2069; ++_i2073)
             {
               xfer += this->success[_i2073].read(iprot);
+=======
+            uint32_t _size2097;
+            ::apache::thrift::protocol::TType _etype2100;
+            xfer += iprot->readListBegin(_etype2100, _size2097);
+            this->success.resize(_size2097);
+            uint32_t _i2101;
+            for (_i2101 = 0; _i2101 < _size2097; ++_i2101)
+            {
+              xfer += this->success[_i2101].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -22133,10 +24739,17 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_result::write(::apache:
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<Partition> ::const_iterator _iter2074;
       for (_iter2074 = this->success.begin(); _iter2074 != this->success.end(); ++_iter2074)
       {
         xfer += (*_iter2074).write(oprot);
+=======
+      std::vector<Partition> ::const_iterator _iter2102;
+      for (_iter2102 = this->success.begin(); _iter2102 != this->success.end(); ++_iter2102)
+      {
+        xfer += (*_iter2102).write(oprot);
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -22185,6 +24798,7 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_presult::read(::apache:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size2075;
             ::apache::thrift::protocol::TType _etype2078;
             xfer += iprot->readListBegin(_etype2078, _size2075);
@@ -22193,6 +24807,16 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_presult::read(::apache:
             for (_i2079 = 0; _i2079 < _size2075; ++_i2079)
             {
               xfer += (*(this->success))[_i2079].read(iprot);
+=======
+            uint32_t _size2103;
+            ::apache::thrift::protocol::TType _etype2106;
+            xfer += iprot->readListBegin(_etype2106, _size2103);
+            (*(this->success)).resize(_size2103);
+            uint32_t _i2107;
+            for (_i2107 = 0; _i2107 < _size2103; ++_i2107)
+            {
+              xfer += (*(this->success))[_i2107].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -22502,6 +25126,7 @@ uint32_t ThriftHiveMetastore_get_partition_names_ps_args::read(::apache::thrift:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
+<<<<<<< HEAD
             uint32_t _size2080;
             ::apache::thrift::protocol::TType _etype2083;
             xfer += iprot->readListBegin(_etype2083, _size2080);
@@ -22510,6 +25135,16 @@ uint32_t ThriftHiveMetastore_get_partition_names_ps_args::read(::apache::thrift:
             for (_i2084 = 0; _i2084 < _size2080; ++_i2084)
             {
               xfer += iprot->readString(this->part_vals[_i2084]);
+=======
+            uint32_t _size2108;
+            ::apache::thrift::protocol::TType _etype2111;
+            xfer += iprot->readListBegin(_etype2111, _size2108);
+            this->part_vals.resize(_size2108);
+            uint32_t _i2112;
+            for (_i2112 = 0; _i2112 < _size2108; ++_i2112)
+            {
+              xfer += iprot->readString(this->part_vals[_i2112]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -22554,10 +25189,17 @@ uint32_t ThriftHiveMetastore_get_partition_names_ps_args::write(::apache::thrift
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter2085;
     for (_iter2085 = this->part_vals.begin(); _iter2085 != this->part_vals.end(); ++_iter2085)
     {
       xfer += oprot->writeString((*_iter2085));
+=======
+    std::vector<std::string> ::const_iterator _iter2113;
+    for (_iter2113 = this->part_vals.begin(); _iter2113 != this->part_vals.end(); ++_iter2113)
+    {
+      xfer += oprot->writeString((*_iter2113));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -22593,10 +25235,17 @@ uint32_t ThriftHiveMetastore_get_partition_names_ps_pargs::write(::apache::thrif
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter2086;
     for (_iter2086 = (*(this->part_vals)).begin(); _iter2086 != (*(this->part_vals)).end(); ++_iter2086)
     {
       xfer += oprot->writeString((*_iter2086));
+=======
+    std::vector<std::string> ::const_iterator _iter2114;
+    for (_iter2114 = (*(this->part_vals)).begin(); _iter2114 != (*(this->part_vals)).end(); ++_iter2114)
+    {
+      xfer += oprot->writeString((*_iter2114));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -22641,6 +25290,7 @@ uint32_t ThriftHiveMetastore_get_partition_names_ps_result::read(::apache::thrif
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size2087;
             ::apache::thrift::protocol::TType _etype2090;
             xfer += iprot->readListBegin(_etype2090, _size2087);
@@ -22649,6 +25299,16 @@ uint32_t ThriftHiveMetastore_get_partition_names_ps_result::read(::apache::thrif
             for (_i2091 = 0; _i2091 < _size2087; ++_i2091)
             {
               xfer += iprot->readString(this->success[_i2091]);
+=======
+            uint32_t _size2115;
+            ::apache::thrift::protocol::TType _etype2118;
+            xfer += iprot->readListBegin(_etype2118, _size2115);
+            this->success.resize(_size2115);
+            uint32_t _i2119;
+            for (_i2119 = 0; _i2119 < _size2115; ++_i2119)
+            {
+              xfer += iprot->readString(this->success[_i2119]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -22695,10 +25355,17 @@ uint32_t ThriftHiveMetastore_get_partition_names_ps_result::write(::apache::thri
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<std::string> ::const_iterator _iter2092;
       for (_iter2092 = this->success.begin(); _iter2092 != this->success.end(); ++_iter2092)
       {
         xfer += oprot->writeString((*_iter2092));
+=======
+      std::vector<std::string> ::const_iterator _iter2120;
+      for (_iter2120 = this->success.begin(); _iter2120 != this->success.end(); ++_iter2120)
+      {
+        xfer += oprot->writeString((*_iter2120));
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -22747,6 +25414,7 @@ uint32_t ThriftHiveMetastore_get_partition_names_ps_presult::read(::apache::thri
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size2093;
             ::apache::thrift::protocol::TType _etype2096;
             xfer += iprot->readListBegin(_etype2096, _size2093);
@@ -22755,6 +25423,16 @@ uint32_t ThriftHiveMetastore_get_partition_names_ps_presult::read(::apache::thri
             for (_i2097 = 0; _i2097 < _size2093; ++_i2097)
             {
               xfer += iprot->readString((*(this->success))[_i2097]);
+=======
+            uint32_t _size2121;
+            ::apache::thrift::protocol::TType _etype2124;
+            xfer += iprot->readListBegin(_etype2124, _size2121);
+            (*(this->success)).resize(_size2121);
+            uint32_t _i2125;
+            for (_i2125 = 0; _i2125 < _size2121; ++_i2125)
+            {
+              xfer += iprot->readString((*(this->success))[_i2125]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -23127,6 +25805,7 @@ uint32_t ThriftHiveMetastore_get_partition_names_req_result::read(::apache::thri
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size2098;
             ::apache::thrift::protocol::TType _etype2101;
             xfer += iprot->readListBegin(_etype2101, _size2098);
@@ -23135,6 +25814,16 @@ uint32_t ThriftHiveMetastore_get_partition_names_req_result::read(::apache::thri
             for (_i2102 = 0; _i2102 < _size2098; ++_i2102)
             {
               xfer += iprot->readString(this->success[_i2102]);
+=======
+            uint32_t _size2126;
+            ::apache::thrift::protocol::TType _etype2129;
+            xfer += iprot->readListBegin(_etype2129, _size2126);
+            this->success.resize(_size2126);
+            uint32_t _i2130;
+            for (_i2130 = 0; _i2130 < _size2126; ++_i2130)
+            {
+              xfer += iprot->readString(this->success[_i2130]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -23181,10 +25870,17 @@ uint32_t ThriftHiveMetastore_get_partition_names_req_result::write(::apache::thr
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<std::string> ::const_iterator _iter2103;
       for (_iter2103 = this->success.begin(); _iter2103 != this->success.end(); ++_iter2103)
       {
         xfer += oprot->writeString((*_iter2103));
+=======
+      std::vector<std::string> ::const_iterator _iter2131;
+      for (_iter2131 = this->success.begin(); _iter2131 != this->success.end(); ++_iter2131)
+      {
+        xfer += oprot->writeString((*_iter2131));
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -23233,6 +25929,7 @@ uint32_t ThriftHiveMetastore_get_partition_names_req_presult::read(::apache::thr
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size2104;
             ::apache::thrift::protocol::TType _etype2107;
             xfer += iprot->readListBegin(_etype2107, _size2104);
@@ -23241,6 +25938,16 @@ uint32_t ThriftHiveMetastore_get_partition_names_req_presult::read(::apache::thr
             for (_i2108 = 0; _i2108 < _size2104; ++_i2108)
             {
               xfer += iprot->readString((*(this->success))[_i2108]);
+=======
+            uint32_t _size2132;
+            ::apache::thrift::protocol::TType _etype2135;
+            xfer += iprot->readListBegin(_etype2135, _size2132);
+            (*(this->success)).resize(_size2132);
+            uint32_t _i2136;
+            for (_i2136 = 0; _i2136 < _size2132; ++_i2136)
+            {
+              xfer += iprot->readString((*(this->success))[_i2136]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -23434,6 +26141,7 @@ uint32_t ThriftHiveMetastore_get_partitions_by_filter_result::read(::apache::thr
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size2109;
             ::apache::thrift::protocol::TType _etype2112;
             xfer += iprot->readListBegin(_etype2112, _size2109);
@@ -23442,6 +26150,16 @@ uint32_t ThriftHiveMetastore_get_partitions_by_filter_result::read(::apache::thr
             for (_i2113 = 0; _i2113 < _size2109; ++_i2113)
             {
               xfer += this->success[_i2113].read(iprot);
+=======
+            uint32_t _size2137;
+            ::apache::thrift::protocol::TType _etype2140;
+            xfer += iprot->readListBegin(_etype2140, _size2137);
+            this->success.resize(_size2137);
+            uint32_t _i2141;
+            for (_i2141 = 0; _i2141 < _size2137; ++_i2141)
+            {
+              xfer += this->success[_i2141].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -23488,10 +26206,17 @@ uint32_t ThriftHiveMetastore_get_partitions_by_filter_result::write(::apache::th
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<Partition> ::const_iterator _iter2114;
       for (_iter2114 = this->success.begin(); _iter2114 != this->success.end(); ++_iter2114)
       {
         xfer += (*_iter2114).write(oprot);
+=======
+      std::vector<Partition> ::const_iterator _iter2142;
+      for (_iter2142 = this->success.begin(); _iter2142 != this->success.end(); ++_iter2142)
+      {
+        xfer += (*_iter2142).write(oprot);
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -23540,6 +26265,7 @@ uint32_t ThriftHiveMetastore_get_partitions_by_filter_presult::read(::apache::th
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size2115;
             ::apache::thrift::protocol::TType _etype2118;
             xfer += iprot->readListBegin(_etype2118, _size2115);
@@ -23548,6 +26274,16 @@ uint32_t ThriftHiveMetastore_get_partitions_by_filter_presult::read(::apache::th
             for (_i2119 = 0; _i2119 < _size2115; ++_i2119)
             {
               xfer += (*(this->success))[_i2119].read(iprot);
+=======
+            uint32_t _size2143;
+            ::apache::thrift::protocol::TType _etype2146;
+            xfer += iprot->readListBegin(_etype2146, _size2143);
+            (*(this->success)).resize(_size2143);
+            uint32_t _i2147;
+            for (_i2147 = 0; _i2147 < _size2143; ++_i2147)
+            {
+              xfer += (*(this->success))[_i2147].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -23741,6 +26477,7 @@ uint32_t ThriftHiveMetastore_get_part_specs_by_filter_result::read(::apache::thr
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size2120;
             ::apache::thrift::protocol::TType _etype2123;
             xfer += iprot->readListBegin(_etype2123, _size2120);
@@ -23749,6 +26486,16 @@ uint32_t ThriftHiveMetastore_get_part_specs_by_filter_result::read(::apache::thr
             for (_i2124 = 0; _i2124 < _size2120; ++_i2124)
             {
               xfer += this->success[_i2124].read(iprot);
+=======
+            uint32_t _size2148;
+            ::apache::thrift::protocol::TType _etype2151;
+            xfer += iprot->readListBegin(_etype2151, _size2148);
+            this->success.resize(_size2148);
+            uint32_t _i2152;
+            for (_i2152 = 0; _i2152 < _size2148; ++_i2152)
+            {
+              xfer += this->success[_i2152].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -23795,10 +26542,17 @@ uint32_t ThriftHiveMetastore_get_part_specs_by_filter_result::write(::apache::th
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<PartitionSpec> ::const_iterator _iter2125;
       for (_iter2125 = this->success.begin(); _iter2125 != this->success.end(); ++_iter2125)
       {
         xfer += (*_iter2125).write(oprot);
+=======
+      std::vector<PartitionSpec> ::const_iterator _iter2153;
+      for (_iter2153 = this->success.begin(); _iter2153 != this->success.end(); ++_iter2153)
+      {
+        xfer += (*_iter2153).write(oprot);
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -23847,6 +26601,7 @@ uint32_t ThriftHiveMetastore_get_part_specs_by_filter_presult::read(::apache::th
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size2126;
             ::apache::thrift::protocol::TType _etype2129;
             xfer += iprot->readListBegin(_etype2129, _size2126);
@@ -23855,6 +26610,16 @@ uint32_t ThriftHiveMetastore_get_part_specs_by_filter_presult::read(::apache::th
             for (_i2130 = 0; _i2130 < _size2126; ++_i2130)
             {
               xfer += (*(this->success))[_i2130].read(iprot);
+=======
+            uint32_t _size2154;
+            ::apache::thrift::protocol::TType _etype2157;
+            xfer += iprot->readListBegin(_etype2157, _size2154);
+            (*(this->success)).resize(_size2154);
+            uint32_t _i2158;
+            for (_i2158 = 0; _i2158 < _size2154; ++_i2158)
+            {
+              xfer += (*(this->success))[_i2158].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -24650,6 +27415,7 @@ uint32_t ThriftHiveMetastore_get_partitions_by_names_args::read(::apache::thrift
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->names.clear();
+<<<<<<< HEAD
             uint32_t _size2131;
             ::apache::thrift::protocol::TType _etype2134;
             xfer += iprot->readListBegin(_etype2134, _size2131);
@@ -24658,6 +27424,16 @@ uint32_t ThriftHiveMetastore_get_partitions_by_names_args::read(::apache::thrift
             for (_i2135 = 0; _i2135 < _size2131; ++_i2135)
             {
               xfer += iprot->readString(this->names[_i2135]);
+=======
+            uint32_t _size2159;
+            ::apache::thrift::protocol::TType _etype2162;
+            xfer += iprot->readListBegin(_etype2162, _size2159);
+            this->names.resize(_size2159);
+            uint32_t _i2163;
+            for (_i2163 = 0; _i2163 < _size2159; ++_i2163)
+            {
+              xfer += iprot->readString(this->names[_i2163]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -24694,10 +27470,17 @@ uint32_t ThriftHiveMetastore_get_partitions_by_names_args::write(::apache::thrif
   xfer += oprot->writeFieldBegin("names", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->names.size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter2136;
     for (_iter2136 = this->names.begin(); _iter2136 != this->names.end(); ++_iter2136)
     {
       xfer += oprot->writeString((*_iter2136));
+=======
+    std::vector<std::string> ::const_iterator _iter2164;
+    for (_iter2164 = this->names.begin(); _iter2164 != this->names.end(); ++_iter2164)
+    {
+      xfer += oprot->writeString((*_iter2164));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -24729,10 +27512,17 @@ uint32_t ThriftHiveMetastore_get_partitions_by_names_pargs::write(::apache::thri
   xfer += oprot->writeFieldBegin("names", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->names)).size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter2137;
     for (_iter2137 = (*(this->names)).begin(); _iter2137 != (*(this->names)).end(); ++_iter2137)
     {
       xfer += oprot->writeString((*_iter2137));
+=======
+    std::vector<std::string> ::const_iterator _iter2165;
+    for (_iter2165 = (*(this->names)).begin(); _iter2165 != (*(this->names)).end(); ++_iter2165)
+    {
+      xfer += oprot->writeString((*_iter2165));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -24773,6 +27563,7 @@ uint32_t ThriftHiveMetastore_get_partitions_by_names_result::read(::apache::thri
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size2138;
             ::apache::thrift::protocol::TType _etype2141;
             xfer += iprot->readListBegin(_etype2141, _size2138);
@@ -24781,6 +27572,16 @@ uint32_t ThriftHiveMetastore_get_partitions_by_names_result::read(::apache::thri
             for (_i2142 = 0; _i2142 < _size2138; ++_i2142)
             {
               xfer += this->success[_i2142].read(iprot);
+=======
+            uint32_t _size2166;
+            ::apache::thrift::protocol::TType _etype2169;
+            xfer += iprot->readListBegin(_etype2169, _size2166);
+            this->success.resize(_size2166);
+            uint32_t _i2170;
+            for (_i2170 = 0; _i2170 < _size2166; ++_i2170)
+            {
+              xfer += this->success[_i2170].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -24827,10 +27628,17 @@ uint32_t ThriftHiveMetastore_get_partitions_by_names_result::write(::apache::thr
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<Partition> ::const_iterator _iter2143;
       for (_iter2143 = this->success.begin(); _iter2143 != this->success.end(); ++_iter2143)
       {
         xfer += (*_iter2143).write(oprot);
+=======
+      std::vector<Partition> ::const_iterator _iter2171;
+      for (_iter2171 = this->success.begin(); _iter2171 != this->success.end(); ++_iter2171)
+      {
+        xfer += (*_iter2171).write(oprot);
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -24879,6 +27687,7 @@ uint32_t ThriftHiveMetastore_get_partitions_by_names_presult::read(::apache::thr
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size2144;
             ::apache::thrift::protocol::TType _etype2147;
             xfer += iprot->readListBegin(_etype2147, _size2144);
@@ -24887,6 +27696,16 @@ uint32_t ThriftHiveMetastore_get_partitions_by_names_presult::read(::apache::thr
             for (_i2148 = 0; _i2148 < _size2144; ++_i2148)
             {
               xfer += (*(this->success))[_i2148].read(iprot);
+=======
+            uint32_t _size2172;
+            ::apache::thrift::protocol::TType _etype2175;
+            xfer += iprot->readListBegin(_etype2175, _size2172);
+            (*(this->success)).resize(_size2172);
+            uint32_t _i2176;
+            for (_i2176 = 0; _i2176 < _size2172; ++_i2176)
+            {
+              xfer += (*(this->success))[_i2176].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -25435,6 +28254,7 @@ uint32_t ThriftHiveMetastore_alter_partitions_args::read(::apache::thrift::proto
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->new_parts.clear();
+<<<<<<< HEAD
             uint32_t _size2149;
             ::apache::thrift::protocol::TType _etype2152;
             xfer += iprot->readListBegin(_etype2152, _size2149);
@@ -25443,6 +28263,16 @@ uint32_t ThriftHiveMetastore_alter_partitions_args::read(::apache::thrift::proto
             for (_i2153 = 0; _i2153 < _size2149; ++_i2153)
             {
               xfer += this->new_parts[_i2153].read(iprot);
+=======
+            uint32_t _size2177;
+            ::apache::thrift::protocol::TType _etype2180;
+            xfer += iprot->readListBegin(_etype2180, _size2177);
+            this->new_parts.resize(_size2177);
+            uint32_t _i2181;
+            for (_i2181 = 0; _i2181 < _size2177; ++_i2181)
+            {
+              xfer += this->new_parts[_i2181].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -25479,10 +28309,17 @@ uint32_t ThriftHiveMetastore_alter_partitions_args::write(::apache::thrift::prot
   xfer += oprot->writeFieldBegin("new_parts", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->new_parts.size()));
+<<<<<<< HEAD
     std::vector<Partition> ::const_iterator _iter2154;
     for (_iter2154 = this->new_parts.begin(); _iter2154 != this->new_parts.end(); ++_iter2154)
     {
       xfer += (*_iter2154).write(oprot);
+=======
+    std::vector<Partition> ::const_iterator _iter2182;
+    for (_iter2182 = this->new_parts.begin(); _iter2182 != this->new_parts.end(); ++_iter2182)
+    {
+      xfer += (*_iter2182).write(oprot);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -25514,10 +28351,17 @@ uint32_t ThriftHiveMetastore_alter_partitions_pargs::write(::apache::thrift::pro
   xfer += oprot->writeFieldBegin("new_parts", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->new_parts)).size()));
+<<<<<<< HEAD
     std::vector<Partition> ::const_iterator _iter2155;
     for (_iter2155 = (*(this->new_parts)).begin(); _iter2155 != (*(this->new_parts)).end(); ++_iter2155)
     {
       xfer += (*_iter2155).write(oprot);
+=======
+    std::vector<Partition> ::const_iterator _iter2183;
+    for (_iter2183 = (*(this->new_parts)).begin(); _iter2183 != (*(this->new_parts)).end(); ++_iter2183)
+    {
+      xfer += (*_iter2183).write(oprot);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -25702,6 +28546,7 @@ uint32_t ThriftHiveMetastore_alter_partitions_with_environment_context_args::rea
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->new_parts.clear();
+<<<<<<< HEAD
             uint32_t _size2156;
             ::apache::thrift::protocol::TType _etype2159;
             xfer += iprot->readListBegin(_etype2159, _size2156);
@@ -25710,6 +28555,16 @@ uint32_t ThriftHiveMetastore_alter_partitions_with_environment_context_args::rea
             for (_i2160 = 0; _i2160 < _size2156; ++_i2160)
             {
               xfer += this->new_parts[_i2160].read(iprot);
+=======
+            uint32_t _size2184;
+            ::apache::thrift::protocol::TType _etype2187;
+            xfer += iprot->readListBegin(_etype2187, _size2184);
+            this->new_parts.resize(_size2184);
+            uint32_t _i2188;
+            for (_i2188 = 0; _i2188 < _size2184; ++_i2188)
+            {
+              xfer += this->new_parts[_i2188].read(iprot);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -25754,10 +28609,17 @@ uint32_t ThriftHiveMetastore_alter_partitions_with_environment_context_args::wri
   xfer += oprot->writeFieldBegin("new_parts", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->new_parts.size()));
+<<<<<<< HEAD
     std::vector<Partition> ::const_iterator _iter2161;
     for (_iter2161 = this->new_parts.begin(); _iter2161 != this->new_parts.end(); ++_iter2161)
     {
       xfer += (*_iter2161).write(oprot);
+=======
+    std::vector<Partition> ::const_iterator _iter2189;
+    for (_iter2189 = this->new_parts.begin(); _iter2189 != this->new_parts.end(); ++_iter2189)
+    {
+      xfer += (*_iter2189).write(oprot);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -25793,10 +28655,17 @@ uint32_t ThriftHiveMetastore_alter_partitions_with_environment_context_pargs::wr
   xfer += oprot->writeFieldBegin("new_parts", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->new_parts)).size()));
+<<<<<<< HEAD
     std::vector<Partition> ::const_iterator _iter2162;
     for (_iter2162 = (*(this->new_parts)).begin(); _iter2162 != (*(this->new_parts)).end(); ++_iter2162)
     {
       xfer += (*_iter2162).write(oprot);
+=======
+    std::vector<Partition> ::const_iterator _iter2190;
+    for (_iter2190 = (*(this->new_parts)).begin(); _iter2190 != (*(this->new_parts)).end(); ++_iter2190)
+    {
+      xfer += (*_iter2190).write(oprot);
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -26467,6 +29336,7 @@ uint32_t ThriftHiveMetastore_rename_partition_args::read(::apache::thrift::proto
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
+<<<<<<< HEAD
             uint32_t _size2163;
             ::apache::thrift::protocol::TType _etype2166;
             xfer += iprot->readListBegin(_etype2166, _size2163);
@@ -26475,6 +29345,16 @@ uint32_t ThriftHiveMetastore_rename_partition_args::read(::apache::thrift::proto
             for (_i2167 = 0; _i2167 < _size2163; ++_i2167)
             {
               xfer += iprot->readString(this->part_vals[_i2167]);
+=======
+            uint32_t _size2191;
+            ::apache::thrift::protocol::TType _etype2194;
+            xfer += iprot->readListBegin(_etype2194, _size2191);
+            this->part_vals.resize(_size2191);
+            uint32_t _i2195;
+            for (_i2195 = 0; _i2195 < _size2191; ++_i2195)
+            {
+              xfer += iprot->readString(this->part_vals[_i2195]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -26519,10 +29399,17 @@ uint32_t ThriftHiveMetastore_rename_partition_args::write(::apache::thrift::prot
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter2168;
     for (_iter2168 = this->part_vals.begin(); _iter2168 != this->part_vals.end(); ++_iter2168)
     {
       xfer += oprot->writeString((*_iter2168));
+=======
+    std::vector<std::string> ::const_iterator _iter2196;
+    for (_iter2196 = this->part_vals.begin(); _iter2196 != this->part_vals.end(); ++_iter2196)
+    {
+      xfer += oprot->writeString((*_iter2196));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -26558,10 +29445,17 @@ uint32_t ThriftHiveMetastore_rename_partition_pargs::write(::apache::thrift::pro
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter2169;
     for (_iter2169 = (*(this->part_vals)).begin(); _iter2169 != (*(this->part_vals)).end(); ++_iter2169)
     {
       xfer += oprot->writeString((*_iter2169));
+=======
+    std::vector<std::string> ::const_iterator _iter2197;
+    for (_iter2197 = (*(this->part_vals)).begin(); _iter2197 != (*(this->part_vals)).end(); ++_iter2197)
+    {
+      xfer += oprot->writeString((*_iter2197));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -26961,6 +29855,7 @@ uint32_t ThriftHiveMetastore_partition_name_has_valid_characters_args::read(::ap
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
+<<<<<<< HEAD
             uint32_t _size2170;
             ::apache::thrift::protocol::TType _etype2173;
             xfer += iprot->readListBegin(_etype2173, _size2170);
@@ -26969,6 +29864,16 @@ uint32_t ThriftHiveMetastore_partition_name_has_valid_characters_args::read(::ap
             for (_i2174 = 0; _i2174 < _size2170; ++_i2174)
             {
               xfer += iprot->readString(this->part_vals[_i2174]);
+=======
+            uint32_t _size2198;
+            ::apache::thrift::protocol::TType _etype2201;
+            xfer += iprot->readListBegin(_etype2201, _size2198);
+            this->part_vals.resize(_size2198);
+            uint32_t _i2202;
+            for (_i2202 = 0; _i2202 < _size2198; ++_i2202)
+            {
+              xfer += iprot->readString(this->part_vals[_i2202]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -27005,10 +29910,17 @@ uint32_t ThriftHiveMetastore_partition_name_has_valid_characters_args::write(::a
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 1);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter2175;
     for (_iter2175 = this->part_vals.begin(); _iter2175 != this->part_vals.end(); ++_iter2175)
     {
       xfer += oprot->writeString((*_iter2175));
+=======
+    std::vector<std::string> ::const_iterator _iter2203;
+    for (_iter2203 = this->part_vals.begin(); _iter2203 != this->part_vals.end(); ++_iter2203)
+    {
+      xfer += oprot->writeString((*_iter2203));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -27036,10 +29948,17 @@ uint32_t ThriftHiveMetastore_partition_name_has_valid_characters_pargs::write(::
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 1);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
+<<<<<<< HEAD
     std::vector<std::string> ::const_iterator _iter2176;
     for (_iter2176 = (*(this->part_vals)).begin(); _iter2176 != (*(this->part_vals)).end(); ++_iter2176)
     {
       xfer += oprot->writeString((*_iter2176));
+=======
+    std::vector<std::string> ::const_iterator _iter2204;
+    for (_iter2204 = (*(this->part_vals)).begin(); _iter2204 != (*(this->part_vals)).end(); ++_iter2204)
+    {
+      xfer += oprot->writeString((*_iter2204));
+>>>>>>> External metastore: clean after rebase
     }
     xfer += oprot->writeListEnd();
   }
@@ -27514,6 +30433,7 @@ uint32_t ThriftHiveMetastore_partition_name_to_vals_result::read(::apache::thrif
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size2177;
             ::apache::thrift::protocol::TType _etype2180;
             xfer += iprot->readListBegin(_etype2180, _size2177);
@@ -27522,6 +30442,16 @@ uint32_t ThriftHiveMetastore_partition_name_to_vals_result::read(::apache::thrif
             for (_i2181 = 0; _i2181 < _size2177; ++_i2181)
             {
               xfer += iprot->readString(this->success[_i2181]);
+=======
+            uint32_t _size2205;
+            ::apache::thrift::protocol::TType _etype2208;
+            xfer += iprot->readListBegin(_etype2208, _size2205);
+            this->success.resize(_size2205);
+            uint32_t _i2209;
+            for (_i2209 = 0; _i2209 < _size2205; ++_i2209)
+            {
+              xfer += iprot->readString(this->success[_i2209]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -27560,10 +30490,17 @@ uint32_t ThriftHiveMetastore_partition_name_to_vals_result::write(::apache::thri
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
+<<<<<<< HEAD
       std::vector<std::string> ::const_iterator _iter2182;
       for (_iter2182 = this->success.begin(); _iter2182 != this->success.end(); ++_iter2182)
       {
         xfer += oprot->writeString((*_iter2182));
+=======
+      std::vector<std::string> ::const_iterator _iter2210;
+      for (_iter2210 = this->success.begin(); _iter2210 != this->success.end(); ++_iter2210)
+      {
+        xfer += oprot->writeString((*_iter2210));
+>>>>>>> External metastore: clean after rebase
       }
       xfer += oprot->writeListEnd();
     }
@@ -27608,6 +30545,7 @@ uint32_t ThriftHiveMetastore_partition_name_to_vals_presult::read(::apache::thri
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
+<<<<<<< HEAD
             uint32_t _size2183;
             ::apache::thrift::protocol::TType _etype2186;
             xfer += iprot->readListBegin(_etype2186, _size2183);
@@ -27616,6 +30554,16 @@ uint32_t ThriftHiveMetastore_partition_name_to_vals_presult::read(::apache::thri
             for (_i2187 = 0; _i2187 < _size2183; ++_i2187)
             {
               xfer += iprot->readString((*(this->success))[_i2187]);
+=======
+            uint32_t _size2211;
+            ::apache::thrift::protocol::TType _etype2214;
+            xfer += iprot->readListBegin(_etype2214, _size2211);
+            (*(this->success)).resize(_size2211);
+            uint32_t _i2215;
+            for (_i2215 = 0; _i2215 < _size2211; ++_i2215)
+            {
+              xfer += iprot->readString((*(this->success))[_i2215]);
+>>>>>>> External metastore: clean after rebase
             }
             xfer += iprot->readListEnd();
           }
@@ -27753,6 +30701,7 @@ uint32_t ThriftHiveMetastore_partition_name_to_spec_result::read(::apache::thrif
         if (ftype == ::apache::thrift::protocol::T_MAP) {
           {
             this->success.clear();
+<<<<<<< HEAD
             uint32_t _size2188;
             ::apache::thrift::protocol::TType _ktype2189;
             ::apache::thrift::protocol::TType _vtype2190;
@@ -27764,6 +30713,19 @@ uint32_t ThriftHiveMetastore_partition_name_to_spec_result::read(::apache::thrif
               xfer += iprot->readString(_key2193);
               std::string& _val2194 = this->success[_key2193];
               xfer += iprot->readString(_val2194);
+=======
+            uint32_t _size2216;
+            ::apache::thrift::protocol::TType _ktype2217;
+            ::apache::thrift::protocol::TType _vtype2218;
+            xfer += iprot->readMapBegin(_ktype2217, _vtype2218, _size2216);
... 76708 lines suppressed ...

[hive] 38/38: HIVE-24396: Additional feedback incorporated (Naveen Gangam) Removed ReplicationSpec for connectors Notification event for alter connector removed some code.

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 2eb0e00d5d614d3144519cf4861ec1759a373c7d
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Fri Apr 2 16:02:20 2021 -0400

    HIVE-24396: Additional feedback incorporated (Naveen Gangam)
                Removed ReplicationSpec for connectors
                Notification event for alter connector
                removed some code.
---
 .../alter/AbstractAlterDataConnectorDesc.java      | 13 +----
 .../alter/AbstractAlterDataConnectorOperation.java | 12 ++---
 .../owner/AlterDataConnectorSetOwnerAnalyzer.java  |  2 +-
 .../owner/AlterDataConnectorSetOwnerDesc.java      |  5 +-
 .../owner/AlterDataConnectorSetOwnerOperation.java |  4 +-
 .../AlterDataConnectorSetPropertiesAnalyzer.java   |  2 +-
 .../AlterDataConnectorSetPropertiesDesc.java       |  6 +--
 .../AlterDataConnectorSetPropertiesOperation.java  |  3 +-
 .../alter/url/AlterDataConnectorSetUrlDesc.java    |  2 +-
 .../url/AlterDataConnectorSetUrlOperation.java     |  3 +-
 .../drop/DropDataConnectorAnalyzer.java            |  3 +-
 .../dataconnector/drop/DropDataConnectorDesc.java  | 13 +----
 .../drop/DropDataConnectorOperation.java           | 22 +--------
 .../hive/metastore/MetaStoreEventListener.java     |  8 +++
 .../hive/metastore/MetaStoreListenerNotifier.java  |  8 +++
 .../DataConnectorProviderFactory.java              | 12 -----
 .../metastore/events/AlterDataConnectorEvent.java  | 57 ++++++++++++++++++++++
 17 files changed, 92 insertions(+), 83 deletions(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorDesc.java
index 281378f..2258161 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorDesc.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorDesc.java
@@ -21,7 +21,6 @@ package org.apache.hadoop.hive.ql.ddl.dataconnector.alter;
 import java.io.Serializable;
 
 import org.apache.hadoop.hive.ql.ddl.DDLDesc;
-import org.apache.hadoop.hive.ql.parse.ReplicationSpec;
 import org.apache.hadoop.hive.ql.plan.Explain;
 import org.apache.hadoop.hive.ql.plan.Explain.Level;
 
@@ -32,23 +31,13 @@ public abstract class AbstractAlterDataConnectorDesc implements DDLDesc, Seriali
   private static final long serialVersionUID = 1L;
 
   private final String connectorName;
-  private final ReplicationSpec replicationSpec;
 
-  public AbstractAlterDataConnectorDesc(String connectorName, ReplicationSpec replicationSpec) {
+  public AbstractAlterDataConnectorDesc(String connectorName) {
     this.connectorName = connectorName;
-    this.replicationSpec = replicationSpec;
   }
 
   @Explain(displayName="name", explainLevels = {Level.USER, Level.DEFAULT, Level.EXTENDED })
   public String getConnectorName() {
     return connectorName;
   }
-
-  /**
-   * @return what kind of replication scope this alter is running under.
-   * This can result in a "ALTER IF NEWER THAN" kind of semantic
-   */
-  public ReplicationSpec getReplicationSpec() {
-    return this.replicationSpec;
-  }
 }
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorOperation.java
index 84093e7..01da755 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorOperation.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorOperation.java
@@ -43,17 +43,13 @@ public abstract class AbstractAlterDataConnectorOperation<T extends AbstractAlte
     }
 
     Map<String, String> params = connector.getParameters();
-    if ((desc.getReplicationSpec() != null) &&
-        !desc.getReplicationSpec().allowEventReplacementInto(params)) {
-      LOG.debug("DDLTask: Alter Connector {} is skipped as connector is newer than update", dcName);
-      return 0; // no replacement, the existing connector state is newer than our update.
-    }
-
-    doAlteration(connector, params);
+    // this call is to set the values from the alter descriptor onto the connector object
+    doAlteration(connector);
 
+    // This is the HMS metadata operation to modify the object
     context.getDb().alterDataConnector(connector.getName(), connector);
     return 0;
   }
 
-  protected abstract void doAlteration(DataConnector connector, Map<String, String> params) throws HiveException;
+  protected abstract void doAlteration(DataConnector connector) throws HiveException;
 }
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerAnalyzer.java
index 1fb34e1..4634f82 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerAnalyzer.java
@@ -48,7 +48,7 @@ public class AlterDataConnectorSetOwnerAnalyzer extends AbstractAlterDataConnect
       throw new SemanticException("Owner type can't be null in alter connector set owner command");
     }
 
-    AlterDataConnectorSetOwnerDesc desc = new AlterDataConnectorSetOwnerDesc(connectorName, principalDesc, null);
+    AlterDataConnectorSetOwnerDesc desc = new AlterDataConnectorSetOwnerDesc(connectorName, principalDesc);
     addAlterDataConnectorDesc(desc);
   }
 }
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerDesc.java
index 8d2c0c3..70c923d7 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerDesc.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerDesc.java
@@ -20,7 +20,6 @@ package org.apache.hadoop.hive.ql.ddl.dataconnector.alter.owner;
 
 import org.apache.hadoop.hive.ql.ddl.dataconnector.alter.AbstractAlterDataConnectorDesc;
 import org.apache.hadoop.hive.ql.ddl.privilege.PrincipalDesc;
-import org.apache.hadoop.hive.ql.parse.ReplicationSpec;
 import org.apache.hadoop.hive.ql.plan.Explain;
 import org.apache.hadoop.hive.ql.plan.Explain.Level;
 
@@ -33,8 +32,8 @@ public class AlterDataConnectorSetOwnerDesc extends AbstractAlterDataConnectorDe
 
   private final PrincipalDesc ownerPrincipal;
 
-  public AlterDataConnectorSetOwnerDesc(String connectorName, PrincipalDesc ownerPrincipal, ReplicationSpec replicationSpec) {
-    super(connectorName, replicationSpec);
+  public AlterDataConnectorSetOwnerDesc(String connectorName, PrincipalDesc ownerPrincipal) {
+    super(connectorName);
     this.ownerPrincipal = ownerPrincipal;
   }
 
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerOperation.java
index 7f06a4d..bd740a5 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerOperation.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerOperation.java
@@ -18,8 +18,6 @@
 
 package org.apache.hadoop.hive.ql.ddl.dataconnector.alter.owner;
 
-import java.util.Map;
-
 import org.apache.hadoop.hive.metastore.api.DataConnector;
 import org.apache.hadoop.hive.ql.ddl.DDLOperationContext;
 import org.apache.hadoop.hive.ql.ddl.dataconnector.alter.AbstractAlterDataConnectorOperation;
@@ -34,7 +32,7 @@ public class AlterDataConnectorSetOwnerOperation extends
   }
 
   @Override
-  protected void doAlteration(DataConnector connector, Map<String, String> params) {
+  protected void doAlteration(DataConnector connector) {
     connector.setOwnerName(desc.getOwnerPrincipal().getName());
     connector.setOwnerType(desc.getOwnerPrincipal().getType());
   }
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesAnalyzer.java
index e8fb1b9..1d347b0 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesAnalyzer.java
@@ -51,7 +51,7 @@ public class AlterDataConnectorSetPropertiesAnalyzer extends AbstractAlterDataCo
       }
     }
 
-    AlterDataConnectorSetPropertiesDesc desc = new AlterDataConnectorSetPropertiesDesc(connectorName, dbProps, null);
+    AlterDataConnectorSetPropertiesDesc desc = new AlterDataConnectorSetPropertiesDesc(connectorName, dbProps);
     addAlterDataConnectorDesc(desc);
   }
 }
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesDesc.java
index 07958c2..d53260e 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesDesc.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesDesc.java
@@ -21,7 +21,6 @@ package org.apache.hadoop.hive.ql.ddl.dataconnector.alter.properties;
 import java.util.Map;
 
 import org.apache.hadoop.hive.ql.ddl.dataconnector.alter.AbstractAlterDataConnectorDesc;
-import org.apache.hadoop.hive.ql.parse.ReplicationSpec;
 import org.apache.hadoop.hive.ql.plan.Explain;
 import org.apache.hadoop.hive.ql.plan.Explain.Level;
 
@@ -34,9 +33,8 @@ public class AlterDataConnectorSetPropertiesDesc extends AbstractAlterDataConnec
 
   private final Map<String, String> dcProperties;
 
-  public AlterDataConnectorSetPropertiesDesc(String connectorName, Map<String, String> dcProperties,
-      ReplicationSpec replicationSpec) {
-    super(connectorName, replicationSpec);
+  public AlterDataConnectorSetPropertiesDesc(String connectorName, Map<String, String> dcProperties) {
+    super(connectorName);
     this.dcProperties = dcProperties;
   }
 
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesOperation.java
index c9fa032..2037539 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesOperation.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesOperation.java
@@ -34,8 +34,9 @@ public class AlterDataConnectorSetPropertiesOperation
   }
 
   @Override
-  protected void doAlteration(DataConnector connector, Map<String, String> params) {
+  protected void doAlteration(DataConnector connector) {
     Map<String, String> newParams = desc.getConnectorProperties();
+    Map<String, String> params = connector.getParameters();
 
     // if both old and new params are not null, merge them
     if (params != null && newParams != null) {
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlDesc.java
index a142ea0..9416a97 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlDesc.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlDesc.java
@@ -32,7 +32,7 @@ public class AlterDataConnectorSetUrlDesc extends AbstractAlterDataConnectorDesc
   private final String url;
 
   public AlterDataConnectorSetUrlDesc(String connectorName, String location) {
-    super(connectorName, null);
+    super(connectorName);
     this.url = location;
   }
 
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlOperation.java
index 190e833..364187b 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlOperation.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlOperation.java
@@ -20,7 +20,6 @@ package org.apache.hadoop.hive.ql.ddl.dataconnector.alter.url;
 
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.util.Map;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.hadoop.hive.metastore.api.DataConnector;
@@ -39,7 +38,7 @@ public class AlterDataConnectorSetUrlOperation extends
   }
 
   @Override
-  protected void doAlteration(DataConnector connector, Map<String, String> params) throws HiveException {
+  protected void doAlteration(DataConnector connector) throws HiveException {
     try {
       String newUrl = desc.getURL();
 
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorAnalyzer.java
index 37817db..7cb8b8b 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorAnalyzer.java
@@ -28,7 +28,6 @@ import org.apache.hadoop.hive.ql.hooks.WriteEntity;
 import org.apache.hadoop.hive.ql.parse.ASTNode;
 import org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer;
 import org.apache.hadoop.hive.ql.parse.HiveParser;
-import org.apache.hadoop.hive.ql.parse.ReplicationSpec;
 import org.apache.hadoop.hive.ql.parse.SemanticException;
 
 /**
@@ -53,7 +52,7 @@ public class DropDataConnectorAnalyzer extends BaseSemanticAnalyzer {
     inputs.add(new ReadEntity(connector));
     outputs.add(new WriteEntity(connector, WriteEntity.WriteType.DDL_EXCLUSIVE));
 
-    DropDataConnectorDesc desc = new DropDataConnectorDesc(connectorName, ifExists, new ReplicationSpec());
+    DropDataConnectorDesc desc = new DropDataConnectorDesc(connectorName, ifExists);
     rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc)));
   }
 }
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorDesc.java
index 8e3bc6b..d07c976 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorDesc.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorDesc.java
@@ -21,7 +21,6 @@ package org.apache.hadoop.hive.ql.ddl.dataconnector.drop;
 import java.io.Serializable;
 
 import org.apache.hadoop.hive.ql.ddl.DDLDesc;
-import org.apache.hadoop.hive.ql.parse.ReplicationSpec;
 import org.apache.hadoop.hive.ql.plan.Explain;
 import org.apache.hadoop.hive.ql.plan.Explain.Level;
 
@@ -34,16 +33,10 @@ public class DropDataConnectorDesc implements DDLDesc, Serializable {
 
   private final String connectorName;
   private final boolean ifExists;
-  private final ReplicationSpec replicationSpec;
 
-  public DropDataConnectorDesc(String connectorName, boolean ifExists, ReplicationSpec replicationSpec) {
-    this(connectorName, ifExists, false, replicationSpec);
-  }
-
-  public DropDataConnectorDesc(String connectorName, boolean ifExists, boolean cascade, ReplicationSpec replicationSpec) {
+  public DropDataConnectorDesc(String connectorName, boolean ifExists) {
     this.connectorName = connectorName;
     this.ifExists = ifExists;
-    this.replicationSpec = replicationSpec;
   }
 
   @Explain(displayName = "connector", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
@@ -55,8 +48,4 @@ public class DropDataConnectorDesc implements DDLDesc, Serializable {
   public boolean getIfExists() {
     return ifExists;
   }
-
-  public ReplicationSpec getReplicationSpec() {
-    return replicationSpec;
-  }
 }
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorOperation.java
index 64692f7..81a41b9 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorOperation.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorOperation.java
@@ -18,15 +18,11 @@
 
 package org.apache.hadoop.hive.ql.ddl.dataconnector.drop;
 
-import org.apache.hadoop.hive.llap.LlapHiveUtils;
-import org.apache.hadoop.hive.llap.ProactiveEviction;
-import org.apache.hadoop.hive.metastore.api.DataConnector;
 import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
 import org.apache.hadoop.hive.ql.ErrorMsg;
 import org.apache.hadoop.hive.ql.ddl.DDLOperation;
 import org.apache.hadoop.hive.ql.ddl.DDLOperationContext;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
-import org.apache.hadoop.hive.ql.parse.ReplicationSpec;
 
 /**
  * Operation process of dropping a data connector.
@@ -39,23 +35,7 @@ public class DropDataConnectorOperation extends DDLOperation<DropDataConnectorDe
   @Override
   public int execute() throws HiveException {
     try {
-      String dcName = desc.getConnectorName();
-      ReplicationSpec replicationSpec = desc.getReplicationSpec();
-      if (replicationSpec.isInReplicationScope()) {
-        DataConnector connector = context.getDb().getDataConnector(dcName);
-        if (connector == null || !replicationSpec.allowEventReplacementInto(connector.getParameters())) {
-          return 0;
-        }
-      }
-
-      context.getDb().dropDataConnector(dcName, desc.getIfExists());
-
-      // TODO is this required for Connectors
-      if (LlapHiveUtils.isLlapMode(context.getConf())) {
-        ProactiveEviction.Request.Builder llapEvictRequestBuilder = ProactiveEviction.Request.Builder.create();
-        llapEvictRequestBuilder.addDb(dcName);
-        ProactiveEviction.evict(context.getConf(), llapEvictRequestBuilder.build());
-      }
+      context.getDb().dropDataConnector(desc.getConnectorName(), desc.getIfExists());
     } catch (NoSuchObjectException ex) {
       throw new HiveException(ex, ErrorMsg.DATACONNECTOR_NOT_EXISTS, desc.getConnectorName());
     }
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreEventListener.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreEventListener.java
index 78a2079..aff4855 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreEventListener.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreEventListener.java
@@ -32,6 +32,7 @@ import org.apache.hadoop.hive.metastore.events.AddSchemaVersionEvent;
 import org.apache.hadoop.hive.metastore.events.AddUniqueConstraintEvent;
 import org.apache.hadoop.hive.metastore.events.AlterCatalogEvent;
 import org.apache.hadoop.hive.metastore.events.AlterDatabaseEvent;
+import org.apache.hadoop.hive.metastore.events.AlterDataConnectorEvent;
 import org.apache.hadoop.hive.metastore.events.AlterISchemaEvent;
 import org.apache.hadoop.hive.metastore.events.AddPartitionEvent;
 import org.apache.hadoop.hive.metastore.events.AlterPartitionEvent;
@@ -162,6 +163,13 @@ public abstract class MetaStoreEventListener implements Configurable {
   }
 
   /**
+   * @param dcEvent alter data connector event
+   * @throws MetaException
+   */
+  public void onAlterDataConnector(AlterDataConnectorEvent dcEvent) throws MetaException {
+  }
+
+  /**
    * @param dbEvent alter database event
    * @throws MetaException
    */
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreListenerNotifier.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreListenerNotifier.java
index 43ba3f1..d5cf811 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreListenerNotifier.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreListenerNotifier.java
@@ -34,6 +34,7 @@ import org.apache.hadoop.hive.metastore.events.AddSchemaVersionEvent;
 import org.apache.hadoop.hive.metastore.events.AddUniqueConstraintEvent;
 import org.apache.hadoop.hive.metastore.events.AlterCatalogEvent;
 import org.apache.hadoop.hive.metastore.events.AlterDatabaseEvent;
+import org.apache.hadoop.hive.metastore.events.AlterDataConnectorEvent;
 import org.apache.hadoop.hive.metastore.events.AlterISchemaEvent;
 import org.apache.hadoop.hive.metastore.events.AlterPartitionEvent;
 import org.apache.hadoop.hive.metastore.events.AlterSchemaVersionEvent;
@@ -140,6 +141,13 @@ public class MetaStoreListenerNotifier {
               listener.onAlterDatabase((AlterDatabaseEvent)event);
             }
           })
+          .put(EventType.ALTER_DATACONNECTOR, new EventNotifier() {
+            @Override
+            public void notify(MetaStoreEventListener listener,
+                ListenerEvent event) throws MetaException {
+              listener.onAlterDataConnector((AlterDataConnectorEvent)event);
+            }
+          })
           .put(EventType.ALTER_TABLE, new EventNotifier() {
             @Override
             public void notify(MetaStoreEventListener listener, ListenerEvent event) throws MetaException {
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/DataConnectorProviderFactory.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/DataConnectorProviderFactory.java
index bb2d972..6d404cf 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/DataConnectorProviderFactory.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/DataConnectorProviderFactory.java
@@ -75,18 +75,6 @@ public class DataConnectorProviderFactory {
     return provider;
   }
 
-  IDataConnectorProvider getDataConnectorProvider(String connectorName) {
-    if (connectorName == null || connectorName.isEmpty()) {
-      return null;
-    }
-
-    if (cache.containsKey(connectorName.toLowerCase() != null)) {
-      return cache.get(connectorName.toLowerCase());
-    }
-    return null;
-    // return getDataConnectorProvider();
-  }
-
   public void shutdown() {
     for (IDataConnectorProvider provider: cache.values()) {
       try {
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/events/AlterDataConnectorEvent.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/events/AlterDataConnectorEvent.java
new file mode 100644
index 0000000..cf29b93
--- /dev/null
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/events/AlterDataConnectorEvent.java
@@ -0,0 +1,57 @@
+/*
+ * 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.hadoop.hive.metastore.events;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.hive.metastore.IHMSHandler;
+import org.apache.hadoop.hive.metastore.api.DataConnector;
+
+/**
+ * AlterDataConnectorEvent.
+ * Event which is captured during connector alters for owner info or properties or URI
+ */
+@InterfaceAudience.Public
+@InterfaceStability.Stable
+public class AlterDataConnectorEvent extends ListenerEvent {
+  private final DataConnector oldDc;
+  private final DataConnector newDc;
+
+  public AlterDataConnectorEvent(DataConnector oldDc, DataConnector newDc, boolean status, IHMSHandler handler,
+      boolean isReplicated) {
+    super(status, handler);
+    this.oldDc = oldDc;
+    this.newDc = newDc;
+  }
+
+  /**
+   * @return the old db
+   */
+  public DataConnector getOldDataConnector() {
+    return oldDc;
+  }
+
+  /**
+   * @return the new db
+   */
+  public DataConnector getNewDataConnector() {
+    return newDc;
+  }
+
+}

[hive] 37/38: HIVE-24396: Remaining comments from the feedback (Naveen Gangam)

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 34720cfaf3ed3e6dd371fe7394ce9e1495ffa3a8
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Mon Mar 29 12:28:37 2021 -0400

    HIVE-24396: Remaining comments from the feedback (Naveen Gangam)
---
 .../properties/AlterDataConnectorSetPropertiesAnalyzer.java |  5 ++---
 .../apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java   |  2 +-
 .../org/apache/hadoop/hive/metastore/cache/CachedStore.java |  6 ------
 .../dataconnector/JDBCConnectorProviderFactory.java         | 13 -------------
 .../dataconnector/jdbc/AbstractJDBCConnectorProvider.java   |  5 +++--
 5 files changed, 6 insertions(+), 25 deletions(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesAnalyzer.java
index 1ddb73f..e8fb1b9 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesAnalyzer.java
@@ -43,11 +43,10 @@ public class AlterDataConnectorSetPropertiesAnalyzer extends AbstractAlterDataCo
     Map<String, String> dbProps = null;
     for (int i = 1; i < root.getChildCount(); i++) {
       ASTNode childNode = (ASTNode) root.getChild(i);
-      switch (childNode.getToken().getType()) {
-      case HiveParser.TOK_DATACONNECTORPROPERTIES:
+      if (childNode.getToken().getType() == HiveParser.TOK_DATACONNECTORPROPERTIES) {
         dbProps = getProps((ASTNode) childNode.getChild(0));
         break;
-      default:
+      } else {
         throw new SemanticException("Unrecognized token in ALTER CONNECTOR statement");
       }
     }
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java
index 3f58661..7f3b641 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java
@@ -1729,7 +1729,7 @@ public abstract class BaseSemanticAnalyzer {
     try {
       connector = db.getDataConnector(dcName);
     } catch (Exception e) {
-      throw new SemanticException(e.getMessage(), e);
+      throw new SemanticException(e);
     }
     if (connector == null && throwException) {
       throw new SemanticException(ErrorMsg.DATACONNECTOR_NOT_EXISTS.getMsg(dcName));
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java
index b792f78..253031d 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java
@@ -1165,12 +1165,6 @@ public class CachedStore implements RawStore, Configurable {
 
   @Override public void createDataConnector(DataConnector connector) throws InvalidObjectException, MetaException {
     rawStore.createDataConnector(connector);
-    // in case of event based cache update, cache will be updated during commit.
-    /*
-    if (!canUseEvents) {
-      sharedCache.addDatabaseToCache(connector);
-    }
-     */
   }
 
   @Override public DataConnector getDataConnector(String dcName) throws NoSuchObjectException {
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/JDBCConnectorProviderFactory.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/JDBCConnectorProviderFactory.java
index b1ebfe0..10ab2bf 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/JDBCConnectorProviderFactory.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/JDBCConnectorProviderFactory.java
@@ -14,19 +14,6 @@ public class JDBCConnectorProviderFactory {
     switch(connector.getType().toLowerCase()) {
     case MYSQL_TYPE:
       provider = new MySQLConnectorProvider(dbName, connector);
-      /*
-      try {
-        Class.forName(driverClassName);
-        handle = DriverManager.getConnection(jdbcUrl, username, password);
-        isOpen = true;
-      } catch (ClassNotFoundException cnfe) {
-        LOG.warn("Driver class not found in classpath:" + driverClassName);
-        throw new RuntimeException("Driver class not found:" + driverClassName);
-      } catch (SQLException sqle) {
-        LOG.warn("Could not connect to remote data source at " + jdbcUrl);
-        throw new ConnectException("Could not connect to remote datasource at " + jdbcUrl + ",cause:" + sqle.getMessage());
-      }
-       */
       break;
     case POSTGRES_TYPE:
       provider = new PostgreSQLConnectorProvider(dbName, connector);
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
index 72a6efb..e53a356 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
@@ -88,7 +88,7 @@ public abstract class AbstractJDBCConnectorProvider extends AbstractDataConnecto
       isOpen = true;
     } catch (ClassNotFoundException cnfe) {
       LOG.warn("Driver class not found in classpath:" + driverClassName);
-      throw new RuntimeException("Driver class not found:" + driverClassName);
+      throw new RuntimeException("Driver class not found:" + driverClassName, cnfe);
     } catch (SQLException sqle) {
       LOG.warn("Could not connect to remote data source at " + jdbcUrl);
       throw new ConnectException("Could not connect to remote datasource at " + jdbcUrl + ",cause:" + sqle.getMessage());
@@ -100,7 +100,7 @@ public abstract class AbstractJDBCConnectorProvider extends AbstractDataConnecto
       if (!isOpen)
         open();
     } catch (ConnectException ce) {
-      throw new RuntimeException(ce.getMessage());
+      throw new RuntimeException(ce.getMessage(), ce);
     }
 
     if (handle instanceof Connection)
@@ -115,6 +115,7 @@ public abstract class AbstractJDBCConnectorProvider extends AbstractDataConnecto
         ((Connection)handle).close();
       } catch (SQLException sqle) {
         LOG.warn("Could not close jdbc connection to " + jdbcUrl, sqle);
+        throw new RuntimeException(sqle);
       }
     }
   }

[hive] 31/38: HIVE-24396: Duplicate SQL statements in derby upgrade script (Naveen Gangam)

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 5f5ec66cf9fe17346e1419c08b28ffa372e453fe
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Thu Mar 4 18:33:54 2021 -0500

    HIVE-24396: Duplicate SQL statements in derby upgrade script (Naveen Gangam)
---
 .../metastore-server/src/main/sql/derby/upgrade-3.2.0-to-4.0.0.derby.sql | 1 -
 1 file changed, 1 deletion(-)

diff --git a/standalone-metastore/metastore-server/src/main/sql/derby/upgrade-3.2.0-to-4.0.0.derby.sql b/standalone-metastore/metastore-server/src/main/sql/derby/upgrade-3.2.0-to-4.0.0.derby.sql
index a31e663..3dca262 100644
--- a/standalone-metastore/metastore-server/src/main/sql/derby/upgrade-3.2.0-to-4.0.0.derby.sql
+++ b/standalone-metastore/metastore-server/src/main/sql/derby/upgrade-3.2.0-to-4.0.0.derby.sql
@@ -148,7 +148,6 @@ ALTER TABLE COMPLETED_COMPACTIONS ADD CC_INITIATOR_VERSION varchar(128);
 ALTER TABLE COMPLETED_COMPACTIONS ADD CC_WORKER_VERSION varchar(128);
 
 -- HIVE-24396
-CREATE TABLE "APP"."DATACONNECTORS" ("DC_NAME" VARCHAR(128) NOT NULL, "TYPE" VARCHAR(128) NOT NULL, "COMMENT" VARCHAR(256), "OWNER_NAME" VARCHAR(256), "OWNER_TYPE" VARCHAR(10), "CREATE_TIME" INTEGER);
 CREATE TABLE "APP"."DATACONNECTORS" ("DC_NAME" VARCHAR(128) NOT NULL, "TYPE" VARCHAR(128) NOT NULL, "COMMENT" VARCHAR(256), "OWNER_NAME" VARCHAR(256), "OWNER_TYPE" VARCHAR(10), "CREATE_TIME" INTEGER NOT NULL);
 CREATE TABLE "APP"."DATACONNECTOR_PARAMS" ("DC_NAME" VARCHAR(128) NOT NULL, "PARAM_KEY" VARCHAR(180) NOT NULL, "PARAM_VALUE" VARCHAR(4000), "COMMENT" VARCHAR(256));
 ALTER TABLE "APP"."DBS" ADD COLUMN "TYPE" VARCHAR(32) DEFAULT 'NATIVE' NOT NULL;

[hive] 30/38: HIVE-24396: Some changes with formatters after the rebase (Naveen Gangam)

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit d7a8eb719510da766246cccb699454d754e69fd3
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Thu Mar 4 10:20:33 2021 -0500

    HIVE-24396: Some changes with formatters after the rebase (Naveen Gangam)
---
 .../ddl/database/desc/DescDatabaseFormatter.java   |    23 +-
 .../desc/DescDataConnectorFormatter.java}          |    58 +-
 .../desc/DescDataConnectorOperation.java           |     7 +-
 .../show/ShowDataConnectorsFormatter.java          |    69 +
 .../show/ShowDataConnectorsOperation.java          |     7 +-
 .../metadata/formatting/JsonMetaDataFormatter.java |   704 --
 .../hadoop/hive/metastore/HiveMetaStore.java       | 10368 -------------------
 .../src/main/resources/package.jdo                 |     1 +
 8 files changed, 127 insertions(+), 11110 deletions(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseFormatter.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseFormatter.java
index f6cd633..5e10c3b 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseFormatter.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseFormatter.java
@@ -46,7 +46,8 @@ abstract class DescDatabaseFormatter {
   }
 
   abstract void showDatabaseDescription(DataOutputStream out, String database, String comment, String location,
-      String managedLocation, String ownerName, PrincipalType ownerType, Map<String, String> params)
+      String managedLocation, String ownerName, PrincipalType ownerType, Map<String, String> params,
+      String connectorName, String remoteDbName)
       throws HiveException;
 
   // ------ Implementations ------
@@ -54,7 +55,8 @@ abstract class DescDatabaseFormatter {
   static class JsonDescDatabaseFormatter extends DescDatabaseFormatter {
     @Override
     void showDatabaseDescription(DataOutputStream out, String database, String comment, String location,
-        String managedLocation, String ownerName, PrincipalType ownerType, Map<String, String> params)
+        String managedLocation, String ownerName, PrincipalType ownerType, Map<String, String> params,
+        String connectorName, String remoteDbName)
         throws HiveException {
       MapBuilder builder = MapBuilder.create()
           .put("database", database)
@@ -69,6 +71,12 @@ abstract class DescDatabaseFormatter {
       if (ownerType != null) {
         builder.put("ownerType", ownerType.name());
       }
+      if (null != connectorName) {
+        builder.put("connector_name", connectorName);
+      }
+      if (null != remoteDbName) {
+        builder.put("remote_dbname", remoteDbName);
+      }
       if (MapUtils.isNotEmpty(params)) {
         builder.put("params", params);
       }
@@ -79,7 +87,8 @@ abstract class DescDatabaseFormatter {
   static class TextDescDatabaseFormatter extends DescDatabaseFormatter {
     @Override
     void showDatabaseDescription(DataOutputStream out, String database, String comment, String location,
-        String managedLocation, String ownerName, PrincipalType ownerType, Map<String, String> params)
+        String managedLocation, String ownerName, PrincipalType ownerType, Map<String, String> params,
+        String connectorName, String remoteDbName)
         throws HiveException {
       try {
         out.write(database.getBytes(StandardCharsets.UTF_8));
@@ -104,6 +113,14 @@ abstract class DescDatabaseFormatter {
           out.write(ownerType.name().getBytes(StandardCharsets.UTF_8));
         }
         out.write(Utilities.tabCode);
+        if (connectorName != null) {
+          out.write(connectorName.getBytes(StandardCharsets.UTF_8));
+        }
+        out.write(Utilities.tabCode);
+        if (remoteDbName != null) {
+          out.write(remoteDbName.getBytes(StandardCharsets.UTF_8));
+        }
+        out.write(Utilities.tabCode);
         if (MapUtils.isNotEmpty(params)) {
           out.write(params.toString().getBytes(StandardCharsets.UTF_8));
         }
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseFormatter.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/desc/DescDataConnectorFormatter.java
similarity index 65%
copy from ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseFormatter.java
copy to ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/desc/DescDataConnectorFormatter.java
index f6cd633..3865c62 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseFormatter.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/desc/DescDataConnectorFormatter.java
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.hadoop.hive.ql.ddl.database.desc;
+package org.apache.hadoop.hive.ql.ddl.dataconnector.desc;
 
 import org.apache.commons.collections.MapUtils;
 import org.apache.hadoop.hive.conf.HiveConf;
@@ -34,41 +34,41 @@ import java.nio.charset.StandardCharsets;
 import java.util.Map;
 
 /**
- * Formats DESC DATABASES results.
+ * Formats DESC CONNECTOR results.
  */
-abstract class DescDatabaseFormatter {
-  static DescDatabaseFormatter getFormatter(HiveConf conf) {
+abstract class DescDataConnectorFormatter {
+  static DescDataConnectorFormatter getFormatter(HiveConf conf) {
     if (MetaDataFormatUtils.isJson(conf)) {
-      return new JsonDescDatabaseFormatter();
+      return new JsonDescDataConnectorFormatter();
     } else {
-      return new TextDescDatabaseFormatter();
+      return new TextDescDataConnectorFormatter();
     }
   }
 
-  abstract void showDatabaseDescription(DataOutputStream out, String database, String comment, String location,
-      String managedLocation, String ownerName, PrincipalType ownerType, Map<String, String> params)
+  abstract void showDataConnectorDescription(DataOutputStream out, String connector, String type, String url,
+      String ownerName, PrincipalType ownerType, String comment, Map<String, String> params)
       throws HiveException;
 
   // ------ Implementations ------
 
-  static class JsonDescDatabaseFormatter extends DescDatabaseFormatter {
+  static class JsonDescDataConnectorFormatter extends DescDataConnectorFormatter {
     @Override
-    void showDatabaseDescription(DataOutputStream out, String database, String comment, String location,
-        String managedLocation, String ownerName, PrincipalType ownerType, Map<String, String> params)
+    void showDataConnectorDescription(DataOutputStream out, String connector, String type, String url,
+        String ownerName, PrincipalType ownerType, String comment, Map<String, String> params)
         throws HiveException {
       MapBuilder builder = MapBuilder.create()
-          .put("database", database)
-          .put("comment", comment)
-          .put("location", location);
-      if (managedLocation != null) {
-        builder.put("managedLocation", managedLocation);
-      }
+          .put("connector", connector)
+          .put("type", type)
+          .put("url", url);
       if (ownerName != null) {
         builder.put("owner", ownerName);
       }
       if (ownerType != null) {
         builder.put("ownerType", ownerType.name());
       }
+      if (comment != null) {
+        builder.put("comment", comment);
+      }
       if (MapUtils.isNotEmpty(params)) {
         builder.put("params", params);
       }
@@ -76,24 +76,20 @@ abstract class DescDatabaseFormatter {
     }
   }
 
-  static class TextDescDatabaseFormatter extends DescDatabaseFormatter {
+  static class TextDescDataConnectorFormatter extends DescDataConnectorFormatter {
     @Override
-    void showDatabaseDescription(DataOutputStream out, String database, String comment, String location,
-        String managedLocation, String ownerName, PrincipalType ownerType, Map<String, String> params)
+    void showDataConnectorDescription(DataOutputStream out, String connector, String type, String url,
+        String ownerName, PrincipalType ownerType, String comment, Map<String, String> params)
         throws HiveException {
       try {
-        out.write(database.getBytes(StandardCharsets.UTF_8));
-        out.write(Utilities.tabCode);
-        if (comment != null) {
-          out.write(HiveStringUtils.escapeJava(comment).getBytes(StandardCharsets.UTF_8));
-        }
+        out.write(connector.getBytes(StandardCharsets.UTF_8));
         out.write(Utilities.tabCode);
-        if (location != null) {
-          out.write(location.getBytes(StandardCharsets.UTF_8));
+        if (type != null) {
+          out.write(type.getBytes(StandardCharsets.UTF_8));
         }
         out.write(Utilities.tabCode);
-        if (managedLocation != null) {
-          out.write(managedLocation.getBytes(StandardCharsets.UTF_8));
+        if (url != null) {
+          out.write(url.getBytes(StandardCharsets.UTF_8));
         }
         out.write(Utilities.tabCode);
         if (ownerName != null) {
@@ -104,6 +100,10 @@ abstract class DescDatabaseFormatter {
           out.write(ownerType.name().getBytes(StandardCharsets.UTF_8));
         }
         out.write(Utilities.tabCode);
+        if (comment != null) {
+          out.write(HiveStringUtils.escapeJava(comment).getBytes(StandardCharsets.UTF_8));
+        }
+        out.write(Utilities.tabCode);
         if (MapUtils.isNotEmpty(params)) {
           out.write(params.toString().getBytes(StandardCharsets.UTF_8));
         }
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/desc/DescDataConnectorOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/desc/DescDataConnectorOperation.java
index de76842..9614f24 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/desc/DescDataConnectorOperation.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/desc/DescDataConnectorOperation.java
@@ -27,7 +27,7 @@ import org.apache.hadoop.hive.metastore.api.DataConnector;
 import org.apache.hadoop.hive.ql.ErrorMsg;
 import org.apache.hadoop.hive.ql.ddl.DDLOperation;
 import org.apache.hadoop.hive.ql.ddl.DDLOperationContext;
-import org.apache.hadoop.hive.ql.ddl.DDLUtils;
+import org.apache.hadoop.hive.ql.ddl.ShowUtils;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
 
 /**
@@ -40,7 +40,7 @@ public class DescDataConnectorOperation extends DDLOperation<DescDataConnectorDe
 
   @Override
   public int execute() throws HiveException {
-    try (DataOutputStream outStream = DDLUtils.getOutputStream(new Path(desc.getResFile()), context)) {
+    try (DataOutputStream outStream = ShowUtils.getOutputStream(new Path(desc.getResFile()), context)) {
       DataConnector connector = context.getDb().getDataConnector(desc.getConnectorName());
       if (connector == null) {
         throw new HiveException(ErrorMsg.DATACONNECTOR_NOT_EXISTS, desc.getConnectorName());
@@ -51,7 +51,8 @@ public class DescDataConnectorOperation extends DDLOperation<DescDataConnectorDe
         params = new TreeMap<>(connector.getParameters());
       }
 
-      context.getFormatter().showDataConnectorDescription(outStream, connector.getName(), connector.getType(),
+      DescDataConnectorFormatter formatter = DescDataConnectorFormatter.getFormatter(context.getConf());
+      formatter.showDataConnectorDescription(outStream, connector.getName(), connector.getType(),
           connector.getUrl(), connector.getOwnerName(), connector.getOwnerType(), connector.getDescription(), params);
     } catch (Exception e) {
       throw new HiveException(e, ErrorMsg.GENERIC_ERROR);
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsFormatter.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsFormatter.java
new file mode 100644
index 0000000..7ef6531
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsFormatter.java
@@ -0,0 +1,69 @@
+/*
+ * 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.hadoop.hive.ql.ddl.dataconnector.show;
+
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.ql.ddl.ShowUtils;
+import org.apache.hadoop.hive.ql.exec.Utilities;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.metadata.formatting.MapBuilder;
+import org.apache.hadoop.hive.ql.metadata.formatting.MetaDataFormatUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+
+/**
+ * Formats SHOW CONNECTORS results.
+ */
+abstract class ShowDataConnectorsFormatter {
+  static ShowDataConnectorsFormatter getFormatter(HiveConf conf) {
+    if (MetaDataFormatUtils.isJson(conf)) {
+      return new JsonShowDataConnectorsFormatter();
+    } else {
+      return new TextShowDataConnectorsFormatter();
+    }
+  }
+
+  abstract void showDataConnectors(DataOutputStream out, List<String> connectors) throws HiveException;
+
+  // ------ Implementations ------
+
+  static class JsonShowDataConnectorsFormatter extends ShowDataConnectorsFormatter {
+    @Override
+    void showDataConnectors(DataOutputStream out, List<String> connectors) throws HiveException {
+      ShowUtils.asJson(out, MapBuilder.create().put("connectors", connectors).build());
+    }
+  }
+
+  static class TextShowDataConnectorsFormatter extends ShowDataConnectorsFormatter {
+    @Override
+    void showDataConnectors(DataOutputStream out, List<String> connectors) throws HiveException {
+      try {
+        for (String connector : connectors) {
+          out.write(connector.getBytes(StandardCharsets.UTF_8));
+          out.write(Utilities.newLineCode);
+        }
+      } catch (IOException e) {
+        throw new HiveException(e);
+      }
+    }
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsOperation.java
index 8ecc9eb..22b10d8 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsOperation.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsOperation.java
@@ -27,7 +27,7 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.ql.ErrorMsg;
 import org.apache.hadoop.hive.ql.ddl.DDLOperation;
 import org.apache.hadoop.hive.ql.ddl.DDLOperationContext;
-import org.apache.hadoop.hive.ql.ddl.DDLUtils;
+import org.apache.hadoop.hive.ql.ddl.ShowUtils;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
 import org.apache.hadoop.hive.ql.udf.UDFLike;
 import org.apache.hadoop.io.IOUtils;
@@ -52,9 +52,10 @@ public class ShowDataConnectorsOperation extends DDLOperation<ShowDataConnectors
     LOG.info("Found {} connector(s) matching the SHOW CONNECTORS statement.", connectors.size());
 
     // write the results in the file
-    DataOutputStream outStream = DDLUtils.getOutputStream(new Path(desc.getResFile()), context);
+    DataOutputStream outStream = ShowUtils.getOutputStream(new Path(desc.getResFile()), context);
     try {
-      context.getFormatter().showDataConnectors(outStream, connectors);
+      ShowDataConnectorsFormatter formatter = ShowDataConnectorsFormatter.getFormatter(context.getConf());
+      formatter.showDataConnectors(outStream, connectors);
     } catch (Exception e) {
       throw new HiveException(e, ErrorMsg.GENERIC_ERROR, "show connectors");
     } finally {
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java
index 6a5234a..9a245c9 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java
@@ -66,710 +66,6 @@ public class JsonMetaDataFormatter implements MetaDataFormatter {
     asJson(out, mb.build());
   }
 
-  /**
-   * Show a list of tables.
-   */
-  @Override
-  public void showTables(DataOutputStream out, List<String> tables)
-      throws HiveException {
-    asJson(out, MapBuilder.create().put("tables", tables).build());
-  }
-
-  /**
-   * Show a list of tables including table types.
-   */
-  @Override
-  public void showTablesExtended(DataOutputStream out, List<Table> tables) throws HiveException {
-    if (tables.isEmpty()) {
-      return;
-    }
-
-    List<Map<String, Object>> tableDataList = new ArrayList<Map<String, Object>>();
-    for (Table table : tables) {
-      Map<String, Object> tableData = ImmutableMap.of(
-          "Table Name", table.getTableName(),
-          "Table Type", table.getTableType().toString());
-      tableDataList.add(tableData);
-    }
-    asJson(out, ImmutableMap.of("tables", tableDataList));
-  }
-
-  /**
-   * Show a list of materialized views.
-   */
-  @Override
-  public void showMaterializedViews(DataOutputStream out, List<Table> materializedViews) throws HiveException {
-    if (materializedViews.isEmpty()) {
-      return;
-    }
-
-    List<Map<String, Object>> materializedViewDataList = new ArrayList<Map<String, Object>>();
-    for (Table materializedView : materializedViews) {
-      // Currently, we only support manual refresh
-      // TODO: Update whenever we have other modes
-      String refreshMode = "Manual refresh";
-      String timeWindowString = materializedView.getProperty(MATERIALIZED_VIEW_REWRITING_TIME_WINDOW);
-      String mode;
-      if (!StringUtils.isEmpty(timeWindowString)) {
-        long time = HiveConf.toTime(timeWindowString,
-            HiveConf.getDefaultTimeUnit(HiveConf.ConfVars.HIVE_MATERIALIZED_VIEW_REWRITING_TIME_WINDOW),
-            TimeUnit.MINUTES);
-        if (time > 0L) {
-          mode = refreshMode + " (Valid for " + time + "min)";
-        } else if (time == 0L) {
-          mode = refreshMode + " (Valid until source tables modified)";
-        } else {
-          mode = refreshMode + " (Valid always)";
-        }
-      } else {
-        mode = refreshMode;
-      }
-
-      Map<String, Object> materializedViewData = ImmutableMap.of(
-          "MV Name", materializedView.getTableName(),
-          "Rewriting Enabled", materializedView.isRewriteEnabled() ? "Yes" : "No",
-          "Mode", mode);
-      materializedViewDataList.add(materializedViewData);
-    }
-    asJson(out, ImmutableMap.of("materialized views", materializedViewDataList));
-  }
-
-  /**
-   * Describe table.
-   */
-  @Override
-  public void describeTable(DataOutputStream out, String colPath, String tableName, Table tbl, Partition part,
-      List<FieldSchema> cols, boolean isFormatted, boolean isExt, boolean isOutputPadded,
-      List<ColumnStatisticsObj> colStats) throws HiveException {
-    MapBuilder builder = MapBuilder.create();
-    builder.put("columns", createColumnsInfo(cols, colStats));
-
-    if (isExt) {
-      if (part != null) {
-        builder.put("partitionInfo", part.getTPartition());
-      }
-      else {
-        builder.put("tableInfo", tbl.getTTable());
-      }
-      if (PrimaryKeyInfo.isPrimaryKeyInfoNotEmpty(tbl.getPrimaryKeyInfo())) {
-        builder.put("primaryKeyInfo", tbl.getPrimaryKeyInfo());
-      }
-      if (ForeignKeyInfo.isForeignKeyInfoNotEmpty(tbl.getForeignKeyInfo())) {
-        builder.put("foreignKeyInfo", tbl.getForeignKeyInfo());
-      }
-      if (UniqueConstraint.isUniqueConstraintNotEmpty(tbl.getUniqueKeyInfo())) {
-        builder.put("uniqueConstraintInfo", tbl.getUniqueKeyInfo());
-      }
-      if (NotNullConstraint.isNotNullConstraintNotEmpty(tbl.getNotNullConstraint())) {
-        builder.put("notNullConstraintInfo", tbl.getNotNullConstraint());
-      }
-      if (DefaultConstraint.isCheckConstraintNotEmpty(tbl.getDefaultConstraint())) {
-        builder.put("defaultConstraintInfo", tbl.getDefaultConstraint());
-      }
-      if (CheckConstraint.isCheckConstraintNotEmpty(tbl.getCheckConstraint())) {
-        builder.put("checkConstraintInfo", tbl.getCheckConstraint());
-      }
-      if (tbl.getStorageHandlerInfo() != null) {
-        builder.put("storageHandlerInfo", tbl.getStorageHandlerInfo().toString());
-      }
-    }
-
-    asJson(out, builder.build());
-  }
-
-  private List<Map<String, Object>> createColumnsInfo(List<FieldSchema> columns,
-      List<ColumnStatisticsObj> columnStatisticsList) {
-    ArrayList<Map<String, Object>> res = new ArrayList<Map<String, Object>>();
-    for (FieldSchema column : columns) {
-      ColumnStatisticsData statistics = getStatistics(column, columnStatisticsList);
-      res.add(createColumnInfo(column, statistics));
-    }
-    return res;
-  }
-
-  private ColumnStatisticsData getStatistics(FieldSchema column, List<ColumnStatisticsObj> columnStatisticsList) {
-    for (ColumnStatisticsObj columnStatistics : columnStatisticsList) {
-      if (column.getName().equals(columnStatistics.getColName())) {
-        return columnStatistics.getStatsData();
-      }
-    }
-
-    return null;
-  }
-
-  private Map<String, Object> createColumnInfo(FieldSchema column, ColumnStatisticsData statistics) {
-    Map<String, Object> result = MapBuilder.create()
-        .put(COLUMN_NAME, column.getName())
-        .put(COLUMN_TYPE, column.getType())
-        .put(COLUMN_COMMENT, column.getComment())
-        .build();
-
-    if (statistics != null) {
-      if (statistics.isSetBinaryStats()) {
-        if (statistics.getBinaryStats().isSetNumNulls()) {
-          result.put(COLUMN_NUM_NULLS, statistics.getBinaryStats().getNumNulls());
-        }
-        if (statistics.getBinaryStats().isSetAvgColLen()) {
-          result.put(COLUMN_AVG_LENGTH, statistics.getBinaryStats().getAvgColLen());
-        }
-        if (statistics.getBinaryStats().isSetMaxColLen()) {
-          result.put(COLUMN_MAX_LENGTH, statistics.getBinaryStats().getMaxColLen());
-        }
-      } else if (statistics.isSetStringStats()) {
-        if (statistics.getStringStats().isSetNumNulls()) {
-          result.put(COLUMN_NUM_NULLS, statistics.getStringStats().getNumNulls());
-        }
-        if (statistics.getStringStats().isSetNumDVs()) {
-          result.put(COLUMN_DISTINCT_COUNT, statistics.getStringStats().getNumDVs());
-        }
-        if (statistics.getStringStats().isSetAvgColLen()) {
-          result.put(COLUMN_AVG_LENGTH, statistics.getStringStats().getAvgColLen());
-        }
-        if (statistics.getStringStats().isSetMaxColLen()) {
-          result.put(COLUMN_MAX_LENGTH, statistics.getStringStats().getMaxColLen());
-        }
-      } else if (statistics.isSetBooleanStats()) {
-        if (statistics.getBooleanStats().isSetNumNulls()) {
-          result.put(COLUMN_NUM_NULLS, statistics.getBooleanStats().getNumNulls());
-        }
-        if (statistics.getBooleanStats().isSetNumTrues()) {
-          result.put(COLUMN_NUM_TRUES, statistics.getBooleanStats().getNumTrues());
-        }
-        if (statistics.getBooleanStats().isSetNumFalses()) {
-          result.put(COLUMN_NUM_FALSES, statistics.getBooleanStats().getNumFalses());
-        }
-      } else if (statistics.isSetDecimalStats()) {
-        if (statistics.getDecimalStats().isSetLowValue()) {
-          result.put(COLUMN_MIN, MetaDataFormatUtils.convertToString(statistics.getDecimalStats().getLowValue()));
-        }
-        if (statistics.getDecimalStats().isSetHighValue()) {
-          result.put(COLUMN_MAX, MetaDataFormatUtils.convertToString(statistics.getDecimalStats().getHighValue()));
-        }
-        if (statistics.getDecimalStats().isSetNumNulls()) {
-          result.put(COLUMN_NUM_NULLS, statistics.getDecimalStats().getNumNulls());
-        }
-        if (statistics.getDecimalStats().isSetNumDVs()) {
-          result.put(COLUMN_DISTINCT_COUNT, statistics.getDecimalStats().getNumDVs());
-        }
-      } else if (statistics.isSetDoubleStats()) {
-        if (statistics.getDoubleStats().isSetLowValue()) {
-          result.put(COLUMN_MIN, statistics.getDoubleStats().getLowValue());
-        }
-        if (statistics.getDoubleStats().isSetHighValue()) {
-          result.put(COLUMN_MAX, statistics.getDoubleStats().getHighValue());
-        }
-        if (statistics.getDoubleStats().isSetNumNulls()) {
-          result.put(COLUMN_NUM_NULLS, statistics.getDoubleStats().getNumNulls());
-        }
-        if (statistics.getDoubleStats().isSetNumDVs()) {
-          result.put(COLUMN_DISTINCT_COUNT, statistics.getDoubleStats().getNumDVs());
-        }
-      } else if (statistics.isSetLongStats()) {
-        if (statistics.getLongStats().isSetLowValue()) {
-          result.put(COLUMN_MIN, statistics.getLongStats().getLowValue());
-        }
-        if (statistics.getLongStats().isSetHighValue()) {
-          result.put(COLUMN_MAX, statistics.getLongStats().getHighValue());
-        }
-        if (statistics.getLongStats().isSetNumNulls()) {
-          result.put(COLUMN_NUM_NULLS, statistics.getLongStats().getNumNulls());
-        }
-        if (statistics.getLongStats().isSetNumDVs()) {
-          result.put(COLUMN_DISTINCT_COUNT, statistics.getLongStats().getNumDVs());
-        }
-      } else if (statistics.isSetDateStats()) {
-        if (statistics.getDateStats().isSetLowValue()) {
-          result.put(COLUMN_MIN, MetaDataFormatUtils.convertToString(statistics.getDateStats().getLowValue()));
-        }
-        if (statistics.getDateStats().isSetHighValue()) {
-          result.put(COLUMN_MAX, MetaDataFormatUtils.convertToString(statistics.getDateStats().getHighValue()));
-        }
-        if (statistics.getDateStats().isSetNumNulls()) {
-          result.put(COLUMN_NUM_NULLS, statistics.getDateStats().getNumNulls());
-        }
-        if (statistics.getDateStats().isSetNumDVs()) {
-          result.put(COLUMN_DISTINCT_COUNT, statistics.getDateStats().getNumDVs());
-        }
-      } else if (statistics.isSetTimestampStats()) {
-        if (statistics.getTimestampStats().isSetLowValue()) {
-          result.put(COLUMN_MIN, MetaDataFormatUtils.convertToString(statistics.getTimestampStats().getLowValue()));
-        }
-        if (statistics.getTimestampStats().isSetHighValue()) {
-          result.put(COLUMN_MAX, MetaDataFormatUtils.convertToString(statistics.getTimestampStats().getHighValue()));
-        }
-        if (statistics.getTimestampStats().isSetNumNulls()) {
-          result.put(COLUMN_NUM_NULLS, statistics.getTimestampStats().getNumNulls());
-        }
-        if (statistics.getTimestampStats().isSetNumDVs()) {
-          result.put(COLUMN_DISTINCT_COUNT, statistics.getTimestampStats().getNumDVs());
-        }
-      }
-    }
-
-    return result;
-  }
-
-  @Override
-  public void showTableStatus(DataOutputStream out, Hive db, HiveConf conf,
-      List<Table> tbls, Map<String, String> part, Partition par)
-          throws HiveException {
-    asJson(out, MapBuilder.create().put(
-        "tables", makeAllTableStatus(db, conf, tbls, part, par)).build());
-  }
-
-  private List<Map<String, Object>> makeAllTableStatus(Hive db, HiveConf conf,
-      List<Table> tbls, Map<String, String> part, Partition par)
-          throws HiveException {
-    try {
-      ArrayList<Map<String, Object>> res = new ArrayList<Map<String, Object>>();
-      for (Table tbl : tbls) {
-        res.add(makeOneTableStatus(tbl, db, conf, part, par));
-      }
-      return res;
-    } catch(IOException e) {
-      throw new HiveException(e);
-    }
-  }
-
-  private Map<String, Object> makeOneTableStatus(Table tbl, Hive db,
-      HiveConf conf, Map<String, String> part, Partition par)
-          throws HiveException, IOException {
-    String tblLoc = null;
-    String inputFormattCls = null;
-    String outputFormattCls = null;
-    if (part != null) {
-      if (par != null) {
-        if (par.getLocation() != null) {
-          tblLoc = par.getDataLocation().toString();
-        }
-        inputFormattCls = par.getInputFormatClass() == null ? null : par.getInputFormatClass().getName();
-        outputFormattCls = par.getOutputFormatClass() == null ? null : par.getOutputFormatClass().getName();
-      }
-    } else {
-      if (tbl.getPath() != null) {
-        tblLoc = tbl.getDataLocation().toString();
-      }
-      inputFormattCls = tbl.getInputFormatClass() == null ? null : tbl.getInputFormatClass().getName();
-      outputFormattCls = tbl.getOutputFormatClass() == null ? null : tbl.getOutputFormatClass().getName();
-    }
-
-    MapBuilder builder = MapBuilder.create();
-
-    builder.put("tableName", tbl.getTableName());
-    builder.put("ownerType", (tbl.getOwnerType() != null) ? tbl.getOwnerType().name() : "null");
-    builder.put("owner", tbl.getOwner());
-    builder.put("location", tblLoc);
-    builder.put("inputFormat", inputFormattCls);
-    builder.put("outputFormat", outputFormattCls);
-    builder.put("columns", createColumnsInfo(tbl.getCols(), new ArrayList<ColumnStatisticsObj>()));
-
-    builder.put("partitioned", tbl.isPartitioned());
-    if (tbl.isPartitioned()) {
-      builder.put("partitionColumns", createColumnsInfo(tbl.getPartCols(), new ArrayList<ColumnStatisticsObj>()));
-    }
-    if(tbl.getTableType() != TableType.VIRTUAL_VIEW) {
-      //tbl.getPath() is null for views
-      putFileSystemsStats(builder, makeTableStatusLocations(tbl, db, par),
-        conf, tbl.getPath());
-    }
-
-    return builder.build();
-  }
-
-  private List<Path> makeTableStatusLocations(Table tbl, Hive db, Partition par)
-      throws HiveException {
-    // output file system information
-    Path tblPath = tbl.getPath();
-    List<Path> locations = new ArrayList<Path>();
-    if (tbl.isPartitioned()) {
-      if (par == null) {
-        for (Partition curPart : db.getPartitions(tbl)) {
-          if (curPart.getLocation() != null) {
-            locations.add(new Path(curPart.getLocation()));
-          }
-        }
-      } else {
-        if (par.getLocation() != null) {
-          locations.add(new Path(par.getLocation()));
-        }
-      }
-    } else {
-      if (tblPath != null) {
-        locations.add(tblPath);
-      }
-    }
-
-    return locations;
-  }
-
-  /**
-   * @param tblPath not NULL
-   * @throws IOException
-   */
-  // Duplicates logic in TextMetaDataFormatter
-  private void putFileSystemsStats(MapBuilder builder, List<Path> locations,
-      HiveConf conf, Path tblPath)
-          throws IOException {
-    long totalFileSize = 0;
-    long maxFileSize = 0;
-    long minFileSize = Long.MAX_VALUE;
-    long lastAccessTime = 0;
-    long lastUpdateTime = 0;
-    int numOfFiles = 0;
-
-    boolean unknown = false;
-    FileSystem fs = tblPath.getFileSystem(conf);
-    // in case all files in locations do not exist
-    try {
-      FileStatus tmpStatus = fs.getFileStatus(tblPath);
-      lastAccessTime = tmpStatus.getAccessTime();
-      lastUpdateTime = tmpStatus.getModificationTime();
-    } catch (IOException e) {
-      LOG.warn(
-          "Cannot access File System. File System status will be unknown: ", e);
-      unknown = true;
-    }
-
-    if (!unknown) {
-      for (Path loc : locations) {
-        try {
-          FileStatus status = fs.getFileStatus(tblPath);
-          FileStatus[] files = fs.listStatus(loc);
-          long accessTime = status.getAccessTime();
-          long updateTime = status.getModificationTime();
-          // no matter loc is the table location or part location, it must be a
-          // directory.
-          if (!status.isDir()) {
-            continue;
-          }
-          if (accessTime > lastAccessTime) {
-            lastAccessTime = accessTime;
-          }
-          if (updateTime > lastUpdateTime) {
-            lastUpdateTime = updateTime;
-          }
-          for (FileStatus currentStatus : files) {
-            if (currentStatus.isDir()) {
-              continue;
-            }
-            numOfFiles++;
-            long fileLen = currentStatus.getLen();
-            totalFileSize += fileLen;
-            if (fileLen > maxFileSize) {
-              maxFileSize = fileLen;
-            }
-            if (fileLen < minFileSize) {
-              minFileSize = fileLen;
-            }
-            accessTime = currentStatus.getAccessTime();
-            updateTime = currentStatus.getModificationTime();
-            if (accessTime > lastAccessTime) {
-              lastAccessTime = accessTime;
-            }
-            if (updateTime > lastUpdateTime) {
-              lastUpdateTime = updateTime;
-            }
-          }
-        } catch (IOException e) {
-          // ignore
-        }
-      }
-    }
-
-    builder
-    .put("totalNumberFiles", numOfFiles, ! unknown)
-    .put("totalFileSize",    totalFileSize, ! unknown)
-    .put("maxFileSize",      maxFileSize, ! unknown)
-    .put("minFileSize",      numOfFiles > 0 ? minFileSize : 0, ! unknown)
-    .put("lastAccessTime",   lastAccessTime, ! (unknown  || lastAccessTime < 0))
-    .put("lastUpdateTime",   lastUpdateTime, ! unknown);
-  }
-
-  /**
-   * Show the table partitions.
-   */
-  @Override
-  public void showTablePartitions(DataOutputStream out, List<String> parts)
-      throws HiveException {
-    asJson(out, MapBuilder.create().put("partitions",
-        makeTablePartions(parts)).build());
-  }
-
-  private List<Map<String, Object>> makeTablePartions(List<String> parts) {
-    ArrayList<Map<String, Object>> res =
-        new ArrayList<Map<String, Object>>(parts.size());
-    for (String part : parts) {
-      res.add(makeOneTablePartition(part));
-    }
-    return res;
-  }
-
-  // This seems like a very wrong implementation.
-  private Map<String, Object> makeOneTablePartition(String partIdent) {
-    ArrayList<Map<String, Object>> res = new ArrayList<Map<String, Object>>();
-
-    ArrayList<String> names = new ArrayList<String>();
-    for (String part : StringUtils.split(partIdent, "/")) {
-      String name = part;
-      String val = null;
-      String[] kv = StringUtils.split(part, "=", 2);
-      if (kv != null) {
-        name = kv[0];
-        if (kv.length > 1) {
-          try {
-            val = URLDecoder.decode(kv[1], StandardCharsets.UTF_8.name());
-          } catch (UnsupportedEncodingException e) {
-          }
-        }
-      }
-      if (val != null) {
-        names.add(name + "='" + val + "'");
-      }
-      else {
-        names.add(name);
-      }
-
-      res.add(MapBuilder.create()
-          .put("columnName", name)
-          .put("columnValue", val)
-          .build());
-    }
-
-    return MapBuilder.create()
-        .put("name", StringUtils.join(names, ","))
-        .put("values", res)
-        .build();
-  }
-
-  /**
-   * Show a list of databases
-   */
-  @Override
-  public void showDatabases(DataOutputStream out, List<String> databases)
-      throws HiveException {
-    asJson(out, MapBuilder.create().put("databases", databases).build());
-  }
-
-  /**
-   * Show the description of a database
-   */
-  @Override
-  public void showDatabaseDescription(DataOutputStream out, String database, String comment,
-      String location, String managedLocation, String ownerName, PrincipalType ownerType, String connectorName, String remoteDbName, Map<String, String> params)
-          throws HiveException {
-    MapBuilder builder = MapBuilder.create().put("database", database).put("comment", comment)
-        .put("location", location);
-    if (null != managedLocation) {
-      builder.put("managedLocation", managedLocation);
-    }
-    if (null != ownerName) {
-      builder.put("owner", ownerName);
-    }
-    if (null != ownerType) {
-      builder.put("ownerType", ownerType.name());
-    }
-    if (null != connectorName) {
-      builder.put("connector_name", connectorName);
-    }
-    if (null != remoteDbName) {
-      builder.put("remote_dbname", remoteDbName);
-    }
-    if (null != params && !params.isEmpty()) {
-      builder.put("params", params);
-    }
-    asJson(out, builder.build());
-  }
-
-  /**
-   * Show a list of dataconnectors
-   */
-  @Override
-  public void showDataConnectors(DataOutputStream out, List<String> connectors)
-      throws HiveException {
-    asJson(out, MapBuilder.create().put("connectors", connectors).build());
-  }
-
-  /**
-   * Show the description of a dataconnector
-   */
-  @Override
-  public void showDataConnectorDescription(DataOutputStream out, String dcName, String type,
-      String url, String ownerName, PrincipalType ownerType, String comment, Map<String, String> params)
-          throws HiveException {
-    MapBuilder builder = MapBuilder.create().put("connector", dcName).put("type", type)
-        .put("url", url);
-    if (null != ownerName) {
-      builder.put("owner", ownerName);
-    }
-    if (null != ownerType) {
-      builder.put("ownerType", ownerType.name());
-    }
-    if (null != comment) {
-      builder.put("comment", comment);
-    }
-    if (null != params && !params.isEmpty()) {
-      builder.put("params", params);
-    }
-    asJson(out, builder.build());
-  }
-
-  @Override
-  public void showResourcePlans(DataOutputStream out, List<WMResourcePlan> resourcePlans)
-      throws HiveException {
-    JsonGenerator generator = null;
-    try {
-      generator = new ObjectMapper().getJsonFactory().createJsonGenerator(out);
-      generator.writeStartArray();
-      for (WMResourcePlan plan : resourcePlans) {
-        generator.writeStartObject();
-        generator.writeStringField("name", plan.getName());
-        generator.writeStringField("status", plan.getStatus().name());
-        if (plan.isSetQueryParallelism()) {
-          generator.writeNumberField("queryParallelism", plan.getQueryParallelism());
-        }
-        if (plan.isSetDefaultPoolPath()) {
-          generator.writeStringField("defaultPoolPath", plan.getDefaultPoolPath());
-        }
-        generator.writeEndObject();
-      }
-      generator.writeEndArray();
-      generator.close();
-    } catch (IOException e) {
-      throw new HiveException(e);
-    } finally {
-      if (generator != null) {
-        IOUtils.closeQuietly(generator);
-      }
-    }
-  }
-
-  /**
-   * Formats a resource plan into a json object, the structure is as follows:
-   * {
-   *    name: "<rp_name>",
-   *    parallelism: "<parallelism>",
-   *    defaultQueue: "<defaultQueue>",
-   *    pools : [
-   *      {
-   *        name: "<pool_name>",
-   *        parallelism: "<parallelism>",
-   *        schedulingPolicy: "<policy>",
-   *        triggers: [
-   *          { name: "<triggerName>", trigger: "<trigExpression>", action: "<actionExpr">}
-   *          ...
-   *        ]
-   *      }
-   *      ...
-   *    ]
-   * }
-   */
-  private static class JsonRPFormatter implements MetaDataFormatUtils.RPFormatter, Closeable {
-    private final JsonGenerator generator;
-
-    JsonRPFormatter(DataOutputStream out) throws IOException {
-      generator = new ObjectMapper().getJsonFactory().createJsonGenerator(out);
-    }
-
-    private void writeNameAndFields(String name, Object ... kvPairs) throws IOException {
-      if (kvPairs.length % 2 != 0) {
-        throw new IllegalArgumentException("Expected pairs");
-      }
-      generator.writeStringField("name", name);
-      for (int i = 0; i < kvPairs.length; i += 2) {
-        generator.writeObjectField(kvPairs[i].toString(), kvPairs[i + 1]);
-      }
-    }
-
-    @Override
-    public void startRP(String rpName, Object ... kvPairs) throws IOException {
-      generator.writeStartObject();
-      writeNameAndFields(rpName, kvPairs);
-    }
-
-    @Override
-    public void endRP() throws IOException {
-      // End the root rp object.
-      generator.writeEndObject();
-    }
-
-    @Override
-    public void startPools() throws IOException {
-      generator.writeArrayFieldStart("pools");
-    }
-
-    @Override
-    public void endPools() throws IOException {
-      // End the pools array.
-      generator.writeEndArray();
-    }
-
-    @Override
-    public void startPool(String poolName, Object ... kvPairs) throws IOException {
-      generator.writeStartObject();
-      writeNameAndFields(poolName, kvPairs);
-    }
-
-    @Override
-    public void startTriggers() throws IOException {
-      generator.writeArrayFieldStart("triggers");
-    }
-
-    @Override
-    public void endTriggers() throws IOException {
-      generator.writeEndArray();
-    }
-
-    @Override
-    public void startMappings() throws IOException {
-      generator.writeArrayFieldStart("mappings");
-    }
-
-    @Override
-    public void endMappings() throws IOException {
-      generator.writeEndArray();
-    }
-
-    @Override
-    public void endPool() throws IOException {
-      generator.writeEndObject();
-    }
-
-    @Override
-    public void formatTrigger(String triggerName, String actionExpression,
-        String triggerExpression) throws IOException {
-      generator.writeStartObject();
-      writeNameAndFields(triggerName, "action", actionExpression, "trigger", triggerExpression);
-      generator.writeEndObject();
-    }
-
-    @Override
-    public void formatMappingType(String type, List<String> names) throws IOException {
-      generator.writeStartObject();
-      generator.writeStringField("type", type);
-      generator.writeArrayFieldStart("values");
-      for (String name : names) {
-        generator.writeString(name);
-      }
-      generator.writeEndArray();
-      generator.writeEndObject();
-    }
-
-    @Override
-    public void close() throws IOException {
-      generator.close();
-    }
-  }
-
-  public void showFullResourcePlan(DataOutputStream out, WMFullResourcePlan resourcePlan)
-      throws HiveException {
-    try (JsonRPFormatter formatter = new JsonRPFormatter(out)) {
-      MetaDataFormatUtils.formatFullRP(formatter, resourcePlan);
-    } catch (IOException e) {
-      throw new HiveException(e);
-    }
->>>>>>> External metastore: clean after rebase
-  }
-
   @Override
   public void showErrors(DataOutputStream out, WMValidateResourcePlanResponse response) throws HiveException {
     try (JsonGenerator generator = new ObjectMapper().getJsonFactory().createJsonGenerator(out)) {
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
index d66d928..2af557e 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
@@ -15,10374 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.hadoop.hive.metastore;
-
-import static org.apache.commons.lang3.StringUtils.join;
-import static org.apache.commons.lang3.StringUtils.isBlank;
-import static org.apache.hadoop.hive.metastore.Warehouse.DEFAULT_DATABASE_COMMENT;
-import static org.apache.hadoop.hive.metastore.Warehouse.DEFAULT_DATABASE_NAME;
-import static org.apache.hadoop.hive.metastore.Warehouse.DEFAULT_CATALOG_NAME;
-import static org.apache.hadoop.hive.metastore.Warehouse.getCatalogQualifiedTableName;
-import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.getDefaultCatalog;
-import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.parseDbName;
-import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.CAT_NAME;
-import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.DB_NAME;
-import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.prependCatalogToDbName;
-import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.prependNotNullCatToDbName;
-
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.nio.ByteBuffer;
-import java.security.PrivilegedExceptionAction;
-import java.util.AbstractMap;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.BitSet;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-import java.util.regex.Pattern;
-
-import javax.jdo.JDOException;
-
-import com.codahale.metrics.Counter;
-import com.google.common.base.Supplier;
-import com.google.common.base.Suppliers;
-import com.google.common.collect.Lists;
-
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FSDataOutputStream;
-import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hive.common.AcidConstants;
-import org.apache.hadoop.hive.common.AcidMetaDataFile;
-import org.apache.hadoop.hive.common.StatsSetupConst;
-import org.apache.hadoop.hive.common.TableName;
-import org.apache.hadoop.hive.common.ValidReaderWriteIdList;
-import org.apache.hadoop.hive.common.ValidWriteIdList;
-import org.apache.hadoop.hive.common.ZooKeeperHiveHelper;
-import org.apache.hadoop.hive.common.ZKDeRegisterWatcher;
-import org.apache.hadoop.hive.common.repl.ReplConst;
-import org.apache.hadoop.hive.metastore.api.*;
-import org.apache.hadoop.hive.metastore.dataconnector.DataConnectorProviderFactory;
-import org.apache.hadoop.hive.metastore.events.*;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf.StatsUpdateMode;
-import org.apache.hadoop.hive.metastore.messaging.EventMessage.EventType;
-import org.apache.hadoop.hive.metastore.metrics.JvmPauseMonitor;
-import org.apache.hadoop.hive.metastore.metrics.Metrics;
-import org.apache.hadoop.hive.metastore.metrics.MetricsConstants;
-import org.apache.hadoop.hive.metastore.metrics.PerfLogger;
-import org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy;
-import org.apache.hadoop.hive.metastore.security.HadoopThriftAuthBridge;
-import org.apache.hadoop.hive.metastore.security.MetastoreDelegationTokenManager;
-import org.apache.hadoop.hive.metastore.txn.CompactionInfo;
-import org.apache.hadoop.hive.metastore.txn.TxnStore;
-import org.apache.hadoop.hive.metastore.txn.TxnUtils;
-import org.apache.hadoop.hive.metastore.utils.FilterUtils;
-import org.apache.hadoop.hive.metastore.utils.MetaStoreServerUtils;
-import org.apache.hadoop.security.SecurityUtil;
-import org.apache.hadoop.hive.metastore.utils.CommonCliOptions;
-import org.apache.hadoop.hive.metastore.utils.FileUtils;
-import org.apache.hadoop.hive.metastore.utils.HdfsUtils;
-import org.apache.hadoop.hive.metastore.utils.JavaUtils;
-import org.apache.hadoop.hive.metastore.utils.LogUtils;
-import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils;
-import org.apache.hadoop.hive.metastore.utils.MetastoreVersionInfo;
-import org.apache.hadoop.hive.metastore.utils.SecurityUtils;
-import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.hadoop.util.ReflectionUtils;
-import org.apache.hadoop.util.ShutdownHookManager;
-import org.apache.hadoop.util.StringUtils;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.thrift.TException;
-import org.apache.thrift.TProcessor;
-import org.apache.thrift.protocol.TBinaryProtocol;
-import org.apache.thrift.protocol.TCompactProtocol;
-import org.apache.thrift.protocol.TProtocol;
-import org.apache.thrift.protocol.TProtocolFactory;
-import org.apache.thrift.server.ServerContext;
-import org.apache.thrift.server.TServer;
-import org.apache.thrift.server.TServerEventHandler;
-import org.apache.thrift.server.TThreadPoolServer;
-import org.apache.thrift.transport.TServerSocket;
-import org.apache.thrift.transport.TTransport;
-import org.apache.thrift.transport.TTransportFactory;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.facebook.fb303.FacebookBase;
-import com.facebook.fb303.fb_status;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Splitter;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-
-/**
- * TODO:pc remove application logic to a separate interface.
- */
-public class HiveMetaStore extends ThriftHiveMetastore {
-  public static final Logger LOG = LoggerFactory.getLogger(HiveMetaStore.class);
-  public static final String PARTITION_NUMBER_EXCEED_LIMIT_MSG =
-      "Number of partitions scanned (=%d) on table '%s' exceeds limit (=%d). This is controlled on the metastore server by %s.";
-
-  // boolean that tells if the HiveMetaStore (remote) server is being used.
-  // Can be used to determine if the calls to metastore api (HMSHandler) are being made with
-  // embedded metastore or a remote one
-  private static boolean isMetaStoreRemote = false;
-
-  // Used for testing to simulate method timeout.
-  @VisibleForTesting
-  static boolean TEST_TIMEOUT_ENABLED = false;
-  @VisibleForTesting
-  static long TEST_TIMEOUT_VALUE = -1;
-
-  private static ShutdownHookManager shutdownHookMgr;
-
-  public static final String ADMIN = "admin";
-  public static final String PUBLIC = "public";
-  /** MM write states. */
-  public static final char MM_WRITE_OPEN = 'o', MM_WRITE_COMMITTED = 'c', MM_WRITE_ABORTED = 'a';
-
-  private static HadoopThriftAuthBridge.Server saslServer;
-  private static MetastoreDelegationTokenManager delegationTokenManager;
-  private static boolean useSasl;
-
-  static final String NO_FILTER_STRING = "";
-  static final int UNLIMITED_MAX_PARTITIONS = -1;
-  private static ZooKeeperHiveHelper zooKeeperHelper = null;
-  private static String msHost = null;
-
-  public static boolean isRenameAllowed(Database srcDB, Database destDB) {
-    if (!srcDB.getName().equalsIgnoreCase(destDB.getName())) {
-      if (ReplChangeManager.isSourceOfReplication(srcDB) || ReplChangeManager.isSourceOfReplication(destDB)) {
-        return false;
-      }
-    }
-    return true;
-  }
-
-  public static class HMSHandler extends FacebookBase implements IHMSHandler {
-    public static final Logger LOG = HiveMetaStore.LOG;
-    private final Configuration conf; // stores datastore (jpox) properties,
-                                     // right now they come from jpox.properties
-
-    // Flag to control that always threads are initialized only once
-    // instead of multiple times
-    private final static AtomicBoolean alwaysThreadsInitialized =
-        new AtomicBoolean(false);
-
-    private static String currentUrl;
-    private FileMetadataManager fileMetadataManager;
-    private PartitionExpressionProxy expressionProxy;
-    private StorageSchemaReader storageSchemaReader;
-    private IMetaStoreMetadataTransformer transformer;
-    private static DataConnectorProviderFactory dataconnectorFactory = null;
-
-    // Variables for metrics
-    // Package visible so that HMSMetricsListener can see them.
-    static AtomicInteger databaseCount, tableCount, partCount;
-
-    private Warehouse wh; // hdfs warehouse
-    private static final ThreadLocal<RawStore> threadLocalMS =
-        new ThreadLocal<RawStore>() {
-          @Override
-          protected RawStore initialValue() {
-            return null;
-          }
-        };
-
-    private static final ThreadLocal<TxnStore> threadLocalTxn = new ThreadLocal<TxnStore>() {
-      @Override
-      protected TxnStore initialValue() {
-        return null;
-      }
-    };
-
-    private static final ThreadLocal<Map<String, com.codahale.metrics.Timer.Context>> timerContexts =
-        new ThreadLocal<Map<String, com.codahale.metrics.Timer.Context>>() {
-      @Override
-      protected Map<String, com.codahale.metrics.Timer.Context> initialValue() {
-        return new HashMap<>();
-      }
-    };
-
-    public static RawStore getRawStore() {
-      return threadLocalMS.get();
-    }
-
-    static void removeRawStore() {
-      threadLocalMS.remove();
-    }
-
-    // Thread local configuration is needed as many threads could make changes
-    // to the conf using the connection hook
-    private static final ThreadLocal<Configuration> threadLocalConf =
-        new ThreadLocal<Configuration>() {
-          @Override
-          protected Configuration initialValue() {
-            return null;
-          }
-        };
-
-    /**
-     * Thread local HMSHandler used during shutdown to notify meta listeners
-     */
-    private static final ThreadLocal<HMSHandler> threadLocalHMSHandler = new ThreadLocal<>();
-
-    /**
-     * Thread local Map to keep track of modified meta conf keys
-     */
-    private static final ThreadLocal<Map<String, String>> threadLocalModifiedConfig =
-        new ThreadLocal<>();
-
-    private static ExecutorService threadPool;
-
-    static final Logger auditLog = LoggerFactory.getLogger(
-        HiveMetaStore.class.getName() + ".audit");
-
-    private static void logAuditEvent(String cmd) {
-      if (cmd == null) {
-        return;
-      }
-
-      UserGroupInformation ugi;
-      try {
-        ugi = SecurityUtils.getUGI();
-      } catch (Exception ex) {
-        throw new RuntimeException(ex);
-      }
-
-      String address = getIPAddress();
-      if (address == null) {
-        address = "unknown-ip-addr";
-      }
-
-      auditLog.info("ugi={}	ip={}	cmd={}	", ugi.getUserName(), address, cmd);
-    }
-
-    public static String getIPAddress() {
-      if (useSasl) {
-        if (saslServer != null && saslServer.getRemoteAddress() != null) {
-          return saslServer.getRemoteAddress().getHostAddress();
-        }
-      } else {
-        // if kerberos is not enabled
-        return getThreadLocalIpAddress();
-      }
-      return null;
-    }
-
-    private static AtomicInteger nextSerialNum = new AtomicInteger();
-    private static ThreadLocal<Integer> threadLocalId = new ThreadLocal<Integer>() {
-      @Override
-      protected Integer initialValue() {
-        return nextSerialNum.getAndIncrement();
-      }
-    };
-
-    // This will only be set if the metastore is being accessed from a metastore Thrift server,
-    // not if it is from the CLI. Also, only if the TTransport being used to connect is an
-    // instance of TSocket. This is also not set when kerberos is used.
-    private static ThreadLocal<String> threadLocalIpAddress = new ThreadLocal<String>() {
-      @Override
-      protected String initialValue() {
-        return null;
-      }
-    };
-
-    /**
-     * Internal function to notify listeners for meta config change events
-     */
-    private void notifyMetaListeners(String key, String oldValue, String newValue) throws MetaException {
-      for (MetaStoreEventListener listener : listeners) {
-        listener.onConfigChange(new ConfigChangeEvent(this, key, oldValue, newValue));
-      }
-
-      if (transactionalListeners.size() > 0) {
-        // All the fields of this event are final, so no reason to create a new one for each
-        // listener
-        ConfigChangeEvent cce = new ConfigChangeEvent(this, key, oldValue, newValue);
-        for (MetaStoreEventListener transactionalListener : transactionalListeners) {
-          transactionalListener.onConfigChange(cce);
-        }
-      }
-    }
-
-    /**
-     * Internal function to notify listeners to revert back to old values of keys
-     * that were modified during setMetaConf. This would get called from HiveMetaStore#cleanupRawStore
-     */
-    private void notifyMetaListenersOnShutDown() {
-      Map<String, String> modifiedConf = threadLocalModifiedConfig.get();
-      if (modifiedConf == null) {
-        // Nothing got modified
-        return;
-      }
-      try {
-        Configuration conf = threadLocalConf.get();
-        if (conf == null) {
-          throw new MetaException("Unexpected: modifiedConf is non-null but conf is null");
-        }
-        // Notify listeners of the changed value
-        for (Entry<String, String> entry : modifiedConf.entrySet()) {
-          String key = entry.getKey();
-          // curr value becomes old and vice-versa
-          String currVal = entry.getValue();
-          String oldVal = conf.get(key);
-          if (!Objects.equals(oldVal, currVal)) {
-            notifyMetaListeners(key, oldVal, currVal);
-          }
-        }
-        logAndAudit("Meta listeners shutdown notification completed.");
-      } catch (MetaException e) {
-        LOG.error("Failed to notify meta listeners on shutdown: ", e);
-      }
-    }
-
-    static void setThreadLocalIpAddress(String ipAddress) {
-      threadLocalIpAddress.set(ipAddress);
-    }
-
-    // This will return null if the metastore is not being accessed from a metastore Thrift server,
-    // or if the TTransport being used to connect is not an instance of TSocket, or if kereberos
-    // is used
-    static String getThreadLocalIpAddress() {
-      return threadLocalIpAddress.get();
-    }
-
-    // Make it possible for tests to check that the right type of PartitionExpressionProxy was
-    // instantiated.
-    @VisibleForTesting
-    PartitionExpressionProxy getExpressionProxy() {
-      return expressionProxy;
-    }
-
-    /**
-     * Use {@link #getThreadId()} instead.
-     * @return thread id
-     */
-    @Deprecated
-    public static Integer get() {
-      return threadLocalId.get();
-    }
-
-    @Override
-    public int getThreadId() {
-      return threadLocalId.get();
-    }
-
-    public HMSHandler(String name) throws MetaException {
-      this(name, MetastoreConf.newMetastoreConf(), true);
-    }
-
-    public HMSHandler(String name, Configuration conf) throws MetaException {
-      this(name, conf, true);
-    }
-
-    public HMSHandler(String name, Configuration conf, boolean init) throws MetaException {
-      super(name);
-      this.conf = conf;
-      isInTest = MetastoreConf.getBoolVar(this.conf, ConfVars.HIVE_IN_TEST);
-      if (threadPool == null) {
-        synchronized (HMSHandler.class) {
-          int numThreads = MetastoreConf.getIntVar(conf, ConfVars.FS_HANDLER_THREADS_COUNT);
-          threadPool = Executors.newFixedThreadPool(numThreads,
-              new ThreadFactoryBuilder().setDaemon(true)
-                  .setNameFormat("HMSHandler #%d").build());
-        }
-      }
-      if (init) {
-        init();
-      }
-    }
-
-    /**
-     * Use {@link #getConf()} instead.
-     * @return Configuration object
-     */
-    @Deprecated
-    public Configuration getHiveConf() {
-      return conf;
-    }
-
-    private ClassLoader classLoader;
-    private AlterHandler alterHandler;
-    private List<MetaStorePreEventListener> preListeners;
-    private List<MetaStoreEventListener> listeners;
-    private List<TransactionalMetaStoreEventListener> transactionalListeners;
-    private List<MetaStoreEndFunctionListener> endFunctionListeners;
-    private List<MetaStoreInitListener> initListeners;
-    private MetaStoreFilterHook filterHook;
-    private boolean isServerFilterEnabled = false;
-
-    private Pattern partitionValidationPattern;
-    private final boolean isInTest;
-
-    {
-      classLoader = Thread.currentThread().getContextClassLoader();
-      if (classLoader == null) {
-        classLoader = Configuration.class.getClassLoader();
-      }
-    }
-
-    @Override
-    public List<TransactionalMetaStoreEventListener> getTransactionalListeners() {
-      return transactionalListeners;
-    }
-
-    @Override
-    public List<MetaStoreEventListener> getListeners() {
-      return listeners;
-    }
-
-    @Override
-    public void init() throws MetaException {
-      initListeners = MetaStoreServerUtils.getMetaStoreListeners(
-          MetaStoreInitListener.class, conf, MetastoreConf.getVar(conf, ConfVars.INIT_HOOKS));
-      for (MetaStoreInitListener singleInitListener: initListeners) {
-          MetaStoreInitContext context = new MetaStoreInitContext();
-          singleInitListener.onInit(context);
-      }
-
-      String alterHandlerName = MetastoreConf.getVar(conf, ConfVars.ALTER_HANDLER);
-      alterHandler = ReflectionUtils.newInstance(JavaUtils.getClass(
-          alterHandlerName, AlterHandler.class), conf);
-      wh = new Warehouse(conf);
-
-      synchronized (HMSHandler.class) {
-        if (currentUrl == null || !currentUrl.equals(MetaStoreInit.getConnectionURL(conf))) {
-          createDefaultDB();
-          createDefaultRoles();
-          addAdminUsers();
-          currentUrl = MetaStoreInit.getConnectionURL(conf);
-        }
-      }
-
-      //Start Metrics
-      if (MetastoreConf.getBoolVar(conf, ConfVars.METRICS_ENABLED)) {
-        LOG.info("Begin calculating metadata count metrics.");
-        Metrics.initialize(conf);
-        databaseCount = Metrics.getOrCreateGauge(MetricsConstants.TOTAL_DATABASES);
-        tableCount = Metrics.getOrCreateGauge(MetricsConstants.TOTAL_TABLES);
-        partCount = Metrics.getOrCreateGauge(MetricsConstants.TOTAL_PARTITIONS);
-        updateMetrics();
-
-      }
-
-      preListeners = MetaStoreServerUtils.getMetaStoreListeners(MetaStorePreEventListener.class,
-          conf, MetastoreConf.getVar(conf, ConfVars.PRE_EVENT_LISTENERS));
-      preListeners.add(0, new TransactionalValidationListener(conf));
-      listeners = MetaStoreServerUtils.getMetaStoreListeners(MetaStoreEventListener.class, conf,
-          MetastoreConf.getVar(conf, ConfVars.EVENT_LISTENERS));
-      listeners.add(new SessionPropertiesListener(conf));
-      transactionalListeners = new ArrayList() {{
-          add(new AcidEventListener(conf));
-      }};
-      transactionalListeners.addAll(MetaStoreServerUtils.getMetaStoreListeners(
-              TransactionalMetaStoreEventListener.class, conf,
-              MetastoreConf.getVar(conf, ConfVars.TRANSACTIONAL_EVENT_LISTENERS)));
-      if (Metrics.getRegistry() != null) {
-        listeners.add(new HMSMetricsListener(conf));
-      }
-
-      boolean canCachedStoreCanUseEvent = false;
-      for (MetaStoreEventListener listener : transactionalListeners) {
-        if (listener.doesAddEventsToNotificationLogTable()) {
-          canCachedStoreCanUseEvent = true;
-          break;
-        }
-      }
-      if (conf.getBoolean(ConfVars.METASTORE_CACHE_CAN_USE_EVENT.getVarname(), false) &&
-              !canCachedStoreCanUseEvent) {
-        throw new MetaException("CahcedStore can not use events for invalidation as there is no " +
-                " TransactionalMetaStoreEventListener to add events to notification table");
-      }
-
-      endFunctionListeners = MetaStoreServerUtils.getMetaStoreListeners(
-          MetaStoreEndFunctionListener.class, conf, MetastoreConf.getVar(conf, ConfVars.END_FUNCTION_LISTENERS));
-
-      String partitionValidationRegex =
-          MetastoreConf.getVar(conf, ConfVars.PARTITION_NAME_WHITELIST_PATTERN);
-      if (partitionValidationRegex != null && !partitionValidationRegex.isEmpty()) {
-        partitionValidationPattern = Pattern.compile(partitionValidationRegex);
-      } else {
-        partitionValidationPattern = null;
-      }
-
-      // We only initialize once the tasks that need to be run periodically. For remote metastore
-      // these threads are started along with the other housekeeping threads only in the leader
-      // HMS.
-      String leaderHost = MetastoreConf.getVar(conf,
-              MetastoreConf.ConfVars.METASTORE_HOUSEKEEPING_LEADER_HOSTNAME);
-      if (!isMetaStoreRemote() && ((leaderHost == null) || leaderHost.trim().isEmpty())) {
-        startAlwaysTaskThreads(conf);
-      } else if (!isMetaStoreRemote()) {
-        LOG.info("Not starting tasks specified by " + ConfVars.TASK_THREADS_ALWAYS.getVarname() +
-                " since " + leaderHost + " is configured to run these tasks.");
-      }
-      expressionProxy = PartFilterExprUtil.createExpressionProxy(conf);
-      fileMetadataManager = new FileMetadataManager(this.getMS(), conf);
-
-      isServerFilterEnabled = getIfServerFilterenabled();
-      filterHook = isServerFilterEnabled ? loadFilterHooks() : null;
-
-      String className = MetastoreConf.getVar(conf, MetastoreConf.ConfVars.METASTORE_METADATA_TRANSFORMER_CLASS);
-      if (className != null && !className.trim().isEmpty()) {
-        Class<?> clazz;
-        try {
-          clazz = conf.getClassByName(className);
-        } catch (ClassNotFoundException e) {
-          LOG.error("Unable to load class " + className, e);
-          throw new IllegalArgumentException(e);
-        }
-        Constructor<?> constructor;
-        try {
-          constructor = clazz.getConstructor(IHMSHandler.class);
-          if (Modifier.isPrivate(constructor.getModifiers()))
-            throw new IllegalArgumentException("Illegal implementation for metadata transformer. Constructor is private");
-          transformer = (IMetaStoreMetadataTransformer) constructor.newInstance(this);
-        } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
-          LOG.error("Unable to create instance of class " + className, e);
-          throw new IllegalArgumentException(e);
-        }
-      }
-      dataconnectorFactory = DataConnectorProviderFactory.getInstance(this);
-    }
-
-    private static void startAlwaysTaskThreads(Configuration conf) throws MetaException {
-      if (alwaysThreadsInitialized.compareAndSet(false, true)) {
-        ThreadPool.initialize(conf);
-        Collection<String> taskNames =
-                MetastoreConf.getStringCollection(conf, ConfVars.TASK_THREADS_ALWAYS);
-        for (String taskName : taskNames) {
-          MetastoreTaskThread task =
-                  JavaUtils.newInstance(JavaUtils.getClass(taskName, MetastoreTaskThread.class));
-          task.setConf(conf);
-          long freq = task.runFrequency(TimeUnit.MILLISECONDS);
-          LOG.info("Scheduling for " + task.getClass().getCanonicalName() + " service with " +
-                  "frequency " + freq + "ms.");
-          // For backwards compatibility, since some threads used to be hard coded but only run if
-          // frequency was > 0
-          if (freq > 0) {
-            ThreadPool.getPool().scheduleAtFixedRate(task, freq, freq, TimeUnit.MILLISECONDS);
-          }
-        }
-      }
-    }
-
-    /**
-     *
-     * Filter is actually enabled only when the configured filter hook is configured, not default, and
-     * enabled in configuration
-     * @return
-     */
-    private boolean getIfServerFilterenabled() throws MetaException{
-      boolean isEnabled = MetastoreConf.getBoolVar(conf, ConfVars.METASTORE_SERVER_FILTER_ENABLED);
-
-      if (!isEnabled) {
-        LOG.info("HMS server filtering is disabled by configuration");
-        return false;
-      }
-
-      String filterHookClassName = MetastoreConf.getVar(conf, ConfVars.FILTER_HOOK);
-
-      if (isBlank(filterHookClassName)) {
-        throw new MetaException("HMS server filtering is enabled but no filter hook is configured");
-      }
-
-      if (filterHookClassName.trim().equalsIgnoreCase(DefaultMetaStoreFilterHookImpl.class.getName())) {
-        throw new MetaException("HMS server filtering is enabled but the filter hook is DefaultMetaStoreFilterHookImpl, which does no filtering");
-      }
-
-      LOG.info("HMS server filtering is enabled. The filter class is " + filterHookClassName);
-      return true;
-    }
-
-    private MetaStoreFilterHook loadFilterHooks() throws IllegalStateException  {
-      String errorMsg = "Unable to load filter hook at HMS server. ";
-
-      String filterHookClassName = MetastoreConf.getVar(conf, ConfVars.FILTER_HOOK);
-      Preconditions.checkState(!isBlank(filterHookClassName));
-
-      try {
-        return (MetaStoreFilterHook)Class.forName(
-            filterHookClassName.trim(), true, JavaUtils.getClassLoader()).getConstructor(
-            Configuration.class).newInstance(conf);
-      } catch (Exception e) {
-        LOG.error(errorMsg, e);
-        throw new IllegalStateException(errorMsg + e.getMessage(), e);
-      }
-    }
-
-    /**
-     * Check if user can access the table associated with the partition. If not, then throw exception
-     * so user cannot access partitions associated with this table
-     * We are not calling Pre event listener for authorization because it requires getting the
-     * table object from DB, more overhead. Instead ,we call filter hook to filter out table if user
-     * has no access. Filter hook only requires table name, not table object. That saves DB access for
-     * table object, and still achieve the same purpose: checking if user can access the specified
-     * table
-     *
-     * @param catName catalog name of the table
-     * @param dbName database name of the table
-     * @param tblName table name
-     * @throws NoSuchObjectException
-     * @throws MetaException
-     */
-    private void authorizeTableForPartitionMetadata(
-        final String catName, final String dbName, final String tblName)
-        throws NoSuchObjectException, MetaException {
-
-      FilterUtils.checkDbAndTableFilters(
-          isServerFilterEnabled, filterHook, catName, dbName, tblName);
-    }
-
-    private static String addPrefix(String s) {
-      return threadLocalId.get() + ": " + s;
-    }
-
-    /**
-     * Set copy of invoking HMSHandler on thread local
-     */
-    private static void setHMSHandler(HMSHandler handler) {
-      if (threadLocalHMSHandler.get() == null) {
-        threadLocalHMSHandler.set(handler);
-      }
-    }
-    @Override
-    public void setConf(Configuration conf) {
-      threadLocalConf.set(conf);
-      RawStore ms = threadLocalMS.get();
-      if (ms != null) {
-        ms.setConf(conf); // reload if DS related configuration is changed
-      }
-    }
-
-    @Override
-    public Configuration getConf() {
-      Configuration conf = threadLocalConf.get();
-      if (conf == null) {
-        conf = new Configuration(this.conf);
-        threadLocalConf.set(conf);
-      }
-      return conf;
-    }
-
-    private Map<String, String> getModifiedConf() {
-      Map<String, String> modifiedConf = threadLocalModifiedConfig.get();
-      if (modifiedConf == null) {
-        modifiedConf = new HashMap<>();
-        threadLocalModifiedConfig.set(modifiedConf);
-      }
-      return modifiedConf;
-    }
-
-    @Override
-    public Warehouse getWh() {
-      return wh;
-    }
-
-    @Override
-    public void setMetaConf(String key, String value) throws MetaException {
-      ConfVars confVar = MetastoreConf.getMetaConf(key);
-      if (confVar == null) {
-        throw new MetaException("Invalid configuration key " + key);
-      }
-      try {
-        confVar.validate(value);
-      } catch (IllegalArgumentException e) {
-        throw new MetaException("Invalid configuration value " + value + " for key " + key +
-            " by " + e.getMessage());
-      }
-      Configuration configuration = getConf();
-      String oldValue = MetastoreConf.get(configuration, key);
-      // Save prev val of the key on threadLocal
-      Map<String, String> modifiedConf = getModifiedConf();
-      if (!modifiedConf.containsKey(key)) {
-        modifiedConf.put(key, oldValue);
-      }
-      // Set invoking HMSHandler on threadLocal, this will be used later to notify
-      // metaListeners in HiveMetaStore#cleanupRawStore
-      setHMSHandler(this);
-      configuration.set(key, value);
-      notifyMetaListeners(key, oldValue, value);
-
-      if (ConfVars.TRY_DIRECT_SQL == confVar) {
-        HMSHandler.LOG.info("Direct SQL optimization = {}",  value);
-      }
-    }
-
-    @Override
-    public String getMetaConf(String key) throws MetaException {
-      ConfVars confVar = MetastoreConf.getMetaConf(key);
-      if (confVar == null) {
-        throw new MetaException("Invalid configuration key " + key);
-      }
-      return getConf().get(key, confVar.getDefaultVal().toString());
-    }
-
-    /**
-     * Get a cached RawStore.
-     *
-     * @return the cached RawStore
-     * @throws MetaException
-     */
-    @Override
-    public RawStore getMS() throws MetaException {
-      Configuration conf = getConf();
-      return getMSForConf(conf);
-    }
-
-    public static RawStore getMSForConf(Configuration conf) throws MetaException {
-      RawStore ms = threadLocalMS.get();
-      if (ms == null) {
-        ms = newRawStoreForConf(conf);
-        try {
-          ms.verifySchema();
-        } catch (MetaException e) {
-          ms.shutdown();
-          throw e;
-        }
-        threadLocalMS.set(ms);
-        ms = threadLocalMS.get();
-        LOG.info("Created RawStore: " + ms + " from thread id: " + Thread.currentThread().getId());
-      }
-      return ms;
-    }
-
-    @Override
-    public TxnStore getTxnHandler() {
-      return getMsThreadTxnHandler(conf);
-    }
-
-    public static TxnStore getMsThreadTxnHandler(Configuration conf) {
-      TxnStore txn = threadLocalTxn.get();
-      if (txn == null) {
-        txn = TxnUtils.getTxnStore(conf);
-        threadLocalTxn.set(txn);
-      }
-      return txn;
-    }
-
-    static RawStore newRawStoreForConf(Configuration conf) throws MetaException {
-      Configuration newConf = new Configuration(conf);
-      String rawStoreClassName = MetastoreConf.getVar(newConf, ConfVars.RAW_STORE_IMPL);
-      LOG.info(addPrefix("Opening raw store with implementation class:" + rawStoreClassName));
-      return RawStoreProxy.getProxy(newConf, conf, rawStoreClassName, threadLocalId.get());
-    }
-
-    @VisibleForTesting
-    public static void createDefaultCatalog(RawStore ms, Warehouse wh) throws MetaException,
-        InvalidOperationException {
-      try {
-        Catalog defaultCat = ms.getCatalog(DEFAULT_CATALOG_NAME);
-        // Null check because in some test cases we get a null from ms.getCatalog.
-        if (defaultCat !=null && defaultCat.getLocationUri().equals("TBD")) {
-          // One time update issue.  When the new 'hive' catalog is created in an upgrade the
-          // script does not know the location of the warehouse.  So we need to update it.
-          LOG.info("Setting location of default catalog, as it hasn't been done after upgrade");
-          defaultCat.setLocationUri(wh.getWhRoot().toString());
-          ms.alterCatalog(defaultCat.getName(), defaultCat);
-        }
-
-      } catch (NoSuchObjectException e) {
-        Catalog cat = new Catalog(DEFAULT_CATALOG_NAME, wh.getWhRoot().toString());
-        long time = System.currentTimeMillis() / 1000;
-        cat.setCreateTime((int) time);
-        cat.setDescription(Warehouse.DEFAULT_CATALOG_COMMENT);
-        ms.createCatalog(cat);
-      }
-    }
-
-    private void createDefaultDB_core(RawStore ms) throws MetaException, InvalidObjectException {
-      try {
-        ms.getDatabase(DEFAULT_CATALOG_NAME, DEFAULT_DATABASE_NAME);
-      } catch (NoSuchObjectException e) {
-        LOG.info("Started creating a default database with name: "+DEFAULT_DATABASE_NAME);
-        Database db = new Database(DEFAULT_DATABASE_NAME, DEFAULT_DATABASE_COMMENT,
-            wh.getDefaultDatabasePath(DEFAULT_DATABASE_NAME, true).toString(), null);
-        db.setOwnerName(PUBLIC);
-        db.setOwnerType(PrincipalType.ROLE);
-        db.setCatalogName(DEFAULT_CATALOG_NAME);
-        long time = System.currentTimeMillis() / 1000;
-        db.setCreateTime((int) time);
-        ms.createDatabase(db);
-        LOG.info("Successfully created a default database with name: "+DEFAULT_DATABASE_NAME);
-      }
-    }
-
-    /**
-     * create default database if it doesn't exist.
-     *
-     * This is a potential contention when HiveServer2 using embedded metastore and Metastore
-     * Server try to concurrently invoke createDefaultDB. If one failed, JDOException was caught
-     * for one more time try, if failed again, simply ignored by warning, which meant another
-     * succeeds.
-     *
-     * @throws MetaException
-     */
-    private void createDefaultDB() throws MetaException {
-      try {
-        RawStore ms = getMS();
-        createDefaultCatalog(ms, wh);
-        createDefaultDB_core(ms);
-      } catch (JDOException e) {
-        LOG.warn("Retrying creating default database after error: " + e.getMessage(), e);
-        try {
-          RawStore ms = getMS();
-          createDefaultCatalog(ms, wh);
-          createDefaultDB_core(ms);
-        } catch (InvalidObjectException | InvalidOperationException e1) {
-          throw new MetaException(e1.getMessage());
-        }
-      } catch (InvalidObjectException|InvalidOperationException e) {
-        throw new MetaException(e.getMessage());
-      }
-    }
-
-    /**
-     * create default roles if they don't exist.
-     *
-     * This is a potential contention when HiveServer2 using embedded metastore and Metastore
-     * Server try to concurrently invoke createDefaultRoles. If one failed, JDOException was caught
-     * for one more time try, if failed again, simply ignored by warning, which meant another
-     * succeeds.
-     *
-     * @throws MetaException
-     */
-    private void createDefaultRoles() throws MetaException {
-      try {
-        createDefaultRoles_core();
-      } catch (JDOException e) {
-        LOG.warn("Retrying creating default roles after error: " + e.getMessage(), e);
-        createDefaultRoles_core();
-      }
-    }
-
-    private void createDefaultRoles_core() throws MetaException {
-
-      RawStore ms = getMS();
-      try {
-        ms.addRole(ADMIN, ADMIN);
-      } catch (InvalidObjectException e) {
-        LOG.debug(ADMIN +" role already exists",e);
-      } catch (NoSuchObjectException e) {
-        // This should never be thrown.
-        LOG.warn("Unexpected exception while adding " +ADMIN+" roles" , e);
-      }
-      LOG.info("Added "+ ADMIN+ " role in metastore");
-      try {
-        ms.addRole(PUBLIC, PUBLIC);
-      } catch (InvalidObjectException e) {
-        LOG.debug(PUBLIC + " role already exists",e);
-      } catch (NoSuchObjectException e) {
-        // This should never be thrown.
-        LOG.warn("Unexpected exception while adding "+PUBLIC +" roles" , e);
-      }
-      LOG.info("Added "+PUBLIC+ " role in metastore");
-      // now grant all privs to admin
-      PrivilegeBag privs = new PrivilegeBag();
-      privs.addToPrivileges(new HiveObjectPrivilege( new HiveObjectRef(HiveObjectType.GLOBAL, null,
-        null, null, null), ADMIN, PrincipalType.ROLE, new PrivilegeGrantInfo("All", 0, ADMIN,
-          PrincipalType.ROLE, true), "SQL"));
-      try {
-        ms.grantPrivileges(privs);
-      } catch (InvalidObjectException e) {
-        // Surprisingly these privs are already granted.
-        LOG.debug("Failed while granting global privs to admin", e);
-      } catch (NoSuchObjectException e) {
-        // Unlikely to be thrown.
-        LOG.warn("Failed while granting global privs to admin", e);
-      }
-    }
-
-    /**
-     * add admin users if they don't exist.
-     *
-     * This is a potential contention when HiveServer2 using embedded metastore and Metastore
-     * Server try to concurrently invoke addAdminUsers. If one failed, JDOException was caught for
-     * one more time try, if failed again, simply ignored by warning, which meant another succeeds.
-     *
-     * @throws MetaException
-     */
-    private void addAdminUsers() throws MetaException {
-      try {
-        addAdminUsers_core();
-      } catch (JDOException e) {
-        LOG.warn("Retrying adding admin users after error: " + e.getMessage(), e);
-        addAdminUsers_core();
-      }
-    }
-
-    private void addAdminUsers_core() throws MetaException {
-
-      // now add pre-configured users to admin role
-      String userStr = MetastoreConf.getVar(conf,ConfVars.USERS_IN_ADMIN_ROLE,"").trim();
-      if (userStr.isEmpty()) {
-        LOG.info("No user is added in admin role, since config is empty");
-        return;
-      }
-      // Since user names need to be valid unix user names, per IEEE Std 1003.1-2001 they cannot
-      // contain comma, so we can safely split above string on comma.
-
-     Iterator<String> users = Splitter.on(",").trimResults().omitEmptyStrings().split(userStr).iterator();
-      if (!users.hasNext()) {
-        LOG.info("No user is added in admin role, since config value "+ userStr +
-          " is in incorrect format. We accept comma separated list of users.");
-        return;
-      }
-      Role adminRole;
-      RawStore ms = getMS();
-      try {
-        adminRole = ms.getRole(ADMIN);
-      } catch (NoSuchObjectException e) {
-        LOG.error("Failed to retrieve just added admin role",e);
-        return;
-      }
-      while (users.hasNext()) {
-        String userName = users.next();
-        try {
-          ms.grantRole(adminRole, userName, PrincipalType.USER, ADMIN, PrincipalType.ROLE, true);
-          LOG.info("Added " + userName + " to admin role");
-        } catch (NoSuchObjectException e) {
-          LOG.error("Failed to add "+ userName + " in admin role",e);
-        } catch (InvalidObjectException e) {
-          LOG.debug(userName + " already in admin role", e);
-        }
-      }
-    }
-
-    private static void logAndAudit(final String m) {
-      LOG.debug("{}: {}", threadLocalId.get(), m);
-      logAuditEvent(m);
-    }
-
-    private String startFunction(String function, String extraLogInfo) {
-      incrementCounter(function);
-      logAndAudit((getThreadLocalIpAddress() == null ? "" : "source:" + getThreadLocalIpAddress() + " ") +
-          function + extraLogInfo);
-      com.codahale.metrics.Timer timer =
-          Metrics.getOrCreateTimer(MetricsConstants.API_PREFIX + function);
-      if (timer != null) {
-        // Timer will be null we aren't using the metrics
-        timerContexts.get().put(function, timer.time());
-      }
-      Counter counter = Metrics.getOrCreateCounter(MetricsConstants.ACTIVE_CALLS + function);
-      if (counter != null) {
-        counter.inc();
-      }
-      return function;
-    }
-
-    private String startFunction(String function) {
-      return startFunction(function, "");
-    }
-
-    private void startTableFunction(String function, String catName, String db, String tbl) {
-      startFunction(function, " : tbl=" +
-          TableName.getQualified(catName, db, tbl));
-    }
-
-    private void startMultiTableFunction(String function, String db, List<String> tbls) {
-      String tableNames = join(tbls, ",");
-      startFunction(function, " : db=" + db + " tbls=" + tableNames);
-    }
-
-    private void startPartitionFunction(String function, String cat, String db, String tbl,
-                                        List<String> partVals) {
-      startFunction(function, " : tbl=" +
-          TableName.getQualified(cat, db, tbl) + "[" + join(partVals, ",") + "]");
-    }
-
-    private void startPartitionFunction(String function, String catName, String db, String tbl,
-                                        Map<String, String> partName) {
-      startFunction(function, " : tbl=" +
-          TableName.getQualified(catName, db, tbl) + "partition=" + partName);
-    }
-
-    private void endFunction(String function, boolean successful, Exception e) {
-      endFunction(function, successful, e, null);
-    }
-    private void endFunction(String function, boolean successful, Exception e,
-                            String inputTableName) {
-      endFunction(function, new MetaStoreEndFunctionContext(successful, e, inputTableName));
-    }
-
-    private void endFunction(String function, MetaStoreEndFunctionContext context) {
-      com.codahale.metrics.Timer.Context timerContext = timerContexts.get().remove(function);
-      if (timerContext != null) {
-        long timeTaken = timerContext.stop();
-        LOG.debug((getThreadLocalIpAddress() == null ? "" : "source:" + getThreadLocalIpAddress() + " ") +
-            function + "time taken(ns): " + timeTaken);
-      }
-      Counter counter = Metrics.getOrCreateCounter(MetricsConstants.ACTIVE_CALLS + function);
-      if (counter != null) {
-        counter.dec();
-      }
-
-      for (MetaStoreEndFunctionListener listener : endFunctionListeners) {
-        listener.onEndFunction(function, context);
-      }
-    }
-
-    @Override
-    public fb_status getStatus() {
-      return fb_status.ALIVE;
-    }
-
-    @Override
-    public void shutdown() {
-      cleanupRawStore();
-      PerfLogger.getPerfLogger(false).cleanupPerfLogMetrics();
-      ThreadPool.shutdown();
-    }
-
-    @Override
-    public AbstractMap<String, Long> getCounters() {
-      AbstractMap<String, Long> counters = super.getCounters();
-
-      // Allow endFunctionListeners to add any counters they have collected
-      if (endFunctionListeners != null) {
-        for (MetaStoreEndFunctionListener listener : endFunctionListeners) {
-          listener.exportCounters(counters);
-        }
-      }
-
-      return counters;
-    }
-
-    @Override
-    public void create_catalog(CreateCatalogRequest rqst)
-        throws AlreadyExistsException, InvalidObjectException, MetaException {
-      Catalog catalog = rqst.getCatalog();
-      startFunction("create_catalog", ": " + catalog.toString());
-      boolean success = false;
-      Exception ex = null;
-      try {
-        try {
-          getMS().getCatalog(catalog.getName());
-          throw new AlreadyExistsException("Catalog " + catalog.getName() + " already exists");
-        } catch (NoSuchObjectException e) {
-          // expected
-        }
-
-        if (!MetaStoreUtils.validateName(catalog.getName(), null)) {
-          throw new InvalidObjectException(catalog.getName() + " is not a valid catalog name");
-        }
-
-        if (catalog.getLocationUri() == null) {
-          throw new InvalidObjectException("You must specify a path for the catalog");
-        }
-
-        RawStore ms = getMS();
-        Path catPath = new Path(catalog.getLocationUri());
-        boolean madeDir = false;
-        Map<String, String> transactionalListenersResponses = Collections.emptyMap();
-        try {
-          firePreEvent(new PreCreateCatalogEvent(this, catalog));
-          if (!wh.isDir(catPath)) {
-            if (!wh.mkdirs(catPath)) {
-              throw new MetaException("Unable to create catalog path " + catPath +
-                  ", failed to create catalog " + catalog.getName());
-            }
-            madeDir = true;
-          }
-          // set the create time of catalog
-          long time = System.currentTimeMillis() / 1000;
-          catalog.setCreateTime((int) time);
-          ms.openTransaction();
-          ms.createCatalog(catalog);
-
-          // Create a default database inside the catalog
-          Database db = new Database(DEFAULT_DATABASE_NAME,
-              "Default database for catalog " + catalog.getName(), catalog.getLocationUri(),
-              Collections.emptyMap());
-          db.setCatalogName(catalog.getName());
-          create_database_core(ms, db);
-
-          if (!transactionalListeners.isEmpty()) {
-            transactionalListenersResponses =
-                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                    EventType.CREATE_CATALOG,
-                    new CreateCatalogEvent(true, this, catalog));
-          }
-
-          success = ms.commitTransaction();
-        } finally {
-          if (!success) {
-            ms.rollbackTransaction();
-            if (madeDir) {
-              wh.deleteDir(catPath, true, false, false);
-            }
-          }
-
-          if (!listeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(listeners,
-                EventType.CREATE_CATALOG,
-                new CreateCatalogEvent(success, this, catalog),
-                null,
-                transactionalListenersResponses, ms);
-          }
-        }
-        success = true;
-      } catch (AlreadyExistsException|InvalidObjectException|MetaException e) {
-        ex = e;
-        throw e;
-      } finally {
-        endFunction("create_catalog", success, ex);
-      }
-    }
-
-    @Override
-    public void alter_catalog(AlterCatalogRequest rqst) throws TException {
-      startFunction("alter_catalog " + rqst.getName());
-      boolean success = false;
-      Exception ex = null;
-      RawStore ms = getMS();
-      Map<String, String> transactionalListenersResponses = Collections.emptyMap();
-      GetCatalogResponse oldCat = null;
-
-      try {
-        oldCat = get_catalog(new GetCatalogRequest(rqst.getName()));
-        // Above should have thrown NoSuchObjectException if there is no such catalog
-        assert oldCat != null && oldCat.getCatalog() != null;
-        firePreEvent(new PreAlterCatalogEvent(oldCat.getCatalog(), rqst.getNewCat(), this));
-
-        ms.openTransaction();
-        ms.alterCatalog(rqst.getName(), rqst.getNewCat());
-
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenersResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                  EventType.ALTER_CATALOG,
-                  new AlterCatalogEvent(oldCat.getCatalog(), rqst.getNewCat(), true, this));
-        }
-
-        success = ms.commitTransaction();
-      } catch (MetaException|NoSuchObjectException e) {
-        ex = e;
-        throw e;
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-
-        if ((null != oldCat) && (!listeners.isEmpty())) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-              EventType.ALTER_CATALOG,
-              new AlterCatalogEvent(oldCat.getCatalog(), rqst.getNewCat(), success, this),
-              null, transactionalListenersResponses, ms);
-        }
-        endFunction("alter_catalog", success, ex);
-      }
-
-    }
-
-    @Override
-    public GetCatalogResponse get_catalog(GetCatalogRequest rqst)
-        throws NoSuchObjectException, TException {
-      String catName = rqst.getName();
-      startFunction("get_catalog", ": " + catName);
-      Catalog cat = null;
-      Exception ex = null;
-      try {
-        cat = getMS().getCatalog(catName);
-        firePreEvent(new PreReadCatalogEvent(this, cat));
-        return new GetCatalogResponse(cat);
-      } catch (MetaException|NoSuchObjectException e) {
-        ex = e;
-        throw e;
-      } finally {
-        endFunction("get_catalog", cat != null, ex);
-      }
-    }
-
-    @Override
-    public GetCatalogsResponse get_catalogs() throws MetaException {
-      startFunction("get_catalogs");
-
-      List<String> ret = null;
-      Exception ex = null;
-      try {
-        ret = getMS().getCatalogs();
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } finally {
-        endFunction("get_catalog", ret != null, ex);
-      }
-      return new GetCatalogsResponse(ret == null ? Collections.emptyList() : ret);
-
-    }
-
-    @Override
-    public void drop_catalog(DropCatalogRequest rqst)
-        throws NoSuchObjectException, InvalidOperationException, MetaException {
-      String catName = rqst.getName();
-      startFunction("drop_catalog", ": " + catName);
-      if (DEFAULT_CATALOG_NAME.equalsIgnoreCase(catName)) {
-        endFunction("drop_catalog", false, null);
-        throw new MetaException("Can not drop " + DEFAULT_CATALOG_NAME + " catalog");
-      }
-
-      boolean success = false;
-      Exception ex = null;
-      try {
-        dropCatalogCore(catName);
-        success = true;
-      } catch (NoSuchObjectException|InvalidOperationException|MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("drop_catalog", success, ex);
-      }
-
-    }
-
-    private void dropCatalogCore(String catName)
-        throws MetaException, NoSuchObjectException, InvalidOperationException {
-      boolean success = false;
-      Catalog cat = null;
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-      RawStore ms = getMS();
-      try {
-        ms.openTransaction();
-        cat = ms.getCatalog(catName);
-
-        firePreEvent(new PreDropCatalogEvent(this, cat));
-
-        List<String> allDbs = get_databases(prependNotNullCatToDbName(catName, null));
-        if (allDbs != null && !allDbs.isEmpty()) {
-          // It might just be the default, in which case we can drop that one if it's empty
-          if (allDbs.size() == 1 && allDbs.get(0).equals(DEFAULT_DATABASE_NAME)) {
-            try {
-              drop_database_core(ms, catName, DEFAULT_DATABASE_NAME, true, false);
-            } catch (InvalidOperationException e) {
-              // This means there are tables of something in the database
-              throw new InvalidOperationException("There are still objects in the default " +
-                  "database for catalog " + catName);
-            } catch (InvalidObjectException|IOException|InvalidInputException e) {
-              MetaException me = new MetaException("Error attempt to drop default database for " +
-                  "catalog " + catName);
-              me.initCause(e);
-              throw me;
-            }
-          } else {
-            throw new InvalidOperationException("There are non-default databases in the catalog " +
-                catName + " so it cannot be dropped.");
-          }
-        }
-
-        ms.dropCatalog(catName) ;
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenerResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                  EventType.DROP_CATALOG,
-                  new DropCatalogEvent(true, this, cat));
-        }
-
-        success = ms.commitTransaction();
-      } finally {
-        if (success) {
-          wh.deleteDir(wh.getDnsPath(new Path(cat.getLocationUri())), false, false, false);
-        } else {
-          ms.rollbackTransaction();
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-              EventType.DROP_CATALOG,
-              new DropCatalogEvent(success, this, cat),
-              null,
-              transactionalListenerResponses, ms);
-        }
-      }
-    }
-
-    static boolean isDbReplicationTarget(Database db) {
-      if (db.getParameters() == null) {
-        return false;
-      }
-
-      if (!db.getParameters().containsKey(ReplConst.REPL_TARGET_DB_PROPERTY)) {
-        return false;
-      }
-
-      return !db.getParameters().get(ReplConst.REPL_TARGET_DB_PROPERTY).trim().isEmpty();
-    }
-
-    // Assumes that the catalog has already been set.
-    private void create_database_core(RawStore ms, final Database db)
-        throws AlreadyExistsException, InvalidObjectException, MetaException {
-      if (!MetaStoreUtils.validateName(db.getName(), conf)) {
-        throw new InvalidObjectException(db.getName() + " is not a valid database name");
-      }
-
-      Catalog cat = null;
-      try {
-        cat = getMS().getCatalog(db.getCatalogName());
-      } catch (NoSuchObjectException e) {
-        LOG.error("No such catalog " + db.getCatalogName());
-        throw new InvalidObjectException("No such catalog " + db.getCatalogName());
-      }
-      boolean skipAuthorization = false;
-      String passedInURI = db.getLocationUri();
-      String passedInManagedURI = db.getManagedLocationUri();
-      if (passedInURI == null && passedInManagedURI == null) {
-        skipAuthorization = true;
-      }
-      final Path defaultDbExtPath = wh.getDefaultDatabasePath(db.getName(), true);
-      final Path defaultDbMgdPath = wh.getDefaultDatabasePath(db.getName(), false);
-      final Path dbExtPath = (passedInURI != null) ? wh.getDnsPath(new Path(passedInURI)) : wh.determineDatabasePath(cat, db);
-      final Path dbMgdPath = (passedInManagedURI != null) ? wh.getDnsPath(new Path(passedInManagedURI)) : null;
-
-      if ((defaultDbExtPath.equals(dbExtPath) && defaultDbMgdPath.equals(dbMgdPath)) &&
-          ((dbMgdPath == null) || dbMgdPath.equals(defaultDbMgdPath))) {
-        skipAuthorization = true;
-      }
-
-      if ( skipAuthorization ) {
-        //null out to skip authorizer URI check
-        db.setLocationUri(null);
-        db.setManagedLocationUri(null);
-      }else{
-        db.setLocationUri(dbExtPath.toString());
-        if (dbMgdPath != null) {
-          db.setManagedLocationUri(dbMgdPath.toString());
-        }
-      }
-      if (db.getOwnerName() == null){
-        try {
-          db.setOwnerName(SecurityUtils.getUGI().getShortUserName());
-        }catch (Exception e){
-          LOG.warn("Failed to get owner name for create database operation.", e);
-        }
-      }
-      long time = System.currentTimeMillis()/1000;
-      db.setCreateTime((int) time);
-      boolean success = false;
-      boolean madeManagedDir = false;
-      boolean madeExternalDir = false;
-      boolean isReplicated = isDbReplicationTarget(db);
-      Map<String, String> transactionalListenersResponses = Collections.emptyMap();
-      try {
-        firePreEvent(new PreCreateDatabaseEvent(db, this));
-        //reinstate location uri for metastore db.
-        if (skipAuthorization == true){
-          db.setLocationUri(dbExtPath.toString());
-          if (dbMgdPath != null)
-            db.setManagedLocationUri(dbMgdPath.toString());
-        }
-        if (db.getCatalogName() != null && !db.getCatalogName().
-            equals(Warehouse.DEFAULT_CATALOG_NAME)) {
-          if (!wh.isDir(dbExtPath)) {
-            LOG.debug("Creating database path " + dbExtPath);
-            if (!wh.mkdirs(dbExtPath)) {
-              throw new MetaException("Unable to create database path " + dbExtPath +
-                  ", failed to create database " + db.getName());
-            }
-            madeExternalDir = true;
-          }
-        } else {
-          if (dbMgdPath != null) {
-            try {
-              // Since this may be done as random user (if doAs=true) he may not have access
-              // to the managed directory. We run this as an admin user
-              madeManagedDir = UserGroupInformation.getLoginUser().doAs(new PrivilegedExceptionAction<Boolean>() {
-                @Override public Boolean run() throws MetaException {
-                  if (!wh.isDir(dbMgdPath)) {
-                    LOG.info("Creating database path in managed directory " + dbMgdPath);
-                    if (!wh.mkdirs(dbMgdPath)) {
-                      throw new MetaException("Unable to create database managed path " + dbMgdPath + ", failed to create database " + db.getName());
-                    }
-                    return true;
-                  }
-                  return false;
-                }
-              });
-              if (madeManagedDir) {
-                LOG.info("Created database path in managed directory " + dbMgdPath);
-              } else {
-                throw new MetaException(
-                    "Unable to create database managed directory " + dbMgdPath + ", failed to create database " + db.getName());
-              }
-            } catch (IOException | InterruptedException e) {
-              throw new MetaException(
-                  "Unable to create database managed directory " + dbMgdPath + ", failed to create database " + db.getName() + ":" + e.getMessage());
-            }
-          }
-          if (dbExtPath != null) {
-            try {
-              madeExternalDir = UserGroupInformation.getCurrentUser().doAs(new PrivilegedExceptionAction<Boolean>() {
-                @Override public Boolean run() throws MetaException {
-                  if (!wh.isDir(dbExtPath)) {
-                    LOG.info("Creating database path in external directory " + dbExtPath);
-                    return wh.mkdirs(dbExtPath);
-                  }
-                  return false;
-                }
-              });
-              if (madeExternalDir) {
-                LOG.info("Created database path in external directory " + dbExtPath);
-              } else {
-                LOG.warn("Failed to create external path " + dbExtPath + " for database " + db.getName() + ". This may result in access not being allowed if the "
-                    + "StorageBasedAuthorizationProvider is enabled");
-              }
-            } catch (IOException | InterruptedException | UndeclaredThrowableException e) {
-              throw new MetaException("Failed to create external path " + dbExtPath + " for database " + db.getName() + ". This may result in access not being allowed if the "
-                  + "StorageBasedAuthorizationProvider is enabled: " + e.getMessage());
-            }
-          } else {
-            LOG.info("Database external path won't be created since the external warehouse directory is not defined");
-          }
-        }
-
-        ms.openTransaction();
-        ms.createDatabase(db);
-
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenersResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                    EventType.CREATE_DATABASE,
-                                                    new CreateDatabaseEvent(db, true, this, isReplicated));
-        }
-
-        success = ms.commitTransaction();
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-
-          if (db.getCatalogName() != null && !db.getCatalogName().
-              equals(Warehouse.DEFAULT_CATALOG_NAME)) {
-            if (madeManagedDir) {
-              wh.deleteDir(dbMgdPath, true, db);
-            }
-          } else {
-            if (madeManagedDir) {
-              try {
-                UserGroupInformation.getLoginUser().doAs(new PrivilegedExceptionAction<Void>() {
-                  @Override public Void run() throws Exception {
-                    wh.deleteDir(dbMgdPath, true, db);
-                    return null;
-                  }
-                });
-              } catch (IOException | InterruptedException e) {
-                LOG.error(
-                    "Couldn't delete managed directory " + dbMgdPath + " after " + "it was created for database " + db.getName() + " " + e.getMessage());
-              }
-            }
-
-            if (madeExternalDir) {
-              try {
-                UserGroupInformation.getCurrentUser().doAs(new PrivilegedExceptionAction<Void>() {
-                  @Override public Void run() throws Exception {
-                    wh.deleteDir(dbExtPath, true, db);
-                    return null;
-                  }
-                });
-              } catch (IOException | InterruptedException e) {
-                LOG.error("Couldn't delete external directory " + dbExtPath + " after " + "it was created for database "
-                    + db.getName() + " " + e.getMessage());
-              }
-            }
-          }
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.CREATE_DATABASE,
-                                                new CreateDatabaseEvent(db, success, this, isReplicated),
-                                                null,
-                                                transactionalListenersResponses, ms);
-        }
-      }
-    }
-
-    @Override
-    public void create_database(final Database db)
-        throws AlreadyExistsException, InvalidObjectException, MetaException {
-      startFunction("create_database", ": " + db.toString());
-      boolean success = false;
-      Exception ex = null;
-      if (!db.isSetCatalogName()) {
-        db.setCatalogName(getDefaultCatalog(conf));
-      }
-      try {
-        try {
-          if (null != get_database_core(db.getCatalogName(), db.getName())) {
-            throw new AlreadyExistsException("Database " + db.getName() + " already exists");
-          }
-        } catch (NoSuchObjectException e) {
-          // expected
-        }
-
-        if (TEST_TIMEOUT_ENABLED) {
-          try {
-            Thread.sleep(TEST_TIMEOUT_VALUE);
-          } catch (InterruptedException e) {
-            // do nothing
-          }
-          Deadline.checkTimeout();
-        }
-        create_database_core(getMS(), db);
-        success = true;
-      } catch (MetaException | InvalidObjectException | AlreadyExistsException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("create_database", success, ex);
-      }
-    }
-
-    @Override
-    public Database get_database(final String name)
-        throws NoSuchObjectException, MetaException {
-      GetDatabaseRequest request = new GetDatabaseRequest();
-      String[] parsedDbName = parseDbName(name, conf);
-      request.setName(parsedDbName[DB_NAME]);
-      if (parsedDbName[CAT_NAME] != null)
-          request.setCatalogName(parsedDbName[CAT_NAME]);
-        return get_database_req(request);
-    }
-
-    @Override
-    public Database get_database_core(String catName, final String name) throws NoSuchObjectException, MetaException {
-      Database db = null;
-      if (name == null) {
-        throw new MetaException("Database name cannot be null.");
-      }
-      try {
-        db = getMS().getDatabase(catName, name);
-      } catch (MetaException | NoSuchObjectException e) {
-        throw e;
-      } catch (Exception e) {
-        assert (e instanceof RuntimeException);
-        throw (RuntimeException) e;
-      }
-      return db;
-    }
-
-    @Override
-    public Database get_database_req(GetDatabaseRequest request) throws NoSuchObjectException, MetaException {
-      startFunction("get_database", ": " + request.getName());
-      Database db = null;
-      Exception ex = null;
-      if (request.getName() == null) {
-        throw new MetaException("Database name cannot be null.");
-      }
-      List<String> processorCapabilities = request.getProcessorCapabilities();
-      String processorId = request.getProcessorIdentifier();
-      try {
-        db = getMS().getDatabase(request.getCatalogName(), request.getName());
-        firePreEvent(new PreReadDatabaseEvent(db, this));
-        if (processorCapabilities != null && transformer != null) {
-          db = transformer.transformDatabase(db, processorCapabilities, processorId);
-        }
-      } catch (MetaException | NoSuchObjectException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        assert (e instanceof RuntimeException);
-        throw (RuntimeException) e;
-      } finally {
-        endFunction("get_database", db != null, ex);
-      }
-      return db;
-    }
-
-    @Override
-    public void alter_database(final String dbName, final Database newDB) throws TException {
-      startFunction("alter_database " + dbName);
-      boolean success = false;
-      Exception ex = null;
-      RawStore ms = getMS();
-      Database oldDB = null;
-      Map<String, String> transactionalListenersResponses = Collections.emptyMap();
-
-      // Perform the same URI normalization as create_database_core.
-      if (newDB.getLocationUri() != null) {
-        newDB.setLocationUri(wh.getDnsPath(new Path(newDB.getLocationUri())).toString());
-      }
-
-      String[] parsedDbName = parseDbName(dbName, conf);
-
-      // We can replicate into an empty database, in which case newDB will have indication that
-      // it's target of replication but not oldDB. But replication flow will never alter a
-      // database so that oldDB indicates that it's target or replication but not the newDB. So,
-      // relying solely on newDB to check whether the database is target of replication works.
-      boolean isReplicated = isDbReplicationTarget(newDB);
-      try {
-        oldDB = get_database_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]);
-        if (oldDB == null) {
-          throw new MetaException("Could not alter database \"" + parsedDbName[DB_NAME] +
-              "\". Could not retrieve old definition.");
-        }
-        firePreEvent(new PreAlterDatabaseEvent(oldDB, newDB, this));
-
-        ms.openTransaction();
-        ms.alterDatabase(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], newDB);
-
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenersResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                  EventType.ALTER_DATABASE,
-                  new AlterDatabaseEvent(oldDB, newDB, true, this, isReplicated));
-        }
-
-        success = ms.commitTransaction();
-      } catch (MetaException|NoSuchObjectException e) {
-        ex = e;
-        throw e;
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-
-        if ((null != oldDB) && (!listeners.isEmpty())) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-              EventType.ALTER_DATABASE,
-              new AlterDatabaseEvent(oldDB, newDB, success, this, isReplicated),
-              null,
-              transactionalListenersResponses, ms);
-        }
-        endFunction("alter_database", success, ex);
-      }
-    }
-
-    private void drop_database_core(RawStore ms, String catName,
-        final String name, final boolean deleteData, final boolean cascade)
-        throws NoSuchObjectException, InvalidOperationException, MetaException,
-        IOException, InvalidObjectException, InvalidInputException {
-      boolean success = false;
-      Database db = null;
-      List<Path> tablePaths = new ArrayList<>();
-      List<Path> partitionPaths = new ArrayList<>();
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-      if (name == null) {
-        throw new MetaException("Database name cannot be null.");
-      }
-      boolean isReplicated = false;
-      try {
-        ms.openTransaction();
-        db = ms.getDatabase(catName, name);
-        if (db.getType() == DatabaseType.REMOTE) {
-          success = drop_remote_database_core(ms, db);
-          return;
-        }
-        isReplicated = isDbReplicationTarget(db);
-
-        if (!isInTest && ReplChangeManager.isSourceOfReplication(db)) {
-          throw new InvalidOperationException("can not drop a database which is a source of replication");
-        }
-
-        firePreEvent(new PreDropDatabaseEvent(db, this));
-        String catPrependedName = MetaStoreUtils.prependCatalogToDbName(catName, name, conf);
-
-        Set<String> uniqueTableNames = new HashSet<>(get_all_tables(catPrependedName));
-        List<String> allFunctions = get_functions(catPrependedName, "*");
-        ListStoredProcedureRequest request = new ListStoredProcedureRequest(catName);
-        request.setDbName(name);
-        List<String> allProcedures = get_all_stored_procedures(request);
-
-        if (!cascade) {
-          if (!uniqueTableNames.isEmpty()) {
-            throw new InvalidOperationException(
-                "Database " + db.getName() + " is not empty. One or more tables exist.");
-          }
-          if (!allFunctions.isEmpty()) {
-            throw new InvalidOperationException(
-                "Database " + db.getName() + " is not empty. One or more functions exist.");
-          }
-          if (!allProcedures.isEmpty()) {
-            throw new InvalidOperationException(
-                    "Database " + db.getName() + " is not empty. One or more stored procedures exist.");
-          }
-        }
-        Path path = new Path(db.getLocationUri()).getParent();
-        if (!wh.isWritable(path)) {
-          throw new MetaException("Database not dropped since " +
-              path + " is not writable by " +
-              SecurityUtils.getUser());
-        }
-
-        Path databasePath = wh.getDnsPath(wh.getDatabasePath(db));
-
-        // drop any functions before dropping db
-        for (String funcName : allFunctions) {
-          drop_function(catPrependedName, funcName);
-        }
-
-        for (String procName : allProcedures) {
-          drop_stored_procedure(new StoredProcedureRequest(catName, name, procName));
-        }
-
-        final int tableBatchSize = MetastoreConf.getIntVar(conf,
-            ConfVars.BATCH_RETRIEVE_MAX);
-
-        // First pass will drop the materialized views
-        List<String> materializedViewNames = getTablesByTypeCore(catName, name, ".*",
-            TableType.MATERIALIZED_VIEW.toString());
-        int startIndex = 0;
-        // retrieve the tables from the metastore in batches to alleviate memory constraints
-        while (startIndex < materializedViewNames.size()) {
-          int endIndex = Math.min(startIndex + tableBatchSize, materializedViewNames.size());
-
-          List<Table> materializedViews;
-          try {
-            materializedViews = ms.getTableObjectsByName(catName, name, materializedViewNames.subList(startIndex, endIndex));
-          } catch (UnknownDBException e) {
-            throw new MetaException(e.getMessage());
-          }
-
-          if (materializedViews != null && !materializedViews.isEmpty()) {
-            for (Table materializedView : materializedViews) {
-              if (materializedView.getSd().getLocation() != null) {
-                Path materializedViewPath = wh.getDnsPath(new Path(materializedView.getSd().getLocation()));
-                if (!wh.isWritable(materializedViewPath.getParent())) {
-                  throw new MetaException("Database metadata not deleted since table: " +
-                      materializedView.getTableName() + " has a parent location " + materializedViewPath.getParent() +
-                      " which is not writable by " + SecurityUtils.getUser());
-                }
-
-                if (!FileUtils.isSubdirectory(databasePath.toString(),
-                    materializedViewPath.toString())) {
-                  tablePaths.add(materializedViewPath);
-                }
-              }
-              // Drop the materialized view but not its data
-              drop_table(name, materializedView.getTableName(), false);
-              // Remove from all tables
-              uniqueTableNames.remove(materializedView.getTableName());
-            }
-          }
-          startIndex = endIndex;
-        }
-
-        // drop tables before dropping db
-        List<String> allTables = new ArrayList<>(uniqueTableNames);
-        startIndex = 0;
-        // retrieve the tables from the metastore in batches to alleviate memory constraints
-        while (startIndex < allTables.size()) {
-          int endIndex = Math.min(startIndex + tableBatchSize, allTables.size());
-
-          List<Table> tables;
-          try {
-            tables = ms.getTableObjectsByName(catName, name, allTables.subList(startIndex, endIndex));
-          } catch (UnknownDBException e) {
-            throw new MetaException(e.getMessage());
-          }
-
-          if (tables != null && !tables.isEmpty()) {
-            for (Table table : tables) {
-
-              // If the table is not external and it might not be in a subdirectory of the database
-              // add it's locations to the list of paths to delete
-              Path tablePath = null;
-              boolean tableDataShouldBeDeleted = checkTableDataShouldBeDeleted(table, deleteData);
-              if (table.getSd().getLocation() != null && tableDataShouldBeDeleted) {
-                tablePath = wh.getDnsPath(new Path(table.getSd().getLocation()));
-                if (!wh.isWritable(tablePath.getParent())) {
-                  throw new MetaException("Database metadata not deleted since table: " +
-                      table.getTableName() + " has a parent location " + tablePath.getParent() +
-                      " which is not writable by " + SecurityUtils.getUser());
-                }
-
-                if (!FileUtils.isSubdirectory(databasePath.toString(), tablePath.toString())) {
-                  tablePaths.add(tablePath);
-                }
-              }
-
-              // For each partition in each table, drop the partitions and get a list of
-              // partitions' locations which might need to be deleted
-              partitionPaths = dropPartitionsAndGetLocations(ms, catName, name, table.getTableName(),
-                  tablePath, tableDataShouldBeDeleted);
-
-              // Drop the table but not its data
-              drop_table(MetaStoreUtils.prependCatalogToDbName(table.getCatName(), table.getDbName(), conf),
-                  table.getTableName(), false);
-            }
-          }
-
-          startIndex = endIndex;
-        }
-
-        if (ms.dropDatabase(catName, name)) {
-          if (!transactionalListeners.isEmpty()) {
-            transactionalListenerResponses =
-                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                      EventType.DROP_DATABASE,
-                                                      new DropDatabaseEvent(db, true, this, isReplicated));
-          }
-
-          success = ms.commitTransaction();
-        }
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else if (deleteData) {
-          // Delete the data in the partitions which have other locations
-          deletePartitionData(partitionPaths, false, db);
-          // Delete the data in the tables which have other locations
-          for (Path tablePath : tablePaths) {
-            deleteTableData(tablePath, false, db);
-          }
-          // Delete the data in the database
-          try {
-            if (db.getManagedLocationUri() != null) {
-              wh.deleteDir(new Path(db.getManagedLocationUri()), true, db);
-            }
-          } catch (Exception e) {
-            LOG.error("Failed to delete database directory: " + db.getManagedLocationUri() +
-                " " + e.getMessage());
-          }
-          // Delete the data in the database's location only if it is a legacy db path?
-          try {
-            wh.deleteDir(new Path(db.getLocationUri()), true, db);
-          } catch (Exception e) {
-            LOG.error("Failed to delete database directory: " + db.getLocationUri() +
-                " " + e.getMessage());
-          }
-          // it is not a terrible thing even if the data is not deleted
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.DROP_DATABASE,
-                                                new DropDatabaseEvent(db, success, this, isReplicated),
-                                                null,
-                                                transactionalListenerResponses, ms);
-        }
-      }
-    }
-
-    private boolean drop_remote_database_core(RawStore ms, final Database db) throws MetaException, NoSuchObjectException {
-      boolean success = false;
-      firePreEvent(new PreDropDatabaseEvent(db, this));
-
-      if (ms.dropDatabase(db.getCatalogName(), db.getName())) {
-        success = ms.commitTransaction();
-      }
-      return success;
-    }
-
-    @Override
-    public void drop_database(final String dbName, final boolean deleteData, final boolean cascade)
-        throws NoSuchObjectException, InvalidOperationException, MetaException {
-      startFunction("drop_database", ": " + dbName);
-      String[] parsedDbName = parseDbName(dbName, conf);
-      if (DEFAULT_CATALOG_NAME.equalsIgnoreCase(parsedDbName[CAT_NAME]) &&
-          DEFAULT_DATABASE_NAME.equalsIgnoreCase(parsedDbName[DB_NAME])) {
-        endFunction("drop_database", false, null);
-        throw new MetaException("Can not drop " + DEFAULT_DATABASE_NAME + " database in catalog "
-            + DEFAULT_CATALOG_NAME);
-      }
-
-      boolean success = false;
-      Exception ex = null;
-      try {
-        drop_database_core(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME], deleteData,
-            cascade);
-        success = true;
-      } catch (NoSuchObjectException|InvalidOperationException|MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("drop_database", success, ex);
-      }
-    }
-
-
-    @Override
-    public List<String> get_databases(final String pattern) throws MetaException {
-      startFunction("get_databases", ": " + pattern);
-
-      String[] parsedDbNamed = parseDbName(pattern, conf);
-      List<String> ret = null;
-      Exception ex = null;
-      try {
-        if (parsedDbNamed[DB_NAME] == null) {
-          ret = getMS().getAllDatabases(parsedDbNamed[CAT_NAME]);
-          ret = FilterUtils.filterDbNamesIfEnabled(isServerFilterEnabled, filterHook, ret);
-        } else {
-          ret = getMS().getDatabases(parsedDbNamed[CAT_NAME], parsedDbNamed[DB_NAME]);
-          ret = FilterUtils.filterDbNamesIfEnabled(isServerFilterEnabled, filterHook, ret);
-        }
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_databases", ret != null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public List<String> get_all_databases() throws MetaException {
-      // get_databases filters results already. No need to filter here
-      return get_databases(MetaStoreUtils.prependCatalogToDbName(null, null, conf));
-    }
-
-    private void create_type_core(final RawStore ms, final Type type)
-        throws AlreadyExistsException, MetaException, InvalidObjectException {
-      if (!MetaStoreUtils.validateName(type.getName(), null)) {
-        throw new InvalidObjectException("Invalid type name");
-      }
-
-      boolean success = false;
-      try {
-        ms.openTransaction();
-        if (is_type_exists(ms, type.getName())) {
-          throw new AlreadyExistsException("Type " + type.getName() + " already exists");
-        }
-        ms.createType(type);
-        success = ms.commitTransaction();
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-      }
-    }
-
-    private void create_dataconnector_core(RawStore ms, final DataConnector connector)
-        throws AlreadyExistsException, InvalidObjectException, MetaException {
-      if (!MetaStoreUtils.validateName(connector.getName(), conf)) {
-        throw new InvalidObjectException(connector.getName() + " is not a valid dataconnector name");
-      }
-
-      if (connector.getOwnerName() == null){
-        try {
-          connector.setOwnerName(SecurityUtils.getUGI().getShortUserName());
-        }catch (Exception e){
-          LOG.warn("Failed to get owner name for create dataconnector operation.", e);
-        }
-      }
-      long time = System.currentTimeMillis()/1000;
-      connector.setCreateTime((int) time);
-      boolean success = false;
-      Map<String, String> transactionalListenersResponses = Collections.emptyMap();
-      try {
-        firePreEvent(new PreCreateDataConnectorEvent(connector, this));
-
-        ms.openTransaction();
-        ms.createDataConnector(connector);
-
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenersResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                  EventType.CREATE_DATACONNECTOR,
-                  new CreateDataConnectorEvent(connector, true, this));
-        }
-
-        success = ms.commitTransaction();
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-              EventType.CREATE_DATACONNECTOR,
-              new CreateDataConnectorEvent(connector, success, this),
-              null,
-              transactionalListenersResponses, ms);
-        }
-      }
-    }
-
-    @Override
-    public void create_dataconnector(final DataConnector connector)
-        throws AlreadyExistsException, InvalidObjectException, MetaException {
-      startFunction("create_dataconnector", ": " + connector.toString());
-      boolean success = false;
-      Exception ex = null;
-      try {
-        try {
-          if (null != get_dataconnector_core(connector.getName())) {
-            throw new AlreadyExistsException("DataConnector " + connector.getName() + " already exists");
-          }
-        } catch (NoSuchObjectException e) {
-          // expected
-        }
-
-        if (TEST_TIMEOUT_ENABLED) {
-          try {
-            Thread.sleep(TEST_TIMEOUT_VALUE);
-          } catch (InterruptedException e) {
-            // do nothing
-          }
-          Deadline.checkTimeout();
-        }
-        create_dataconnector_core(getMS(), connector);
-        success = true;
-      } catch (MetaException | InvalidObjectException | AlreadyExistsException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("create_connector", success, ex);
-      }
-    }
-
-    @Override
-    public DataConnector get_dataconnector_core(final String name) throws NoSuchObjectException, MetaException {
-      DataConnector connector = null;
-      if (name == null) {
-        throw new MetaException("Data connector name cannot be null.");
-      }
-      try {
-        connector = getMS().getDataConnector(name);
-      } catch (MetaException | NoSuchObjectException e) {
-        throw e;
-      } catch (Exception e) {
-        assert (e instanceof RuntimeException);
-        throw (RuntimeException) e;
-      }
-      return connector;
-    }
-
-    @Override
-    public DataConnector get_dataconnector_req(GetDataConnectorRequest request) throws NoSuchObjectException, MetaException {
-      startFunction("get_dataconnector", ": " + request.getConnectorName());
-      DataConnector connector = null;
-      Exception ex = null;
-      try {
-        connector = get_dataconnector_core(request.getConnectorName());
-      } catch (MetaException | NoSuchObjectException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        assert (e instanceof RuntimeException);
-        throw (RuntimeException) e;
-      } finally {
-        endFunction("get_dataconnector", connector != null, ex);
-      }
-      return connector;
-    }
-
-    @Override
-    public void alter_dataconnector(final String dcName, final DataConnector newDC) throws TException {
-      startFunction("alter_dataconnector " + dcName);
-      boolean success = false;
-      Exception ex = null;
-      RawStore ms = getMS();
-      DataConnector oldDC = null;
-      Map<String, String> transactionalListenersResponses = Collections.emptyMap();
-
-      try {
-        oldDC = get_dataconnector_core(dcName);
-        if (oldDC == null) {
-          throw new MetaException("Could not alter dataconnector \"" + dcName +
-              "\". Could not retrieve old definition.");
-        }
-        // firePreEvent(new PreAlterDatabaseEvent(oldDC, newDC, this));
-
-        ms.openTransaction();
-        ms.alterDataConnector(dcName, newDC);
-
-        /*
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenersResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                  EventType.ALTER_DATACONNECTOR,
-                  new AlterDataConnectorEvent(oldDC, newDC, true, this));
-        }
-         */
-
-        success = ms.commitTransaction();
-      } catch (MetaException|NoSuchObjectException e) {
-        ex = e;
-        throw e;
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-/*
-        if ((null != oldDC) && (!listeners.isEmpty())) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-              EventType.ALTER_DATACONNECTOR,
-              new AlterDataConnectorEvent(oldDC, newDC, success, this),
-              null,
-              transactionalListenersResponses, ms);
-        }
- */
-        endFunction("alter_database", success, ex);
-      }
-    }
-
-    @Override
-    public List<String> get_dataconnectors() throws MetaException {
-      startFunction("get_dataconnectors");
-
-      List<String> ret = null;
-      Exception ex = null;
-      try {
-          ret = getMS().getAllDataConnectors();
-          ret = FilterUtils.filterDataConnectorsIfEnabled(isServerFilterEnabled, filterHook, ret);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_dataconnectors", ret != null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public void drop_dataconnector(final String dcName, boolean ifNotExists, boolean checkReferences) throws NoSuchObjectException, InvalidOperationException, MetaException {
-      startFunction("drop_dataconnector", ": " + dcName);
-      boolean success = false;
-      DataConnector connector = null;
-      Exception ex = null;
-      RawStore ms = getMS();
-      try {
-        ms.openTransaction();
-        connector = getMS().getDataConnector(dcName);
-
-        if (connector == null) {
-          if (!ifNotExists) {
-            throw new NoSuchObjectException("DataConnector " + dcName + " doesn't exist");
-          } else {
-            return;
-          }
-        }
-        // TODO find DBs with references to this connector
-        // if any existing references and checkReferences=true, do not drop
-
-        // firePreEvent(new PreDropTableEvent(tbl, deleteData, this));
-
-        if (!ms.dropDataConnector(dcName)) {
-          throw new MetaException("Unable to drop dataconnector " + dcName);
-        } else {
-/*
-          if (!transactionalListeners.isEmpty()) {
-            transactionalListenerResponses =
-                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                    EventType.DROP_TABLE,
-                    new DropTableEvent(tbl, true, deleteData,
-                        this, isReplicated),
-                    envContext);
-          }
-
- */
-          success = ms.commitTransaction();
-        }
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-/*
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-              EventType.DROP_TABLE,
-              new DropTableEvent(tbl, success, deleteData, this, isReplicated),
-              envContext,
-              transactionalListenerResponses, ms);
-        }
-
- */
-        endFunction("drop_dataconnector", success, ex);
-      }
-    }
-
-
-
-    @Override
-    public boolean create_type(final Type type) throws AlreadyExistsException,
-        MetaException, InvalidObjectException {
-      startFunction("create_type", ": " + type.toString());
-      boolean success = false;
-      Exception ex = null;
-      try {
-        create_type_core(getMS(), type);
-        success = true;
-      } catch (MetaException | InvalidObjectException | AlreadyExistsException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("create_type", success, ex);
-      }
-
-      return success;
-    }
-
-    @Override
-    public Type get_type(final String name) throws MetaException, NoSuchObjectException {
-      startFunction("get_type", ": " + name);
-
-      Type ret = null;
-      Exception ex = null;
-      try {
-        ret = getMS().getType(name);
-        if (null == ret) {
-          throw new NoSuchObjectException("Type \"" + name + "\" not found.");
-        }
-      } catch (Exception e) {
-        ex = e;
-        throwMetaException(e);
-      } finally {
-        endFunction("get_type", ret != null, ex);
-      }
-      return ret;
-    }
-
-    private boolean is_type_exists(RawStore ms, String typeName)
-        throws MetaException {
-      return (ms.getType(typeName) != null);
-    }
-
-    @Override
-    public boolean drop_type(final String name) throws MetaException, NoSuchObjectException {
-      startFunction("drop_type", ": " + name);
-
-      boolean success = false;
-      Exception ex = null;
-      try {
-        // TODO:pc validate that there are no types that refer to this
-        success = getMS().dropType(name);
-      } catch (Exception e) {
-        ex = e;
-        throwMetaException(e);
-      } finally {
-        endFunction("drop_type", success, ex);
-      }
-      return success;
-    }
-
-    @Override
-    public Map<String, Type> get_type_all(String name) throws MetaException {
-      // TODO Auto-generated method stub
-      startFunction("get_type_all", ": " + name);
-      endFunction("get_type_all", false, null);
-      throw new MetaException("Not yet implemented");
-    }
-
-    private void create_table_core(final RawStore ms, final Table tbl,
-        final EnvironmentContext envContext)
-            throws AlreadyExistsException, MetaException,
-            InvalidObjectException, NoSuchObjectException, InvalidInputException {
-      CreateTableRequest req = new CreateTableRequest(tbl);
-      req.setEnvContext(envContext);
-      create_table_core(ms, req);
-    }
-
-    private void create_table_core(final RawStore ms, final Table tbl,
-        final EnvironmentContext envContext, List<SQLPrimaryKey> primaryKeys,
-        List<SQLForeignKey> foreignKeys, List<SQLUniqueConstraint> uniqueConstraints,
-        List<SQLNotNullConstraint> notNullConstraints, List<SQLDefaultConstraint> defaultConstraints,
-                                   List<SQLCheckConstraint> checkConstraints,
-                                   List<String> processorCapabilities, String processorIdentifier)
-        throws AlreadyExistsException, MetaException,
-        InvalidObjectException, NoSuchObjectException, InvalidInputException {
-      CreateTableRequest req = new CreateTableRequest(tbl);
-      if (envContext != null)
-        req.setEnvContext(envContext);
-      if (primaryKeys != null)
-        req.setPrimaryKeys(primaryKeys);
-      if (foreignKeys != null)
-        req.setForeignKeys(foreignKeys);
-      if (uniqueConstraints != null)
-        req.setUniqueConstraints(uniqueConstraints);
-      if (notNullConstraints != null)
-        req.setNotNullConstraints(notNullConstraints);
-      if (defaultConstraints != null)
-        req.setDefaultConstraints(defaultConstraints);
-      if (checkConstraints != null)
-        req.setCheckConstraints(checkConstraints);
-      if (processorCapabilities != null) {
-        req.setProcessorCapabilities(processorCapabilities);
-        req.setProcessorIdentifier(processorIdentifier);
-      }
-      create_table_core(ms, req);
-    }
-
-    private void create_table_core(final RawStore ms, final CreateTableRequest req)
-        throws AlreadyExistsException, MetaException,
-              InvalidObjectException, NoSuchObjectException, InvalidInputException {
-      ColumnStatistics colStats = null;
-      Table tbl = req.getTable();
-      EnvironmentContext envContext = req.getEnvContext();
-      SQLAllTableConstraints constraints = new SQLAllTableConstraints();
-      constraints.setPrimaryKeys(req.getPrimaryKeys());
-      constraints.setForeignKeys(req.getForeignKeys());
-      constraints.setUniqueConstraints(req.getUniqueConstraints());
-      constraints.setDefaultConstraints(req.getDefaultConstraints());
-      constraints.setCheckConstraints(req.getCheckConstraints());
-      constraints.setNotNullConstraints(req.getNotNullConstraints());
-      List<String> processorCapabilities = req.getProcessorCapabilities();
-      String processorId = req.getProcessorIdentifier();
-
-      // To preserve backward compatibility throw MetaException in case of null database
-      if (tbl.getDbName() == null) {
-        throw new MetaException("Null database name is not allowed");
-      }
-
-      if (!MetaStoreUtils.validateName(tbl.getTableName(), conf)) {
-        throw new InvalidObjectException(tbl.getTableName()
-            + " is not a valid object name");
-      }
-
-      if (!tbl.isSetCatName()) {
-        tbl.setCatName(getDefaultCatalog(conf));
-      }
-
-      Database db = get_database_core(tbl.getCatName(), tbl.getDbName());
-      if (db != null && db.getType().equals(DatabaseType.REMOTE)) {
-        DataConnectorProviderFactory.getDataConnectorProvider(db).createTable(tbl);
-        return;
-      }
-
-      if (transformer != null && !isInTest) {
-        tbl = transformer.transformCreateTable(tbl, processorCapabilities, processorId);
-      }
-
-      // If the given table has column statistics, save it here. We will update it later.
-      // We don't want it to be part of the Table object being created, lest the create table
-      // event will also have the col stats which we don't want.
-      if (tbl.isSetColStats()) {
-        colStats = tbl.getColStats();
-        tbl.unsetColStats();
-      }
-
-      String validate = MetaStoreServerUtils.validateTblColumns(tbl.getSd().getCols());
-      if (validate != null) {
-        throw new InvalidObjectException("Invalid column " + validate);
-      }
-      if (tbl.getPartitionKeys() != null) {
-        validate = MetaStoreServerUtils.validateTblColumns(tbl.getPartitionKeys());
-        if (validate != null) {
-          throw new InvalidObjectException("Invalid partition column " + validate);
-        }
-      }
-      if (tbl.isSetId()) {
-        LOG.debug("Id shouldn't be set but table {}.{} has the Id set to {}. Id is ignored.", tbl.getDbName(),
-            tbl.getTableName(), tbl.getId());
-        tbl.unsetId();
-      }
-      SkewedInfo skew = tbl.getSd().getSkewedInfo();
-      if (skew != null) {
-        validate = MetaStoreServerUtils.validateSkewedColNames(skew.getSkewedColNames());
-        if (validate != null) {
-          throw new InvalidObjectException("Invalid skew column " + validate);
-        }
-        validate = MetaStoreServerUtils.validateSkewedColNamesSubsetCol(
-            skew.getSkewedColNames(), tbl.getSd().getCols());
-        if (validate != null) {
-          throw new InvalidObjectException("Invalid skew column " + validate);
-        }
-      }
-
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-      Path tblPath = null;
-      boolean success = false, madeDir = false;
-      boolean isReplicated = false;
-      try {
-        firePreEvent(new PreCreateTableEvent(tbl, this));
-
-        ms.openTransaction();
-        isReplicated = isDbReplicationTarget(db);
-
-        // get_table checks whether database exists, it should be moved here
-        if (is_table_exists(ms, tbl.getCatName(), tbl.getDbName(), tbl.getTableName())) {
-          throw new AlreadyExistsException("Table " + getCatalogQualifiedTableName(tbl)
-              + " already exists");
-        }
-
-        if (!TableType.VIRTUAL_VIEW.toString().equals(tbl.getTableType())) {
-          if (tbl.getSd().getLocation() == null
-              || tbl.getSd().getLocation().isEmpty()) {
-            tblPath = wh.getDefaultTablePath(db, tbl);
-          } else {
-            if (!isExternal(tbl) && !MetaStoreUtils.isNonNativeTable(tbl)) {
-              LOG.warn("Location: " + tbl.getSd().getLocation()
-                  + " specified for non-external table:" + tbl.getTableName());
-            }
-            tblPath = wh.getDnsPath(new Path(tbl.getSd().getLocation()));
-          }
-          tbl.getSd().setLocation(tblPath.toString());
-        }
-
-        if (tblPath != null) {
-          if (!wh.isDir(tblPath)) {
-            if (!wh.mkdirs(tblPath)) {
-              throw new MetaException(tblPath
-                  + " is not a directory or unable to create one");
-            }
-            madeDir = true;
-          }
-        }
-        if (MetastoreConf.getBoolVar(conf, ConfVars.STATS_AUTO_GATHER) &&
-            !MetaStoreUtils.isView(tbl)) {
-          MetaStoreServerUtils.updateTableStatsSlow(db, tbl, wh, madeDir, false, envContext);
-        }
-
-        // set create time
-        long time = System.currentTimeMillis() / 1000;
-        tbl.setCreateTime((int) time);
-        if (tbl.getParameters() == null ||
-            tbl.getParameters().get(hive_metastoreConstants.DDL_TIME) == null) {
-          tbl.putToParameters(hive_metastoreConstants.DDL_TIME, Long.toString(time));
-        }
-
-        if (CollectionUtils.isEmpty(constraints.getPrimaryKeys()) && CollectionUtils.isEmpty(constraints.getForeignKeys())
-                && CollectionUtils.isEmpty(constraints.getUniqueConstraints())&& CollectionUtils.isEmpty(constraints.getNotNullConstraints())&& CollectionUtils.isEmpty(constraints.getDefaultConstraints())
-            && CollectionUtils.isEmpty(constraints.getCheckConstraints())) {
-          ms.createTable(tbl);
-        } else {
-          final String catName = tbl.getCatName();
-          // Check that constraints have catalog name properly set first
-          if (CollectionUtils.isNotEmpty(constraints.getPrimaryKeys()) && !constraints.getPrimaryKeys().get(0).isSetCatName()) {
-            constraints.getPrimaryKeys().forEach(constraint -> constraint.setCatName(catName));
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getForeignKeys()) && !constraints.getForeignKeys().get(0).isSetCatName()) {
-            constraints.getForeignKeys().forEach(constraint -> constraint.setCatName(catName));
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getUniqueConstraints()) && !constraints.getUniqueConstraints().get(0).isSetCatName()) {
-            constraints.getUniqueConstraints().forEach(constraint -> constraint.setCatName(catName));
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getNotNullConstraints()) && !constraints.getNotNullConstraints().get(0).isSetCatName()) {
-            constraints.getNotNullConstraints().forEach(constraint -> constraint.setCatName(catName));
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getDefaultConstraints()) && !constraints.getDefaultConstraints().get(0).isSetCatName()) {
-            constraints.getDefaultConstraints().forEach(constraint -> constraint.setCatName(catName));
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getCheckConstraints()) && !constraints.getCheckConstraints().get(0).isSetCatName()) {
-            constraints.getCheckConstraints().forEach(constraint -> constraint.setCatName(catName));
-          }
-          // Set constraint name if null before sending to listener
-          constraints = ms.createTableWithConstraints(tbl, constraints);
-
-        }
-
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenerResponses = MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-              EventType.CREATE_TABLE, new CreateTableEvent(tbl, true, this, isReplicated), envContext);
-          if (CollectionUtils.isNotEmpty(constraints.getPrimaryKeys())) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.ADD_PRIMARYKEY,
-                new AddPrimaryKeyEvent(constraints.getPrimaryKeys(), true, this), envContext);
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getForeignKeys())) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.ADD_FOREIGNKEY,
-                new AddForeignKeyEvent(constraints.getForeignKeys(), true, this), envContext);
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getUniqueConstraints())) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.ADD_UNIQUECONSTRAINT,
-                new AddUniqueConstraintEvent(constraints.getUniqueConstraints(), true, this), envContext);
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getNotNullConstraints())) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.ADD_NOTNULLCONSTRAINT,
-                new AddNotNullConstraintEvent(constraints.getNotNullConstraints(), true, this), envContext);
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getCheckConstraints())) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.ADD_CHECKCONSTRAINT,
-                new AddCheckConstraintEvent(constraints.getCheckConstraints(), true, this), envContext);
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getDefaultConstraints())) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.ADD_DEFAULTCONSTRAINT,
-                new AddDefaultConstraintEvent(constraints.getDefaultConstraints(), true, this), envContext);
-          }
-        }
-
-        success = ms.commitTransaction();
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-          if (madeDir) {
-            wh.deleteDir(tblPath, true, false, ReplChangeManager.shouldEnableCm(db, tbl));
-          }
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners, EventType.CREATE_TABLE,
-              new CreateTableEvent(tbl, success, this, isReplicated), envContext,
-                  transactionalListenerResponses, ms);
-          if (CollectionUtils.isNotEmpty(constraints.getPrimaryKeys())) {
-            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ADD_PRIMARYKEY,
-                new AddPrimaryKeyEvent(constraints.getPrimaryKeys(), success, this), envContext);
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getForeignKeys())) {
-            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ADD_FOREIGNKEY,
-                new AddForeignKeyEvent(constraints.getForeignKeys(), success, this), envContext);
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getUniqueConstraints())) {
-            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ADD_UNIQUECONSTRAINT,
-                new AddUniqueConstraintEvent(constraints.getUniqueConstraints(), success, this), envContext);
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getNotNullConstraints())) {
-            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ADD_NOTNULLCONSTRAINT,
-                new AddNotNullConstraintEvent(constraints.getNotNullConstraints(), success, this), envContext);
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getDefaultConstraints())) {
-            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ADD_DEFAULTCONSTRAINT,
-                new AddDefaultConstraintEvent(constraints.getDefaultConstraints(), success, this), envContext);
-          }
-          if (CollectionUtils.isNotEmpty(constraints.getCheckConstraints())) {
-            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ADD_CHECKCONSTRAINT,
-                new AddCheckConstraintEvent(constraints.getCheckConstraints(), success, this), envContext);
-          }
-        }
-      }
-
-      // If the table has column statistics, update it into the metastore. We need a valid
-      // writeId list to update column statistics for a transactional table. But during bootstrap
-      // replication, where we use this feature, we do not have a valid writeId list which was
-      // used to update the stats. But we know for sure that the writeId associated with the
-      // stats was valid then (otherwise stats update would have failed on the source). So, craft
-      // a valid transaction list with only that writeId and use it to update the stats.
-      if (colStats != null) {
-        long writeId = tbl.getWriteId();
-        String validWriteIds = null;
-        if (writeId > 0) {
-          ValidWriteIdList validWriteIdList =
-                  new ValidReaderWriteIdList(TableName.getDbTable(tbl.getDbName(),
-                                                                  tbl.getTableName()),
-                                              new long[0], new BitSet(), writeId);
-          validWriteIds = validWriteIdList.toString();
-        }
-        updateTableColumnStatsInternal(colStats, validWriteIds, tbl.getWriteId());
-      }
-    }
-
-    @Override
-    public void create_table(final Table tbl) throws AlreadyExistsException,
-        MetaException, InvalidObjectException, InvalidInputException {
-      create_table_with_environment_context(tbl, null);
-    }
-
-    @Override
-    public void create_table_with_environment_context(final Table tbl,
-        final EnvironmentContext envContext)
-        throws AlreadyExistsException, MetaException, InvalidObjectException,
-            InvalidInputException {
-      startFunction("create_table", ": " + tbl.toString());
-      boolean success = false;
-      Exception ex = null;
-      try {
-        create_table_core(getMS(), tbl, envContext);
-        success = true;
-      } catch (NoSuchObjectException e) {
-        LOG.warn("create_table_with_environment_context got ", e);
-        ex = e;
-        throw new InvalidObjectException(e.getMessage());
-      } catch (MetaException | InvalidObjectException | AlreadyExistsException | InvalidInputException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("create_table", success, ex, tbl.getTableName());
-      }
-    }
-
-    @Override
-    public void create_table_req(final CreateTableRequest req)
-            throws AlreadyExistsException, MetaException, InvalidObjectException,
-            InvalidInputException {
-      Table tbl = req.getTable();
-      startFunction("create_table_req", ": " + tbl.toString());
-      boolean success = false;
-      Exception ex = null;
-      try {
-        create_table_core(getMS(), req);
-        success = true;
-      } catch (NoSuchObjectException e) {
-        LOG.warn("create_table_req got ", e);
-        ex = e;
-        throw new InvalidObjectException(e.getMessage());
-      } catch (MetaException | InvalidObjectException | AlreadyExistsException | InvalidInputException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("create_table_req", success, ex, tbl.getTableName());
-      }
-    }
-
-    @Override
-    public void create_table_with_constraints(final Table tbl,
-        final List<SQLPrimaryKey> primaryKeys, final List<SQLForeignKey> foreignKeys,
-        List<SQLUniqueConstraint> uniqueConstraints,
-        List<SQLNotNullConstraint> notNullConstraints,
-        List<SQLDefaultConstraint> defaultConstraints,
-        List<SQLCheckConstraint> checkConstraints)
-        throws AlreadyExistsException, MetaException, InvalidObjectException,
-            InvalidInputException {
-      startFunction("create_table", ": " + tbl.toString());
-      boolean success = false;
-      Exception ex = null;
-      try {
-        CreateTableRequest req = new CreateTableRequest(tbl);
-        req.setPrimaryKeys(primaryKeys);
-        req.setForeignKeys(foreignKeys);
-        req.setUniqueConstraints(uniqueConstraints);
-        req.setNotNullConstraints(notNullConstraints);
-        req.setDefaultConstraints(defaultConstraints);
-        req.setCheckConstraints(checkConstraints);
-        create_table_req(req);
-        success = true;
-      } catch (MetaException | InvalidObjectException | AlreadyExistsException |
-              InvalidInputException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("create_table_with_constraints", success, ex, tbl.getTableName());
-      }
-    }
-
-    @Override
-    public void drop_constraint(DropConstraintRequest req)
-        throws MetaException, InvalidObjectException {
-      String catName = req.isSetCatName() ? req.getCatName() : getDefaultCatalog(conf);
-      String dbName = req.getDbname();
-      String tableName = req.getTablename();
-      String constraintName = req.getConstraintname();
-      startFunction("drop_constraint", ": " + constraintName);
-      boolean success = false;
-      Exception ex = null;
-      RawStore ms = getMS();
-      try {
-        ms.openTransaction();
-        ms.dropConstraint(catName, dbName, tableName, constraintName);
-        if (transactionalListeners.size() > 0) {
-          DropConstraintEvent dropConstraintEvent = new DropConstraintEvent(catName, dbName,
-              tableName, constraintName, true, this);
-          for (MetaStoreEventListener transactionalListener : transactionalListeners) {
-            transactionalListener.onDropConstraint(dropConstraintEvent);
-          }
-        }
-        success = ms.commitTransaction();
-      } catch (NoSuchObjectException e) {
-        ex = e;
-        throw new InvalidObjectException(e.getMessage());
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else {
-          for (MetaStoreEventListener listener : listeners) {
-            DropConstraintEvent dropConstraintEvent = new DropConstraintEvent(catName, dbName,
-                tableName, constraintName, true, this);
-            listener.onDropConstraint(dropConstraintEvent);
-          }
-        }
-        endFunction("drop_constraint", success, ex, constraintName);
-      }
-    }
-
-    @Override
-    public void add_primary_key(AddPrimaryKeyRequest req)
-      throws MetaException, InvalidObjectException {
-      List<SQLPrimaryKey> primaryKeyCols = req.getPrimaryKeyCols();
-      String constraintName = (CollectionUtils.isNotEmpty(primaryKeyCols)) ?
-        primaryKeyCols.get(0).getPk_name() : "null";
-      startFunction("add_primary_key", ": " + constraintName);
-      boolean success = false;
-      Exception ex = null;
-      if (CollectionUtils.isNotEmpty(primaryKeyCols) && !primaryKeyCols.get(0).isSetCatName()) {
-        String defaultCat = getDefaultCatalog(conf);
-        primaryKeyCols.forEach(pk -> pk.setCatName(defaultCat));
-      }
-      RawStore ms = getMS();
-      try {
-        ms.openTransaction();
-        List<SQLPrimaryKey> primaryKeys = ms.addPrimaryKeys(primaryKeyCols);
-        if (transactionalListeners.size() > 0) {
-          if (CollectionUtils.isNotEmpty(primaryKeys)) {
-            AddPrimaryKeyEvent addPrimaryKeyEvent = new AddPrimaryKeyEvent(primaryKeys, true, this);
-            for (MetaStoreEventListener transactionalListener : transactionalListeners) {
-              transactionalListener.onAddPrimaryKey(addPrimaryKeyEvent);
-            }
-          }
-        }
-        success = ms.commitTransaction();
-      } catch (MetaException | InvalidObjectException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else if (primaryKeyCols != null && primaryKeyCols.size() > 0) {
-          for (MetaStoreEventListener listener : listeners) {
-            AddPrimaryKeyEvent addPrimaryKeyEvent = new AddPrimaryKeyEvent(primaryKeyCols, true, this);
-            listener.onAddPrimaryKey(addPrimaryKeyEvent);
-          }
-        }
-        endFunction("add_primary_key", success, ex, constraintName);
-      }
-    }
-
-    @Override
-    public void add_foreign_key(AddForeignKeyRequest req)
-      throws MetaException, InvalidObjectException {
-      List<SQLForeignKey> foreignKeys = req.getForeignKeyCols();
-      String constraintName = CollectionUtils.isNotEmpty(foreignKeys) ?
-        foreignKeys.get(0).getFk_name() : "null";
-      startFunction("add_foreign_key", ": " + constraintName);
-      boolean success = false;
-      Exception ex = null;
-      if (CollectionUtils.isNotEmpty(foreignKeys) && !foreignKeys.get(0).isSetCatName()) {
-        String defaultCat = getDefaultCatalog(conf);
-        foreignKeys.forEach(pk -> pk.setCatName(defaultCat));
-      }
-      RawStore ms = getMS();
-      try {
-        ms.openTransaction();
-        foreignKeys = ms.addForeignKeys(foreignKeys);
-        if (transactionalListeners.size() > 0) {
-          if (CollectionUtils.isNotEmpty(foreignKeys)) {
-            AddForeignKeyEvent addForeignKeyEvent = new AddForeignKeyEvent(foreignKeys, true, this);
-            for (MetaStoreEventListener transactionalListener : transactionalListeners) {
-              transactionalListener.onAddForeignKey(addForeignKeyEvent);
-            }
-          }
-        }
-        success = ms.commitTransaction();
-      } catch (MetaException | InvalidObjectException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else if (CollectionUtils.isNotEmpty(foreignKeys)) {
-          for (MetaStoreEventListener listener : listeners) {
-            AddForeignKeyEvent addForeignKeyEvent = new AddForeignKeyEvent(foreignKeys, true, this);
-            listener.onAddForeignKey(addForeignKeyEvent);
-          }
-        }
-        endFunction("add_foreign_key", success, ex, constraintName);
-      }
-    }
-
-    @Override
-    public void add_unique_constraint(AddUniqueConstraintRequest req)
-      throws MetaException, InvalidObjectException {
-      List<SQLUniqueConstraint> uniqueConstraints = req.getUniqueConstraintCols();
-      String constraintName = (uniqueConstraints != null && uniqueConstraints.size() > 0) ?
-              uniqueConstraints.get(0).getUk_name() : "null";
-      startFunction("add_unique_constraint", ": " + constraintName);
-      boolean success = false;
-      Exception ex = null;
-      if (!uniqueConstraints.isEmpty() && !uniqueConstraints.get(0).isSetCatName()) {
-        String defaultCat = getDefaultCatalog(conf);
-        uniqueConstraints.forEach(pk -> pk.setCatName(defaultCat));
-      }
-      RawStore ms = getMS();
-      try {
-        ms.openTransaction();
-        uniqueConstraints = ms.addUniqueConstraints(uniqueConstraints);
-        if (transactionalListeners.size() > 0) {
-          if (CollectionUtils.isNotEmpty(uniqueConstraints)) {
-            AddUniqueConstraintEvent addUniqueConstraintEvent = new AddUniqueConstraintEvent(uniqueConstraints, true, this);
-            for (MetaStoreEventListener transactionalListener : transactionalListeners) {
-              transactionalListener.onAddUniqueConstraint(addUniqueConstraintEvent);
-            }
-          }
-        }
-        success = ms.commitTransaction();
-      } catch (MetaException | InvalidObjectException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else if (CollectionUtils.isNotEmpty(uniqueConstraints)) {
-          for (MetaStoreEventListener listener : listeners) {
-            AddUniqueConstraintEvent addUniqueConstraintEvent = new AddUniqueConstraintEvent(uniqueConstraints, true, this);
-            listener.onAddUniqueConstraint(addUniqueConstraintEvent);
-          }
-        }
-        endFunction("add_unique_constraint", success, ex, constraintName);
-      }
-    }
-
-    @Override
-    public void add_not_null_constraint(AddNotNullConstraintRequest req)
-      throws MetaException, InvalidObjectException {
-      List<SQLNotNullConstraint> notNullConstraints = req.getNotNullConstraintCols();
-      String constraintName = (notNullConstraints != null && notNullConstraints.size() > 0) ?
-              notNullConstraints.get(0).getNn_name() : "null";
-      startFunction("add_not_null_constraint", ": " + constraintName);
-      boolean success = false;
-      Exception ex = null;
-      if (!notNullConstraints.isEmpty() && !notNullConstraints.get(0).isSetCatName()) {
-        String defaultCat = getDefaultCatalog(conf);
-        notNullConstraints.forEach(pk -> pk.setCatName(defaultCat));
-      }
-      RawStore ms = getMS();
-      try {
-        ms.openTransaction();
-        notNullConstraints = ms.addNotNullConstraints(notNullConstraints);
-
-        if (transactionalListeners.size() > 0) {
-          if (CollectionUtils.isNotEmpty(notNullConstraints)) {
-            AddNotNullConstraintEvent addNotNullConstraintEvent = new AddNotNullConstraintEvent(notNullConstraints, true, this);
-            for (MetaStoreEventListener transactionalListener : transactionalListeners) {
-              transactionalListener.onAddNotNullConstraint(addNotNullConstraintEvent);
-            }
-          }
-        }
-        success = ms.commitTransaction();
-      } catch (MetaException | InvalidObjectException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else if (CollectionUtils.isNotEmpty(notNullConstraints)) {
-          for (MetaStoreEventListener listener : listeners) {
-            AddNotNullConstraintEvent addNotNullConstraintEvent = new AddNotNullConstraintEvent(notNullConstraints, true, this);
-            listener.onAddNotNullConstraint(addNotNullConstraintEvent);
-          }
-        }
-        endFunction("add_not_null_constraint", success, ex, constraintName);
-      }
-    }
-
-    @Override
-    public void add_default_constraint(AddDefaultConstraintRequest req) throws MetaException, InvalidObjectException {
-      List<SQLDefaultConstraint> defaultConstraints = req.getDefaultConstraintCols();
-      String constraintName =
-          CollectionUtils.isNotEmpty(defaultConstraints) ? defaultConstraints.get(0).getDc_name() : "null";
-      startFunction("add_default_constraint", ": " + constraintName);
-      boolean success = false;
-      Exception ex = null;
-      if (!defaultConstraints.isEmpty() && !defaultConstraints.get(0).isSetCatName()) {
-        String defaultCat = getDefaultCatalog(conf);
-        defaultConstraints.forEach(pk -> pk.setCatName(defaultCat));
-      }
-      RawStore ms = getMS();
-      try {
-        ms.openTransaction();
-        defaultConstraints = ms.addDefaultConstraints(defaultConstraints);
-        if (transactionalListeners.size() > 0) {
-          if (CollectionUtils.isNotEmpty(defaultConstraints)) {
-            AddDefaultConstraintEvent addDefaultConstraintEvent =
-                new AddDefaultConstraintEvent(defaultConstraints, true, this);
-            for (MetaStoreEventListener transactionalListener : transactionalListeners) {
-              transactionalListener.onAddDefaultConstraint(addDefaultConstraintEvent);
-            }
-          }
-        }
-        success = ms.commitTransaction();
-      } catch (MetaException | InvalidObjectException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else if (CollectionUtils.isNotEmpty(defaultConstraints)) {
-          for (MetaStoreEventListener listener : listeners) {
-            AddDefaultConstraintEvent addDefaultConstraintEvent =
-                new AddDefaultConstraintEvent(defaultConstraints, true, this);
-            listener.onAddDefaultConstraint(addDefaultConstraintEvent);
-          }
-        }
-        endFunction("add_default_constraint", success, ex, constraintName);
-      }
-    }
-
-    @Override
-    public void add_check_constraint(AddCheckConstraintRequest req)
-        throws MetaException, InvalidObjectException {
-      List<SQLCheckConstraint> checkConstraints= req.getCheckConstraintCols();
-      String constraintName = CollectionUtils.isNotEmpty(checkConstraints) ?
-          checkConstraints.get(0).getDc_name() : "null";
-      startFunction("add_check_constraint", ": " + constraintName);
-      boolean success = false;
-      Exception ex = null;
-      if (!checkConstraints.isEmpty() && !checkConstraints.get(0).isSetCatName()) {
-        String defaultCat = getDefaultCatalog(conf);
-        checkConstraints.forEach(pk -> pk.setCatName(defaultCat));
-      }
-      RawStore ms = getMS();
-      try {
-        ms.openTransaction();
-        checkConstraints = ms.addCheckConstraints(checkConstraints);
-        if (transactionalListeners.size() > 0) {
-          if (CollectionUtils.isNotEmpty(checkConstraints)) {
-            AddCheckConstraintEvent addcheckConstraintEvent = new AddCheckConstraintEvent(checkConstraints, true, this);
-            for (MetaStoreEventListener transactionalListener : transactionalListeners) {
-             transactionalListener.onAddCheckConstraint(addcheckConstraintEvent);
-            }
-          }
-        }
-        success = ms.commitTransaction();
-      } catch (MetaException | InvalidObjectException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else if (CollectionUtils.isNotEmpty(checkConstraints)) {
-          for (MetaStoreEventListener listener : listeners) {
-            AddCheckConstraintEvent addCheckConstraintEvent = new AddCheckConstraintEvent(checkConstraints, true, this);
-            listener.onAddCheckConstraint(addCheckConstraintEvent);
-          }
-        }
-        endFunction("add_check_constraint", success, ex, constraintName);
-      }
-    }
-
-    private boolean is_table_exists(RawStore ms, String catName, String dbname, String name)
-        throws MetaException {
-      return (ms.getTable(catName, dbname, name, null) != null);
-    }
-
-    private boolean drop_table_core(final RawStore ms, final String catName, final String dbname,
-                                    final String name, final boolean deleteData,
-                                    final EnvironmentContext envContext, final String indexName)
-        throws NoSuchObjectException, MetaException, IOException, InvalidObjectException,
-        InvalidInputException {
-      boolean success = false;
-      boolean tableDataShouldBeDeleted = false;
-      Path tblPath = null;
-      List<Path> partPaths = null;
-      Table tbl = null;
-      boolean ifPurge = false;
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-      Database db = null;
-      boolean isReplicated = false;
-      try {
-        ms.openTransaction();
-        db = ms.getDatabase(catName, dbname);
-        if (db.getType() == DatabaseType.REMOTE) {
-          return DataConnectorProviderFactory.getDataConnectorProvider(db).dropTable(name);
-        }
-        isReplicated = isDbReplicationTarget(db);
-
-        // drop any partitions
-        tbl = get_table_core(catName, dbname, name, null);
-        if (tbl == null) {
-          throw new NoSuchObjectException(name + " doesn't exist");
-        }
-
-        // Check if table is part of a materialized view.
-        // If it is, it cannot be dropped.
-        List<String> isPartOfMV = ms.isPartOfMaterializedView(catName, dbname, name);
-        if (!isPartOfMV.isEmpty()) {
-            throw new MetaException(String.format("Cannot drop table as it is used in the following materialized" +
-                    " views %s%n", isPartOfMV));
-        }
-
-        if (tbl.getSd() == null) {
-          throw new MetaException("Table metadata is corrupted");
-        }
-        ifPurge = isMustPurge(envContext, tbl);
-
-        firePreEvent(new PreDropTableEvent(tbl, deleteData, this));
-
-        tableDataShouldBeDeleted = checkTableDataShouldBeDeleted(tbl, deleteData);
-        if (tbl.getSd().getLocation() != null) {
-          tblPath = new Path(tbl.getSd().getLocation());
-          if (!wh.isWritable(tblPath.getParent())) {
-            String target = indexName == null ? "Table" : "Index table";
-            throw new MetaException(target + " metadata not deleted since " +
-                tblPath.getParent() + " is not writable by " +
-                SecurityUtils.getUser());
-          }
-        }
-
-        // Drop the partitions and get a list of locations which need to be deleted
-        partPaths = dropPartitionsAndGetLocations(ms, catName, dbname, name, tblPath,
-            tableDataShouldBeDeleted);
-
-        // Drop any constraints on the table
-        ms.dropConstraint(catName, dbname, name, null, true);
-
-        if (!ms.dropTable(catName, dbname, name)) {
-          String tableName = TableName.getQualified(catName, dbname, name);
-          throw new MetaException(indexName == null ? "Unable to drop table " + tableName:
-              "Unable to drop index table " + tableName + " for index " + indexName);
-        } else {
-          if (!transactionalListeners.isEmpty()) {
-            transactionalListenerResponses =
-                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                      EventType.DROP_TABLE,
-                                                      new DropTableEvent(tbl, true, deleteData,
-                                                              this, isReplicated),
-                                                      envContext);
-          }
-          success = ms.commitTransaction();
-        }
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else if (tableDataShouldBeDeleted) {
-          // Data needs deletion. Check if trash may be skipped.
-          // Delete the data in the partitions which have other locations
-          deletePartitionData(partPaths, ifPurge, ReplChangeManager.shouldEnableCm(db, tbl));
-          // Delete the data in the table
-          deleteTableData(tblPath, ifPurge, ReplChangeManager.shouldEnableCm(db, tbl));
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.DROP_TABLE,
-                                                new DropTableEvent(tbl, success, deleteData, this, isReplicated),
-                                                envContext,
-                                                transactionalListenerResponses, ms);
-        }
-      }
-      return success;
-    }
-
-    private boolean checkTableDataShouldBeDeleted(Table tbl, boolean deleteData) {
-      if (deleteData && isExternal(tbl)) {
-        // External table data can be deleted if EXTERNAL_TABLE_PURGE is true
-        return isExternalTablePurge(tbl);
-      }
-      return deleteData;
-    }
-
-    /**
-     * Deletes the data in a table's location, if it fails logs an error
-     *
-     * @param tablePath
-     * @param ifPurge completely purge the table (skipping trash) while removing
-     *                data from warehouse
-     * @param shouldEnableCm If cm should be enabled
-     */
-    private void deleteTableData(Path tablePath, boolean ifPurge, boolean shouldEnableCm) {
-      if (tablePath != null) {
-        deleteDataExcludeCmroot(tablePath, ifPurge, shouldEnableCm);
-      }
-    }
-
-    /**
-     * Deletes the data in a table's location, if it fails logs an error.
-     *
-     * @param tablePath
-     * @param ifPurge completely purge the table (skipping trash) while removing
-     *                data from warehouse
-     * @param db Database
-     */
-    private void deleteTableData(Path tablePath, boolean ifPurge, Database db) {
-      if (tablePath != null) {
-        try {
-          wh.deleteDir(tablePath, true, ifPurge, db);
-        } catch (Exception e) {
-          LOG.error("Failed to delete table directory: " + tablePath +
-                  " " + e.getMessage());
-        }
-      }
-    }
-
-    /**
-    * Give a list of partitions' locations, tries to delete each one
-    * and for each that fails logs an error.
-    *
-    * @param partPaths
-    * @param ifPurge completely purge the partition (skipping trash) while
-    *                removing data from warehouse
-    * @param shouldEnableCm If cm should be enabled
-    */
-    private void deletePartitionData(List<Path> partPaths, boolean ifPurge, boolean shouldEnableCm) {
-      if (partPaths != null && !partPaths.isEmpty()) {
-        for (Path partPath : partPaths) {
-          deleteDataExcludeCmroot(partPath, ifPurge, shouldEnableCm);
-        }
-      }
-    }
-
-    /**
-     * Give a list of partitions' locations, tries to delete each one
-     * and for each that fails logs an error.
-     *
-     * @param partPaths
-     * @param ifPurge completely purge the partition (skipping trash) while
-     *                removing data from warehouse
-     * @param db Database
-     */
-    private void deletePartitionData(List<Path> partPaths, boolean ifPurge, Database db) {
-      if (partPaths != null && !partPaths.isEmpty()) {
-        for (Path partPath : partPaths) {
-          try {
-            wh.deleteDir(partPath, true, ifPurge, db);
-          } catch (Exception e) {
-            LOG.error("Failed to delete partition directory: " + partPath +
-                    " " + e.getMessage());
-          }
-        }
-      }
-    }
-
-    /**
-     * Delete data from path excluding cmdir
-     * and for each that fails logs an error.
-     *
-     * @param path
-     * @param ifPurge completely purge the partition (skipping trash) while
-     *                removing data from warehouse
-     * @param shouldEnableCm If cm should be enabled
-     */
-    private void deleteDataExcludeCmroot(Path path, boolean ifPurge, boolean shouldEnableCm) {
-      try {
-        if (shouldEnableCm) {
-          //Don't delete cmdir if its inside the partition path
-          FileStatus[] statuses = path.getFileSystem(conf).listStatus(path,
-                  ReplChangeManager.CMROOT_PATH_FILTER);
-          for (final FileStatus status : statuses) {
-            wh.deleteDir(status.getPath(), true, ifPurge, shouldEnableCm);
-          }
-          //Check if table directory is empty, delete it
-          FileStatus[] statusWithoutFilter = path.getFileSystem(conf).listStatus(path);
-          if (statusWithoutFilter.length == 0) {
-            wh.deleteDir(path, true, ifPurge, shouldEnableCm);
-          }
-        } else {
-          //If no cm delete the complete table directory
-          wh.deleteDir(path, true, ifPurge, shouldEnableCm);
-        }
-      } catch (Exception e) {
-        LOG.error("Failed to delete directory: " + path +
-                " " + e.getMessage());
-      }
-    }
-
-    /**
-     * Deletes the partitions specified by catName, dbName, tableName. If checkLocation is true, for
-     * locations of partitions which may not be subdirectories of tablePath checks to make sure the
-     * locations are writable.
-     *
-     * Drops the metadata for each partition.
-     *
-     * Provides a list of locations of partitions which may not be subdirectories of tablePath.
-     *
-     * @param ms RawStore to use for metadata retrieval and delete
-     * @param catName The catName
-     * @param dbName The dbName
-     * @param tableName The tableName
-     * @param tablePath The tablePath of which subdirectories does not have to be checked
-     * @param checkLocation Should we check the locations at all
-     * @return The list of the Path objects to delete (only in case checkLocation is true)
-     * @throws MetaException
-     * @throws IOException
-     * @throws NoSuchObjectException
-     */
-    private List<Path> dropPartitionsAndGetLocations(RawStore ms, String catName, String dbName,
-        String tableName, Path tablePath, boolean checkLocation)
-        throws MetaException, IOException, NoSuchObjectException {
-      int batchSize = MetastoreConf.getIntVar(conf, ConfVars.BATCH_RETRIEVE_OBJECTS_MAX);
-      String tableDnsPath = null;
-      if (tablePath != null) {
-        tableDnsPath = wh.getDnsPath(tablePath).toString();
-      }
-
-      List<Path> partPaths = new ArrayList<>();
-      while (true) {
-        Map<String, String> partitionLocations = ms.getPartitionLocations(catName, dbName, tableName,
-            tableDnsPath, batchSize);
-        if (partitionLocations == null || partitionLocations.isEmpty()) {
-          // No more partitions left to drop. Return with the collected path list to delete.
-          return partPaths;
-        }
-
-        if (checkLocation) {
-          for (String partName : partitionLocations.keySet()) {
-            String pathString = partitionLocations.get(partName);
-            if (pathString != null) {
-              Path partPath = wh.getDnsPath(new Path(pathString));
-              // Double check here. Maybe Warehouse.getDnsPath revealed relationship between the
-              // path objects
-              if (tableDnsPath == null ||
-                      !FileUtils.isSubdirectory(tableDnsPath, partPath.toString())) {
-                if (!wh.isWritable(partPath.getParent())) {
-                  throw new MetaException("Table metadata not deleted since the partition "
-                      + partName + " has parent location " + partPath.getParent()
-                      + " which is not writable by " + SecurityUtils.getUser());
-                }
-                partPaths.add(partPath);
-              }
-            }
-          }
-        }
-
-        for (MetaStoreEventListener listener : listeners) {
-          //No drop part listener events fired for public listeners historically, for drop table case.
-          //Limiting to internal listeners for now, to avoid unexpected calls for public listeners.
-          if (listener instanceof HMSMetricsListener) {
-            for (@SuppressWarnings("unused") String partName : partitionLocations.keySet()) {
-              listener.onDropPartition(null);
-            }
-          }
-        }
-
-        ms.dropPartitions(catName, dbName, tableName, new ArrayList<>(partitionLocations.keySet()));
-      }
-    }
-
-    @Override
-    public void drop_table(final String dbname, final String name, final boolean deleteData)
-        throws NoSuchObjectException, MetaException {
-      drop_table_with_environment_context(dbname, name, deleteData, null);
-    }
-
-    @Override
-    public void drop_table_with_environment_context(final String dbname, final String name,
-        final boolean deleteData, final EnvironmentContext envContext)
-        throws NoSuchObjectException, MetaException {
-      String[] parsedDbName = parseDbName(dbname, conf);
-      startTableFunction("drop_table", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], name);
-
-      boolean success = false;
-      Exception ex = null;
-      try {
-        success = drop_table_core(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME], name,
-            deleteData, envContext, null);
-      } catch (IOException e) {
-        ex = e;
-        throw new MetaException(e.getMessage());
-      } catch (Exception e) {
-        ex = e;
-        throwMetaException(e);
-      } finally {
-        endFunction("drop_table", success, ex, name);
-      }
-
-    }
-
-    private void updateStatsForTruncate(Map<String,String> props, EnvironmentContext environmentContext) {
-      if (null == props) {
-        return;
-      }
-      for (String stat : StatsSetupConst.SUPPORTED_STATS) {
-        String statVal = props.get(stat);
-        if (statVal != null) {
-          //In the case of truncate table, we set the stats to be 0.
-          props.put(stat, "0");
-        }
-      }
-      //first set basic stats to true
-      StatsSetupConst.setBasicStatsState(props, StatsSetupConst.TRUE);
-      environmentContext.putToProperties(StatsSetupConst.STATS_GENERATED, StatsSetupConst.TASK);
-      environmentContext.putToProperties(StatsSetupConst.DO_NOT_POPULATE_QUICK_STATS, StatsSetupConst.TRUE);
-      //then invalidate column stats
-      StatsSetupConst.clearColumnStatsState(props);
-      return;
-    }
-
-    private void alterPartitionForTruncate(RawStore ms, String catName, String dbName, String tableName,
-        Table table, Partition partition, String validWriteIds, long writeId) throws Exception {
-      EnvironmentContext environmentContext = new EnvironmentContext();
-      updateStatsForTruncate(partition.getParameters(), environmentContext);
-
-      if (!transactionalListeners.isEmpty()) {
-        MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                EventType.ALTER_PARTITION,
-                new AlterPartitionEvent(partition, partition, table, true, true,
-                        writeId, this));
-      }
-
-      if (!listeners.isEmpty()) {
-        MetaStoreListenerNotifier.notifyEvent(listeners,
-                EventType.ALTER_PARTITION,
-                new AlterPartitionEvent(partition, partition, table, true, true,
-                        writeId, this));
-      }
-
-      if (writeId > 0) {
-        partition.setWriteId(writeId);
-      }
-      alterHandler.alterPartition(ms, wh, catName, dbName, tableName, null, partition,
-          environmentContext, this, validWriteIds);
-    }
-
-    private void alterTableStatsForTruncate(RawStore ms, String catName, String dbName,
-        String tableName, Table table, List<String> partNames,
-        String validWriteIds, long writeId) throws Exception {
-      if (partNames == null) {
-        if (0 != table.getPartitionKeysSize()) {
-          for (Partition partition : ms.getPartitions(catName, dbName, tableName, -1)) {
-            alterPartitionForTruncate(ms, catName, dbName, tableName, table, partition,
-                validWriteIds, writeId);
-          }
-        } else {
-          EnvironmentContext environmentContext = new EnvironmentContext();
-          updateStatsForTruncate(table.getParameters(), environmentContext);
-
-          boolean isReplicated = isDbReplicationTarget(ms.getDatabase(catName, dbName));
-          if (!transactionalListeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                    EventType.ALTER_TABLE,
-                    new AlterTableEvent(table, table, true, true,
-                            writeId, this, isReplicated));
-          }
-
-          if (!listeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(listeners,
-                    EventType.ALTER_TABLE,
-                    new AlterTableEvent(table, table, true, true,
-                            writeId, this, isReplicated));
-          }
-
-          // TODO: this should actually pass thru and set writeId for txn stats.
-          if (writeId > 0) {
-            table.setWriteId(writeId);
-          }
-          alterHandler.alterTable(ms, wh, catName, dbName, tableName, table,
-              environmentContext, this, validWriteIds);
-        }
-      } else {
-        for (Partition partition : ms.getPartitionsByNames(catName, dbName, tableName, partNames)) {
-          alterPartitionForTruncate(ms, catName, dbName, tableName, table, partition,
-              validWriteIds, writeId);
-        }
-      }
-      return;
-    }
-
-    private List<Path> getLocationsForTruncate(final RawStore ms,
-                                               final String catName,
-                                               final String dbName,
-                                               final String tableName,
-                                               final Table table,
-                                               final List<String> partNames) throws Exception {
-      List<Path> locations = new ArrayList<>();
-      if (partNames == null) {
-        if (0 != table.getPartitionKeysSize()) {
-          for (Partition partition : ms.getPartitions(catName, dbName, tableName, -1)) {
-            locations.add(new Path(partition.getSd().getLocation()));
-          }
-        } else {
-          locations.add(new Path(table.getSd().getLocation()));
-        }
-      } else {
-        for (Partition partition : ms.getPartitionsByNames(catName, dbName, tableName, partNames)) {
-          locations.add(new Path(partition.getSd().getLocation()));
-        }
-      }
-      return locations;
-    }
-
-    @Override
-    public CmRecycleResponse cm_recycle(final CmRecycleRequest request) throws MetaException {
-      wh.recycleDirToCmPath(new Path(request.getDataPath()), request.isPurge());
-      return new CmRecycleResponse();
-    }
-
-    @Override
-    public void truncate_table(final String dbName, final String tableName, List<String> partNames)
-      throws NoSuchObjectException, MetaException {
-      // Deprecated path, won't work for txn tables.
-      truncateTableInternal(dbName, tableName, partNames, null, -1);
-    }
-
-    @Override
-    public TruncateTableResponse truncate_table_req(TruncateTableRequest req)
-        throws MetaException, TException {
-      truncateTableInternal(req.getDbName(), req.getTableName(), req.getPartNames(),
-          req.getValidWriteIdList(), req.getWriteId());
-      return new TruncateTableResponse();
-    }
-
-    private void truncateTableInternal(String dbName, String tableName, List<String> partNames,
-        String validWriteIds, long writeId) throws MetaException, NoSuchObjectException {
-      try {
-        String[] parsedDbName = parseDbName(dbName, conf);
-        Table tbl = get_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName);
-
-        boolean truncateFiles = !TxnUtils.isTransactionalTable(tbl) ||
-            !MetastoreConf.getBoolVar(getConf(), MetastoreConf.ConfVars.TRUNCATE_ACID_USE_BASE);
-        // This is not transactional
-        for (Path location : getLocationsForTruncate(getMS(), parsedDbName[CAT_NAME],
-            parsedDbName[DB_NAME], tableName, tbl, partNames)) {
-          FileSystem fs = location.getFileSystem(getConf());
-          if (truncateFiles) {
-            truncateDataFiles(tbl, parsedDbName, location, fs);
-          } else {
-            // For Acid tables we don't need to delete the old files, only write an empty baseDir.
-            // Compaction and cleaner will take care of the rest
-            addTruncateBaseFile(location, writeId, fs);
-          }
-        }
-
-        // Alter the table/partition stats and also notify truncate table event
-        alterTableStatsForTruncate(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tableName, tbl, partNames, validWriteIds, writeId);
-      } catch (IOException e) {
-        throw new MetaException(e.getMessage());
-      } catch (MetaException | NoSuchObjectException e) {
-        throw e;
-      } catch (Exception e) {
-        throw newMetaException(e);
-      }
-    }
-
-    /**
-     * Add an empty baseDir with a truncate metadatafile
-     * @param location partition or table directory
-     * @param writeId allocated writeId
-     * @param fs FileSystem
-     * @throws Exception
-     */
-    private void addTruncateBaseFile(Path location, long writeId, FileSystem fs) throws Exception {
-      Path basePath = new Path(location, AcidConstants.baseDir(writeId));
-      fs.mkdirs(basePath);
-      // We can not leave the folder empty, otherwise it will be skipped at some file listing in AcidUtils
-      // No need for a data file, a simple metadata is enough
-      AcidMetaDataFile.writeToFile(fs, basePath, AcidMetaDataFile.DataFormat.TRUNCATED);
-    }
-
-    private void truncateDataFiles(Table tbl, String[] parsedDbName, Path location, FileSystem fs)
-        throws IOException, MetaException, NoSuchObjectException {
-      boolean isSkipTrash = MetaStoreUtils.isSkipTrash(tbl.getParameters());
-      Database db = get_database_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]);
-      if (!HdfsUtils.isPathEncrypted(getConf(), fs.getUri(), location) &&
-          !FileUtils.pathHasSnapshotSubDir(location, fs)) {
-        HdfsUtils.HadoopFileStatus status = new HdfsUtils.HadoopFileStatus(getConf(), fs, location);
-        FileStatus targetStatus = fs.getFileStatus(location);
-        String targetGroup = targetStatus == null ? null : targetStatus.getGroup();
-        wh.deleteDir(location, true, isSkipTrash, ReplChangeManager.shouldEnableCm(db, tbl));
-        fs.mkdirs(location);
-        HdfsUtils.setFullFileStatus(getConf(), status, targetGroup, fs, location, false);
-      } else {
-        FileStatus[] statuses = fs.listStatus(location, FileUtils.HIDDEN_FILES_PATH_FILTER);
-        if (statuses == null || statuses.length == 0) {
-          return;
-        }
-        for (final FileStatus status : statuses) {
-          wh.deleteDir(status.getPath(), true, isSkipTrash, ReplChangeManager.shouldEnableCm(db, tbl));
-        }
-      }
-    }
-
-    /**
-     * Is this an external table?
-     *
-     * @param table
-     *          Check if this table is external.
-     * @return True if the table is external, otherwise false.
-     */
-    private boolean isExternal(Table table) {
-      return MetaStoreUtils.isExternalTable(table);
-    }
-
-    private boolean isExternalTablePurge(Table table) {
-      return MetaStoreUtils.isExternalTablePurge(table);
-    }
-
-    @Override
-    @Deprecated
-    public Table get_table(final String dbname, final String name) throws MetaException,
-        NoSuchObjectException {
-      String[] parsedDbName = parseDbName(dbname, conf);
-      return getTableInternal(
-            parsedDbName[CAT_NAME], parsedDbName[DB_NAME], name, null, null, false, null, null, null);
-    }
-
-    @Override
-    public List<ExtendedTableInfo> get_tables_ext(final GetTablesExtRequest req) throws MetaException {
-      List<String> tables = new ArrayList<String>();
-      List<ExtendedTableInfo> ret = new ArrayList<ExtendedTableInfo>();
-      String catalog  = req.getCatalog();
-      String database = req.getDatabase();
-      String pattern  = req.getTableNamePattern();
-      List<String> processorCapabilities = req.getProcessorCapabilities();
-      int limit = req.getLimit();
-      String processorId  = req.getProcessorIdentifier();
-      List<Table> tObjects = new ArrayList<>();
-
-      startTableFunction("get_tables_ext", catalog, database, pattern);
-      Exception ex = null;
-      try {
-        tables = getMS().getTables(catalog, database, pattern, null, limit);
-        LOG.debug("get_tables_ext:getTables() returned " + tables.size());
-        tables = FilterUtils.filterTableNamesIfEnabled(isServerFilterEnabled, filterHook,
-                catalog, database, tables);
-
-        if (tables.size() > 0) {
-          tObjects = getMS().getTableObjectsByName(catalog, database, tables);
-          LOG.debug("get_tables_ext:getTableObjectsByName() returned " + tObjects.size());
-          if (processorCapabilities == null || processorCapabilities.size() == 0 ||
-                processorCapabilities.contains("MANAGERAWMETADATA")) {
-            LOG.info("Skipping translation for processor with " + processorId);
-          } else {
-            if (transformer != null) {
-              Map<Table, List<String>> retMap = transformer.transform(tObjects, processorCapabilities, processorId);
-
-              for (Map.Entry<Table, List<String>> entry : retMap.entrySet())  {
-                LOG.debug("Table " + entry.getKey().getTableName() + " requires " + Arrays.toString((entry.getValue()).toArray()));
-                ret.add(convertTableToExtendedTable(entry.getKey(), entry.getValue(), req.getRequestedFields()));
-              }
-            } else {
-              for (Table table : tObjects) {
-                ret.add(convertTableToExtendedTable(table, processorCapabilities, req.getRequestedFields()));
-              }
-            }
-          }
-        }
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_tables_ext", ret != null, ex);
-      }
-      return ret;
-    }
-
-    private ExtendedTableInfo convertTableToExtendedTable (Table table,
-          List<String> processorCapabilities, int mask) {
-      ExtendedTableInfo extTable = new ExtendedTableInfo(table.getTableName());
-      if ((mask & GetTablesExtRequestFields.ACCESS_TYPE.getValue()) == GetTablesExtRequestFields.ACCESS_TYPE.getValue())
-        extTable.setAccessType(table.getAccessType());
-
-      if ((mask & GetTablesExtRequestFields.PROCESSOR_CAPABILITIES.getValue())
-             == GetTablesExtRequestFields.PROCESSOR_CAPABILITIES.getValue()) {
-        extTable.setRequiredReadCapabilities(table.getRequiredReadCapabilities());
-        extTable.setRequiredWriteCapabilities(table.getRequiredWriteCapabilities());
-      }
-
-      return extTable;
-    }
-
-    @Override
-    public GetTableResult get_table_req(GetTableRequest req) throws MetaException,
-        NoSuchObjectException {
-      String catName = req.isSetCatName() ? req.getCatName() : getDefaultCatalog(conf);
-      return new GetTableResult(getTableInternal(catName, req.getDbName(), req.getTblName(),
-          req.getCapabilities(), req.getValidWriteIdList(), req.isGetColumnStats(), req.getEngine(),
-          req.getProcessorCapabilities(), req.getProcessorIdentifier()));
-    }
-
-    /**
-     * This function retrieves table from metastore. If getColumnStats flag is true,
-     * then engine should be specified so the table is retrieve with the column stats
-     * for that engine.
-     */
-    private Table getTableInternal(String catName, String dbname, String name,
-        ClientCapabilities capabilities, String writeIdList, boolean getColumnStats, String engine,
-        List<String> processorCapabilities, String processorId)
-        throws MetaException, NoSuchObjectException {
-      Preconditions.checkArgument(!getColumnStats || engine != null,
-          "To retrieve column statistics with a table, engine parameter cannot be null");
-
-      if (isInTest) {
-        assertClientHasCapability(capabilities, ClientCapability.TEST_CAPABILITY,
-            "Hive tests", "get_table_req");
-      }
-
-      Table t = null;
-      startTableFunction("get_table", catName, dbname, name);
-      Exception ex = null;
-      try {
-        t = get_table_core(catName, dbname, name, writeIdList, getColumnStats, engine);
-        if (MetaStoreUtils.isInsertOnlyTableParam(t.getParameters())) {
-          assertClientHasCapability(capabilities, ClientCapability.INSERT_ONLY_TABLES,
-              "insert-only tables", "get_table_req");
-        }
-
-        if (processorCapabilities == null || processorCapabilities.size() == 0 ||
-              processorCapabilities.contains("MANAGERAWMETADATA")) {
-          LOG.info("Skipping translation for processor with " + processorId);
-        } else {
-          if (transformer != null) {
-            List<Table> tList = new ArrayList<>();
-            tList.add(t);
-            Map<Table, List<String>> ret = transformer.transform(tList, processorCapabilities, processorId);
-            if (ret.size() > 1) {
-              LOG.warn("Unexpected resultset size:" + ret.size());
-              throw new MetaException("Unexpected result from metadata transformer:return list size is " + ret.size());
-            }
-            t = (Table)(ret.keySet().iterator().next());
-          }
-        }
-
-        firePreEvent(new PreReadTableEvent(t, this));
-      } catch (MetaException | NoSuchObjectException e) {
-        ex = e;
-        throw e;
-      } finally {
-        endFunction("get_table", t != null, ex, name);
-      }
-      return t;
-    }
-
-    @Override
-    public List<TableMeta> get_table_meta(String dbnames, String tblNames, List<String> tblTypes)
-        throws MetaException, NoSuchObjectException {
-      List<TableMeta> t = null;
-      String[] parsedDbName = parseDbName(dbnames, conf);
-      startTableFunction("get_table_metas", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblNames);
-      Exception ex = null;
-      try {
-        t = getMS().getTableMeta(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblNames, tblTypes);
-        t = FilterUtils.filterTableMetasIfEnabled(isServerFilterEnabled, filterHook,
-            parsedDbName[CAT_NAME], parsedDbName[DB_NAME], t);
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_table_metas", t != null, ex);
-      }
-      return t;
-    }
-
-    @Override
-    public Table get_table_core(
-        final String catName,
-        final String dbname,
-        final String name)
-        throws MetaException, NoSuchObjectException {
-      return get_table_core(catName, dbname, name, null);
-    }
-
-    @Override
-    public Table get_table_core(
-        final String catName,
-        final String dbname,
-        final String name,
-        final String writeIdList)
-        throws MetaException, NoSuchObjectException {
-      return get_table_core(catName, dbname, name, writeIdList, false, null);
-    }
-
-    /**
-     * This function retrieves table from metastore. If getColumnStats flag is true,
-     * then engine should be specified so the table is retrieve with the column stats
-     * for that engine.
-     */
-    public Table get_table_core(final String catName,
-        final String dbname,
-        final String name,
-        final String writeIdList,
-        boolean getColumnStats, String engine)
-        throws MetaException, NoSuchObjectException {
-      Preconditions.checkArgument(!getColumnStats || engine != null,
-          "To retrieve column statistics with a table, engine parameter cannot be null");
-
-      Database db = null;
-      Table t = null;
-      try {
-        db = get_database_core(catName, dbname);
-      } catch (Exception e) { /* appears exception is not thrown currently if db doesnt exist */ }
-
-      if (db != null) {
-        if (db.getType().equals(DatabaseType.REMOTE)) {
-          t = DataConnectorProviderFactory.getDataConnectorProvider(db).getTable(name);
-          if (t == null) {
-            throw new NoSuchObjectException(TableName.getQualified(catName, dbname, name) +
-              " table not found");
-          }
-          t.setDbName(dbname);
-          return t;
-        }
-      }
-
-      try {
-        t = getMS().getTable(catName, dbname, name, writeIdList);
-        if (t == null) {
-          throw new NoSuchObjectException(TableName.getQualified(catName, dbname, name) +
-            " table not found");
-        }
-
-        // If column statistics was requested and is valid fetch it.
-        if (getColumnStats) {
-          ColumnStatistics colStats = getMS().getTableColumnStatistics(catName, dbname, name,
-                  StatsSetupConst.getColumnsHavingStats(t.getParameters()), engine, writeIdList);
-          if (colStats != null) {
-            t.setColStats(colStats);
-          }
-        }
-      } catch (Exception e) {
-        throwMetaException(e);
-      }
-      return t;
-    }
-
-    /**
-     * Gets multiple tables from the hive metastore.
-     *
-     * @param dbName
-     *          The name of the database in which the tables reside
-     * @param tableNames
-     *          The names of the tables to get.
-     *
-     * @return A list of tables whose names are in the the list "names" and
-     *         are retrievable from the database specified by "dbnames."
-     *         There is no guarantee of the order of the returned tables.
-     *         If there are duplicate names, only one instance of the table will be returned.
-     * @throws MetaException
-     * @throws InvalidOperationException
-     * @throws UnknownDBException
-     */
-    @Override
-    @Deprecated
-    public List<Table> get_table_objects_by_name(final String dbName, final List<String> tableNames)
-        throws MetaException, InvalidOperationException, UnknownDBException {
-      String[] parsedDbName = parseDbName(dbName, conf);
-      return getTableObjectsInternal(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableNames, null);
-    }
-
-    @Override
-    public GetTablesResult get_table_objects_by_name_req(GetTablesRequest req) throws TException {
-      String catName = req.isSetCatName() ? req.getCatName() : getDefaultCatalog(conf);
-      return new GetTablesResult(getTableObjectsInternal(catName, req.getDbName(),
-          req.getTblNames(), req.getCapabilities()));
-    }
-
-    private List<Table> getTableObjectsInternal(String catName, String dbName,
-                                                List<String> tableNames,
-                                                ClientCapabilities capabilities)
-            throws MetaException, InvalidOperationException, UnknownDBException {
-      if (isInTest) {
-        assertClientHasCapability(capabilities, ClientCapability.TEST_CAPABILITY,
-            "Hive tests", "get_table_objects_by_name_req");
-      }
-      List<Table> tables = new ArrayList<>();
-      startMultiTableFunction("get_multi_table", dbName, tableNames);
-      Exception ex = null;
-      int tableBatchSize = MetastoreConf.getIntVar(conf,
-          ConfVars.BATCH_RETRIEVE_MAX);
-
-      try {
-        if (dbName == null || dbName.isEmpty()) {
-          throw new UnknownDBException("DB name is null or empty");
-        }
-        if (tableNames == null) {
-          throw new InvalidOperationException(dbName + " cannot find null tables");
-        }
-
-        // The list of table names could contain duplicates. RawStore.getTableObjectsByName()
-        // only guarantees returning no duplicate table objects in one batch. If we need
-        // to break into multiple batches, remove duplicates first.
-        List<String> distinctTableNames = tableNames;
-        if (distinctTableNames.size() > tableBatchSize) {
-          List<String> lowercaseTableNames = new ArrayList<>();
-          for (String tableName : tableNames) {
-            lowercaseTableNames.add(org.apache.hadoop.hive.metastore.utils.StringUtils.normalizeIdentifier(tableName));
-          }
-          distinctTableNames = new ArrayList<>(new HashSet<>(lowercaseTableNames));
-        }
-
-        RawStore ms = getMS();
-        int startIndex = 0;
-        // Retrieve the tables from the metastore in batches. Some databases like
-        // Oracle cannot have over 1000 expressions in a in-list
-        while (startIndex < distinctTableNames.size()) {
-          int endIndex = Math.min(startIndex + tableBatchSize, distinctTableNames.size());
-          tables.addAll(ms.getTableObjectsByName(catName, dbName, distinctTableNames.subList(
-              startIndex, endIndex)));
-          startIndex = endIndex;
-        }
-        for (Table t : tables) {
-          if (MetaStoreUtils.isInsertOnlyTableParam(t.getParameters())) {
-            assertClientHasCapability(capabilities, ClientCapability.INSERT_ONLY_TABLES,
-                "insert-only tables", "get_table_req");
-          }
-        }
-
-        FilterUtils.filterTablesIfEnabled(isServerFilterEnabled, filterHook, tables);
-      } catch (MetaException | InvalidOperationException | UnknownDBException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_multi_table", tables != null, ex, join(tableNames, ","));
-      }
-      return tables;
-    }
-
-    @Override
-    public Materialization get_materialization_invalidation_info(final CreationMetadata cm, final String validTxnList) throws MetaException {
-      return getTxnHandler().getMaterializationInvalidationInfo(cm, validTxnList);
-    }
-
-    @Override
-    public void update_creation_metadata(String catName, final String dbName, final String tableName, CreationMetadata cm) throws MetaException {
-      getMS().updateCreationMetadata(catName, dbName, tableName, cm);
-    }
-
-    private void assertClientHasCapability(ClientCapabilities client,
-        ClientCapability value, String what, String call) throws MetaException {
-      if (!doesClientHaveCapability(client, value)) {
-        throw new MetaException("Your client does not appear to support " + what + ". To skip"
-            + " capability checks, please set " + ConfVars.CAPABILITY_CHECK.toString()
-            + " to false. This setting can be set globally, or on the client for the current"
-            + " metastore session. Note that this may lead to incorrect results, data loss,"
-            + " undefined behavior, etc. if your client is actually incompatible. You can also"
-            + " specify custom client capabilities via " + call + " API.");
-      }
-    }
-
-    private boolean doesClientHaveCapability(ClientCapabilities client, ClientCapability value) {
-      if (!MetastoreConf.getBoolVar(getConf(), ConfVars.CAPABILITY_CHECK)) {
-        return true;
-      }
-      return (client != null && client.isSetValues() && client.getValues().contains(value));
-    }
-
-    @Override
-    public List<String> get_table_names_by_filter(
-        final String dbName, final String filter, final short maxTables)
-        throws MetaException, InvalidOperationException, UnknownDBException {
-      List<String> tables = null;
-      startFunction("get_table_names_by_filter", ": db = " + dbName + ", filter = " + filter);
-      Exception ex = null;
-      String[] parsedDbName = parseDbName(dbName, conf);
-      try {
-        if (parsedDbName[CAT_NAME] == null || parsedDbName[CAT_NAME].isEmpty() ||
-            parsedDbName[DB_NAME] == null || parsedDbName[DB_NAME].isEmpty()) {
-          throw new UnknownDBException("DB name is null or empty");
-        }
-        if (filter == null) {
-          throw new InvalidOperationException(filter + " cannot apply null filter");
-        }
-        tables = getMS().listTableNamesByFilter(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], filter, maxTables);
-        tables = FilterUtils.filterTableNamesIfEnabled(
-            isServerFilterEnabled, filterHook, parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tables);
-
-      } catch (MetaException | InvalidOperationException | UnknownDBException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_table_names_by_filter", tables != null, ex, join(tables, ","));
-      }
-      return tables;
-    }
-
-    private Partition append_partition_common(RawStore ms, String catName, String dbName,
-                                              String tableName, List<String> part_vals,
-                                              EnvironmentContext envContext)
-            throws InvalidObjectException, AlreadyExistsException, MetaException, NoSuchObjectException {
-
-      Partition part = new Partition();
-      boolean success = false, madeDir = false;
-      Path partLocation = null;
-      Table tbl = null;
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-      Database db = null;
-      try {
-        ms.openTransaction();
-        part.setCatName(catName);
-        part.setDbName(dbName);
-        part.setTableName(tableName);
-        part.setValues(part_vals);
-
-        MetaStoreServerUtils.validatePartitionNameCharacters(part_vals, partitionValidationPattern);
-
-        tbl = ms.getTable(part.getCatName(), part.getDbName(), part.getTableName(), null);
-        if (tbl == null) {
-          throw new InvalidObjectException(
-              "Unable to add partition because table or database do not exist");
-        }
-        if (tbl.getSd().getLocation() == null) {
-          throw new MetaException(
-              "Cannot append a partition to a view");
-        }
-
-        db = get_database_core(catName, dbName);
-
-        firePreEvent(new PreAddPartitionEvent(tbl, part, this));
-
-        part.setSd(tbl.getSd().deepCopy());
-        partLocation = new Path(tbl.getSd().getLocation(), Warehouse
-            .makePartName(tbl.getPartitionKeys(), part_vals));
-        part.getSd().setLocation(partLocation.toString());
-
-        Partition old_part;
-        try {
-          old_part = ms.getPartition(part.getCatName(), part.getDbName(), part
-              .getTableName(), part.getValues());
-        } catch (NoSuchObjectException e) {
-          // this means there is no existing partition
-          old_part = null;
-        }
-        if (old_part != null) {
-          throw new AlreadyExistsException("Partition already exists:" + part);
-        }
-
-        if (!wh.isDir(partLocation)) {
-          if (!wh.mkdirs(partLocation)) {
-            throw new MetaException(partLocation
-                + " is not a directory or unable to create one");
-          }
-          madeDir = true;
-        }
-
-        // set create time
-        long time = System.currentTimeMillis() / 1000;
-        part.setCreateTime((int) time);
-        part.putToParameters(hive_metastoreConstants.DDL_TIME, Long.toString(time));
-
-        if (canUpdateStats(tbl)) {
-          MetaStoreServerUtils.updatePartitionStatsFast(part, tbl, wh, madeDir, false, envContext, true);
-        }
-
-        if (ms.addPartition(part)) {
-          if (!transactionalListeners.isEmpty()) {
-            transactionalListenerResponses =
-                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                      EventType.ADD_PARTITION,
-                                                      new AddPartitionEvent(tbl, part, true, this),
-                                                      envContext);
-          }
-
-          success = ms.commitTransaction();
-        }
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-          if (madeDir) {
-            wh.deleteDir(partLocation, true, false, ReplChangeManager.shouldEnableCm(db, tbl));
-          }
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.ADD_PARTITION,
-                                                new AddPartitionEvent(tbl, part, success, this),
-                                                envContext,
-                                                transactionalListenerResponses, ms);
-        }
-      }
-      return part;
-    }
-
-    private void firePreEvent(PreEventContext event) throws MetaException {
-      for (MetaStorePreEventListener listener : preListeners) {
-        try {
-          listener.onEvent(event);
-        } catch (NoSuchObjectException e) {
-          throw new MetaException(e.getMessage());
-        } catch (InvalidOperationException e) {
-          throw new MetaException(e.getMessage());
-        }
-      }
-    }
-
-    @Override
-    public Partition append_partition(final String dbName, final String tableName,
-        final List<String> part_vals) throws InvalidObjectException,
-        AlreadyExistsException, MetaException {
-      return append_partition_with_environment_context(dbName, tableName, part_vals, null);
-    }
-
-    @Override
-    public Partition append_partition_with_environment_context(final String dbName,
-        final String tableName, final List<String> part_vals, final EnvironmentContext envContext)
-        throws InvalidObjectException, AlreadyExistsException, MetaException {
-      if (part_vals == null || part_vals.isEmpty()) {
-        throw new MetaException("The partition values must not be null or empty.");
-      }
-      String[] parsedDbName = parseDbName(dbName, conf);
-      startPartitionFunction("append_partition", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName, part_vals);
-      if (LOG.isDebugEnabled()) {
-        for (String part : part_vals) {
-          LOG.debug(part);
-        }
-      }
-
-      Partition ret = null;
-      Exception ex = null;
-      try {
-        ret = append_partition_common(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName, part_vals, envContext);
-      } catch (MetaException | InvalidObjectException | AlreadyExistsException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("append_partition", ret != null, ex, tableName);
-      }
-      return ret;
-    }
-
-    private static class PartValEqWrapperLite {
-      List<String> values;
-      String location;
-
-      PartValEqWrapperLite(Partition partition) {
-        this.values = partition.isSetValues()? partition.getValues() : null;
-        if (partition.getSd() != null) {
-          this.location = partition.getSd().getLocation();
-        }
-      }
-
-      @Override
-      public int hashCode() {
-        return values == null ? 0 : values.hashCode();
-      }
-
-      @Override
-      public boolean equals(Object obj) {
-        if (this == obj) {
-          return true;
-        }
-        if (obj == null || !(obj instanceof PartValEqWrapperLite)) {
-          return false;
-        }
-
-        List<String> lhsValues = this.values;
-        List<String> rhsValues = ((PartValEqWrapperLite)obj).values;
-
-        if (lhsValues == null || rhsValues == null) {
-          return lhsValues == rhsValues;
-        }
-
-        if (lhsValues.size() != rhsValues.size()) {
-          return false;
-        }
-
-        for (int i=0; i<lhsValues.size(); ++i) {
-          String lhsValue = lhsValues.get(i);
-          String rhsValue = rhsValues.get(i);
-
-          if ((lhsValue == null && rhsValue != null)
-              || (lhsValue != null && !lhsValue.equals(rhsValue))) {
-            return false;
-          }
-        }
-
-        return true;
-      }
-    }
-
-    private List<Partition> add_partitions_core(final RawStore ms, String catName,
-        String dbName, String tblName, List<Partition> parts, final boolean ifNotExists)
-        throws TException {
-      logAndAudit("add_partitions");
-      boolean success = false;
-      // Ensures that the list doesn't have dups, and keeps track of directories we have created.
-      final Map<PartValEqWrapperLite, Boolean> addedPartitions = new ConcurrentHashMap<>();
-      final List<Partition> newParts = new ArrayList<>();
-      final List<Partition> existingParts = new ArrayList<>();
-      Table tbl = null;
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-      Database db = null;
-
-      List<ColumnStatistics> partsColStats = new ArrayList<>(parts.size());
-      List<Long> partsWriteIds = new ArrayList<>(parts.size());
-
-      throwUnsupportedExceptionIfRemoteDB(dbName, "add_partitions");
-
-      try {
-        ms.openTransaction();
-        tbl = ms.getTable(catName, dbName, tblName, null);
-        if (tbl == null) {
-          throw new InvalidObjectException("Unable to add partitions because "
-              + TableName.getQualified(catName, dbName, tblName) +
-              " does not exist");
-        }
-
-        db = ms.getDatabase(catName, dbName);
-
-        if (!parts.isEmpty()) {
-          firePreEvent(new PreAddPartitionEvent(tbl, parts, this));
-        }
-
-        Set<PartValEqWrapperLite> partsToAdd = new HashSet<>(parts.size());
-        List<Partition> partitionsToAdd = new ArrayList<>(parts.size());
-        List<FieldSchema> partitionKeys = tbl.getPartitionKeys();
-        for (final Partition part : parts) {
-          // Collect partition column stats to be updated if present. Partition objects passed down
-          // here at the time of replication may have statistics in them, which is required to be
-          // updated in the metadata. But we don't want it to be part of the Partition object when
-          // it's being created or altered, lest it becomes part of the notification event.
-          if (part.isSetColStats()) {
-            partsColStats.add(part.getColStats());
-            part.unsetColStats();
-            partsWriteIds.add(part.getWriteId());
-          }
-
-          // Iterate through the partitions and validate them. If one of the partitions is
-          // incorrect, an exception will be thrown before the threads which create the partition
-          // folders are submitted. This way we can be sure that no partition and no partition
-          // folder will be created if the list contains an invalid partition.
-          if (validatePartition(part, catName, tblName, dbName, partsToAdd, ms, ifNotExists,
-              partitionKeys)) {
-            partitionsToAdd.add(part);
-          } else {
-            existingParts.add(part);
-          }
-        }
-
-        newParts.addAll(createPartitionFolders(partitionsToAdd, tbl, addedPartitions));
-
-        if (!newParts.isEmpty()) {
-          ms.addPartitions(catName, dbName, tblName, newParts);
-        }
-
-        // Notification is generated for newly created partitions only. The subset of partitions
-        // that already exist (existingParts), will not generate notifications.
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenerResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                    EventType.ADD_PARTITION,
-                                                    new AddPartitionEvent(tbl, newParts, true, this));
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                  EventType.ADD_PARTITION,
-                  new AddPartitionEvent(tbl, newParts, true, this),
-                  null,
-                  transactionalListenerResponses, ms);
-
-          if (!existingParts.isEmpty()) {
-            // The request has succeeded but we failed to add these partitions.
-            MetaStoreListenerNotifier.notifyEvent(listeners,
-                    EventType.ADD_PARTITION,
-                    new AddPartitionEvent(tbl, existingParts, false, this),
-                    null, null, ms);
-          }
-        }
-
-        // Update partition column statistics if available. We need a valid writeId list to
-        // update column statistics for a transactional table. But during bootstrap replication,
-        // where we use this feature, we do not have a valid writeId list which was used to
-        // update the stats. But we know for sure that the writeId associated with the stats was
-        // valid then (otherwise stats update would have failed on the source). So, craft a valid
-        // transaction list with only that writeId and use it to update the stats.
-        int cnt = 0;
-        for (ColumnStatistics partColStats: partsColStats) {
-          long writeId = partsWriteIds.get(cnt++);
-          String validWriteIds = null;
-          if (writeId > 0) {
-            ValidWriteIdList validWriteIdList =
-                    new ValidReaderWriteIdList(TableName.getDbTable(tbl.getDbName(),
-                            tbl.getTableName()),
-                            new long[0], new BitSet(), writeId);
-            validWriteIds = validWriteIdList.toString();
-          }
-          updatePartitonColStatsInternal(tbl, partColStats, validWriteIds, writeId);
-        }
-
-        success = ms.commitTransaction();
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-          cleanupPartitionFolders(addedPartitions, db);
-
-          if (!listeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                  EventType.ADD_PARTITION,
-                                                  new AddPartitionEvent(tbl, parts, false, this),
-                                                  null, null, ms);
-          }
-        }
-      }
-
-      return newParts;
-    }
-
-    /**
-     * Remove the newly created partition folders. The values in the addedPartitions map indicates
-     * whether or not the location of the partition was newly created. If the value is false, the
-     * partition folder will not be removed.
-     * @param addedPartitions
-     * @throws MetaException
-     * @throws IllegalArgumentException
-     */
-    private void cleanupPartitionFolders(final Map<PartValEqWrapperLite, Boolean> addedPartitions,
-        Database db) throws MetaException, IllegalArgumentException {
-      for (Map.Entry<PartValEqWrapperLite, Boolean> e : addedPartitions.entrySet()) {
-        if (e.getValue()) {
-          // we just created this directory - it's not a case of pre-creation, so we nuke.
-          wh.deleteDir(new Path(e.getKey().location), true, db);
-        }
-      }
-    }
-
-    /**
-     * Validate a partition before creating it. The validation checks
-     * <ul>
-     * <li>if the database and table names set in the partition are not null and they are matching
-     * with the expected values set in the tblName and dbName parameters.</li>
-     * <li>if the partition values are set.</li>
-     * <li>if none of the partition values is null.</li>
-     * <li>if the partition values are matching with the pattern set in the
-     * 'metastore.partition.name.whitelist.pattern' configuration property.</li>
-     * <li>if the partition doesn't already exist. If the partition already exists, an exception
-     * will be thrown if the ifNotExists parameter is false, otherwise it will be just ignored.</li>
-     * <li>if the partsToAdd set doesn't contain the partition. The partsToAdd set contains the
-     * partitions which are already validated. If the set contains the current partition, it means
-     * that the partition is tried to be added multiple times in the same batch. Please note that
-     * the set will be updated with the current partition if the validation was successful.</li>
-     * </ul>
-     * @param part
-     * @param catName
-     * @param tblName
-     * @param dbName
-     * @param partsToAdd
-     * @param ms
-     * @param ifNotExists
-     * @return
-     * @throws MetaException
-     * @throws TException
-     */
-    private boolean validatePartition(final Partition part, final String catName,
-        final String tblName, final String dbName, final Set<PartValEqWrapperLite> partsToAdd,
-        final RawStore ms, final boolean ifNotExists, List<FieldSchema> partitionKeys) throws MetaException, TException {
-
-      if (part.getDbName() == null || part.getTableName() == null) {
-        throw new MetaException("The database and table name must be set in the partition.");
-      }
-
-      if (!part.getTableName().equalsIgnoreCase(tblName)
-          || !part.getDbName().equalsIgnoreCase(dbName)) {
-        String errorMsg = String.format(
-            "Partition does not belong to target table %s. It belongs to the table %s.%s : %s",
-            TableName.getQualified(catName, dbName, tblName), part.getDbName(),
-            part.getTableName(), part.toString());
-        throw new MetaException(errorMsg);
-      }
-
-      if (part.getValues() == null || part.getValues().isEmpty()) {
-        throw new MetaException("The partition values cannot be null or empty.");
-      }
-
-      if (part.getValues().contains(null)) {
-        throw new MetaException("Partition value cannot be null.");
-      }
-
-      boolean shouldAdd = startAddPartition(ms, part, partitionKeys, ifNotExists);
-      if (!shouldAdd) {
-        LOG.info("Not adding partition {} as it already exists", part);
-        return false;
-      }
-
-      if (!partsToAdd.add(new PartValEqWrapperLite(part))) {
-        // Technically, for ifNotExists case, we could insert one and discard the other
-        // because the first one now "exists", but it seems better to report the problem
-        // upstream as such a command doesn't make sense.
-        throw new MetaException("Duplicate partitions in the list: " + part);
-      }
-      return true;
-    }
-
-    /**
-     * Create the location folders for the partitions. For each partition a separate thread will be
-     * started to create the folder. The method will wait until all threads are finished and returns
-     * the partitions whose folders were created successfully. If an error occurs during the
-     * execution of a thread, a MetaException will be thrown.
-     * @param partitionsToAdd
-     * @param table
-     * @param addedPartitions
-     * @return
-     * @throws MetaException
-     */
-    private List<Partition> createPartitionFolders(final List<Partition> partitionsToAdd,
-        final Table table, final Map<PartValEqWrapperLite, Boolean> addedPartitions)
-        throws MetaException {
-
-      final AtomicBoolean failureOccurred = new AtomicBoolean(false);
-      final List<Future<Partition>> partFutures = new ArrayList<>(partitionsToAdd.size());
-      final Map<PartValEqWrapperLite, Boolean> addedParts = new ConcurrentHashMap<>();
-
-      final UserGroupInformation ugi;
-      try {
-        ugi = UserGroupInformation.getCurrentUser();
-      } catch (IOException e) {
-        throw new RuntimeException(e);
-      }
-
-      for (final Partition partition : partitionsToAdd) {
-        initializePartitionParameters(table, partition);
-
-        partFutures.add(threadPool.submit(() -> {
-          if (failureOccurred.get()) {
-            return null;
-          }
-          ugi.doAs((PrivilegedExceptionAction<Partition>) () -> {
-            try {
-              boolean madeDir = createLocationForAddedPartition(table, partition);
-              addedParts.put(new PartValEqWrapperLite(partition), madeDir);
-              initializeAddedPartition(table, partition, madeDir, null);
-            } catch (MetaException e) {
-              throw new IOException(e.getMessage(), e);
-            }
-            return null;
-          });
-          return partition;
-        }));
-      }
-
-      List<Partition> newParts = new ArrayList<>(partitionsToAdd.size());
-      String errorMessage = null;
-      for (Future<Partition> partFuture : partFutures) {
-        try {
-          Partition part = partFuture.get();
-          if (part != null && !failureOccurred.get()) {
-            newParts.add(part);
-          }
-        } catch (ExecutionException e) {
-          // If an exception is thrown in the execution of a task, set the failureOccurred flag to
-          // true. This flag is visible in the tasks and if its value is true, the partition
-          // folders won't be created.
-          // Then iterate through the remaining tasks and wait for them to finish. The tasks which
-          // are started before the flag got set will then finish creating the partition folders.
-          // The tasks which are started after the flag got set, won't create the partition
-          // folders, to avoid unnecessary work.
-          // This way it is sure that all tasks are finished, when entering the finally part where
-          // the partition folders are cleaned up. It won't happen that a task is still running
-          // when cleaning up the folders, so it is sure we won't have leftover folders.
-          // Canceling the other tasks would be also an option but during testing it turned out
-          // that it is not a trustworthy solution to avoid leftover folders.
-          failureOccurred.compareAndSet(false, true);
-          errorMessage = e.getMessage();
-        } catch (InterruptedException e) {
-          failureOccurred.compareAndSet(false, true);
-          errorMessage = e.getMessage();
-          // Restore interruption status of the corresponding thread
-          Thread.currentThread().interrupt();
-        }
-      }
-
-      addedPartitions.putAll(addedParts);
-      if (failureOccurred.get()) {
-        throw new MetaException(errorMessage);
-      }
-
-      return newParts;
-    }
-
-    @Override
-    public AddPartitionsResult add_partitions_req(AddPartitionsRequest request)
-        throws TException {
-      AddPartitionsResult result = new AddPartitionsResult();
-      if (request.getParts().isEmpty()) {
-        return result;
-      }
-      try {
-        if (!request.isSetCatName()) {
-          request.setCatName(getDefaultCatalog(conf));
-        }
-        // Make sure all of the partitions have the catalog set as well
-        request.getParts().forEach(p -> {
-          if (!p.isSetCatName()) {
-            p.setCatName(getDefaultCatalog(conf));
-          }
-        });
-        List<Partition> parts = add_partitions_core(getMS(), request.getCatName(), request.getDbName(),
-            request.getTblName(), request.getParts(), request.isIfNotExists());
-        if (request.isNeedResult()) {
-          result.setPartitions(parts);
-        }
-      } catch (TException te) {
-        throw te;
-      } catch (Exception e) {
-        throw newMetaException(e);
-      }
-      return result;
-    }
-
-    @Override
-    public int add_partitions(final List<Partition> parts) throws MetaException,
-        InvalidObjectException, AlreadyExistsException {
-      startFunction("add_partition");
-      if (parts == null) {
-        throw new MetaException("Partition list cannot be null.");
-      }
-      if (parts.isEmpty()) {
-        return 0;
-      }
-
-      Integer ret = null;
-      Exception ex = null;
-      try {
-        // Old API assumed all partitions belong to the same table; keep the same assumption
-        if (!parts.get(0).isSetCatName()) {
-          String defaultCat = getDefaultCatalog(conf);
-          for (Partition p : parts) {
-            p.setCatName(defaultCat);
-          }
-        }
-        ret = add_partitions_core(getMS(), parts.get(0).getCatName(), parts.get(0).getDbName(),
-            parts.get(0).getTableName(), parts, false).size();
-        assert ret == parts.size();
-      } catch (MetaException | InvalidObjectException | AlreadyExistsException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        String tableName = parts.get(0).getTableName();
-        endFunction("add_partition", ret != null, ex, tableName);
-      }
-      return ret;
-    }
-
-    @Override
-    public int add_partitions_pspec(final List<PartitionSpec> partSpecs)
-        throws TException {
-      logAndAudit("add_partitions_pspec");
-
-      if (partSpecs.isEmpty()) {
-        return 0;
-      }
-
-      String dbName = partSpecs.get(0).getDbName();
-      String tableName = partSpecs.get(0).getTableName();
-      // If the catalog name isn't set, we need to go through and set it.
-      String catName;
-      if (!partSpecs.get(0).isSetCatName()) {
-        catName = getDefaultCatalog(conf);
-        partSpecs.forEach(ps -> ps.setCatName(catName));
-      } else {
-        catName = partSpecs.get(0).getCatName();
-      }
-
-      return add_partitions_pspec_core(getMS(), catName, dbName, tableName, partSpecs, false);
-    }
-
-    private int add_partitions_pspec_core(RawStore ms, String catName, String dbName,
-                                          String tblName, List<PartitionSpec> partSpecs,
-                                          boolean ifNotExists)
-        throws TException {
-      boolean success = false;
-      if (dbName == null || tblName == null) {
-        throw new MetaException("The database and table name cannot be null.");
-      }
-      // Ensures that the list doesn't have dups, and keeps track of directories we have created.
-      final Map<PartValEqWrapperLite, Boolean> addedPartitions = new ConcurrentHashMap<>();
-      PartitionSpecProxy partitionSpecProxy = PartitionSpecProxy.Factory.get(partSpecs);
-      final PartitionSpecProxy.PartitionIterator partitionIterator = partitionSpecProxy
-          .getPartitionIterator();
-      Table tbl = null;
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-      Database db = null;
-      try {
-        ms.openTransaction();
-        try {
-          db = ms.getDatabase(catName, dbName);
-        } catch (NoSuchObjectException notExists) {
-          throw new InvalidObjectException("Unable to add partitions because "
-              + "database or table " + dbName + "." + tblName + " does not exist");
-        }
-        if (db.getType() == DatabaseType.REMOTE)
-          throw new MetaException("Operation add_partitions_pspec not supported on tables in REMOTE database");
-        tbl = ms.getTable(catName, dbName, tblName, null);
-        if (tbl == null) {
-          throw new InvalidObjectException("Unable to add partitions because "
-              + "database or table " + dbName + "." + tblName + " does not exist");
-        }
-        firePreEvent(new PreAddPartitionEvent(tbl, partitionSpecProxy, this));
-        Set<PartValEqWrapperLite> partsToAdd = new HashSet<>(partitionSpecProxy.size());
-        List<Partition> partitionsToAdd = new ArrayList<>(partitionSpecProxy.size());
-        List<FieldSchema> partitionKeys = tbl.getPartitionKeys();
-        while (partitionIterator.hasNext()) {
-          // Iterate through the partitions and validate them. If one of the partitions is
-          // incorrect, an exception will be thrown before the threads which create the partition
-          // folders are submitted. This way we can be sure that no partition or partition folder
-          // will be created if the list contains an invalid partition.
-          final Partition part = partitionIterator.getCurrent();
-          if (validatePartition(part, catName, tblName, dbName, partsToAdd, ms, ifNotExists,
-              partitionKeys)) {
-            partitionsToAdd.add(part);
-          }
-          partitionIterator.next();
-        }
-
-        createPartitionFolders(partitionsToAdd, tbl, addedPartitions);
-
-        ms.addPartitions(catName, dbName, tblName, partitionSpecProxy, ifNotExists);
-
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenerResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                    EventType.ADD_PARTITION,
-                                                    new AddPartitionEvent(tbl, partitionSpecProxy, true, this));
-        }
-
-        success = ms.commitTransaction();
-        return addedPartitions.size();
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-          cleanupPartitionFolders(addedPartitions, db);
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.ADD_PARTITION,
-                                                new AddPartitionEvent(tbl, partitionSpecProxy, true, this),
-                                                null,
-                                                transactionalListenerResponses, ms);
-        }
-      }
-    }
-
-    private boolean startAddPartition(
-        RawStore ms, Partition part, List<FieldSchema> partitionKeys, boolean ifNotExists)
-        throws TException {
-      MetaStoreServerUtils.validatePartitionNameCharacters(part.getValues(),
-          partitionValidationPattern);
-      boolean doesExist = ms.doesPartitionExist(part.getCatName(),
-          part.getDbName(), part.getTableName(), partitionKeys, part.getValues());
-      if (doesExist && !ifNotExists) {
-        throw new AlreadyExistsException("Partition already exists: " + part);
-      }
-      return !doesExist;
-    }
-
-    /**
-     * Handles the location for a partition being created.
-     * @param tbl Table.
-     * @param part Partition.
-     * @return Whether the partition SD location is set to a newly created directory.
-     */
-    private boolean createLocationForAddedPartition(
-        final Table tbl, final Partition part) throws MetaException {
-      Path partLocation = null;
-      String partLocationStr = null;
-      if (part.getSd() != null) {
-        partLocationStr = part.getSd().getLocation();
-      }
-
-      if (partLocationStr == null || partLocationStr.isEmpty()) {
-        // set default location if not specified and this is
-        // a physical table partition (not a view)
-        if (tbl.getSd().getLocation() != null) {
-          partLocation = new Path(tbl.getSd().getLocation(), Warehouse
-              .makePartName(tbl.getPartitionKeys(), part.getValues()));
-        }
-      } else {
-        if (tbl.getSd().getLocation() == null) {
-          throw new MetaException("Cannot specify location for a view partition");
-        }
-        partLocation = wh.getDnsPath(new Path(partLocationStr));
-      }
-
-      boolean result = false;
-      if (partLocation != null) {
-        part.getSd().setLocation(partLocation.toString());
-
-        // Check to see if the directory already exists before calling
-        // mkdirs() because if the file system is read-only, mkdirs will
-        // throw an exception even if the directory already exists.
-        if (!wh.isDir(partLocation)) {
-          if (!wh.mkdirs(partLocation)) {
-            throw new MetaException(partLocation
-                + " is not a directory or unable to create one");
-          }
-          result = true;
-        }
-      }
-      return result;
-    }
-
-    /**
-     * Verify if update stats while altering partition(s)
-     * For the following three cases HMS will not update partition stats
-     * 1) Table property 'DO_NOT_UPDATE_STATS' = True
-     * 2) HMS configuration property 'STATS_AUTO_GATHER' = False
-     * 3) Is View
-     */
-    private boolean canUpdateStats(Table tbl) {
-        Map<String,String> tblParams = tbl.getParameters();
-        boolean updateStatsTbl = true;
-        if ((tblParams != null) && tblParams.containsKey(StatsSetupConst.DO_NOT_UPDATE_STATS)) {
-            updateStatsTbl = !Boolean.valueOf(tblParams.get(StatsSetupConst.DO_NOT_UPDATE_STATS));
-        }
-        if (!MetastoreConf.getBoolVar(conf, ConfVars.STATS_AUTO_GATHER) ||
-            MetaStoreUtils.isView(tbl) ||
-            !updateStatsTbl) {
-          return false;
-        }
-        return true;
-    }
-
-    private void initializeAddedPartition(final Table tbl, final Partition part, boolean madeDir,
-                                          EnvironmentContext environmentContext) throws MetaException {
-      initializeAddedPartition(tbl,
-              new PartitionSpecProxy.SimplePartitionWrapperIterator(part), madeDir, environmentContext);
-    }
-
-    private void initializeAddedPartition(
-        final Table tbl, final PartitionSpecProxy.PartitionIterator part, boolean madeDir,
-        EnvironmentContext environmentContext) throws MetaException {
-      if (canUpdateStats(tbl)) {
-        MetaStoreServerUtils.updatePartitionStatsFast(part, tbl, wh, madeDir,
-                false, environmentContext, true);
-      }
-
-      // set create time
-      long time = System.currentTimeMillis() / 1000;
-      part.setCreateTime((int) time);
-      if (part.getParameters() == null ||
-          part.getParameters().get(hive_metastoreConstants.DDL_TIME) == null) {
-        part.putToParameters(hive_metastoreConstants.DDL_TIME, Long.toString(time));
-      }
-    }
-
-    private void initializePartitionParameters(final Table tbl, final Partition part)
-        throws MetaException {
-      initializePartitionParameters(tbl,
-          new PartitionSpecProxy.SimplePartitionWrapperIterator(part));
-    }
-
-    private void initializePartitionParameters(final Table tbl,
-        final PartitionSpecProxy.PartitionIterator part) throws MetaException {
-
-      // Inherit table properties into partition properties.
-      Map<String, String> tblParams = tbl.getParameters();
-      String inheritProps = MetastoreConf.getVar(conf, ConfVars.PART_INHERIT_TBL_PROPS).trim();
-      // Default value is empty string in which case no properties will be inherited.
-      // * implies all properties needs to be inherited
-      Set<String> inheritKeys = new HashSet<>(Arrays.asList(inheritProps.split(",")));
-      if (inheritKeys.contains("*")) {
-        inheritKeys = tblParams.keySet();
-      }
-
-      for (String key : inheritKeys) {
-        String paramVal = tblParams.get(key);
-        if (null != paramVal) { // add the property only if it exists in table properties
-          part.putToParameters(key, paramVal);
-        }
-      }
-    }
-
-    private Partition add_partition_core(final RawStore ms,
-        final Partition part, final EnvironmentContext envContext)
-        throws TException {
-      boolean success = false;
-      Table tbl = null;
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-      if (!part.isSetCatName()) {
-        part.setCatName(getDefaultCatalog(conf));
-      }
-
-      throwUnsupportedExceptionIfRemoteDB(part.getDbName(), "add_partition");
-      try {
-        ms.openTransaction();
-        tbl = ms.getTable(part.getCatName(), part.getDbName(), part.getTableName(), null);
-        if (tbl == null) {
-          throw new InvalidObjectException(
-              "Unable to add partition because table or database do not exist");
-        }
-
-        firePreEvent(new PreAddPartitionEvent(tbl, part, this));
-
-        if (part.getValues() == null || part.getValues().isEmpty()) {
-          throw new MetaException("The partition values cannot be null or empty.");
-        }
-        boolean shouldAdd = startAddPartition(ms, part, tbl.getPartitionKeys(), false);
-        assert shouldAdd; // start would throw if it already existed here
-        boolean madeDir = createLocationForAddedPartition(tbl, part);
-        try {
-          initializeAddedPartition(tbl, part, madeDir, envContext);
-          initializePartitionParameters(tbl, part);
-          success = ms.addPartition(part);
-        } finally {
-          if (!success && madeDir) {
-            wh.deleteDir(new Path(part.getSd().getLocation()), true, false,
-                    ReplChangeManager.shouldEnableCm(ms.getDatabase(part.getCatName(), part.getDbName()), tbl));
-          }
-        }
-
-        // Setting success to false to make sure that if the listener fails, rollback happens.
-        success = false;
-
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenerResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                    EventType.ADD_PARTITION,
-                                                    new AddPartitionEvent(tbl, Arrays.asList(part), true, this),
-                                                    envContext);
-
-        }
-
-        // we proceed only if we'd actually succeeded anyway, otherwise,
-        // we'd have thrown an exception
-        success = ms.commitTransaction();
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.ADD_PARTITION,
-                                                new AddPartitionEvent(tbl, Arrays.asList(part), success, this),
-                                                envContext,
-                                                transactionalListenerResponses, ms);
-
-        }
-      }
-      return part;
-    }
-
-    @Override
-    public Partition add_partition(final Partition part)
-        throws InvalidObjectException, AlreadyExistsException, MetaException {
-      return add_partition_with_environment_context(part, null);
-    }
-
-    @Override
-    public Partition add_partition_with_environment_context(
-        final Partition part, EnvironmentContext envContext)
-        throws InvalidObjectException, AlreadyExistsException,
-        MetaException {
-      if (part == null) {
-        throw new MetaException("Partition cannot be null.");
-      }
-      startTableFunction("add_partition",
-          part.getCatName(), part.getDbName(), part.getTableName());
-      Partition ret = null;
-      Exception ex = null;
-      try {
-        ret = add_partition_core(getMS(), part, envContext);
-      } catch (MetaException | InvalidObjectException | AlreadyExistsException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("add_partition", ret != null, ex, part != null ?  part.getTableName(): null);
-      }
-      return ret;
-    }
-
-    @Override
-    public Partition exchange_partition(Map<String, String> partitionSpecs,
-        String sourceDbName, String sourceTableName, String destDbName,
-        String destTableName) throws TException {
-      exchange_partitions(partitionSpecs, sourceDbName, sourceTableName, destDbName, destTableName);
-      // Wouldn't it make more sense to return the first element of the list returned by the
-      // previous call?
-      return new Partition();
-    }
-
-    @Override
-    public List<Partition> exchange_partitions(Map<String, String> partitionSpecs,
-        String sourceDbName, String sourceTableName, String destDbName,
-        String destTableName) throws TException {
-      String[] parsedDestDbName = parseDbName(destDbName, conf);
-      String[] parsedSourceDbName = parseDbName(sourceDbName, conf);
-      // No need to check catalog for null as parseDbName() will never return null for the catalog.
-      if (partitionSpecs == null || parsedSourceDbName[DB_NAME] == null || sourceTableName == null
-          || parsedDestDbName[DB_NAME] == null || destTableName == null) {
-        throw new MetaException("The DB and table name for the source and destination tables,"
-            + " and the partition specs must not be null.");
-      }
-      if (!parsedDestDbName[CAT_NAME].equals(parsedSourceDbName[CAT_NAME])) {
-        throw new MetaException("You cannot move a partition across catalogs");
-      }
-
-      boolean success = false;
-      boolean pathCreated = false;
-      RawStore ms = getMS();
-      ms.openTransaction();
-
-      Table destinationTable =
-          ms.getTable(
-              parsedDestDbName[CAT_NAME], parsedDestDbName[DB_NAME], destTableName, null);
-      if (destinationTable == null) {
-        throw new MetaException( "The destination table " +
-            TableName.getQualified(parsedDestDbName[CAT_NAME],
-                parsedDestDbName[DB_NAME], destTableName) + " not found");
-      }
-      Table sourceTable =
-          ms.getTable(
-              parsedSourceDbName[CAT_NAME], parsedSourceDbName[DB_NAME], sourceTableName, null);
-      if (sourceTable == null) {
-        throw new MetaException("The source table " +
-            TableName.getQualified(parsedSourceDbName[CAT_NAME],
-                parsedSourceDbName[DB_NAME], sourceTableName) + " not found");
-      }
-
-      List<String> partVals = MetaStoreUtils.getPvals(sourceTable.getPartitionKeys(),
-          partitionSpecs);
-      List<String> partValsPresent = new ArrayList<> ();
-      List<FieldSchema> partitionKeysPresent = new ArrayList<> ();
-      int i = 0;
-      for (FieldSchema fs: sourceTable.getPartitionKeys()) {
-        String partVal = partVals.get(i);
-        if (partVal != null && !partVal.equals("")) {
-          partValsPresent.add(partVal);
-          partitionKeysPresent.add(fs);
-        }
-        i++;
-      }
-      // Passed the unparsed DB name here, as get_partitions_ps expects to parse it
-      List<Partition> partitionsToExchange = get_partitions_ps(sourceDbName, sourceTableName,
-          partVals, (short)-1);
-      if (partitionsToExchange == null || partitionsToExchange.isEmpty()) {
-        throw new MetaException("No partition is found with the values " + partitionSpecs
-            + " for the table " + sourceTableName);
-      }
-      boolean sameColumns = MetaStoreUtils.compareFieldColumns(
-          sourceTable.getSd().getCols(), destinationTable.getSd().getCols());
-      boolean samePartitions = MetaStoreUtils.compareFieldColumns(
-          sourceTable.getPartitionKeys(), destinationTable.getPartitionKeys());
-      if (!sameColumns || !samePartitions) {
-        throw new MetaException("The tables have different schemas." +
-            " Their partitions cannot be exchanged.");
-      }
-      Path sourcePath = new Path(sourceTable.getSd().getLocation(),
-          Warehouse.makePartName(partitionKeysPresent, partValsPresent));
-      Path destPath = new Path(destinationTable.getSd().getLocation(),
-          Warehouse.makePartName(partitionKeysPresent, partValsPresent));
-      List<Partition> destPartitions = new ArrayList<>();
-
-      Map<String, String> transactionalListenerResponsesForAddPartition = Collections.emptyMap();
-      List<Map<String, String>> transactionalListenerResponsesForDropPartition =
-          Lists.newArrayListWithCapacity(partitionsToExchange.size());
-
-      // Check if any of the partitions already exists in destTable.
-      List<String> destPartitionNames = ms.listPartitionNames(parsedDestDbName[CAT_NAME],
-          parsedDestDbName[DB_NAME], destTableName, (short) -1);
-      if (destPartitionNames != null && !destPartitionNames.isEmpty()) {
-        for (Partition partition : partitionsToExchange) {
-          String partToExchangeName =
-              Warehouse.makePartName(destinationTable.getPartitionKeys(), partition.getValues());
-          if (destPartitionNames.contains(partToExchangeName)) {
-            throw new MetaException("The partition " + partToExchangeName
-                + " already exists in the table " + destTableName);
-          }
-        }
-      }
-
-      Database srcDb = ms.getDatabase(parsedSourceDbName[CAT_NAME], parsedSourceDbName[DB_NAME]);
-      Database destDb = ms.getDatabase(parsedDestDbName[CAT_NAME], parsedDestDbName[DB_NAME]);
-      if (!isRenameAllowed(srcDb, destDb)) {
-        throw new MetaException("Exchange partition not allowed for " +
-                TableName.getQualified(parsedSourceDbName[CAT_NAME],
-                parsedSourceDbName[DB_NAME], sourceTableName) + " Dest db : " + destDbName);
-      }
-      try {
-        for (Partition partition: partitionsToExchange) {
-          Partition destPartition = new Partition(partition);
-          destPartition.setDbName(parsedDestDbName[DB_NAME]);
-          destPartition.setTableName(destinationTable.getTableName());
-          Path destPartitionPath = new Path(destinationTable.getSd().getLocation(),
-              Warehouse.makePartName(destinationTable.getPartitionKeys(), partition.getValues()));
-          destPartition.getSd().setLocation(destPartitionPath.toString());
-          ms.addPartition(destPartition);
-          destPartitions.add(destPartition);
-          ms.dropPartition(parsedSourceDbName[CAT_NAME], partition.getDbName(), sourceTable.getTableName(),
-            partition.getValues());
-        }
-        Path destParentPath = destPath.getParent();
-        if (!wh.isDir(destParentPath)) {
-          if (!wh.mkdirs(destParentPath)) {
-              throw new MetaException("Unable to create path " + destParentPath);
-          }
-        }
-        /*
-         * TODO: Use the hard link feature of hdfs
-         * once https://issues.apache.org/jira/browse/HDFS-3370 is done
-         */
-        pathCreated = wh.renameDir(sourcePath, destPath, false);
-
-        // Setting success to false to make sure that if the listener fails, rollback happens.
-        success = false;
-
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenerResponsesForAddPartition =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                    EventType.ADD_PARTITION,
-                                                    new AddPartitionEvent(destinationTable, destPartitions, true, this));
-
-          for (Partition partition : partitionsToExchange) {
-            DropPartitionEvent dropPartitionEvent =
-                new DropPartitionEvent(sourceTable, partition, true, true, this);
-            transactionalListenerResponsesForDropPartition.add(
-                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                      EventType.DROP_PARTITION,
-                                                      dropPartitionEvent));
-          }
-        }
-
-        success = ms.commitTransaction();
-        return destPartitions;
-      } finally {
-        if (!success || !pathCreated) {
-          ms.rollbackTransaction();
-          if (pathCreated) {
-            wh.renameDir(destPath, sourcePath, false);
-          }
-        }
-
-        if (!listeners.isEmpty()) {
-          AddPartitionEvent addPartitionEvent = new AddPartitionEvent(destinationTable, destPartitions, success, this);
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.ADD_PARTITION,
-                                                addPartitionEvent,
-                                                null,
-                                                transactionalListenerResponsesForAddPartition, ms);
-
-          i = 0;
-          for (Partition partition : partitionsToExchange) {
-            DropPartitionEvent dropPartitionEvent =
-                new DropPartitionEvent(sourceTable, partition, success, true, this);
-            Map<String, String> parameters =
-                (transactionalListenerResponsesForDropPartition.size() > i)
-                    ? transactionalListenerResponsesForDropPartition.get(i)
-                    : null;
-
-            MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                  EventType.DROP_PARTITION,
-                                                  dropPartitionEvent,
-                                                  null,
-                                                  parameters, ms);
-            i++;
-          }
-        }
-      }
-    }
-
-    private boolean drop_partition_common(RawStore ms, String catName, String db_name,
-                                          String tbl_name, List<String> part_vals,
-                                          final boolean deleteData, final EnvironmentContext envContext)
-        throws MetaException, NoSuchObjectException, IOException, InvalidObjectException,
-      InvalidInputException {
-      boolean success = false;
-      Path partPath = null;
-      Table tbl = null;
-      Partition part = null;
-      boolean isArchived = false;
-      Path archiveParentDir = null;
-      boolean mustPurge = false;
-      boolean tableDataShouldBeDeleted = false;
-      boolean needsCm = false;
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-
-      if (db_name == null) {
-        throw new MetaException("The DB name cannot be null.");
-      }
-      if (tbl_name == null) {
-        throw new MetaException("The table name cannot be null.");
-      }
-      if (part_vals == null) {
-        throw new MetaException("The partition values cannot be null.");
-      }
-
-      try {
-        ms.openTransaction();
-        part = ms.getPartition(catName, db_name, tbl_name, part_vals);
-        tbl = get_table_core(catName, db_name, tbl_name, null);
-        tableDataShouldBeDeleted = checkTableDataShouldBeDeleted(tbl, deleteData);
-        firePreEvent(new PreDropPartitionEvent(tbl, part, deleteData, this));
-        mustPurge = isMustPurge(envContext, tbl);
-
-        if (part == null) {
-          throw new NoSuchObjectException("Partition doesn't exist. "
-              + part_vals);
-        }
-
-        isArchived = MetaStoreUtils.isArchived(part);
-        if (isArchived) {
-          archiveParentDir = MetaStoreUtils.getOriginalLocation(part);
-          verifyIsWritablePath(archiveParentDir);
-        }
-
-        if ((part.getSd() != null) && (part.getSd().getLocation() != null)) {
-          partPath = new Path(part.getSd().getLocation());
-          verifyIsWritablePath(partPath);
-        }
-
-        if (!ms.dropPartition(catName, db_name, tbl_name, part_vals)) {
-          throw new MetaException("Unable to drop partition");
-        } else {
-          if (!transactionalListeners.isEmpty()) {
-
-            transactionalListenerResponses =
-                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                      EventType.DROP_PARTITION,
-                                                      new DropPartitionEvent(tbl, part, true, deleteData, this),
-                                                      envContext);
-          }
-          needsCm = ReplChangeManager.shouldEnableCm(ms.getDatabase(catName, db_name), tbl);
-          success = ms.commitTransaction();
-        }
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else if (deleteData && ((partPath != null) || (archiveParentDir != null))) {
-          if (tableDataShouldBeDeleted) {
-            if (mustPurge) {
-              LOG.info("dropPartition() will purge " + partPath + " directly, skipping trash.");
-            }
-            else {
-              LOG.info("dropPartition() will move " + partPath + " to trash-directory.");
-            }
-            // Archived partitions have har:/to_har_file as their location.
-            // The original directory was saved in params
-
-            if (isArchived) {
-              assert (archiveParentDir != null);
-              wh.deleteDir(archiveParentDir, true, mustPurge, needsCm);
-            } else {
-              assert (partPath != null);
-              wh.deleteDir(partPath, true, mustPurge, needsCm);
-              deleteParentRecursive(partPath.getParent(), part_vals.size() - 1, mustPurge, needsCm);
-            }
-            // ok even if the data is not deleted
-          }
-        }
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.DROP_PARTITION,
-                                                new DropPartitionEvent(tbl, part, success, deleteData, this),
-                                                envContext,
-                                                transactionalListenerResponses, ms);
-        }
-      }
-      return true;
-    }
-
-    private static boolean isMustPurge(EnvironmentContext envContext, Table tbl) {
-      // Data needs deletion. Check if trash may be skipped.
-      // Trash may be skipped iff:
-      //  1. deleteData == true, obviously.
-      //  2. tbl is external.
-      //  3. Either
-      //    3.1. User has specified PURGE from the commandline, and if not,
-      //    3.2. User has set the table to auto-purge.
-      return ((envContext != null) && Boolean.parseBoolean(envContext.getProperties().get("ifPurge")))
-          || MetaStoreUtils.isSkipTrash(tbl.getParameters());
-    }
-
-    private void throwUnsupportedExceptionIfRemoteDB(String dbName, String operationName) throws MetaException {
-      if (isDatabaseRemote(dbName)) {
-        throw new MetaException("Operation " + operationName + " not supported for REMOTE database " + dbName);
-      }
-    }
-
-    private boolean isDatabaseRemote(String name) {
-      try {
-        String[] parsedDbName = parseDbName(name, conf);
-        Database db = get_database_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]);
-        if (db != null && db.getType() == DatabaseType.REMOTE) {
-          return true;
-        }
-      } catch (Exception e) {
-        return false;
-      }
-      return false;
-    }
-
-    private void deleteParentRecursive(Path parent, int depth, boolean mustPurge, boolean needRecycle)
-            throws IOException, MetaException {
-      if (depth > 0 && parent != null && wh.isWritable(parent)) {
-        if (wh.isDir(parent) && wh.isEmptyDir(parent)) {
-          wh.deleteDir(parent, true, mustPurge, needRecycle);
-        }
-        deleteParentRecursive(parent.getParent(), depth - 1, mustPurge, needRecycle);
-      }
-    }
-
-    @Override
-    public boolean drop_partition(final String db_name, final String tbl_name,
-        final List<String> part_vals, final boolean deleteData)
-        throws TException {
-      return drop_partition_with_environment_context(db_name, tbl_name, part_vals, deleteData,
-          null);
-    }
-
-    private static class PathAndPartValSize {
-      PathAndPartValSize(Path path, int partValSize) {
-        this.path = path;
-        this.partValSize = partValSize;
-      }
-      public Path path;
-      int partValSize;
-    }
-
-    @Override
-    public DropPartitionsResult drop_partitions_req(
-        DropPartitionsRequest request) throws TException {
-      RawStore ms = getMS();
-      String dbName = request.getDbName(), tblName = request.getTblName();
-      String catName = request.isSetCatName() ? request.getCatName() : getDefaultCatalog(conf);
-      boolean ifExists = request.isSetIfExists() && request.isIfExists();
-      boolean deleteData = request.isSetDeleteData() && request.isDeleteData();
-      boolean ignoreProtection = request.isSetIgnoreProtection() && request.isIgnoreProtection();
-      boolean needResult = !request.isSetNeedResult() || request.isNeedResult();
-      List<PathAndPartValSize> dirsToDelete = new ArrayList<>();
-      List<Path> archToDelete = new ArrayList<>();
-      EnvironmentContext envContext = request.isSetEnvironmentContext()
-          ? request.getEnvironmentContext() : null;
-
-      boolean success = false;
-      ms.openTransaction();
-      Table tbl = null;
-      List<Partition> parts = null;
-      boolean mustPurge = false;
-      List<Map<String, String>> transactionalListenerResponses = Lists.newArrayList();
-      boolean needsCm = ReplChangeManager.shouldEnableCm(ms.getDatabase(catName, dbName),
-              ms.getTable(catName, dbName, tblName));
-
-      try {
-        // We need Partition-s for firing events and for result; DN needs MPartition-s to drop.
-        // Great... Maybe we could bypass fetching MPartitions by issuing direct SQL deletes.
-        tbl = get_table_core(catName, dbName, tblName);
-        isExternal(tbl);
-        mustPurge = isMustPurge(envContext, tbl);
-        int minCount = 0;
-        RequestPartsSpec spec = request.getParts();
-        List<String> partNames = null;
-        if (spec.isSetExprs()) {
-          // Dropping by expressions.
-          parts = new ArrayList<>(spec.getExprs().size());
-          for (DropPartitionsExpr expr : spec.getExprs()) {
-            ++minCount; // At least one partition per expression, if not ifExists
-            List<Partition> result = new ArrayList<>();
-            boolean hasUnknown = ms.getPartitionsByExpr(
-                catName, dbName, tblName, expr.getExpr(), null, (short)-1, result);
-            if (hasUnknown) {
-              // Expr is built by DDLSA, it should only contain part cols and simple ops
-              throw new MetaException("Unexpected unknown partitions to drop");
-            }
-            // this is to prevent dropping archived partition which is archived in a
-            // different level the drop command specified.
-            if (!ignoreProtection && expr.isSetPartArchiveLevel()) {
-              for (Partition part : parts) {
-                if (MetaStoreUtils.isArchived(part)
-                    && MetaStoreUtils.getArchivingLevel(part) < expr.getPartArchiveLevel()) {
-                  throw new MetaException("Cannot drop a subset of partitions "
-                      + " in an archive, partition " + part);
-                }
-              }
-            }
-            parts.addAll(result);
-          }
-        } else if (spec.isSetNames()) {
-          partNames = spec.getNames();
-          minCount = partNames.size();
-          parts = ms.getPartitionsByNames(catName, dbName, tblName, partNames);
-        } else {
-          throw new MetaException("Partition spec is not set");
-        }
-
-        if ((parts.size() < minCount) && !ifExists) {
-          throw new NoSuchObjectException("Some partitions to drop are missing");
-        }
-
-        List<String> colNames = null;
-        if (partNames == null) {
-          partNames = new ArrayList<>(parts.size());
-          colNames = new ArrayList<>(tbl.getPartitionKeys().size());
-          for (FieldSchema col : tbl.getPartitionKeys()) {
-            colNames.add(col.getName());
-          }
-        }
-
-        for (Partition part : parts) {
-
-          // TODO - we need to speed this up for the normal path where all partitions are under
-          // the table and we don't have to stat every partition
-
-          firePreEvent(new PreDropPartitionEvent(tbl, part, deleteData, this));
-          if (colNames != null) {
-            partNames.add(FileUtils.makePartName(colNames, part.getValues()));
-          }
-          // Preserve the old behavior of failing when we cannot write, even w/o deleteData,
-          // and even if the table is external. That might not make any sense.
-          if (MetaStoreUtils.isArchived(part)) {
-            Path archiveParentDir = MetaStoreUtils.getOriginalLocation(part);
-            verifyIsWritablePath(archiveParentDir);
-            archToDelete.add(archiveParentDir);
-          }
-          if ((part.getSd() != null) && (part.getSd().getLocation() != null)) {
-            Path partPath = new Path(part.getSd().getLocation());
-            verifyIsWritablePath(partPath);
-            dirsToDelete.add(new PathAndPartValSize(partPath, part.getValues().size()));
-          }
-        }
-
-        ms.dropPartitions(catName, dbName, tblName, partNames);
-        if (parts != null && !transactionalListeners.isEmpty()) {
-          for (Partition part : parts) {
-            transactionalListenerResponses.add(
-                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                      EventType.DROP_PARTITION,
-                                                      new DropPartitionEvent(tbl, part, true, deleteData, this),
-                                                      envContext));
-          }
-        }
-
-        success = ms.commitTransaction();
-        DropPartitionsResult result = new DropPartitionsResult();
-        if (needResult) {
-          result.setPartitions(parts);
-        }
-
-        return result;
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        } else if (checkTableDataShouldBeDeleted(tbl, deleteData)) {
-          LOG.info( mustPurge?
-                      "dropPartition() will purge partition-directories directly, skipping trash."
-                    :  "dropPartition() will move partition-directories to trash-directory.");
-          // Archived partitions have har:/to_har_file as their location.
-          // The original directory was saved in params
-          for (Path path : archToDelete) {
-            wh.deleteDir(path, true, mustPurge, needsCm);
-          }
-          for (PathAndPartValSize p : dirsToDelete) {
-            wh.deleteDir(p.path, true, mustPurge, needsCm);
-            try {
-              deleteParentRecursive(p.path.getParent(), p.partValSize - 1, mustPurge, needsCm);
-            } catch (IOException ex) {
-              LOG.warn("Error from deleteParentRecursive", ex);
-              throw new MetaException("Failed to delete parent: " + ex.getMessage());
-            }
-          }
-        }
-        if (parts != null) {
-          int i = 0;
-          if (parts != null && !listeners.isEmpty()) {
-            for (Partition part : parts) {
-              Map<String, String> parameters =
-                  (!transactionalListenerResponses.isEmpty()) ? transactionalListenerResponses.get(i) : null;
-
-              MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                    EventType.DROP_PARTITION,
-                                                    new DropPartitionEvent(tbl, part, success, deleteData, this),
-                                                    envContext,
-                                                    parameters, ms);
-
-              i++;
-            }
-          }
-        }
-      }
-    }
-
-    private void verifyIsWritablePath(Path dir) throws MetaException {
-      try {
-        if (!wh.isWritable(dir.getParent())) {
-          throw new MetaException("Table partition not deleted since " + dir.getParent()
-              + " is not writable by " + SecurityUtils.getUser());
-        }
-      } catch (IOException ex) {
-        LOG.warn("Error from isWritable", ex);
-        throw new MetaException("Table partition not deleted since " + dir.getParent()
-            + " access cannot be checked: " + ex.getMessage());
-      }
-    }
-
-    @Override
-    public boolean drop_partition_with_environment_context(final String db_name,
-        final String tbl_name, final List<String> part_vals, final boolean deleteData,
-        final EnvironmentContext envContext)
-        throws TException {
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startPartitionFunction("drop_partition", parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-          tbl_name, part_vals);
-      LOG.info("Partition values:" + part_vals);
-
-      boolean ret = false;
-      Exception ex = null;
-      try {
-        ret = drop_partition_common(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tbl_name, part_vals, deleteData, envContext);
-      } catch (IOException e) {
-        ex = e;
-        throw new MetaException(e.getMessage());
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("drop_partition", ret, ex, tbl_name);
-      }
-      return ret;
-
-    }
-
-    /**
-     * Use {@link #get_partition_req(GetPartitionRequest)} ()} instead.
-     *
-     */
-    @Override
-    @Deprecated
-    public Partition get_partition(final String db_name, final String tbl_name,
-        final List<String> part_vals) throws MetaException, NoSuchObjectException {
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startPartitionFunction("get_partition", parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-          tbl_name, part_vals);
-
-      Partition ret = null;
-      Exception ex = null;
-      try {
-        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-        fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-        ret = getMS().getPartition(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name, part_vals);
-        ret = FilterUtils.filterPartitionIfEnabled(isServerFilterEnabled, filterHook, ret);
-      } catch (Exception e) {
-        ex = e;
-        throwMetaException(e);
-      } finally {
-        endFunction("get_partition", ret != null, ex, tbl_name);
-      }
-      return ret;
-    }
-
-    @Override
-    public GetPartitionResponse get_partition_req(GetPartitionRequest req)
-        throws MetaException, NoSuchObjectException, TException {
-      // TODO Move the logic from get_partition to here, as that method is getting deprecated
-      String dbName = MetaStoreUtils.prependCatalogToDbName(req.getCatName(), req.getDbName(), conf);
-      Partition p = get_partition(dbName, req.getTblName(), req.getPartVals());
-      GetPartitionResponse res = new GetPartitionResponse();
-      res.setPartition(p);
-      return res;
-    }
-
-    /**
-     * Fire a pre-event for read table operation, if there are any
-     * pre-event listeners registered
-     */
-    private void fireReadTablePreEvent(String catName, String dbName, String tblName)
-        throws MetaException, NoSuchObjectException {
-      if(preListeners.size() > 0) {
-        Supplier<Table> tableSupplier = Suppliers.memoize(new Supplier<Table>() {
-          @Override public Table get() {
-            try {
-              Table t = getMS().getTable(catName, dbName, tblName, null);
-              if (t == null) {
-                throw new NoSuchObjectException(TableName.getQualified(catName, dbName, tblName)
-                    + " table not found");
-              }
-              return t;
-            } catch(MetaException | NoSuchObjectException e) {
-              throw new RuntimeException(e);
-            }
-          }
-        });
-        firePreEvent(new PreReadTableEvent(tableSupplier, this));
-      }
-    }
-
-    @Override
-    @Deprecated
-    public Partition get_partition_with_auth(final String db_name,
-        final String tbl_name, final List<String> part_vals,
-        final String user_name, final List<String> group_names)
-        throws TException {
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startPartitionFunction("get_partition_with_auth", parsedDbName[CAT_NAME],
-          parsedDbName[DB_NAME], tbl_name, part_vals);
-      fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-      Partition ret = null;
-      Exception ex = null;
-      try {
-        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-
-        ret = getMS().getPartitionWithAuth(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tbl_name, part_vals, user_name, group_names);
-        ret = FilterUtils.filterPartitionIfEnabled(isServerFilterEnabled, filterHook, ret);
-      } catch (InvalidObjectException e) {
-        ex = e;
-        throw new NoSuchObjectException(e.getMessage());
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partition_with_auth", ret != null, ex, tbl_name);
-      }
-      return ret;
-    }
-
-    /**
-     * Use {@link #get_partitions_req(PartitionsRequest)} ()} instead.
-     *
-     */
-    @Override
-    @Deprecated
-    public List<Partition> get_partitions(final String db_name, final String tbl_name,
-        final short max_parts) throws NoSuchObjectException, MetaException {
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startTableFunction("get_partitions", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-      fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-      List<Partition> ret = null;
-      Exception ex = null;
-      try {
-        checkLimitNumberOfPartitionsByFilter(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tbl_name, NO_FILTER_STRING, max_parts);
-
-        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-
-        ret = getMS().getPartitions(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name,
-            max_parts);
-        ret = FilterUtils.filterPartitionsIfEnabled(isServerFilterEnabled, filterHook, ret);
-      } catch (Exception e) {
-        ex = e;
-        throwMetaException(e);
-      } finally {
-        endFunction("get_partitions", ret != null, ex, tbl_name);
-      }
-      return ret;
-
-    }
-
-    @Override
-    public PartitionsResponse get_partitions_req(PartitionsRequest req)
-        throws NoSuchObjectException, MetaException, TException {
-      String dbName = MetaStoreUtils.prependCatalogToDbName(req.getCatName(), req.getDbName(), conf);
-      List<Partition> partitions = get_partitions(dbName, req.getTblName(), req.getMaxParts());
-      PartitionsResponse res = new PartitionsResponse();
-      res.setPartitions(partitions);
-      return res;
-    }
-
-    @Override
-    @Deprecated
-    public List<Partition> get_partitions_with_auth(final String dbName,
-        final String tblName, final short maxParts, final String userName,
-        final List<String> groupNames) throws TException {
-      String[] parsedDbName = parseDbName(dbName, conf);
-      startTableFunction("get_partitions_with_auth", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName);
-
-      List<Partition> ret = null;
-      Exception ex = null;
-      try {
-        checkLimitNumberOfPartitionsByFilter(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tblName, NO_FILTER_STRING, maxParts);
-
-        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName);
-
-        ret = getMS().getPartitionsWithAuth(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName,
-            maxParts, userName, groupNames);
-        ret = FilterUtils.filterPartitionsIfEnabled(isServerFilterEnabled, filterHook, ret);
-      } catch (InvalidObjectException e) {
-        ex = e;
-        throw new NoSuchObjectException(e.getMessage());
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partitions_with_auth", ret != null, ex, tblName);
-      }
-      return ret;
-
-    }
-
-    private void checkLimitNumberOfPartitionsByFilter(String catName, String dbName,
-                                                      String tblName, String filterString,
-                                                      int maxParts) throws TException {
-      if (isPartitionLimitEnabled()) {
-        checkLimitNumberOfPartitions(tblName, get_num_partitions_by_filter(prependCatalogToDbName(
-            catName, dbName, conf), tblName, filterString), maxParts);
-      }
-    }
-
-    private void checkLimitNumberOfPartitionsByExpr(String catName, String dbName, String tblName,
-                                                    byte[] filterExpr, int maxParts)
-        throws TException {
-      if (isPartitionLimitEnabled()) {
-        checkLimitNumberOfPartitions(tblName, get_num_partitions_by_expr(catName, dbName, tblName,
-            filterExpr), maxParts);
-      }
-    }
-
-    private boolean isPartitionLimitEnabled() {
-      int partitionLimit = MetastoreConf.getIntVar(conf, ConfVars.LIMIT_PARTITION_REQUEST);
-      return partitionLimit > -1;
-    }
-
-    private void checkLimitNumberOfPartitions(String tblName, int numPartitions, int maxToFetch) throws MetaException {
-      if (isPartitionLimitEnabled()) {
-        int partitionLimit = MetastoreConf.getIntVar(conf, ConfVars.LIMIT_PARTITION_REQUEST);
-        int partitionRequest = (maxToFetch < 0) ? numPartitions : maxToFetch;
-        if (partitionRequest > partitionLimit) {
-          String configName = ConfVars.LIMIT_PARTITION_REQUEST.toString();
-          throw new MetaException(String.format(PARTITION_NUMBER_EXCEED_LIMIT_MSG, partitionRequest,
-              tblName, partitionLimit, configName));
-        }
-      }
-    }
-
-    @Override
-    @Deprecated
-    public List<PartitionSpec> get_partitions_pspec(final String db_name, final String tbl_name, final int max_parts)
-      throws NoSuchObjectException, MetaException  {
-
-      String[] parsedDbName = parseDbName(db_name, conf);
-      String tableName = tbl_name.toLowerCase();
-
-      startTableFunction("get_partitions_pspec", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName);
-
-      List<PartitionSpec> partitionSpecs = null;
-      try {
-        Table table = get_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName);
-        // get_partitions will parse out the catalog and db names itself
-        List<Partition> partitions = get_partitions(db_name, tableName, (short) max_parts);
-
-        if (is_partition_spec_grouping_enabled(table)) {
-          partitionSpecs = MetaStoreServerUtils
-              .getPartitionspecsGroupedByStorageDescriptor(table, partitions);
-        }
-        else {
-          PartitionSpec pSpec = new PartitionSpec();
-          pSpec.setPartitionList(new PartitionListComposingSpec(partitions));
-          pSpec.setCatName(parsedDbName[CAT_NAME]);
-          pSpec.setDbName(parsedDbName[DB_NAME]);
-          pSpec.setTableName(tableName);
-          pSpec.setRootPath(table.getSd().getLocation());
-          partitionSpecs = Arrays.asList(pSpec);
-        }
-
-        return partitionSpecs;
-      }
-      finally {
-        endFunction("get_partitions_pspec", partitionSpecs != null && !partitionSpecs.isEmpty(), null, tbl_name);
-      }
-    }
-
-    @Override
-    public GetPartitionsResponse get_partitions_with_specs(GetPartitionsRequest request)
-        throws MetaException, TException {
-      String catName = null;
-      if (request.isSetCatName()) {
-        catName = request.getCatName();
-      }
-      String[] parsedDbName = parseDbName(request.getDbName(), conf);
-      String tableName = request.getTblName();
-      if (catName == null) {
-        // if catName is not provided in the request use the catName parsed from the dbName
-        catName = parsedDbName[CAT_NAME];
-      }
-      startTableFunction("get_partitions_with_specs", catName, parsedDbName[DB_NAME],
-          tableName);
-      GetPartitionsResponse response = null;
-      Exception ex = null;
-      try {
-        Table table = get_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName);
-        List<Partition> partitions = getMS()
-            .getPartitionSpecsByFilterAndProjection(table, request.getProjectionSpec(),
-                request.getFilterSpec());
-        List<String> processorCapabilities = request.getProcessorCapabilities();
-        String processorId = request.getProcessorIdentifier();
-        if (processorCapabilities == null || processorCapabilities.size() == 0 ||
-              processorCapabilities.contains("MANAGERAWMETADATA")) {
-          LOG.info("Skipping translation for processor with " + processorId);
-        } else {
-          if (transformer != null) {
-            partitions = transformer.transformPartitions(partitions, table, processorCapabilities, processorId);
-          }
-        }
-        List<PartitionSpec> partitionSpecs =
-            MetaStoreServerUtils.getPartitionspecsGroupedByStorageDescriptor(table, partitions);
-        response = new GetPartitionsResponse();
-        response.setPartitionSpec(partitionSpecs);
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partitions_with_specs", response != null, ex, tableName);
-      }
-      return response;
-    }
-
-    private static boolean is_partition_spec_grouping_enabled(Table table) {
-
-      Map<String, String> parameters = table.getParameters();
-      return parameters.containsKey("hive.hcatalog.partition.spec.grouping.enabled")
-          && parameters.get("hive.hcatalog.partition.spec.grouping.enabled").equalsIgnoreCase("true");
-    }
-
-    @Override
-    @Deprecated
-    public List<String> get_partition_names(final String db_name, final String tbl_name,
-        final short max_parts) throws NoSuchObjectException, MetaException {
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startTableFunction("get_partition_names", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-      fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-      List<String> ret = null;
-      Exception ex = null;
-      try {
-        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-        ret = getMS().listPartitionNames(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name,
-            max_parts);
-        ret = FilterUtils.filterPartitionNamesIfEnabled(isServerFilterEnabled,
-            filterHook, parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name, ret);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_partition_names", ret != null, ex, tbl_name);
-      }
-      return ret;
-    }
-
-    @Override
-    public PartitionValuesResponse get_partition_values(PartitionValuesRequest request)
-        throws MetaException {
-      String catName = request.isSetCatName() ? request.getCatName() : getDefaultCatalog(conf);
-      String dbName = request.getDbName();
-      String tblName = request.getTblName();
-
-      try {
-        authorizeTableForPartitionMetadata(catName, dbName, tblName);
-
-        // This is serious black magic, as the following 2 lines do nothing AFAICT but without them
-        // the subsequent call to listPartitionValues fails.
-        List<FieldSchema> partCols = new ArrayList<FieldSchema>();
-        partCols.add(request.getPartitionKeys().get(0));
-        return getMS().listPartitionValues(catName, dbName, tblName, request.getPartitionKeys(),
-            request.isApplyDistinct(), request.getFilter(), request.isAscending(),
-            request.getPartitionOrder(), request.getMaxParts());
-      } catch (NoSuchObjectException e) {
-        LOG.error(String.format("Unable to get partition for %s.%s.%s", catName, dbName, tblName), e);
-        throw new MetaException(e.getMessage());
-      }
-    }
-
-    @Deprecated
-    @Override
-    public void alter_partition(final String db_name, final String tbl_name,
-        final Partition new_part)
-        throws TException {
-      rename_partition(db_name, tbl_name, null, new_part);
-    }
-
-    @Deprecated
-    @Override
-    public void alter_partition_with_environment_context(final String dbName,
-        final String tableName, final Partition newPartition,
-        final EnvironmentContext envContext)
-        throws TException {
-      String[] parsedDbName = parseDbName(dbName, conf);
-      // TODO: this method name is confusing, it actually does full alter (sortof)
-      rename_partition(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName, null, newPartition,
-          envContext, null);
-    }
-
-    @Deprecated
-    @Override
-    public void rename_partition(final String db_name, final String tbl_name,
-        final List<String> part_vals, final Partition new_part)
-        throws TException {
-      // Call rename_partition without an environment context.
-      String[] parsedDbName = parseDbName(db_name, conf);
-      rename_partition(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name, part_vals, new_part,
-          null, null);
-    }
-
-    @Override
-    public RenamePartitionResponse rename_partition_req(
-        RenamePartitionRequest req) throws InvalidOperationException ,MetaException ,TException {
-      rename_partition(req.getCatName(), req.getDbName(), req.getTableName(), req.getPartVals(),
-          req.getNewPart(), null, req.getValidWriteIdList());
-      return new RenamePartitionResponse();
-    };
-
-    private void rename_partition(String catName, String db_name, String tbl_name,
-        List<String> part_vals, Partition new_part, EnvironmentContext envContext,
-        String validWriteIds) throws TException {
-      startTableFunction("alter_partition", catName, db_name, tbl_name);
-
-      if (LOG.isInfoEnabled()) {
-        LOG.info("New partition values:" + new_part.getValues());
-        if (part_vals != null && part_vals.size() > 0) {
-          LOG.info("Old Partition values:" + part_vals);
-        }
-      }
-
-      // Adds the missing scheme/authority for the new partition location
-      if (new_part.getSd() != null) {
-        String newLocation = new_part.getSd().getLocation();
-        if (org.apache.commons.lang3.StringUtils.isNotEmpty(newLocation)) {
-          Path tblPath = wh.getDnsPath(new Path(newLocation));
-          new_part.getSd().setLocation(tblPath.toString());
-        }
-      }
-
-      // Make sure the new partition has the catalog value set
-      if (!new_part.isSetCatName()) {
-        new_part.setCatName(catName);
-      }
-
-      Partition oldPart = null;
-      Exception ex = null;
-      try {
-        firePreEvent(new PreAlterPartitionEvent(db_name, tbl_name, part_vals, new_part, this));
-        if (part_vals != null && !part_vals.isEmpty()) {
-          MetaStoreServerUtils.validatePartitionNameCharacters(new_part.getValues(),
-              partitionValidationPattern);
-        }
-
-        oldPart = alterHandler.alterPartition(getMS(), wh, catName, db_name, tbl_name,
-            part_vals, new_part, envContext, this, validWriteIds);
-
-        // Only fetch the table if we actually have a listener
-        Table table = null;
-        if (!listeners.isEmpty()) {
-          if (table == null) {
-            table = getMS().getTable(catName, db_name, tbl_name, null);
-          }
-
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.ALTER_PARTITION,
-                                                new AlterPartitionEvent(oldPart, new_part, table, false,
-                                                        true, new_part.getWriteId(), this),
-                                                envContext);
-        }
-      } catch (InvalidObjectException e) {
-        ex = e;
-        throw new InvalidOperationException(e.getMessage());
-      } catch (AlreadyExistsException e) {
-        ex = e;
-        throw new InvalidOperationException(e.getMessage());
-      } catch (MetaException | InvalidOperationException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("alter_partition", oldPart != null, ex, tbl_name);
-      }
-    }
-
-    @Override
-    public void alter_partitions(final String db_name, final String tbl_name,
-        final List<Partition> new_parts)
-        throws TException {
-      String[] o = parseDbName(db_name, conf);
-      alter_partitions_with_environment_context(o[0], o[1],
-          tbl_name, new_parts, null, null, -1);
-    }
-
-    @Override
-    public AlterPartitionsResponse alter_partitions_req(AlterPartitionsRequest req) throws TException {
-      alter_partitions_with_environment_context(req.getCatName(),
-          req.getDbName(), req.getTableName(), req.getPartitions(), req.getEnvironmentContext(),
-          req.isSetValidWriteIdList() ? req.getValidWriteIdList() : null,
-          req.isSetWriteId() ? req.getWriteId() : -1);
-      return new AlterPartitionsResponse();
-    }
-
-    // The old API we are keeping for backward compat. Not used within Hive.
-    @Deprecated
-    @Override
-    public void alter_partitions_with_environment_context(final String db_name, final String tbl_name,
-        final List<Partition> new_parts, EnvironmentContext environmentContext)
-            throws TException {
-      String[] o = parseDbName(db_name, conf);
-      alter_partitions_with_environment_context(o[0], o[1], tbl_name, new_parts, environmentContext,
-          null, -1);
-    }
-
-    private void alter_partitions_with_environment_context(String catName, String db_name, final String tbl_name,
-        final List<Partition> new_parts, EnvironmentContext environmentContext,
-        String writeIdList, long writeId)
-        throws TException {
-      if (environmentContext == null) {
-        environmentContext = new EnvironmentContext();
-      }
-      if (catName == null) {
-        catName = MetaStoreUtils.getDefaultCatalog(conf);
-      }
-
-      startTableFunction("alter_partitions", catName, db_name, tbl_name);
-
-      if (LOG.isInfoEnabled()) {
-        for (Partition tmpPart : new_parts) {
-          LOG.info("New partition values:" + tmpPart.getValues());
-        }
-      }
-      // all partitions are altered atomically
-      // all prehooks are fired together followed by all post hooks
-      List<Partition> oldParts = null;
-      Exception ex = null;
-      try {
-        for (Partition tmpPart : new_parts) {
-          // Make sure the catalog name is set in the new partition
-          if (!tmpPart.isSetCatName()) {
-            tmpPart.setCatName(getDefaultCatalog(conf));
-          }
-          firePreEvent(new PreAlterPartitionEvent(db_name, tbl_name, null, tmpPart, this));
-        }
-        oldParts = alterHandler.alterPartitions(getMS(), wh,
-            catName, db_name, tbl_name, new_parts, environmentContext, writeIdList, writeId, this);
-        Iterator<Partition> olditr = oldParts.iterator();
-        // Only fetch the table if we have a listener that needs it.
-        Table table = null;
-        for (Partition tmpPart : new_parts) {
-          Partition oldTmpPart;
-          if (olditr.hasNext()) {
-            oldTmpPart = olditr.next();
-          }
-          else {
-            throw new InvalidOperationException("failed to alterpartitions");
-          }
-
-          if (table == null) {
-            table = getMS().getTable(catName, db_name, tbl_name,  null);
-          }
-
-          if (!listeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                  EventType.ALTER_PARTITION,
-                                                  new AlterPartitionEvent(oldTmpPart, tmpPart, table, false,
-                                                   true, writeId, this));
-          }
-        }
-      } catch (InvalidObjectException e) {
-        ex = e;
-        throw new InvalidOperationException(e.getMessage());
-      } catch (AlreadyExistsException e) {
-        ex = e;
-        throw new InvalidOperationException(e.getMessage());
-      } catch (MetaException | InvalidOperationException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("alter_partition", oldParts != null, ex, tbl_name);
-      }
-    }
-
-    @Override
-    public String getVersion() throws TException {
-      String version = MetastoreVersionInfo.getVersion();
-      endFunction(startFunction("getVersion"), version != null, null);
-      return version;
-    }
-
-    @Override
-    public void alter_table(final String dbname, final String name,
-        final Table newTable)
-        throws InvalidOperationException, MetaException {
-      // Do not set an environment context.
-      String[] parsedDbName = parseDbName(dbname, conf);
-      alter_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], name, newTable,
-          null, null, null, null);
-    }
-
-    @Override
-    public void alter_table_with_cascade(final String dbname, final String name,
-        final Table newTable, final boolean cascade)
-        throws InvalidOperationException, MetaException {
-      EnvironmentContext envContext = null;
-      if (cascade) {
-        envContext = new EnvironmentContext();
-        envContext.putToProperties(StatsSetupConst.CASCADE, StatsSetupConst.TRUE);
-      }
-      String[] parsedDbName = parseDbName(dbname, conf);
-      alter_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], name, newTable,
-          envContext, null, null, null);
-    }
-
-    @Override
-    public AlterTableResponse alter_table_req(AlterTableRequest req)
-        throws InvalidOperationException, MetaException, TException {
-      alter_table_core(req.getCatName(), req.getDbName(), req.getTableName(),
-          req.getTable(), req.getEnvironmentContext(), req.getValidWriteIdList(),
-          req.getProcessorCapabilities(), req.getProcessorIdentifier());
-      return new AlterTableResponse();
-    }
-
-    @Override
-    public void alter_table_with_environment_context(final String dbname,
-        final String name, final Table newTable,
-        final EnvironmentContext envContext)
-        throws InvalidOperationException, MetaException {
-      String[] parsedDbName = parseDbName(dbname, conf);
-      alter_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-          name, newTable, envContext, null, null, null);
-    }
-
-    private void alter_table_core(String catName, String dbname, String name, Table newTable,
-        EnvironmentContext envContext, String validWriteIdList, List<String> processorCapabilities, String processorId)
-        throws InvalidOperationException, MetaException {
-      startFunction("alter_table", ": " + TableName.getQualified(catName, dbname, name)
-          + " newtbl=" + newTable.getTableName());
-      if (envContext == null) {
-        envContext = new EnvironmentContext();
-      }
-      if (catName == null) {
-        catName = MetaStoreUtils.getDefaultCatalog(conf);
-      }
-
-      // Update the time if it hasn't been specified.
-      if (newTable.getParameters() == null ||
-          newTable.getParameters().get(hive_metastoreConstants.DDL_TIME) == null) {
-        newTable.putToParameters(hive_metastoreConstants.DDL_TIME, Long.toString(System
-            .currentTimeMillis() / 1000));
-      }
-
-      // Adds the missing scheme/authority for the new table location
-      if (newTable.getSd() != null) {
-        String newLocation = newTable.getSd().getLocation();
-        if (org.apache.commons.lang3.StringUtils.isNotEmpty(newLocation)) {
-          Path tblPath = wh.getDnsPath(new Path(newLocation));
-          newTable.getSd().setLocation(tblPath.toString());
-        }
-      }
-      // Set the catalog name if it hasn't been set in the new table
-      if (!newTable.isSetCatName()) {
-        newTable.setCatName(catName);
-      }
-
-      boolean success = false;
-      Exception ex = null;
-      try {
-        Table oldt = get_table_core(catName, dbname, name, null);
-        if (transformer != null && !isInTest) {
-          newTable = transformer.transformAlterTable(newTable, processorCapabilities, processorId);
-        }
-        firePreEvent(new PreAlterTableEvent(oldt, newTable, this));
-        alterHandler.alterTable(getMS(), wh, catName, dbname, name, newTable,
-                envContext, this, validWriteIdList);
-        success = true;
-      } catch (NoSuchObjectException e) {
-        // thrown when the table to be altered does not exist
-        ex = e;
-        throw new InvalidOperationException(e.getMessage());
-      } catch (MetaException | InvalidOperationException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("alter_table", success, ex, name);
-      }
-    }
-
-    @Override
-    public List<String> get_tables(final String dbname, final String pattern)
-        throws MetaException {
-      startFunction("get_tables", ": db=" + dbname + " pat=" + pattern);
-
-      List<String> ret = null;
-      Exception ex = null;
-      Database db = null;
-      String[] parsedDbName = parseDbName(dbname, conf);
-      try {
-        db = get_database_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]);
-        if (db != null && db.getType() != null) {
-          if (db.getType().equals(DatabaseType.REMOTE)) {
-            return DataConnectorProviderFactory.getDataConnectorProvider(db).getTableNames();
-          }
-        }
-      } catch (Exception e) { /* appears we return empty set instead of throwing an exception */ }
-
-      try {
-        ret = getMS().getTables(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], pattern);
-        if(ret !=  null && !ret.isEmpty()) {
-          List<Table> tableInfo = new ArrayList<>();
-          tableInfo = getMS().getTableObjectsByName(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], ret);
-          tableInfo = FilterUtils.filterTablesIfEnabled(isServerFilterEnabled, filterHook, tableInfo);// tableInfo object has the owner information of the table which is being passed to FilterUtils.
-          ret = new ArrayList<>();
-          for (Table tbl : tableInfo) {
-            ret.add(tbl.getTableName());
-          }
-        }
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_tables", ret != null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public List<String> get_tables_by_type(final String dbname, final String pattern, final String tableType)
-        throws MetaException {
-      startFunction("get_tables_by_type", ": db=" + dbname + " pat=" + pattern + ",type=" + tableType);
-
-      List<String> ret = null;
-      Exception ex = null;
-      String[] parsedDbName = parseDbName(dbname, conf);
-      try {
-        ret = getTablesByTypeCore(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], pattern, tableType);
-        ret = FilterUtils.filterTableNamesIfEnabled(isServerFilterEnabled, filterHook,
-            parsedDbName[CAT_NAME], parsedDbName[DB_NAME], ret);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_tables_by_type", ret != null, ex);
-      }
-      return ret;
-    }
-
-    private List<String> getTablesByTypeCore(final String catName, final String dbname,
-        final String pattern, final String tableType) throws MetaException {
-      startFunction("getTablesByTypeCore", ": catName=" + catName +
-          ": db=" + dbname + " pat=" + pattern + ",type=" + tableType);
-
-      List<String> ret = null;
-      Exception ex = null;
-      Database db = null;
-      try {
-        db = get_database_core(catName, dbname);
-        if (db != null) {
-          if (db.getType().equals(DatabaseType.REMOTE)) {
-            return DataConnectorProviderFactory.getDataConnectorProvider(db).getTableNames();
-          }
-        }
-      } catch (Exception e) { /* ignore */ }
-
-      try {
-        ret = getMS().getTables(catName, dbname, pattern, TableType.valueOf(tableType), -1);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("getTablesByTypeCore", ret != null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public List<Table> get_all_materialized_view_objects_for_rewriting()
-        throws MetaException {
-      startFunction("get_all_materialized_view_objects_for_rewriting");
-
-      List<Table> ret = null;
-      Exception ex = null;
-      try {
-        ret = getMS().getAllMaterializedViewObjectsForRewriting(DEFAULT_CATALOG_NAME);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_all_materialized_view_objects_for_rewriting", ret != null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public List<String> get_materialized_views_for_rewriting(final String dbname)
-        throws MetaException {
-      startFunction("get_materialized_views_for_rewriting", ": db=" + dbname);
-
-      List<String> ret = null;
-      Exception ex = null;
-      String[] parsedDbName = parseDbName(dbname, conf);
-      try {
-        ret = getMS().getMaterializedViewsForRewriting(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_materialized_views_for_rewriting", ret != null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public List<String> get_all_tables(final String dbname) throws MetaException {
-      startFunction("get_all_tables", ": db=" + dbname);
-
-      List<String> ret = null;
-      Exception ex = null;
-      String[] parsedDbName = parseDbName(dbname, conf);
-      try {
-        ret = getMS().getAllTables(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]);
-        ret = FilterUtils.filterTableNamesIfEnabled(isServerFilterEnabled, filterHook,
-            parsedDbName[CAT_NAME], parsedDbName[DB_NAME], ret);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_all_tables", ret != null, ex);
-      }
-      return ret;
-    }
-
-    /**
-     * Use {@link #get_fields_req(GetFieldsRequest)} ()} instead.
-     *
-     */
-    @Override
-    @Deprecated
-    public List<FieldSchema> get_fields(String db, String tableName)
-        throws MetaException, UnknownTableException, UnknownDBException {
-      return get_fields_with_environment_context(db, tableName, null);
-    }
-
-    @Override
-    @Deprecated
-    public List<FieldSchema> get_fields_with_environment_context(String db, String tableName,
-        final EnvironmentContext envContext)
-        throws MetaException, UnknownTableException, UnknownDBException {
-      startFunction("get_fields_with_environment_context", ": db=" + db + "tbl=" + tableName);
-      String[] names = tableName.split("\\.");
-      String base_table_name = names[0];
-      String[] parsedDbName = parseDbName(db, conf);
-
-      Table tbl;
-      List<FieldSchema> ret = null;
-      Exception ex = null;
-      ClassLoader orgHiveLoader = null;
-      try {
-        try {
-          tbl = get_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], base_table_name);
-          firePreEvent(new PreReadTableEvent(tbl, this));
-        } catch (NoSuchObjectException e) {
-          throw new UnknownTableException(e.getMessage());
-        }
-        if (null == tbl.getSd().getSerdeInfo().getSerializationLib() ||
-          MetastoreConf.getStringCollection(conf,
-              ConfVars.SERDES_USING_METASTORE_FOR_SCHEMA).contains(
-                  tbl.getSd().getSerdeInfo().getSerializationLib())) {
-          ret = tbl.getSd().getCols();
-        } else {
-          StorageSchemaReader schemaReader = getStorageSchemaReader();
-          ret = schemaReader.readSchema(tbl, envContext, getConf());
-        }
-      } catch (UnknownTableException | MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        if (orgHiveLoader != null) {
-          conf.setClassLoader(orgHiveLoader);
-        }
-        endFunction("get_fields_with_environment_context", ret != null, ex, tableName);
-      }
-
-      return ret;
-    }
-
-    @Override
-    public GetFieldsResponse get_fields_req(GetFieldsRequest req)
-        throws MetaException, UnknownTableException, UnknownDBException, TException {
-      String dbName = MetaStoreUtils.prependCatalogToDbName(req.getCatName(), req.getDbName(), conf);
-      List<FieldSchema> fields = get_fields_with_environment_context(
-          dbName, req.getTblName(), req.getEnvContext());
-      GetFieldsResponse res = new GetFieldsResponse();
-      res.setFields(fields);
-      return res;
-    }
-
-    private StorageSchemaReader getStorageSchemaReader() throws MetaException {
-      if (storageSchemaReader == null) {
-        String className =
-            MetastoreConf.getVar(conf, MetastoreConf.ConfVars.STORAGE_SCHEMA_READER_IMPL);
-        Class<? extends StorageSchemaReader> readerClass =
-            JavaUtils.getClass(className, StorageSchemaReader.class);
-        try {
-          storageSchemaReader = readerClass.newInstance();
-        } catch (InstantiationException|IllegalAccessException e) {
-          LOG.error("Unable to instantiate class " + className, e);
-          throw new MetaException(e.getMessage());
-        }
-      }
-      return storageSchemaReader;
-    }
-
-    /**
-     * Use {@link #get_schema_req(GetSchemaRequest)} ()} instead.
-     *
-     */
-    @Override
-    @Deprecated
-    public List<FieldSchema> get_schema(String db, String tableName)
-        throws MetaException, UnknownTableException, UnknownDBException {
-      return get_schema_with_environment_context(db,tableName, null);
-    }
-
-    /**
-     * Return the schema of the table. This function includes partition columns
-     * in addition to the regular columns.
-     *
-     * @param db
-     *          Name of the database
-     * @param tableName
-     *          Name of the table
-     * @param envContext
-     *          Store session based properties
-     * @return List of columns, each column is a FieldSchema structure
-     * @throws MetaException
-     * @throws UnknownTableException
-     * @throws UnknownDBException
-     */
-    @Override
-    @Deprecated
-    public List<FieldSchema> get_schema_with_environment_context(String db, String tableName,
-          final EnvironmentContext envContext)
-        throws MetaException, UnknownTableException, UnknownDBException {
-      startFunction("get_schema_with_environment_context", ": db=" + db + "tbl=" + tableName);
-      boolean success = false;
-      Exception ex = null;
-      try {
-        String[] names = tableName.split("\\.");
-        String base_table_name = names[0];
-        String[] parsedDbName = parseDbName(db, conf);
-
-        Table tbl;
-        try {
-          tbl = get_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], base_table_name);
-        } catch (NoSuchObjectException e) {
-          throw new UnknownTableException(e.getMessage());
-        }
-        // Pass unparsed db name here
-        List<FieldSchema> fieldSchemas = get_fields_with_environment_context(db, base_table_name,
-            envContext);
-
-        if (tbl == null || fieldSchemas == null) {
-          throw new UnknownTableException(tableName + " doesn't exist");
-        }
-
-        if (tbl.getPartitionKeys() != null) {
-          // Combine the column field schemas and the partition keys to create the
-          // whole schema
-          fieldSchemas.addAll(tbl.getPartitionKeys());
-        }
-        success = true;
-        return fieldSchemas;
-      } catch (UnknownDBException | UnknownTableException | MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        MetaException me = new MetaException(e.toString());
-        me.initCause(e);
-        throw me;
-      } finally {
-        endFunction("get_schema_with_environment_context", success, ex, tableName);
-      }
-    }
-
-    @Override
-    public GetSchemaResponse get_schema_req(GetSchemaRequest req)
-        throws MetaException, UnknownTableException, UnknownDBException, TException {
-      String dbName = MetaStoreUtils.prependCatalogToDbName(req.getCatName(), req.getDbName(), conf);
-      List<FieldSchema> fields = get_schema_with_environment_context(
-          dbName, req.getTblName(), req.getEnvContext());
-      GetSchemaResponse res = new GetSchemaResponse();
-      res.setFields(fields);
-      return res;
-    }
-
-    @Override
-    public String getCpuProfile(int profileDurationInSec) throws TException {
-      return "";
-    }
-
-    /**
-     * Returns the value of the given configuration variable name. If the
-     * configuration variable with the given name doesn't exist, or if there
-     * were an exception thrown while retrieving the variable, or if name is
-     * null, defaultValue is returned.
-     */
-    @Override
-    public String get_config_value(String name, String defaultValue)
-        throws TException {
-      startFunction("get_config_value", ": name=" + name + " defaultValue="
-          + defaultValue);
-      boolean success = false;
-      Exception ex = null;
-      try {
-        if (name == null) {
-          success = true;
-          return defaultValue;
-        }
-        // Allow only keys that start with hive.*, hdfs.*, mapred.* for security
-        // i.e. don't allow access to db password
-        if (!Pattern.matches("(hive|hdfs|mapred|metastore).*", name)) {
-          throw new ConfigValSecurityException("For security reasons, the "
-              + "config key " + name + " cannot be accessed");
-        }
-
-        String toReturn = defaultValue;
-        try {
-          toReturn = MetastoreConf.get(conf, name);
-          if (toReturn == null) {
-            toReturn = defaultValue;
-          }
-        } catch (RuntimeException e) {
-          LOG.error(threadLocalId.get().toString() + ": "
-              + "RuntimeException thrown in get_config_value - msg: "
-              + e.getMessage() + " cause: " + e.getCause());
-        }
-        success = true;
-        return toReturn;
-      } catch (ConfigValSecurityException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw new TException(e);
-      } finally {
-        endFunction("get_config_value", success, ex);
-      }
-    }
-
-    private List<String> getPartValsFromName(Table t, String partName)
-        throws MetaException, InvalidObjectException {
-      Preconditions.checkArgument(t != null, "Table can not be null");
-      // Unescape the partition name
-      LinkedHashMap<String, String> hm = Warehouse.makeSpecFromName(partName);
-
-      List<String> partVals = new ArrayList<>();
-      for (FieldSchema field : t.getPartitionKeys()) {
-        String key = field.getName();
-        String val = hm.get(key);
-        if (val == null) {
-          throw new InvalidObjectException("incomplete partition name - missing " + key);
-        }
-        partVals.add(val);
-      }
-      return partVals;
-    }
-
-    private List<String> getPartValsFromName(RawStore ms, String catName, String dbName,
-                                             String tblName, String partName)
-        throws MetaException, InvalidObjectException {
-      Table t = ms.getTable(catName, dbName, tblName,  null);
-      if (t == null) {
-        throw new InvalidObjectException(dbName + "." + tblName
-            + " table not found");
-      }
-      return getPartValsFromName(t, partName);
-    }
-
-    private Partition get_partition_by_name_core(final RawStore ms, final String catName,
-                                                 final String db_name, final String tbl_name,
-                                                 final String part_name) throws TException {
-      fireReadTablePreEvent(catName, db_name, tbl_name);
-      List<String> partVals;
-      try {
-        partVals = getPartValsFromName(ms, catName, db_name, tbl_name, part_name);
-      } catch (InvalidObjectException e) {
-        throw new NoSuchObjectException(e.getMessage());
-      }
-      Partition p = ms.getPartition(catName, db_name, tbl_name, partVals);
-      p = FilterUtils.filterPartitionIfEnabled(isServerFilterEnabled, filterHook, p);
-
-      if (p == null) {
-        throw new NoSuchObjectException(TableName.getQualified(catName, db_name, tbl_name)
-            + " partition (" + part_name + ") not found");
-      }
-      return p;
-    }
-
-    @Override
-    @Deprecated
-    public Partition get_partition_by_name(final String db_name, final String tbl_name,
-        final String part_name) throws TException {
-
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startFunction("get_partition_by_name", ": tbl=" +
-          TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name)
-          + " part=" + part_name);
-      Partition ret = null;
-      Exception ex = null;
-      try {
-        ret = get_partition_by_name_core(getMS(), parsedDbName[CAT_NAME],
-            parsedDbName[DB_NAME], tbl_name, part_name);
-        ret = FilterUtils.filterPartitionIfEnabled(isServerFilterEnabled, filterHook, ret);
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partition_by_name", ret != null, ex, tbl_name);
-      }
-      return ret;
-    }
-
-    @Override
-    public Partition append_partition_by_name(final String db_name, final String tbl_name,
-        final String part_name) throws TException {
-      return append_partition_by_name_with_environment_context(db_name, tbl_name, part_name, null);
-    }
-
-    @Override
-    public Partition append_partition_by_name_with_environment_context(final String db_name,
-        final String tbl_name, final String part_name, final EnvironmentContext env_context)
-        throws TException {
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startFunction("append_partition_by_name", ": tbl="
-          + TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-          tbl_name) + " part=" + part_name);
-
-      Partition ret = null;
-      Exception ex = null;
-      try {
-        RawStore ms = getMS();
-        List<String> partVals = getPartValsFromName(ms, parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name, part_name);
-        ret = append_partition_common(ms, parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name, partVals, env_context);
-      } catch (InvalidObjectException | AlreadyExistsException | MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("append_partition_by_name", ret != null, ex, tbl_name);
-      }
-      return ret;
-    }
-
-    private boolean drop_partition_by_name_core(final RawStore ms, final String catName,
-                                                final String db_name, final String tbl_name,
-                                                final String part_name, final boolean deleteData,
-                                                final EnvironmentContext envContext)
-        throws TException, IOException {
-
-      List<String> partVals;
-      try {
-        partVals = getPartValsFromName(ms, catName, db_name, tbl_name, part_name);
-      } catch (InvalidObjectException e) {
-        throw new NoSuchObjectException(e.getMessage());
-      }
-
-      return drop_partition_common(ms, catName, db_name, tbl_name, partVals, deleteData, envContext);
-    }
-
-    @Override
-    public boolean drop_partition_by_name(final String db_name, final String tbl_name,
-        final String part_name, final boolean deleteData) throws TException {
-      return drop_partition_by_name_with_environment_context(db_name, tbl_name, part_name,
-          deleteData, null);
-    }
-
-    @Override
-    public boolean drop_partition_by_name_with_environment_context(final String db_name,
-        final String tbl_name, final String part_name, final boolean deleteData,
-        final EnvironmentContext envContext) throws TException {
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startFunction("drop_partition_by_name", ": tbl=" +
-          TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name)
-          + " part=" + part_name);
-
-      boolean ret = false;
-      Exception ex = null;
-      try {
-        ret = drop_partition_by_name_core(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tbl_name, part_name, deleteData, envContext);
-      } catch (IOException e) {
-        ex = e;
-        throw new MetaException(e.getMessage());
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("drop_partition_by_name", ret, ex, tbl_name);
-      }
-
-      return ret;
-    }
-
-    @Override
-    @Deprecated
-    public List<Partition> get_partitions_ps(final String db_name,
-        final String tbl_name, final List<String> part_vals,
-        final short max_parts) throws TException {
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startPartitionFunction("get_partitions_ps", parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-          tbl_name, part_vals);
-
-      List<Partition> ret = null;
-      Exception ex = null;
-      try {
-        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-        // Don't send the parsedDbName, as this method will parse itself.
-        ret = get_partitions_ps_with_auth(db_name, tbl_name, part_vals,
-            max_parts, null, null);
-        ret = FilterUtils.filterPartitionsIfEnabled(isServerFilterEnabled, filterHook, ret);
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partitions_ps", ret != null, ex, tbl_name);
-      }
-
-      return ret;
-    }
-
-    /**
-     * Use {@link #get_partitions_ps_with_auth_req(GetPartitionsPsWithAuthRequest)} ()} instead.
-     *
-     */
-    @Override
-    @Deprecated
-    public List<Partition> get_partitions_ps_with_auth(final String db_name,
-        final String tbl_name, final List<String> part_vals,
-        final short max_parts, final String userName,
-        final List<String> groupNames) throws TException {
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startPartitionFunction("get_partitions_ps_with_auth", parsedDbName[CAT_NAME],
-          parsedDbName[DB_NAME], tbl_name, part_vals);
-      fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-      List<Partition> ret = null;
-      Exception ex = null;
-      try {
-        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-        ret = getMS().listPartitionsPsWithAuth(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tbl_name, part_vals, max_parts, userName, groupNames);
-        ret = FilterUtils.filterPartitionsIfEnabled(isServerFilterEnabled, filterHook, ret);
-      } catch (InvalidObjectException e) {
-        ex = e;
-        throw new MetaException(e.getMessage());
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partitions_ps_with_auth", ret != null, ex, tbl_name);
-      }
-      return ret;
-    }
-
-    @Override
-    public GetPartitionsPsWithAuthResponse get_partitions_ps_with_auth_req(GetPartitionsPsWithAuthRequest req)
-            throws MetaException, NoSuchObjectException, TException {
-      String dbName = MetaStoreUtils.prependCatalogToDbName(req.getCatName(), req.getDbName(), conf);
-      List<Partition> partitions = null;
-      if (req.getPartVals() == null) {
-        partitions = get_partitions_with_auth(dbName, req.getTblName(), req.getMaxParts(), req.getUserName(),
-            req.getGroupNames());
-      } else {
-        partitions =
-            get_partitions_ps_with_auth(dbName, req.getTblName(), req.getPartVals(), req.getMaxParts(),
-                req.getUserName(), req.getGroupNames());
-      }
-      GetPartitionsPsWithAuthResponse res = new GetPartitionsPsWithAuthResponse();
-      res.setPartitions(partitions);
-      return res;
-    }
-
-    /**
-     * Use {@link #get_partition_names_ps_req(GetPartitionNamesPsRequest)} ()} instead.
-     *
-     */
-    @Override
-    @Deprecated
-    public List<String> get_partition_names_ps(final String db_name,
-        final String tbl_name, final List<String> part_vals, final short max_parts)
-        throws TException {
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startPartitionFunction("get_partitions_names_ps", parsedDbName[CAT_NAME],
-          parsedDbName[DB_NAME], tbl_name, part_vals);
-      fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-      List<String> ret = null;
-      Exception ex = null;
-      try {
-        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
-        ret = getMS().listPartitionNamesPs(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name,
-            part_vals, max_parts);
-        ret = FilterUtils.filterPartitionNamesIfEnabled(isServerFilterEnabled,
-            filterHook, parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name, ret);
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partitions_names_ps", ret != null, ex, tbl_name);
-      }
-      return ret;
-    }
-
-    @Override
-    public GetPartitionNamesPsResponse get_partition_names_ps_req(GetPartitionNamesPsRequest req)
-            throws MetaException, NoSuchObjectException, TException {
-      String dbName = MetaStoreUtils.prependCatalogToDbName(req.getCatName(), req.getDbName(), conf);
-      List<String> names = get_partition_names_ps(dbName, req.getTblName(), req.getPartValues(),
-              req.getMaxParts());
-      GetPartitionNamesPsResponse res = new GetPartitionNamesPsResponse();
-      res.setNames(names);
-      return res;
-    }
-
-    @Override
-    public List<String> get_partition_names_req(PartitionsByExprRequest req)
-        throws MetaException, NoSuchObjectException, TException {
-      String catName = req.isSetCatName() ? req.getCatName() : getDefaultCatalog(conf);
-      String dbName = req.getDbName(), tblName = req.getTblName();
-      startTableFunction("get_partition_names_req", catName,
-          dbName, tblName);
-      fireReadTablePreEvent(catName, dbName, tblName);
-      List<String> ret = null;
-      Exception ex = null;
-      try {
-        authorizeTableForPartitionMetadata(catName, dbName, tblName);
-        ret = getMS().listPartitionNames(catName, dbName, tblName,
-            req.getDefaultPartitionName(), req.getExpr(), req.getOrder(), req.getMaxParts());
-        ret = FilterUtils.filterPartitionNamesIfEnabled(isServerFilterEnabled,
-            filterHook, catName, dbName, tblName, ret);
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partition_names_req", ret != null, ex, tblName);
-      }
-      return ret;
-    }
-
-    @Override
-    public List<String> partition_name_to_vals(String part_name) throws TException {
-      if (part_name.length() == 0) {
-        return Collections.emptyList();
-      }
-      LinkedHashMap<String, String> map = Warehouse.makeSpecFromName(part_name);
-      return new ArrayList<>(map.values());
-    }
-
-    @Override
-    public Map<String, String> partition_name_to_spec(String part_name) throws TException {
-      if (part_name.length() == 0) {
-        return new HashMap<>();
-      }
-      return Warehouse.makeSpecFromName(part_name);
-    }
-
-    private String lowerCaseConvertPartName(String partName) throws MetaException {
-      if (partName == null) return partName;
-      boolean isFirst = true;
-      Map<String, String> partSpec = Warehouse.makeEscSpecFromName(partName);
-      String convertedPartName = new String();
-
-      for (Map.Entry<String, String> entry : partSpec.entrySet()) {
-        String partColName = entry.getKey();
-        String partColVal = entry.getValue();
-
-        if (!isFirst) {
-          convertedPartName += "/";
-        } else {
-          isFirst = false;
-        }
-        convertedPartName += partColName.toLowerCase() + "=" + partColVal;
-      }
-      return convertedPartName;
-    }
-
-    @Override
-    @Deprecated
-    public ColumnStatistics get_table_column_statistics(String dbName, String tableName,
-      String colName) throws TException {
-      String[] parsedDbName = parseDbName(dbName, conf);
-      parsedDbName[CAT_NAME] = parsedDbName[CAT_NAME].toLowerCase();
-      parsedDbName[DB_NAME] = parsedDbName[DB_NAME].toLowerCase();
-      tableName = tableName.toLowerCase();
-      colName = colName.toLowerCase();
-      startFunction("get_column_statistics_by_table", ": table=" +
-          TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-              tableName) + " column=" + colName);
-      ColumnStatistics statsObj = null;
-      try {
-        statsObj = getMS().getTableColumnStatistics(
-            parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName, Lists.newArrayList(colName),
-            "hive", null);
-        if (statsObj != null) {
-          assert statsObj.getStatsObjSize() <= 1;
-        }
-        return statsObj;
-      } finally {
-        endFunction("get_column_statistics_by_table", statsObj != null, null, tableName);
-      }
-    }
-
-    @Override
-    public TableStatsResult get_table_statistics_req(TableStatsRequest request) throws TException {
-      String catName = request.isSetCatName() ? request.getCatName().toLowerCase() :
-          getDefaultCatalog(conf);
-      String dbName = request.getDbName().toLowerCase();
-      String tblName = request.getTblName().toLowerCase();
-      startFunction("get_table_statistics_req", ": table=" +
-          TableName.getQualified(catName, dbName, tblName));
-      TableStatsResult result = null;
-      List<String> lowerCaseColNames = new ArrayList<>(request.getColNames().size());
-      for (String colName : request.getColNames()) {
-        lowerCaseColNames.add(colName.toLowerCase());
-      }
-      try {
-        ColumnStatistics cs = getMS().getTableColumnStatistics(
-            catName, dbName, tblName, lowerCaseColNames,
-            request.getEngine(), request.getValidWriteIdList());
-        // Note: stats compliance is not propagated to the client; instead, we just return nothing
-        //       if stats are not compliant for now. This won't work for stats merging, but that
-        //       is currently only done on metastore size (see set_aggr...).
-        //       For some optimizations we might make use of incorrect stats that are "better than
-        //       nothing", so this may change in future.
-        result = new TableStatsResult((cs == null || cs.getStatsObj() == null
-            || (cs.isSetIsStatsCompliant() && !cs.isIsStatsCompliant()))
-            ? Lists.newArrayList() : cs.getStatsObj());
-      } finally {
-        endFunction("get_table_statistics_req", result == null, null, tblName);
-      }
-      return result;
-    }
-
-    @Override
-    @Deprecated
-    public ColumnStatistics get_partition_column_statistics(String dbName, String tableName,
-      String partName, String colName) throws TException {
-      // Note: this method appears to be unused within Hive.
-      //       It doesn't take txn stats into account.
-      dbName = dbName.toLowerCase();
-      String[] parsedDbName = parseDbName(dbName, conf);
-      tableName = tableName.toLowerCase();
-      colName = colName.toLowerCase();
-      String convertedPartName = lowerCaseConvertPartName(partName);
-      startFunction("get_column_statistics_by_partition", ": table=" +
-          TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-          tableName) + " partition=" + convertedPartName + " column=" + colName);
-      ColumnStatistics statsObj = null;
-
-      try {
-        List<ColumnStatistics> list = getMS().getPartitionColumnStatistics(
-            parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName,
-            Lists.newArrayList(convertedPartName), Lists.newArrayList(colName),
-            "hive");
-        if (list.isEmpty()) {
-          return null;
-        }
-        if (list.size() != 1) {
-          throw new MetaException(list.size() + " statistics for single column and partition");
-        }
-        statsObj = list.get(0);
-      } finally {
-        endFunction("get_column_statistics_by_partition", statsObj != null, null, tableName);
-      }
-      return statsObj;
-    }
-
-    @Override
-    public PartitionsStatsResult get_partitions_statistics_req(PartitionsStatsRequest request)
-        throws TException {
-      String catName = request.isSetCatName() ? request.getCatName().toLowerCase() : getDefaultCatalog(conf);
-      String dbName = request.getDbName().toLowerCase();
-      String tblName = request.getTblName().toLowerCase();
-      startFunction("get_partitions_statistics_req", ": table=" +
-          TableName.getQualified(catName, dbName, tblName));
-
-      PartitionsStatsResult result = null;
-      List<String> lowerCaseColNames = new ArrayList<>(request.getColNames().size());
-      for (String colName : request.getColNames()) {
-        lowerCaseColNames.add(colName.toLowerCase());
-      }
-      List<String> lowerCasePartNames = new ArrayList<>(request.getPartNames().size());
-      for (String partName : request.getPartNames()) {
-        lowerCasePartNames.add(lowerCaseConvertPartName(partName));
-      }
-      try {
-        List<ColumnStatistics> stats = getMS().getPartitionColumnStatistics(
-            catName, dbName, tblName, lowerCasePartNames, lowerCaseColNames,
-            request.getEngine(), request.isSetValidWriteIdList() ? request.getValidWriteIdList() : null);
-        Map<String, List<ColumnStatisticsObj>> map = new HashMap<>();
-        if (stats != null) {
-          for (ColumnStatistics stat : stats) {
-            // Note: stats compliance is not propagated to the client; instead, we just return nothing
-            //       if stats are not compliant for now. This won't work for stats merging, but that
-            //       is currently only done on metastore size (see set_aggr...).
-            //       For some optimizations we might make use of incorrect stats that are "better than
-            //       nothing", so this may change in future.
-            if (stat.isSetIsStatsCompliant() && !stat.isIsStatsCompliant()) continue;
-            map.put(stat.getStatsDesc().getPartName(), stat.getStatsObj());
-          }
-        }
-        result = new PartitionsStatsResult(map);
-      } finally {
-        endFunction("get_partitions_statistics_req", result == null, null, tblName);
-      }
-      return result;
-    }
-
-    @Override
-    public boolean update_table_column_statistics(ColumnStatistics colStats) throws TException {
-      // Deprecated API, won't work for transactional tables
-      return updateTableColumnStatsInternal(colStats, null, -1);
-    }
-
-    @Override
-    public SetPartitionsStatsResponse update_table_column_statistics_req(
-        SetPartitionsStatsRequest req) throws NoSuchObjectException,
-        InvalidObjectException, MetaException, InvalidInputException,
-        TException {
-      if (req.getColStatsSize() != 1) {
-        throw new InvalidInputException("Only one stats object expected");
-      }
-      if (req.isNeedMerge()) {
-        throw new InvalidInputException("Merge is not supported for non-aggregate stats");
-      }
-      ColumnStatistics colStats = req.getColStatsIterator().next();
-      boolean ret = updateTableColumnStatsInternal(colStats,
-          req.getValidWriteIdList(), req.getWriteId());
-      return new SetPartitionsStatsResponse(ret);
-    }
-
-    private boolean updateTableColumnStatsInternal(ColumnStatistics colStats,
-        String validWriteIds, long writeId)
-        throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException {
-      normalizeColStatsInput(colStats);
-
-      startFunction("write_column_statistics", ":  table=" + TableName.getQualified(
-          colStats.getStatsDesc().getCatName(), colStats.getStatsDesc().getDbName(),
-          colStats.getStatsDesc().getTableName()));
-
-      Map<String, String> parameters = null;
-      getMS().openTransaction();
-      boolean committed = false;
-      try {
-        parameters = getMS().updateTableColumnStatistics(colStats, validWriteIds, writeId);
-        if (parameters != null) {
-          Table tableObj = getMS().getTable(colStats.getStatsDesc().getCatName(),
-                                            colStats.getStatsDesc().getDbName(),
-                                            colStats.getStatsDesc().getTableName(), validWriteIds);
-          if (transactionalListeners != null && !transactionalListeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                    EventType.UPDATE_TABLE_COLUMN_STAT,
-                    new UpdateTableColumnStatEvent(colStats, tableObj, parameters,
-                            writeId, this));
-          }
-          if (!listeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(listeners,
-                    EventType.UPDATE_TABLE_COLUMN_STAT,
-                    new UpdateTableColumnStatEvent(colStats, tableObj, parameters,
-                            writeId,this));
-          }
-        }
-        committed = getMS().commitTransaction();
-      } finally {
-        if (!committed) {
-          getMS().rollbackTransaction();
-        }
-        endFunction("write_column_statistics", parameters != null, null,
-            colStats.getStatsDesc().getTableName());
-      }
-
-      return parameters != null;
-    }
-
-    private void normalizeColStatsInput(ColumnStatistics colStats) throws MetaException {
-      // TODO: is this really needed? this code is propagated from HIVE-1362 but most of it is useless.
-      ColumnStatisticsDesc statsDesc = colStats.getStatsDesc();
-      statsDesc.setCatName(statsDesc.isSetCatName() ? statsDesc.getCatName().toLowerCase() : getDefaultCatalog(conf));
-      statsDesc.setDbName(statsDesc.getDbName().toLowerCase());
-      statsDesc.setTableName(statsDesc.getTableName().toLowerCase());
-      statsDesc.setPartName(lowerCaseConvertPartName(statsDesc.getPartName()));
-      long time = System.currentTimeMillis() / 1000;
-      statsDesc.setLastAnalyzed(time);
-
-      for (ColumnStatisticsObj statsObj : colStats.getStatsObj()) {
-        statsObj.setColName(statsObj.getColName().toLowerCase());
-        statsObj.setColType(statsObj.getColType().toLowerCase());
-      }
-      colStats.setStatsDesc(statsDesc);
-      colStats.setStatsObj(colStats.getStatsObj());
-    }
-
-    private boolean updatePartitonColStatsInternal(Table tbl, ColumnStatistics colStats,
-        String validWriteIds, long writeId)
-        throws MetaException, InvalidObjectException, NoSuchObjectException, InvalidInputException {
-      normalizeColStatsInput(colStats);
-
-      ColumnStatisticsDesc csd = colStats.getStatsDesc();
-      String catName = csd.getCatName(), dbName = csd.getDbName(), tableName = csd.getTableName();
-      startFunction("write_partition_column_statistics", ":  db=" + dbName  + " table=" + tableName
-              + " part=" + csd.getPartName());
-
-      boolean ret = false;
-
-      Map<String, String> parameters;
-      List<String> partVals;
-      boolean committed = false;
-      getMS().openTransaction();
-      try {
-        if (tbl == null) {
-          tbl = getTable(catName, dbName, tableName);
-        }
-        partVals = getPartValsFromName(tbl, csd.getPartName());
-        parameters = getMS().updatePartitionColumnStatistics(colStats, partVals, validWriteIds, writeId);
-        if (parameters != null) {
-          if (transactionalListeners != null && !transactionalListeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-              EventType.UPDATE_PARTITION_COLUMN_STAT,
-              new UpdatePartitionColumnStatEvent(colStats, partVals, parameters, tbl,
-                      writeId, this));
-          }
-          if (!listeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(listeners,
-              EventType.UPDATE_PARTITION_COLUMN_STAT,
-              new UpdatePartitionColumnStatEvent(colStats, partVals, parameters, tbl,
-                      writeId, this));
-          }
-        }
-        committed = getMS().commitTransaction();
-      } finally {
-        if (!committed) {
-          getMS().rollbackTransaction();
-        }
-        endFunction("write_partition_column_statistics", ret != false, null, tableName);
-      }
-
-      return parameters != null;
-    }
-
-    @Override
-    public boolean update_partition_column_statistics(ColumnStatistics colStats) throws TException {
-      // Deprecated API.
-      return updatePartitonColStatsInternal(null, colStats, null, -1);
-    }
-
-
-    @Override
-    public SetPartitionsStatsResponse update_partition_column_statistics_req(
-        SetPartitionsStatsRequest req) throws NoSuchObjectException,
-        InvalidObjectException, MetaException, InvalidInputException,
-        TException {
-      if (req.getColStatsSize() != 1) {
-        throw new InvalidInputException("Only one stats object expected");
-      }
-      if (req.isNeedMerge()) {
-        throw new InvalidInputException("Merge is not supported for non-aggregate stats");
-      }
-      ColumnStatistics colStats = req.getColStatsIterator().next();
-      boolean ret = updatePartitonColStatsInternal(null, colStats,
-          req.getValidWriteIdList(), req.getWriteId());
-      return new SetPartitionsStatsResponse(ret);
-    }
-
-    @Override
-    public boolean delete_partition_column_statistics(String dbName, String tableName,
-        String partName, String colName, String engine) throws TException {
-      dbName = dbName.toLowerCase();
-      String[] parsedDbName = parseDbName(dbName, conf);
-      tableName = tableName.toLowerCase();
-      if (colName != null) {
-        colName = colName.toLowerCase();
-      }
-      String convertedPartName = lowerCaseConvertPartName(partName);
-      startFunction("delete_column_statistics_by_partition",": table=" +
-          TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName) +
-          " partition=" + convertedPartName + " column=" + colName);
-      boolean ret = false, committed = false;
-
-      getMS().openTransaction();
-      try {
-        List<String> partVals = getPartValsFromName(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName, convertedPartName);
-        Table table = getMS().getTable(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName);
-        // This API looks unused; if it were used we'd need to update stats state and write ID.
-        // We cannot just randomly nuke some txn stats.
-        if (TxnUtils.isTransactionalTable(table)) {
-          throw new MetaException("Cannot delete stats via this API for a transactional table");
-        }
-
-        ret = getMS().deletePartitionColumnStatistics(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName,
-            convertedPartName, partVals, colName, engine);
-        if (ret) {
-          if (transactionalListeners != null && !transactionalListeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                    EventType.DELETE_PARTITION_COLUMN_STAT,
-                    new DeletePartitionColumnStatEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName,
-                            convertedPartName, partVals, colName, engine, this));
-          }
-          if (!listeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(listeners,
-                    EventType.DELETE_PARTITION_COLUMN_STAT,
-                    new DeletePartitionColumnStatEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName,
-                            convertedPartName, partVals, colName, engine, this));
-          }
-        }
-        committed = getMS().commitTransaction();
-      } finally {
-        if (!committed) {
-          getMS().rollbackTransaction();
-        }
-        endFunction("delete_column_statistics_by_partition", ret != false, null, tableName);
-      }
-      return ret;
-    }
-
-    @Override
-    public boolean delete_table_column_statistics(String dbName, String tableName, String colName, String engine)
-        throws TException {
-      dbName = dbName.toLowerCase();
-      tableName = tableName.toLowerCase();
-
-      String[] parsedDbName = parseDbName(dbName, conf);
-
-      if (colName != null) {
-        colName = colName.toLowerCase();
-      }
-      startFunction("delete_column_statistics_by_table", ": table=" +
-          TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName) + " column=" +
-          colName);
-
-
-      boolean ret = false, committed = false;
-      getMS().openTransaction();
-      try {
-        Table table = getMS().getTable(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName);
-        // This API looks unused; if it were used we'd need to update stats state and write ID.
-        // We cannot just randomly nuke some txn stats.
-        if (TxnUtils.isTransactionalTable(table)) {
-          throw new MetaException("Cannot delete stats via this API for a transactional table");
-        }
-
-        ret = getMS().deleteTableColumnStatistics(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName, colName, engine);
-        if (ret) {
-          if (transactionalListeners != null && !transactionalListeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                    EventType.DELETE_TABLE_COLUMN_STAT,
-                    new DeleteTableColumnStatEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-                            tableName, colName, engine, this));
-          }
-          if (!listeners.isEmpty()) {
-            MetaStoreListenerNotifier.notifyEvent(listeners,
-                    EventType.DELETE_TABLE_COLUMN_STAT,
-                    new DeleteTableColumnStatEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-                            tableName, colName, engine, this));
-          }
-        }
-        committed = getMS().commitTransaction();
-      } finally {
-        if (!committed) {
-          getMS().rollbackTransaction();
-        }
-        endFunction("delete_column_statistics_by_table", ret != false, null, tableName);
-      }
-      return ret;
-    }
-
-    @Override
-    @Deprecated
-    public List<Partition> get_partitions_by_filter(final String dbName, final String tblName,
-                                                    final String filter, final short maxParts)
-        throws TException {
-      String[] parsedDbName = parseDbName(dbName, conf);
-      startTableFunction("get_partitions_by_filter", parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-          tblName);
-      fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName);
-      List<Partition> ret = null;
-      Exception ex = null;
-      try {
-        checkLimitNumberOfPartitionsByFilter(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tblName, filter, maxParts);
-
-        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName);
-
-        ret = getMS().getPartitionsByFilter(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName,
-            filter, maxParts);
-        ret = FilterUtils.filterPartitionsIfEnabled(isServerFilterEnabled, filterHook, ret);
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partitions_by_filter", ret != null, ex, tblName);
-      }
-      return ret;
-    }
-
-    @Override
-    @Deprecated
-    public List<PartitionSpec> get_part_specs_by_filter(final String dbName, final String tblName,
-                                                        final String filter, final int maxParts)
-        throws TException {
-
-      String[] parsedDbName = parseDbName(dbName, conf);
-      startTableFunction("get_partitions_by_filter_pspec", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName);
-
-      List<PartitionSpec> partitionSpecs = null;
-      try {
-        Table table = get_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName);
-        // Don't pass the parsed db name, as get_partitions_by_filter will parse it itself
-        List<Partition> partitions = get_partitions_by_filter(dbName, tblName, filter, (short) maxParts);
-
-        if (is_partition_spec_grouping_enabled(table)) {
-          partitionSpecs = MetaStoreServerUtils
-              .getPartitionspecsGroupedByStorageDescriptor(table, partitions);
-        }
-        else {
-          PartitionSpec pSpec = new PartitionSpec();
-          pSpec.setPartitionList(new PartitionListComposingSpec(partitions));
-          pSpec.setRootPath(table.getSd().getLocation());
-          pSpec.setCatName(parsedDbName[CAT_NAME]);
-          pSpec.setDbName(parsedDbName[DB_NAME]);
-          pSpec.setTableName(tblName);
-          partitionSpecs = Arrays.asList(pSpec);
-        }
-
-        return partitionSpecs;
-      }
-      finally {
-        endFunction("get_partitions_by_filter_pspec", partitionSpecs != null && !partitionSpecs.isEmpty(), null, tblName);
-      }
-    }
-
-    @Override
-    public PartitionsSpecByExprResult get_partitions_spec_by_expr(
-        PartitionsByExprRequest req) throws TException {
-      String dbName = req.getDbName(), tblName = req.getTblName();
-      String catName = req.isSetCatName() ? req.getCatName() : getDefaultCatalog(conf);
-      startTableFunction("get_partitions_spec_by_expr", catName, dbName, tblName);
-      fireReadTablePreEvent(catName, dbName, tblName);
-      PartitionsSpecByExprResult ret = null;
-      Exception ex = null;
-      try {
-        checkLimitNumberOfPartitionsByExpr(catName, dbName, tblName, req.getExpr(), UNLIMITED_MAX_PARTITIONS);
-        List<Partition> partitions = new LinkedList<>();
-        boolean hasUnknownPartitions = getMS().getPartitionsByExpr(catName, dbName, tblName,
-            req.getExpr(), req.getDefaultPartitionName(), req.getMaxParts(), partitions);
-        Table table = get_table_core(catName, dbName, tblName);
-        List<PartitionSpec> partitionSpecs =
-            MetaStoreServerUtils.getPartitionspecsGroupedByStorageDescriptor(table, partitions);
-        ret = new PartitionsSpecByExprResult(partitionSpecs, hasUnknownPartitions);
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partitions_spec_by_expr", ret != null, ex, tblName);
-      }
-      return ret;
-    }
-
-    @Override
-    public PartitionsByExprResult get_partitions_by_expr(
-        PartitionsByExprRequest req) throws TException {
-      String dbName = req.getDbName(), tblName = req.getTblName();
-      String catName = req.isSetCatName() ? req.getCatName() : getDefaultCatalog(conf);
-      startTableFunction("get_partitions_by_expr", catName, dbName, tblName);
-      fireReadTablePreEvent(catName, dbName, tblName);
-      PartitionsByExprResult ret = null;
-      Exception ex = null;
-      try {
-        checkLimitNumberOfPartitionsByExpr(catName, dbName, tblName, req.getExpr(), UNLIMITED_MAX_PARTITIONS);
-        List<Partition> partitions = new LinkedList<>();
-        boolean hasUnknownPartitions = getMS().getPartitionsByExpr(catName, dbName, tblName,
-            req.getExpr(), req.getDefaultPartitionName(), req.getMaxParts(), partitions);
-        ret = new PartitionsByExprResult(partitions, hasUnknownPartitions);
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_partitions_by_expr", ret != null, ex, tblName);
-      }
-      return ret;
-    }
-
-    private void rethrowException(Exception e) throws TException {
-      // TODO: Both of these are TException, why do we need these separate clauses?
-      if (e instanceof MetaException) {
-        throw (MetaException) e;
-      } else if (e instanceof NoSuchObjectException) {
-        throw (NoSuchObjectException) e;
-      } else if (e instanceof TException) {
-        throw (TException) e;
-      } else {
-        throw newMetaException(e);
-      }
-    }
-
-    @Override
-    @Deprecated
-    public int get_num_partitions_by_filter(final String dbName,
-                                            final String tblName, final String filter)
-            throws TException {
-      String[] parsedDbName = parseDbName(dbName, conf);
-      if (parsedDbName[DB_NAME] == null || tblName == null) {
-        throw new MetaException("The DB and table name cannot be null.");
-      }
-      startTableFunction("get_num_partitions_by_filter", parsedDbName[CAT_NAME],
-          parsedDbName[DB_NAME], tblName);
-
-      int ret = -1;
-      Exception ex = null;
-      try {
-        ret = getMS().getNumPartitionsByFilter(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tblName, filter);
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_num_partitions_by_filter", ret != -1, ex, tblName);
-      }
-      return ret;
-    }
-
-    private int get_num_partitions_by_expr(final String catName, final String dbName,
-                                           final String tblName, final byte[] expr)
-        throws TException {
-      int ret = -1;
-      Exception ex = null;
-      try {
-        ret = getMS().getNumPartitionsByExpr(catName, dbName, tblName, expr);
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_num_partitions_by_expr", ret != -1, ex, tblName);
-      }
-      return ret;
-    }
-
-    @Override
-    @Deprecated
-    public List<Partition> get_partitions_by_names(final String dbName, final String tblName,
-                                                   final List<String> partNames)
-            throws TException {
-      return get_partitions_by_names(dbName, tblName, partNames);
-    }
-
-    @Override
-    public GetPartitionsByNamesResult get_partitions_by_names_req(GetPartitionsByNamesRequest gpbnr)
-            throws TException {
-      List<Partition> partitions = get_partitions_by_names(gpbnr.getDb_name(),
-              gpbnr.getTbl_name(), gpbnr.getNames(),
-              gpbnr.isSetGet_col_stats() && gpbnr.isGet_col_stats(), gpbnr.getEngine(),
-              gpbnr.getProcessorCapabilities(), gpbnr.getProcessorIdentifier());
-      return new GetPartitionsByNamesResult(partitions);
-    }
-
-    public List<Partition> get_partitions_by_names(final String dbName, final String tblName,
-           final List<String> partNames, boolean getColStats, String engine, String validWriteIdList)
-        throws TException {
-      return get_partitions_by_names(
-          dbName, tblName, partNames, getColStats, engine, null, null);
-    }
-
-    public List<Partition> get_partitions_by_names(final String dbName, final String tblName,
-           final List<String> partNames, boolean getColStats, String engine,
-           List<String> processorCapabilities, String processorId) throws TException {
-
-      String[] dbNameParts = parseDbName(dbName, conf);
-      String parsedCatName = dbNameParts[CAT_NAME];
-      String parsedDbName = dbNameParts[DB_NAME];
-      List<Partition> ret = null;
-      Table table = null;
-      Exception ex = null;
-      boolean success = false;
-      startTableFunction("get_partitions_by_names", parsedCatName, parsedDbName,
-              tblName);
-      try {
-        getMS().openTransaction();
-        authorizeTableForPartitionMetadata(parsedCatName, parsedDbName, tblName);
-
-        fireReadTablePreEvent(parsedCatName, parsedDbName, tblName);
-
-        ret = getMS().getPartitionsByNames(parsedCatName, parsedDbName, tblName, partNames);
-        ret = FilterUtils.filterPartitionsIfEnabled(isServerFilterEnabled, filterHook, ret);
-        table = getTable(parsedCatName, parsedDbName, tblName);
-
-        // If requested add column statistics in each of the partition objects
-        if (getColStats) {
-          // Since each partition may have stats collected for different set of columns, we
-          // request them separately.
-          for (Partition part: ret) {
-            String partName = Warehouse.makePartName(table.getPartitionKeys(), part.getValues());
-            List<ColumnStatistics> partColStatsList =
-                    getMS().getPartitionColumnStatistics(parsedCatName, parsedDbName, tblName,
-                            Collections.singletonList(partName),
-                            StatsSetupConst.getColumnsHavingStats(part.getParameters()),
-                            engine);
-            if (partColStatsList != null && !partColStatsList.isEmpty()) {
-              ColumnStatistics partColStats = partColStatsList.get(0);
-              if (partColStats != null) {
-                part.setColStats(partColStats);
-              }
-            }
-          }
-        }
-
-        if (processorCapabilities == null || processorCapabilities.size() == 0 ||
-              processorCapabilities.contains("MANAGERAWMETADATA")) {
-          LOG.info("Skipping translation for processor with " + processorId);
-        } else {
-          if (transformer != null) {
-            ret = transformer.transformPartitions(ret, table, processorCapabilities, processorId);
-          }
-        }
-        success = getMS().commitTransaction();
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        if (!success) {
-          getMS().rollbackTransaction();
-        }
-        endFunction("get_partitions_by_names", ret != null, ex, tblName);
-      }
-      return ret;
-    }
-
-    @Override
-    public PrincipalPrivilegeSet get_privilege_set(HiveObjectRef hiveObject, String userName,
-                                                   List<String> groupNames) throws TException {
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      String catName = hiveObject.isSetCatName() ? hiveObject.getCatName() : getDefaultCatalog(conf);
-      if (hiveObject.getObjectType() == HiveObjectType.COLUMN) {
-        String partName = getPartName(hiveObject);
-        return this.get_column_privilege_set(catName, hiveObject.getDbName(), hiveObject
-            .getObjectName(), partName, hiveObject.getColumnName(), userName,
-            groupNames);
-      } else if (hiveObject.getObjectType() == HiveObjectType.PARTITION) {
-        String partName = getPartName(hiveObject);
-        return this.get_partition_privilege_set(catName, hiveObject.getDbName(),
-            hiveObject.getObjectName(), partName, userName, groupNames);
-      } else if (hiveObject.getObjectType() == HiveObjectType.DATABASE) {
-        return this.get_db_privilege_set(catName, hiveObject.getDbName(), userName,
-            groupNames);
-      } else if (hiveObject.getObjectType() == HiveObjectType.TABLE) {
-        return this.get_table_privilege_set(catName, hiveObject.getDbName(), hiveObject
-            .getObjectName(), userName, groupNames);
-      } else if (hiveObject.getObjectType() == HiveObjectType.GLOBAL) {
-        return this.get_user_privilege_set(userName, groupNames);
-      }
-      return null;
-    }
-
-    private String getPartName(HiveObjectRef hiveObject) throws MetaException {
-      String partName = null;
-      List<String> partValue = hiveObject.getPartValues();
-      if (partValue != null && partValue.size() > 0) {
-        try {
-          String catName = hiveObject.isSetCatName() ? hiveObject.getCatName() :
-              getDefaultCatalog(conf);
-          Table table = get_table_core(catName, hiveObject.getDbName(), hiveObject
-              .getObjectName());
-          partName = Warehouse
-              .makePartName(table.getPartitionKeys(), partValue);
-        } catch (NoSuchObjectException e) {
-          throw new MetaException(e.getMessage());
-        }
-      }
-      return partName;
-    }
-
-    private PrincipalPrivilegeSet get_column_privilege_set(String catName, final String dbName,
-        final String tableName, final String partName, final String columnName,
-        final String userName, final List<String> groupNames) throws TException {
-      incrementCounter("get_column_privilege_set");
-
-      PrincipalPrivilegeSet ret;
-      try {
-        ret = getMS().getColumnPrivilegeSet(
-            catName, dbName, tableName, partName, columnName, userName, groupNames);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-      return ret;
-    }
-
-    private PrincipalPrivilegeSet get_db_privilege_set(String catName, final String dbName,
-        final String userName, final List<String> groupNames) throws TException {
-      incrementCounter("get_db_privilege_set");
-
-      PrincipalPrivilegeSet ret;
-      try {
-        ret = getMS().getDBPrivilegeSet(catName, dbName, userName, groupNames);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-      return ret;
-    }
-
-    private PrincipalPrivilegeSet get_partition_privilege_set(
-        String catName, final String dbName, final String tableName, final String partName,
-        final String userName, final List<String> groupNames)
-        throws TException {
-      incrementCounter("get_partition_privilege_set");
-
-      PrincipalPrivilegeSet ret;
-      try {
-        ret = getMS().getPartitionPrivilegeSet(catName, dbName, tableName, partName,
-            userName, groupNames);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-      return ret;
-    }
-
-    private PrincipalPrivilegeSet get_table_privilege_set(String catName, final String dbName,
-        final String tableName, final String userName,
-        final List<String> groupNames) throws TException {
-      incrementCounter("get_table_privilege_set");
-
-      PrincipalPrivilegeSet ret;
-      try {
-        ret = getMS().getTablePrivilegeSet(catName, dbName, tableName, userName,
-            groupNames);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-      return ret;
-    }
-
-    @Override
-    public boolean grant_role(final String roleName,
-        final String principalName, final PrincipalType principalType,
-        final String grantor, final PrincipalType grantorType, final boolean grantOption)
-        throws TException {
-      incrementCounter("add_role_member");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      if (PUBLIC.equals(roleName)) {
-        throw new MetaException("No user can be added to " + PUBLIC +". Since all users implicitly"
-        + " belong to " + PUBLIC + " role.");
-      }
-      Boolean ret;
-      try {
-        RawStore ms = getMS();
-        Role role = ms.getRole(roleName);
-        if(principalType == PrincipalType.ROLE){
-          //check if this grant statement will end up creating a cycle
-          if(isNewRoleAParent(principalName, roleName)){
-            throw new MetaException("Cannot grant role " + principalName + " to " + roleName +
-                " as " + roleName + " already belongs to the role " + principalName +
-                ". (no cycles allowed)");
-          }
-        }
-        ret = ms.grantRole(role, principalName, principalType, grantor, grantorType, grantOption);
-      } catch (MetaException e) {
-        throw e;
-      } catch (InvalidObjectException | NoSuchObjectException e) {
-        ret = false;
-        MetaStoreUtils.logAndThrowMetaException(e);
-      } catch (Exception e) {
-        throw new TException(e);
-      }
-      return ret;
-    }
-
-
-
-    /**
-     * Check if newRole is in parent hierarchy of curRole
-     * @param newRole
-     * @param curRole
-     * @return true if newRole is curRole or present in its hierarchy
-     * @throws MetaException
-     */
-    private boolean isNewRoleAParent(String newRole, String curRole) throws MetaException {
-      if(newRole.equals(curRole)){
-        return true;
-      }
-      //do this check recursively on all the parent roles of curRole
-      List<Role> parentRoleMaps = getMS().listRoles(curRole, PrincipalType.ROLE);
-      for(Role parentRole : parentRoleMaps){
-        if(isNewRoleAParent(newRole, parentRole.getRoleName())){
-          return true;
-        }
-      }
-      return false;
-    }
-
-    @Override
-    public List<Role> list_roles(final String principalName,
-        final PrincipalType principalType) throws TException {
-      incrementCounter("list_roles");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      return getMS().listRoles(principalName, principalType);
-    }
-
-    @Override
-    public boolean create_role(final Role role) throws TException {
-      incrementCounter("create_role");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      if (PUBLIC.equals(role.getRoleName())) {
-         throw new MetaException(PUBLIC + " role implicitly exists. It can't be created.");
-      }
-      Boolean ret;
-      try {
-        ret = getMS().addRole(role.getRoleName(), role.getOwnerName());
-      } catch (MetaException e) {
-        throw e;
-      } catch (InvalidObjectException | NoSuchObjectException e) {
-        ret = false;
-        MetaStoreUtils.logAndThrowMetaException(e);
-      } catch (Exception e) {
-        throw new TException(e);
-      }
-      return ret;
-    }
-
-    @Override
-    public boolean drop_role(final String roleName) throws TException {
-      incrementCounter("drop_role");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      if (ADMIN.equals(roleName) || PUBLIC.equals(roleName)) {
-        throw new MetaException(PUBLIC + "," + ADMIN + " roles can't be dropped.");
-      }
-      Boolean ret;
-      try {
-        ret = getMS().removeRole(roleName);
-      } catch (MetaException e) {
-        throw e;
-      } catch (NoSuchObjectException e) {
-        ret = false;
-        MetaStoreUtils.logAndThrowMetaException(e);
-      } catch (Exception e) {
-        throw new TException(e);
-      }
-      return ret;
-    }
-
-    @Override
-    public List<String> get_role_names() throws TException {
-      incrementCounter("get_role_names");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      List<String> ret;
-      try {
-        ret = getMS().listRoleNames();
-        return ret;
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-    }
-
-    @Override
-    public boolean grant_privileges(final PrivilegeBag privileges) throws TException {
-      incrementCounter("grant_privileges");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      Boolean ret;
-      try {
-        ret = getMS().grantPrivileges(privileges);
-      } catch (MetaException e) {
-        throw e;
-      } catch (InvalidObjectException | NoSuchObjectException e) {
-        ret = false;
-        MetaStoreUtils.logAndThrowMetaException(e);
-      } catch (Exception e) {
-        throw new TException(e);
-      }
-      return ret;
-    }
-
-    @Override
-    public boolean revoke_role(final String roleName, final String userName,
-        final PrincipalType principalType) throws TException {
-      return revoke_role(roleName, userName, principalType, false);
-    }
-
-    private boolean revoke_role(final String roleName, final String userName,
-        final PrincipalType principalType, boolean grantOption) throws TException {
-      incrementCounter("remove_role_member");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      if (PUBLIC.equals(roleName)) {
-        throw new MetaException(PUBLIC + " role can't be revoked.");
-      }
-      Boolean ret;
-      try {
-        RawStore ms = getMS();
-        Role mRole = ms.getRole(roleName);
-        ret = ms.revokeRole(mRole, userName, principalType, grantOption);
-      } catch (MetaException e) {
-        throw e;
-      } catch (NoSuchObjectException e) {
-        ret = false;
-        MetaStoreUtils.logAndThrowMetaException(e);
-      } catch (Exception e) {
-        throw new TException(e);
-      }
-      return ret;
-    }
-
-    @Override
-    public GrantRevokeRoleResponse grant_revoke_role(GrantRevokeRoleRequest request)
-        throws TException {
-      GrantRevokeRoleResponse response = new GrantRevokeRoleResponse();
-      boolean grantOption = false;
-      if (request.isSetGrantOption()) {
-        grantOption = request.isGrantOption();
-      }
-      switch (request.getRequestType()) {
-        case GRANT: {
-          boolean result = grant_role(request.getRoleName(),
-              request.getPrincipalName(), request.getPrincipalType(),
-              request.getGrantor(), request.getGrantorType(), grantOption);
-          response.setSuccess(result);
-          break;
-        }
-        case REVOKE: {
-          boolean result = revoke_role(request.getRoleName(), request.getPrincipalName(),
-              request.getPrincipalType(), grantOption);
-          response.setSuccess(result);
-          break;
-        }
-        default:
-          throw new MetaException("Unknown request type " + request.getRequestType());
-      }
-
-      return response;
-    }
-
-    @Override
-    public GrantRevokePrivilegeResponse grant_revoke_privileges(GrantRevokePrivilegeRequest request)
-        throws TException {
-      GrantRevokePrivilegeResponse response = new GrantRevokePrivilegeResponse();
-      switch (request.getRequestType()) {
-        case GRANT: {
-          boolean result = grant_privileges(request.getPrivileges());
-          response.setSuccess(result);
-          break;
-        }
-        case REVOKE: {
-          boolean revokeGrantOption = false;
-          if (request.isSetRevokeGrantOption()) {
-            revokeGrantOption = request.isRevokeGrantOption();
-          }
-          boolean result = revoke_privileges(request.getPrivileges(), revokeGrantOption);
-          response.setSuccess(result);
-          break;
-        }
-        default:
-          throw new MetaException("Unknown request type " + request.getRequestType());
-      }
-
-      return response;
-    }
-
-    @Override
-    public GrantRevokePrivilegeResponse refresh_privileges(HiveObjectRef objToRefresh, String authorizer,
-        GrantRevokePrivilegeRequest grantRequest)
-        throws TException {
-      incrementCounter("refresh_privileges");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      GrantRevokePrivilegeResponse response = new GrantRevokePrivilegeResponse();
-      try {
-        boolean result = getMS().refreshPrivileges(objToRefresh, authorizer, grantRequest.getPrivileges());
-        response.setSuccess(result);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-      return response;
-    }
-
-    @Override
-    public boolean revoke_privileges(final PrivilegeBag privileges) throws TException {
-      return revoke_privileges(privileges, false);
-    }
-
-    public boolean revoke_privileges(final PrivilegeBag privileges, boolean grantOption)
-        throws TException {
-      incrementCounter("revoke_privileges");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      Boolean ret;
-      try {
-        ret = getMS().revokePrivileges(privileges, grantOption);
-      } catch (MetaException e) {
-        throw e;
-      } catch (InvalidObjectException | NoSuchObjectException e) {
-        ret = false;
-        MetaStoreUtils.logAndThrowMetaException(e);
-      } catch (Exception e) {
-        throw new TException(e);
-      }
-      return ret;
-    }
-
-    private PrincipalPrivilegeSet get_user_privilege_set(final String userName,
-        final List<String> groupNames) throws TException {
-      incrementCounter("get_user_privilege_set");
-      PrincipalPrivilegeSet ret;
-      try {
-        ret = getMS().getUserPrivilegeSet(userName, groupNames);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-      return ret;
-    }
-
-    @Override
-    public List<HiveObjectPrivilege> list_privileges(String principalName,
-        PrincipalType principalType, HiveObjectRef hiveObject)
-        throws TException {
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      String catName = hiveObject.isSetCatName() ? hiveObject.getCatName() : getDefaultCatalog(conf);
-      if (hiveObject.getObjectType() == null) {
-        return getAllPrivileges(principalName, principalType, catName);
-      }
-      if (hiveObject.getObjectType() == HiveObjectType.GLOBAL) {
-        return list_global_privileges(principalName, principalType);
-      }
-      if (hiveObject.getObjectType() == HiveObjectType.DATABASE) {
-        return list_db_privileges(principalName, principalType, catName, hiveObject
-            .getDbName());
-      }
-      if (hiveObject.getObjectType() == HiveObjectType.TABLE) {
-        return list_table_privileges(principalName, principalType,
-            catName, hiveObject.getDbName(), hiveObject.getObjectName());
-      }
-      if (hiveObject.getObjectType() == HiveObjectType.PARTITION) {
-        return list_partition_privileges(principalName, principalType,
-            catName, hiveObject.getDbName(), hiveObject.getObjectName(), hiveObject
-            .getPartValues());
-      }
-      if (hiveObject.getObjectType() == HiveObjectType.COLUMN) {
-        if (hiveObject.getPartValues() == null || hiveObject.getPartValues().isEmpty()) {
-          return list_table_column_privileges(principalName, principalType,
-              catName, hiveObject.getDbName(), hiveObject.getObjectName(), hiveObject.getColumnName());
-        }
-        return list_partition_column_privileges(principalName, principalType,
-            catName, hiveObject.getDbName(), hiveObject.getObjectName(), hiveObject
-            .getPartValues(), hiveObject.getColumnName());
-      }
-      return null;
-    }
-
-    private List<HiveObjectPrivilege> getAllPrivileges(String principalName,
-        PrincipalType principalType, String catName) throws TException {
-      List<HiveObjectPrivilege> privs = new ArrayList<>();
-      privs.addAll(list_global_privileges(principalName, principalType));
-      privs.addAll(list_db_privileges(principalName, principalType, catName, null));
-      privs.addAll(list_table_privileges(principalName, principalType, catName, null, null));
-      privs.addAll(list_partition_privileges(principalName, principalType, catName, null, null, null));
-      privs.addAll(list_table_column_privileges(principalName, principalType, catName, null, null, null));
-      privs.addAll(list_partition_column_privileges(principalName, principalType,
-          catName, null, null, null, null));
-      return privs;
-    }
-
-    private List<HiveObjectPrivilege> list_table_column_privileges(
-        final String principalName, final PrincipalType principalType, String catName,
-        final String dbName, final String tableName, final String columnName) throws TException {
-      incrementCounter("list_table_column_privileges");
-
-      try {
-        if (dbName == null) {
-          return getMS().listPrincipalTableColumnGrantsAll(principalName, principalType);
-        }
-        if (principalName == null) {
-          return getMS().listTableColumnGrantsAll(catName, dbName, tableName, columnName);
-        }
-        return getMS().listPrincipalTableColumnGrants(principalName, principalType,
-                catName, dbName, tableName, columnName);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-    }
-
-    private List<HiveObjectPrivilege> list_partition_column_privileges(
-        final String principalName, final PrincipalType principalType,
-        String catName, final String dbName, final String tableName, final List<String> partValues,
-        final String columnName) throws TException {
-      incrementCounter("list_partition_column_privileges");
-
-      try {
-        if (dbName == null) {
-          return getMS().listPrincipalPartitionColumnGrantsAll(principalName, principalType);
-        }
-        Table tbl = get_table_core(catName, dbName, tableName);
-        String partName = Warehouse.makePartName(tbl.getPartitionKeys(), partValues);
-        if (principalName == null) {
-          return getMS().listPartitionColumnGrantsAll(catName, dbName, tableName, partName, columnName);
-        }
-
-        return getMS().listPrincipalPartitionColumnGrants(principalName, principalType, catName, dbName,
-                tableName, partValues, partName, columnName);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-    }
-
-    private List<HiveObjectPrivilege> list_db_privileges(final String principalName,
-        final PrincipalType principalType, String catName, final String dbName) throws TException {
-      incrementCounter("list_security_db_grant");
-
-      try {
-        if (dbName == null) {
-          return getMS().listPrincipalDBGrantsAll(principalName, principalType);
-        }
-        if (principalName == null) {
-          return getMS().listDBGrantsAll(catName, dbName);
-        } else {
-          return getMS().listPrincipalDBGrants(principalName, principalType, catName, dbName);
-        }
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-    }
-
-    private List<HiveObjectPrivilege> list_partition_privileges(
-        final String principalName, final PrincipalType principalType,
-        String catName, final String dbName, final String tableName, final List<String> partValues)
-        throws TException {
-      incrementCounter("list_security_partition_grant");
-
-      try {
-        if (dbName == null) {
-          return getMS().listPrincipalPartitionGrantsAll(principalName, principalType);
-        }
-        Table tbl = get_table_core(catName, dbName, tableName);
-        String partName = Warehouse.makePartName(tbl.getPartitionKeys(), partValues);
-        if (principalName == null) {
-          return getMS().listPartitionGrantsAll(catName, dbName, tableName, partName);
-        }
-        return getMS().listPrincipalPartitionGrants(
-            principalName, principalType, catName, dbName, tableName, partValues, partName);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-    }
-
-    private List<HiveObjectPrivilege> list_table_privileges(
-        final String principalName, final PrincipalType principalType,
-        String catName, final String dbName, final String tableName) throws TException {
-      incrementCounter("list_security_table_grant");
-
-      try {
-        if (dbName == null) {
-          return getMS().listPrincipalTableGrantsAll(principalName, principalType);
-        }
-        if (principalName == null) {
-          return getMS().listTableGrantsAll(catName, dbName, tableName);
-        }
-        return getMS().listAllTableGrants(principalName, principalType, catName, dbName, tableName);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-    }
-
-    private List<HiveObjectPrivilege> list_global_privileges(
-        final String principalName, final PrincipalType principalType) throws TException {
-      incrementCounter("list_security_user_grant");
-
-      try {
-        if (principalName == null) {
-          return getMS().listGlobalGrantsAll();
-        }
-        return getMS().listPrincipalGlobalGrants(principalName, principalType);
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-    }
-
-    @Override
-    public void cancel_delegation_token(String token_str_form) throws TException {
-      startFunction("cancel_delegation_token");
-      boolean success = false;
-      Exception ex = null;
-      try {
-        HiveMetaStore.cancelDelegationToken(token_str_form);
-        success = true;
-      } catch (IOException e) {
-        ex = e;
-        throw new MetaException(e.getMessage());
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("cancel_delegation_token", success, ex);
-      }
-    }
-
-    @Override
-    public long renew_delegation_token(String token_str_form) throws TException {
-      startFunction("renew_delegation_token");
-      Long ret = null;
-      Exception ex = null;
-      try {
-        ret = HiveMetaStore.renewDelegationToken(token_str_form);
-      } catch (IOException e) {
-        ex = e;
-        throw new MetaException(e.getMessage());
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("renew_delegation_token", ret != null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public String get_delegation_token(String token_owner, String renewer_kerberos_principal_name)
-        throws TException {
-      startFunction("get_delegation_token");
-      String ret = null;
-      Exception ex = null;
-      try {
-        ret =
-            HiveMetaStore.getDelegationToken(token_owner,
-                renewer_kerberos_principal_name, getIPAddress());
-      } catch (IOException | InterruptedException e) {
-        ex = e;
-        throw new MetaException(e.getMessage());
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_delegation_token", ret != null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public boolean add_token(String token_identifier, String delegation_token) throws TException {
-      startFunction("add_token", ": " + token_identifier);
-      boolean ret = false;
-      Exception ex = null;
-      try {
-        ret = getMS().addToken(token_identifier, delegation_token);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("add_token", ret == true, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public boolean remove_token(String token_identifier) throws TException {
-      startFunction("remove_token", ": " + token_identifier);
-      boolean ret = false;
-      Exception ex = null;
-      try {
-        ret = getMS().removeToken(token_identifier);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("remove_token", ret == true, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public String get_token(String token_identifier) throws TException {
-      startFunction("get_token for", ": " + token_identifier);
-      String ret = null;
-      Exception ex = null;
-      try {
-        ret = getMS().getToken(token_identifier);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_token", ret != null, ex);
-      }
-      //Thrift cannot return null result
-      return ret == null ? "" : ret;
-    }
-
-    @Override
-    public List<String> get_all_token_identifiers() throws TException {
-      startFunction("get_all_token_identifiers.");
-      List<String> ret;
-      Exception ex = null;
-      try {
-        ret = getMS().getAllTokenIdentifiers();
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_all_token_identifiers.", ex == null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public int add_master_key(String key) throws TException {
-      startFunction("add_master_key.");
-      int ret;
-      Exception ex = null;
-      try {
-        ret = getMS().addMasterKey(key);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("add_master_key.", ex == null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public void update_master_key(int seq_number, String key) throws TException {
-      startFunction("update_master_key.");
-      Exception ex = null;
-      try {
-        getMS().updateMasterKey(seq_number, key);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("update_master_key.", ex == null, ex);
-      }
-    }
-
-    @Override
-    public boolean remove_master_key(int key_seq) throws TException {
-      startFunction("remove_master_key.");
-      Exception ex = null;
-      boolean ret;
-      try {
-        ret = getMS().removeMasterKey(key_seq);
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("remove_master_key.", ex == null, ex);
-      }
-      return ret;
-    }
-
-    @Override
-    public List<String> get_master_keys() throws TException {
-      startFunction("get_master_keys.");
-      Exception ex = null;
-      String [] ret = null;
-      try {
-        ret = getMS().getMasterKeys();
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_master_keys.", ret != null, ex);
-      }
-      return Arrays.asList(ret);
-    }
-
-    @Override
-    public void markPartitionForEvent(final String db_name, final String tbl_name,
-        final Map<String, String> partName, final PartitionEventType evtType) throws TException {
-
-      Table tbl = null;
-      Exception ex = null;
-      RawStore ms  = getMS();
-      boolean success = false;
-      try {
-        String[] parsedDbName = parseDbName(db_name, conf);
-        ms.openTransaction();
-        startPartitionFunction("markPartitionForEvent", parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tbl_name, partName);
-        firePreEvent(new PreLoadPartitionDoneEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tbl_name, partName, this));
-        tbl = ms.markPartitionForEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name,
-            partName, evtType);
-        if (null == tbl) {
-          throw new UnknownTableException("Table: " + tbl_name + " not found.");
-        }
-
-        if (transactionalListeners.size() > 0) {
-          LoadPartitionDoneEvent lpde = new LoadPartitionDoneEvent(true, tbl, partName, this);
-          for (MetaStoreEventListener transactionalListener : transactionalListeners) {
-            transactionalListener.onLoadPartitionDone(lpde);
-          }
-        }
-
-        success = ms.commitTransaction();
-        for (MetaStoreEventListener listener : listeners) {
-          listener.onLoadPartitionDone(new LoadPartitionDoneEvent(true, tbl, partName, this));
-        }
-      } catch (UnknownTableException | InvalidPartitionException | MetaException e) {
-        ex = e;
-        LOG.error("Exception caught in mark partition event ", e);
-        throw e;
-      } catch (Exception original) {
-        ex = original;
-        LOG.error("Exception caught in mark partition event ", original);
-        throw newMetaException(original);
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-
-        endFunction("markPartitionForEvent", tbl != null, ex, tbl_name);
-      }
-    }
-
-    @Override
-    public boolean isPartitionMarkedForEvent(final String db_name, final String tbl_name,
-        final Map<String, String> partName, final PartitionEventType evtType) throws TException {
-
-      String[] parsedDbName = parseDbName(db_name, conf);
-      startPartitionFunction("isPartitionMarkedForEvent", parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-          tbl_name, partName);
-      Boolean ret = null;
-      Exception ex = null;
-      try {
-        ret = getMS().isPartitionMarkedForEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
-            tbl_name, partName, evtType);
-      } catch (UnknownTableException | UnknownPartitionException | InvalidPartitionException | MetaException e) {
-        ex = e;
-        LOG.error("Exception caught for isPartitionMarkedForEvent ", e);
-        throw e;
-      } catch (Exception original) {
-        LOG.error("Exception caught for isPartitionMarkedForEvent ", original);
-        ex = original;
-        throw newMetaException(original);
-      } finally {
-                endFunction("isPartitionMarkedForEvent", ret != null, ex, tbl_name);
-      }
-
-      return ret;
-    }
-
-    @Override
-    public List<String> set_ugi(String username, List<String> groupNames) throws TException {
-      Collections.addAll(groupNames, username);
-      return groupNames;
-    }
-
-    @Override
-    public boolean partition_name_has_valid_characters(List<String> part_vals,
-        boolean throw_exception) throws TException {
-      startFunction("partition_name_has_valid_characters");
-      boolean ret;
-      Exception ex = null;
-      try {
-        if (throw_exception) {
-          MetaStoreServerUtils.validatePartitionNameCharacters(part_vals, partitionValidationPattern);
-          ret = true;
-        } else {
-          ret = MetaStoreServerUtils.partitionNameHasValidCharacters(part_vals,
-              partitionValidationPattern);
-        }
-      } catch (MetaException e) {
-        ex = e;
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("partition_name_has_valid_characters", true, ex);
-      }
-      return ret;
-    }
-
-    private static MetaException newMetaException(Exception e) {
-      if (e instanceof MetaException) {
-        return (MetaException)e;
-      }
-      MetaException me = new MetaException(e.toString());
-      me.initCause(e);
-      return me;
-    }
-
-    private void validateFunctionInfo(Function func) throws InvalidObjectException, MetaException {
-      if (func == null) {
-        throw new MetaException("Function cannot be null.");
-      }
-      if (func.getFunctionName() == null) {
-        throw new MetaException("Function name cannot be null.");
-      }
-      if (func.getDbName() == null) {
-        throw new MetaException("Database name in Function cannot be null.");
-      }
-      if (!MetaStoreUtils.validateName(func.getFunctionName(), null)) {
-        throw new InvalidObjectException(func.getFunctionName() + " is not a valid object name");
-      }
-      String className = func.getClassName();
-      if (className == null) {
-        throw new InvalidObjectException("Function class name cannot be null");
-      }
-      if (func.getOwnerType() == null) {
-        throw new MetaException("Function owner type cannot be null.");
-      }
-      if (func.getFunctionType() == null) {
-        throw new MetaException("Function type cannot be null.");
-      }
-    }
-
-    @Override
-    public void create_function(Function func) throws TException {
-      validateFunctionInfo(func);
-      boolean success = false;
-      RawStore ms = getMS();
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-      try {
-        String catName = func.isSetCatName() ? func.getCatName() : getDefaultCatalog(conf);
-        ms.openTransaction();
-        Database db = ms.getDatabase(catName, func.getDbName());
-        if (db == null) {
-          throw new NoSuchObjectException("The database " + func.getDbName() + " does not exist");
-        }
-
-        if (db.getType() == DatabaseType.REMOTE) {
-          throw new MetaException("Operation create_function not support for REMOTE database");
-        }
-
-        Function existingFunc = ms.getFunction(catName, func.getDbName(), func.getFunctionName());
-        if (existingFunc != null) {
-          throw new AlreadyExistsException(
-              "Function " + func.getFunctionName() + " already exists");
-        }
-
-        long time = System.currentTimeMillis() / 1000;
-        func.setCreateTime((int) time);
-        ms.createFunction(func);
-        if (!transactionalListeners.isEmpty()) {
-          transactionalListenerResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                    EventType.CREATE_FUNCTION,
-                                                    new CreateFunctionEvent(func, true, this));
-        }
-
-        success = ms.commitTransaction();
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.CREATE_FUNCTION,
-                                                new CreateFunctionEvent(func, success, this),
-                                                null,
-                                                transactionalListenerResponses, ms);
-        }
-      }
-    }
-
-    @Override
-    public void drop_function(String dbName, String funcName)
-        throws NoSuchObjectException, MetaException,
-        InvalidObjectException, InvalidInputException {
-      if (funcName == null) {
-        throw new MetaException("Function name cannot be null.");
-      }
-      boolean success = false;
-      Function func = null;
-      RawStore ms = getMS();
-      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
-      String[] parsedDbName = parseDbName(dbName, conf);
-      if (parsedDbName[DB_NAME] == null) {
-        throw new MetaException("Database name cannot be null.");
-      }
-      try {
-        ms.openTransaction();
-        func = ms.getFunction(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], funcName);
-        if (func == null) {
-          throw new NoSuchObjectException("Function " + funcName + " does not exist");
-        }
-        Boolean needsCm =
-              ReplChangeManager.isSourceOfReplication(get_database_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]));
-
-        // if copy of jar to change management fails we fail the metastore transaction, since the
-        // user might delete the jars on HDFS externally after dropping the function, hence having
-        // a copy is required to allow incremental replication to work correctly.
-        if (func.getResourceUris() != null && !func.getResourceUris().isEmpty()) {
-          for (ResourceUri uri : func.getResourceUris()) {
-            if (uri.getUri().toLowerCase().startsWith("hdfs:") && needsCm) {
-              wh.addToChangeManagement(new Path(uri.getUri()));
-            }
-          }
-        }
-
-        // if the operation on metastore fails, we don't do anything in change management, but fail
-        // the metastore transaction, as having a copy of the jar in change management is not going
-        // to cause any problem, the cleaner thread will remove this when this jar expires.
-        ms.dropFunction(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], funcName);
-        if (transactionalListeners.size() > 0) {
-          transactionalListenerResponses =
-              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-                                                    EventType.DROP_FUNCTION,
-                                                    new DropFunctionEvent(func, true, this));
-        }
-        success = ms.commitTransaction();
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-
-        if (listeners.size() > 0) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-                                                EventType.DROP_FUNCTION,
-                                                new DropFunctionEvent(func, success, this),
-                                                null,
-                                                transactionalListenerResponses, ms);
-        }
-      }
-    }
-
-    @Override
-    public void alter_function(String dbName, String funcName, Function newFunc) throws TException {
-      String[] parsedDbName = parseDbName(dbName, conf);
-      validateForAlterFunction(parsedDbName[DB_NAME], funcName, newFunc);
-      boolean success = false;
-      RawStore ms = getMS();
-      try {
-        ms.openTransaction();
-        ms.alterFunction(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], funcName, newFunc);
-        success = ms.commitTransaction();
-      } catch (InvalidObjectException e) {
-        // Throwing MetaException instead of InvalidObjectException as the InvalidObjectException
-        // is not defined for the alter_function method in the Thrift interface.
-        throwMetaException(e);
-      } finally {
-        if (!success) {
-          ms.rollbackTransaction();
-        }
-      }
-    }
-
-    private void validateForAlterFunction(String dbName, String funcName, Function newFunc)
-        throws MetaException {
-      if (dbName == null || funcName == null) {
-        throw new MetaException("Database and function name cannot be null.");
-      }
-      try {
-        validateFunctionInfo(newFunc);
-      } catch (InvalidObjectException e) {
-        // The validateFunctionInfo method is used by the create and alter function methods as well
-        // and it can throw InvalidObjectException. But the InvalidObjectException is not defined
-        // for the alter_function method in the Thrift interface, therefore a TApplicationException
-        // will occur at the caller side. Re-throwing the InvalidObjectException as MetaException
-        // would eliminate the TApplicationException at caller side.
-        throw newMetaException(e);
-      }
-    }
-
-    @Override
-    public List<String> get_functions(String dbName, String pattern)
-        throws MetaException {
-      startFunction("get_functions", ": db=" + dbName + " pat=" + pattern);
-
-      RawStore ms = getMS();
-      Exception ex = null;
-      List<String> funcNames = null;
-      String[] parsedDbName = parseDbName(dbName, conf);
-
-      try {
-        funcNames = ms.getFunctions(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], pattern);
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_functions", funcNames != null, ex);
-      }
-
-      return funcNames;
-    }
-
-    @Override
-    public GetAllFunctionsResponse get_all_functions()
-            throws MetaException {
-      GetAllFunctionsResponse response = new GetAllFunctionsResponse();
-      startFunction("get_all_functions");
-      RawStore ms = getMS();
-      List<Function> allFunctions = null;
-      Exception ex = null;
-      try {
-        // Leaving this as the 'hive' catalog (rather than choosing the default from the
-        // configuration) because all the default UDFs are in that catalog, and I think that's
-        // would people really want here.
-        allFunctions = ms.getAllFunctions(DEFAULT_CATALOG_NAME);
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_all_functions", allFunctions != null, ex);
-      }
-      response.setFunctions(allFunctions);
-      return response;
-    }
-
-    @Override
-    public Function get_function(String dbName, String funcName) throws TException {
-      if (dbName == null || funcName == null) {
-        throw new MetaException("Database and function name cannot be null.");
-      }
-      startFunction("get_function", ": " + dbName + "." + funcName);
-
-      RawStore ms = getMS();
-      Function func = null;
-      Exception ex = null;
-      String[] parsedDbName = parseDbName(dbName, conf);
-
-      try {
-        func = ms.getFunction(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], funcName);
-        if (func == null) {
-          throw new NoSuchObjectException(
-              "Function " + dbName + "." + funcName + " does not exist");
-        }
-      } catch (NoSuchObjectException e) {
-        ex = e;
-        rethrowException(e);
-      } catch (Exception e) {
-        ex = e;
-        throw newMetaException(e);
-      } finally {
-        endFunction("get_function", func != null, ex);
-      }
-
-      return func;
-    }
-
-    // Transaction and locking methods
-    @Override
-    public GetOpenTxnsResponse get_open_txns() throws TException {
-      return getTxnHandler().getOpenTxns();
-    }
-
-    @Override
-    public GetOpenTxnsResponse get_open_txns_req(GetOpenTxnsRequest getOpenTxnsRequest) throws TException {
-      return getTxnHandler().getOpenTxns(getOpenTxnsRequest.getExcludeTxnTypes());
-    }
-
-    // Transaction and locking methods
-    @Override
-    public GetOpenTxnsInfoResponse get_open_txns_info() throws TException {
-      return getTxnHandler().getOpenTxnsInfo();
-    }
-
-    @Override
-    public OpenTxnsResponse open_txns(OpenTxnRequest rqst) throws TException {
-      OpenTxnsResponse response = getTxnHandler().openTxns(rqst);
-      List<Long> txnIds = response.getTxn_ids();
-      if (txnIds != null && listeners != null && !listeners.isEmpty()) {
-        MetaStoreListenerNotifier.notifyEvent(listeners, EventType.OPEN_TXN,
-            new OpenTxnEvent(txnIds, this));
-      }
-      return response;
-    }
-
-    @Override
-    public void abort_txn(AbortTxnRequest rqst) throws TException {
-      getTxnHandler().abortTxn(rqst);
-      if (listeners != null && !listeners.isEmpty()) {
-        MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ABORT_TXN,
-                new AbortTxnEvent(rqst.getTxnid(), this));
-      }
-    }
-
-    @Override
-    public void abort_txns(AbortTxnsRequest rqst) throws TException {
-      getTxnHandler().abortTxns(rqst);
-      if (listeners != null && !listeners.isEmpty()) {
-        for (Long txnId : rqst.getTxn_ids()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ABORT_TXN,
-                  new AbortTxnEvent(txnId, this));
-        }
-      }
-    }
-
-    @Override
-    public long get_latest_txnid_in_conflict(long txnId) throws MetaException {
-      return getTxnHandler().getLatestTxnIdInConflict(txnId);
-    }
-
-    @Override
-    public void commit_txn(CommitTxnRequest rqst) throws TException {
-      // in replication flow, the write notification log table will be updated here.
-      if (rqst.isSetWriteEventInfos()) {
-        long targetTxnId = getTxnHandler().getTargetTxnId(rqst.getReplPolicy(), rqst.getTxnid());
-        if (targetTxnId < 0) {
-          //looks like a retry
-          return;
-        }
-        for (WriteEventInfo writeEventInfo : rqst.getWriteEventInfos()) {
-          String[] filesAdded = ReplChangeManager.getListFromSeparatedString(writeEventInfo.getFiles());
-          List<String> partitionValue = null;
-          Partition ptnObj = null;
-          String root;
-          Table tbl = getTblObject(writeEventInfo.getDatabase(), writeEventInfo.getTable());
-
-          if (writeEventInfo.getPartition() != null && !writeEventInfo.getPartition().isEmpty()) {
-            partitionValue = Warehouse.getPartValuesFromPartName(writeEventInfo.getPartition());
-            ptnObj = getPartitionObj(writeEventInfo.getDatabase(), writeEventInfo.getTable(), partitionValue, tbl);
-            root = ptnObj.getSd().getLocation();
-          } else {
-            root = tbl.getSd().getLocation();
-          }
-
-          InsertEventRequestData insertData = new InsertEventRequestData();
-          insertData.setReplace(true);
-
-          // The files in the commit txn message during load will have files with path corresponding to source
-          // warehouse. Need to transform them to target warehouse using table or partition object location.
-          for (String file : filesAdded) {
-            String[] decodedPath = ReplChangeManager.decodeFileUri(file);
-            String name = (new Path(decodedPath[0])).getName();
-            Path newPath = FileUtils.getTransformedPath(name, decodedPath[3], root);
-            insertData.addToFilesAdded(newPath.toUri().toString());
-            insertData.addToSubDirectoryList(decodedPath[3]);
-            try {
-              insertData.addToFilesAddedChecksum(ReplChangeManager.checksumFor(newPath, newPath.getFileSystem(conf)));
-            } catch (IOException e) {
-              LOG.error("failed to get checksum for the file " + newPath + " with error: " + e.getMessage());
-              throw new TException(e.getMessage());
-            }
-          }
-
-          WriteNotificationLogRequest wnRqst = new WriteNotificationLogRequest(targetTxnId,
-                  writeEventInfo.getWriteId(), writeEventInfo.getDatabase(), writeEventInfo.getTable(), insertData);
-          if (partitionValue != null) {
-            wnRqst.setPartitionVals(partitionValue);
-          }
-          addTxnWriteNotificationLog(tbl, ptnObj, wnRqst);
-        }
-      }
-      getTxnHandler().commitTxn(rqst);
-      if (listeners != null && !listeners.isEmpty()) {
-        MetaStoreListenerNotifier.notifyEvent(listeners, EventType.COMMIT_TXN,
-                new CommitTxnEvent(rqst.getTxnid(), this));
-        Optional<CompactionInfo> compactionInfo = getTxnHandler().getCompactionByTxnId(rqst.getTxnid());
-        if (compactionInfo.isPresent()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners, EventType.COMMIT_COMPACTION,
-              new CommitCompactionEvent(rqst.getTxnid(), compactionInfo.get(), this));
-        }
-      }
-    }
-
-    @Override
-    public void repl_tbl_writeid_state(ReplTblWriteIdStateRequest rqst) throws TException {
-      getTxnHandler().replTableWriteIdState(rqst);
-    }
-
-    @Override
-    public GetValidWriteIdsResponse get_valid_write_ids(GetValidWriteIdsRequest rqst) throws TException {
-      return getTxnHandler().getValidWriteIds(rqst);
-    }
-
-    @Override
-    public void set_hadoop_jobid(String jobId, long cqId) {
-      getTxnHandler().setHadoopJobId(jobId, cqId);
-    }
-
-    @Override
-    public OptionalCompactionInfoStruct find_next_compact(String workerId) throws MetaException{
-      return CompactionInfo.compactionInfoToOptionalStruct(
-          getTxnHandler().findNextToCompact(workerId));
-    }
-
-    @Override
-    public void mark_cleaned(CompactionInfoStruct cr) throws MetaException {
-      getTxnHandler().markCleaned(CompactionInfo.compactionStructToInfo(cr));
-    }
-
-    @Override
-    public void mark_compacted(CompactionInfoStruct cr) throws MetaException {
-      getTxnHandler().markCompacted(CompactionInfo.compactionStructToInfo(cr));
-    }
-
-    @Override
-    public void mark_failed(CompactionInfoStruct cr) throws MetaException {
-      getTxnHandler().markFailed(CompactionInfo.compactionStructToInfo(cr));
-    }
-
-    @Override
-    public List<String> find_columns_with_stats(CompactionInfoStruct cr) throws MetaException {
-      return getTxnHandler().findColumnsWithStats(CompactionInfo.compactionStructToInfo(cr));
-    }
-
-    @Override
-    public void update_compactor_state(CompactionInfoStruct cr, long highWaterMark) throws MetaException {
-      getTxnHandler().updateCompactorState(
-          CompactionInfo.compactionStructToInfo(cr), highWaterMark);
-    }
-
-    @Override
-    public AllocateTableWriteIdsResponse allocate_table_write_ids(
-            AllocateTableWriteIdsRequest rqst) throws TException {
-      AllocateTableWriteIdsResponse response = getTxnHandler().allocateTableWriteIds(rqst);
-      if (listeners != null && !listeners.isEmpty()) {
-        MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ALLOC_WRITE_ID,
-                new AllocWriteIdEvent(response.getTxnToWriteIds(), rqst.getDbName(),
-                        rqst.getTableName(), this));
-      }
-      return response;
-    }
-
-    @Override
-    public MaxAllocatedTableWriteIdResponse get_max_allocated_table_write_id(MaxAllocatedTableWriteIdRequest rqst)
-        throws MetaException {
-      return getTxnHandler().getMaxAllocatedTableWrited(rqst);
-    }
-
-    @Override
-    public void seed_write_id(SeedTableWriteIdsRequest rqst) throws MetaException {
-      getTxnHandler().seedWriteId(rqst);
-    }
-
-    @Override
-    public void seed_txn_id(SeedTxnIdRequest rqst) throws MetaException {
-      getTxnHandler().seedTxnId(rqst);
-    }
-
-    private void addTxnWriteNotificationLog(Table tableObj, Partition ptnObj, WriteNotificationLogRequest rqst)
-            throws MetaException {
-      String partition = ""; //Empty string is an invalid partition name. Can be used for non partitioned table.
-      if (ptnObj != null) {
-        partition = Warehouse.makePartName(tableObj.getPartitionKeys(), rqst.getPartitionVals());
-      }
-      AcidWriteEvent event = new AcidWriteEvent(partition, tableObj, ptnObj, rqst);
-      getTxnHandler().addWriteNotificationLog(event);
-      if (listeners != null && !listeners.isEmpty()) {
-        MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ACID_WRITE, event);
-      }
-    }
-
-    private Table getTblObject(String db, String table) throws MetaException, NoSuchObjectException {
-      GetTableRequest req = new GetTableRequest(db, table);
-      req.setCapabilities(new ClientCapabilities(Lists.newArrayList(ClientCapability.TEST_CAPABILITY, ClientCapability.INSERT_ONLY_TABLES)));
-      return get_table_req(req).getTable();
-    }
-
-    private Partition getPartitionObj(String db, String table, List<String> partitionVals, Table tableObj)
-            throws MetaException, NoSuchObjectException {
-      if (tableObj.isSetPartitionKeys() && !tableObj.getPartitionKeys().isEmpty()) {
-        return get_partition(db, table, partitionVals);
-      }
-      return null;
-    }
-
-    @Override
-    public WriteNotificationLogResponse add_write_notification_log(WriteNotificationLogRequest rqst)
-            throws TException {
-      Table tableObj = getTblObject(rqst.getDb(), rqst.getTable());
-      Partition ptnObj = getPartitionObj(rqst.getDb(), rqst.getTable(), rqst.getPartitionVals(), tableObj);
-      addTxnWriteNotificationLog(tableObj, ptnObj, rqst);
-      return new WriteNotificationLogResponse();
-    }
-
-    @Override
-    public LockResponse lock(LockRequest rqst) throws TException {
-      return getTxnHandler().lock(rqst);
-    }
-
-    @Override
-    public LockResponse check_lock(CheckLockRequest rqst) throws TException {
-      return getTxnHandler().checkLock(rqst);
-    }
-
-    @Override
-    public void unlock(UnlockRequest rqst) throws TException {
-      getTxnHandler().unlock(rqst);
-    }
-
-    @Override
-    public ShowLocksResponse show_locks(ShowLocksRequest rqst) throws TException {
-      return getTxnHandler().showLocks(rqst);
-    }
-
-    @Override
-    public void heartbeat(HeartbeatRequest ids) throws TException {
-      getTxnHandler().heartbeat(ids);
-    }
-
-    @Override
-    public HeartbeatTxnRangeResponse heartbeat_txn_range(HeartbeatTxnRangeRequest rqst)
-      throws TException {
-      return getTxnHandler().heartbeatTxnRange(rqst);
-    }
-    @Deprecated
-    @Override
-    public void compact(CompactionRequest rqst) throws TException {
-      compact2(rqst);
-    }
-    @Override
-    public CompactionResponse compact2(CompactionRequest rqst) throws TException {
-      return getTxnHandler().compact(rqst);
-    }
-
-    @Override
-    public ShowCompactResponse show_compact(ShowCompactRequest rqst) throws TException {
-      ShowCompactResponse response = getTxnHandler().showCompact(rqst);
-      response.setCompacts(FilterUtils.filterCompactionsIfEnabled(isServerFilterEnabled,
-              filterHook, getDefaultCatalog(conf), response.getCompacts()));
-      return response;
-    }
-
-    @Override
-    public void flushCache() throws TException {
-      getMS().flushCache();
-    }
-
-    @Override
-    public void add_dynamic_partitions(AddDynamicPartitions rqst) throws TException {
-      getTxnHandler().addDynamicPartitions(rqst);
-    }
-
-    @Override
-    public GetPrincipalsInRoleResponse get_principals_in_role(GetPrincipalsInRoleRequest request)
-        throws TException {
-
-      incrementCounter("get_principals_in_role");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      Exception ex = null;
-      GetPrincipalsInRoleResponse response = null;
-      try {
-        response = new GetPrincipalsInRoleResponse(getMS().listRoleMembers(request.getRoleName()));
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_principals_in_role", ex == null, ex);
-      }
-      return response;
-    }
-
-    @Override
-    public GetRoleGrantsForPrincipalResponse get_role_grants_for_principal(
-        GetRoleGrantsForPrincipalRequest request) throws TException {
-
-      incrementCounter("get_role_grants_for_principal");
-      firePreEvent(new PreAuthorizationCallEvent(this));
-      Exception ex = null;
-      List<RolePrincipalGrant> roleMaps = null;
-      try {
-        roleMaps = getMS().listRolesWithGrants(request.getPrincipal_name(), request.getPrincipal_type());
-      } catch (MetaException e) {
-        throw e;
-      } catch (Exception e) {
-        ex = e;
-        rethrowException(e);
-      } finally {
-        endFunction("get_role_grants_for_principal", ex == null, ex);
-      }
-
-      //List<RolePrincipalGrant> roleGrantsList = getRolePrincipalGrants(roleMaps);
-      return new GetRoleGrantsForPrincipalResponse(roleMaps);
-    }
-
-    @Override
-    public AggrStats get_aggr_stats_for(PartitionsStatsRequest request) throws TException {
-      String catName = request.isSetCatName() ? request.getCatName().toLowerCase() :
-          getDefaultCatalog(conf);
-      String dbName = request.getDbName().toLowerCase();
-      String tblName = request.getTblName().toLowerCase();
-      startFunction("get_aggr_stats_for", ": table=" +
-          TableName.getQualified(catName, dbName, tblName));
-
-      List<String> lowerCaseColNames = new ArrayList<>(request.getColNames().size());
-      for (String colName : request.getColNames()) {
-        lowerCaseColNames.add(colName.toLowerCase());
-      }
-      List<String> lowerCasePartNames = new ArrayList<>(request.getPartNames().size());
-      for (String partName : request.getPartNames()) {
-        lowerCasePartNames.add(lowerCaseConvertPartName(partName));
-      }
-      AggrStats aggrStats = null;
-
-      try {
-        aggrStats = getMS().get_aggr_stats_for(catName, dbName, tblName,
-            lowerCasePartNames, lowerCaseColNames, request.getEngine(), request.getValidWriteIdList());
-        return aggrStats;
-      } finally {
-          endFunction("get_aggr_stats_for", aggrStats == null, null, request.getTblName());
-      }
-
-    }
-
-    @Override
-    public boolean set_aggr_stats_for(SetPartitionsStatsRequest request) throws TException {
-      boolean ret = true;
-      List<ColumnStatistics> csNews = request.getColStats();
-      if (csNews == null || csNews.isEmpty()) {
-        return ret;
-      }
-      // figure out if it is table level or partition level
-      ColumnStatistics firstColStats = csNews.get(0);
-      ColumnStatisticsDesc statsDesc = firstColStats.getStatsDesc();
-      String catName = statsDesc.isSetCatName() ? statsDesc.getCatName() : getDefaultCatalog(conf);
-      String dbName = statsDesc.getDbName();
-      String tableName = statsDesc.getTableName();
-      List<String> colNames = new ArrayList<>();
-      for (ColumnStatisticsObj obj : firstColStats.getStatsObj()) {
-        colNames.add(obj.getColName());
-      }
-      if (statsDesc.isIsTblLevel()) {
-        // there should be only one ColumnStatistics
-        if (request.getColStatsSize() != 1) {
-          throw new MetaException(
-              "Expecting only 1 ColumnStatistics for table's column stats, but find "
-                  + request.getColStatsSize());
-        }
-        if (request.isSetNeedMerge() && request.isNeedMerge()) {
-          return updateTableColumnStatsWithMerge(catName, dbName, tableName, colNames, request);
-        } else {
-          // This is the overwrite case, we do not care about the accuracy.
-          return updateTableColumnStatsInternal(firstColStats,
-              request.getValidWriteIdList(), request.getWriteId());
-        }
-      } else {
-        // partition level column stats merging
-        // note that we may have two or more duplicate partition names.
-        // see autoColumnStats_2.q under TestMiniLlapLocalCliDriver
-        Map<String, ColumnStatistics> newStatsMap = new HashMap<>();
-        for (ColumnStatistics csNew : csNews) {
-          String partName = csNew.getStatsDesc().getPartName();
-          if (newStatsMap.containsKey(partName)) {
-            MetaStoreServerUtils.mergeColStats(csNew, newStatsMap.get(partName));
-          }
-          newStatsMap.put(partName, csNew);
-        }
-
-        if (request.isSetNeedMerge() && request.isNeedMerge()) {
-          ret = updatePartColumnStatsWithMerge(catName, dbName, tableName,
-              colNames, newStatsMap, request);
-        } else { // No merge.
-          Table t = getTable(catName, dbName, tableName);
-          for (Entry<String, ColumnStatistics> entry : newStatsMap.entrySet()) {
-            // We don't short-circuit on errors here anymore. That can leave acid stats invalid.
-            ret = updatePartitonColStatsInternal(t, entry.getValue(),
-                request.getValidWriteIdList(), request.getWriteId()) && ret;
-          }
-        }
... 1435 lines suppressed ...

[hive] 16/38: Test failures with tez driver and duplicate error codes

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit a2a592f40ea58c6136396e9cdbbb38875bc17353
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Mon Nov 23 17:43:26 2020 -0500

    Test failures with tez driver and duplicate error codes
---
 ql/src/test/results/clientpositive/tez/explainanalyze_3.q.out | 2 +-
 ql/src/test/results/clientpositive/tez/explainuser_3.q.out    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ql/src/test/results/clientpositive/tez/explainanalyze_3.q.out b/ql/src/test/results/clientpositive/tez/explainanalyze_3.q.out
index 51ab48b..9add485 100644
--- a/ql/src/test/results/clientpositive/tez/explainanalyze_3.q.out
+++ b/ql/src/test/results/clientpositive/tez/explainanalyze_3.q.out
@@ -127,7 +127,7 @@ PREHOOK: Input: database:newdb
 POSTHOOK: query: describe database extended newDB
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:newdb
-newdb		location/in/test		hive_test_user	USER	
+newdb		location/in/test		hive_test_user	USER			
 PREHOOK: query: use newDB
 PREHOOK: type: SWITCHDATABASE
 PREHOOK: Input: database:newdb
diff --git a/ql/src/test/results/clientpositive/tez/explainuser_3.q.out b/ql/src/test/results/clientpositive/tez/explainuser_3.q.out
index 4234d2d..990d1bd 100644
--- a/ql/src/test/results/clientpositive/tez/explainuser_3.q.out
+++ b/ql/src/test/results/clientpositive/tez/explainuser_3.q.out
@@ -145,7 +145,7 @@ PREHOOK: Input: database:newdb
 POSTHOOK: query: describe database extended newDB
 POSTHOOK: type: DESCDATABASE
 POSTHOOK: Input: database:newdb
-newdb		location/in/test		hive_test_user	USER	
+newdb		location/in/test		hive_test_user	USER			
 PREHOOK: query: explain use newDB
 PREHOOK: type: SWITCHDATABASE
 PREHOOK: Input: database:newdb

[hive] 17/38: HIVE-24396: refactored code to Abstract class and providers share common code

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 3de6032b45890d46269d935f1e02d7bdab3f4cd1
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Mon Nov 23 17:59:30 2020 -0500

    HIVE-24396: refactored code to Abstract class and providers share common code
---
 .../JDBCConnectorProviderFactory.java              |  9 ++-
 .../jdbc/AbstractJDBCConnectorProvider.java        | 13 ++--
 .../jdbc/DerbySQLConnectorProvider.java            | 69 ++++++++++++++++++++
 .../dataconnector/jdbc/MySQLConnectorProvider.java | 74 ++++------------------
 .../jdbc/PostgreSQLConnectorProvider.java          | 71 ++++-----------------
 5 files changed, 102 insertions(+), 134 deletions(-)

diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/JDBCConnectorProviderFactory.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/JDBCConnectorProviderFactory.java
index 537fd2c..b1ebfe0 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/JDBCConnectorProviderFactory.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/JDBCConnectorProviderFactory.java
@@ -1,12 +1,11 @@
 package org.apache.hadoop.hive.metastore.dataconnector;
 
 import org.apache.hadoop.hive.metastore.api.DataConnector;
+import org.apache.hadoop.hive.metastore.dataconnector.jdbc.DerbySQLConnectorProvider;
 import org.apache.hadoop.hive.metastore.dataconnector.jdbc.MySQLConnectorProvider;
 import org.apache.hadoop.hive.metastore.dataconnector.jdbc.PostgreSQLConnectorProvider;
 
-import static org.apache.hadoop.hive.metastore.dataconnector.IDataConnectorProvider.MYSQL_TYPE;
-import static org.apache.hadoop.hive.metastore.dataconnector.IDataConnectorProvider.POSTGRES_TYPE;
-
+import static org.apache.hadoop.hive.metastore.dataconnector.IDataConnectorProvider.*;
 
 public class JDBCConnectorProviderFactory {
 
@@ -33,6 +32,10 @@ public class JDBCConnectorProviderFactory {
       provider = new PostgreSQLConnectorProvider(dbName, connector);
       break;
 
+    case DERBY_TYPE:
+      provider = new DerbySQLConnectorProvider(dbName, connector);
+      break;
+
     default:
       throw new RuntimeException("Unsupported JDBC type");
     }
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
index 62a7786..12ce799 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
@@ -1,5 +1,6 @@
 package org.apache.hadoop.hive.metastore.dataconnector.jdbc;
 
+import org.apache.hadoop.hive.metastore.ColumnType;
 import org.apache.hadoop.hive.metastore.Warehouse;
 import org.apache.hadoop.hive.metastore.api.DataConnector;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
@@ -219,16 +220,13 @@ public abstract class AbstractJDBCConnectorProvider extends AbstractDataConnecto
     return rs;
   }
 
-  private String wrapSize(int size) {
+  protected String wrapSize(int size) {
     return "(" + size + ")";
   }
 
-  protected abstract String getDataType(String dbType, int size);
-
-  /*
-  private String getDataType(String mySqlType, int size) {
-    //TODO: Geomentric, network, bit, array data types of postgresql needs to be supported.
-    switch(mySqlType)
+  // subclasses call this first, anything that is not mappable by this code is mapped in the subclass
+  protected String getDataType(String mySqlType, int size) {
+    switch(mySqlType.toLowerCase())
     {
     case "char":
       return ColumnType.CHAR_TYPE_NAME + wrapSize(size);
@@ -288,7 +286,6 @@ public abstract class AbstractJDBCConnectorProvider extends AbstractDataConnecto
       return ColumnType.VOID_TYPE_NAME;
     }
   }
- */
 
   @Override protected String getInputClass() {
     return JDBC_INPUTFORMAT_CLASS;
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/DerbySQLConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/DerbySQLConnectorProvider.java
new file mode 100644
index 0000000..1cf90bc
--- /dev/null
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/DerbySQLConnectorProvider.java
@@ -0,0 +1,69 @@
+package org.apache.hadoop.hive.metastore.dataconnector.jdbc;
+
+import org.apache.hadoop.hive.metastore.api.DataConnector;
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+
+public class DerbySQLConnectorProvider extends AbstractJDBCConnectorProvider {
+  private static Logger LOG = LoggerFactory.getLogger(DerbySQLConnectorProvider.class);
+
+  // private static final String DRIVER_CLASS = "org.apache.derby.jdbc.EmbeddedDriver".intern();
+  private static final String DRIVER_CLASS = "org.apache.derby.jdbc.AutoloadedDriver".intern();
+
+  public DerbySQLConnectorProvider(String dbName, DataConnector connector) {
+    super(dbName, connector);
+    driverClassName = DRIVER_CLASS;
+  }
+
+  /**
+   * Returns a list of all table names from the remote database.
+   * @return List A collection of all the table names, null if there are no tables.
+   * @throws IOException To indicate any failures with executing this API
+   */
+  @Override
+  protected ResultSet fetchTableNames() throws MetaException {
+    ResultSet rs = null;
+    try {
+      rs = getConnection().getMetaData().getTables(scoped_db, null, null, new String[] { "TABLE" });
+    } catch (SQLException sqle) {
+      LOG.warn("Could not retrieve table names from remote datasource, cause:" + sqle.getMessage());
+      throw new MetaException("Could not retrieve table names from remote datasource, cause:" + sqle.getMessage());
+    }
+    return rs;
+  }
+
+  /**
+   * Fetch a single table with the given name, returns a Hive Table object from the remote database
+   * @return Table A Table object for the matching table, null otherwise.
+   * @throws MetaException To indicate any failures with executing this API
+   * @param tableName
+   */
+  @Override
+  public ResultSet fetchTableMetadata(String tableName) throws MetaException {
+     return null;
+  }
+
+  /**
+   * Returns Hive Table objects from the remote database for tables that match a name pattern.
+   * @return List A collection of objects that match the name pattern, null otherwise.
+   * @throws MetaException To indicate any failures with executing this API
+   * @param regex
+   */
+  @Override
+  public List<Table> getTables(String regex) throws MetaException {
+    return null;
+  }
+
+  protected String getDataType(String dbDataType, int size) {
+    String mappedType = super.getDataType(dbDataType, size);
+    // map any db specific types here. or return
+    return mappedType;
+  }
+}
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConnectorProvider.java
index f4f9b62..cb80c4f 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConnectorProvider.java
@@ -7,7 +7,6 @@ import org.apache.hadoop.hive.metastore.api.Table;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
@@ -26,7 +25,7 @@ public class MySQLConnectorProvider extends AbstractJDBCConnectorProvider {
   /**
    * Returns a list of all table names from the remote database.
    * @return List A collection of all the table names, null if there are no tables.
-   * @throws IOException To indicate any failures with executing this API
+   * @throws MetaException To indicate any failures with executing this API
    */
   @Override protected ResultSet fetchTableNames() throws MetaException {
     ResultSet rs = null;
@@ -46,6 +45,7 @@ public class MySQLConnectorProvider extends AbstractJDBCConnectorProvider {
    * @param regex
    */
   @Override public  List<Table> getTables(String regex) throws MetaException {
+    LOG.info("getTables() not implemented yet");
     return null;
   }
 
@@ -69,70 +69,18 @@ public class MySQLConnectorProvider extends AbstractJDBCConnectorProvider {
     }
   }
 
-  private String wrapSize(int size) {
-    return "(" + size + ")";
-  }
-
   protected String getDataType(String dbDataType, int size) {
-    //TODO: Geomentric, network, bit, array data types of postgresql needs to be supported.
-    switch(dbDataType.toLowerCase())
+    String mappedType = super.getDataType(dbDataType, size);
+    if (!mappedType.equalsIgnoreCase(ColumnType.VOID_TYPE_NAME)) {
+      return mappedType;
+    }
+
+    // map any db specific types here.
+    switch (dbDataType.toLowerCase())
     {
-    case "char":
-      return ColumnType.CHAR_TYPE_NAME + wrapSize(size);
-    case "varchar":
-    case "tinytext":
-      return ColumnType.VARCHAR_TYPE_NAME + wrapSize(size);
-    case "text":
-    case "mediumtext":
-    case "enum":
-    case "set":
-    case "tsvector":
-    case "tsquery":
-    case "uuid":
-    case "json":
-      return ColumnType.STRING_TYPE_NAME;
-    case "blob":
-    case "mediumblob":
-    case "longblob":
-    case "bytea":
-      return ColumnType.BINARY_TYPE_NAME;
-    case "tinyint":
-      return ColumnType.TINYINT_TYPE_NAME;
-    case "smallint":
-    case "smallserial":
-      return ColumnType.SMALLINT_TYPE_NAME;
-    case "mediumint":
-    case "int":
-    case "serial":
-      return ColumnType.INT_TYPE_NAME;
-    case "bigint":
-    case "bigserial":
-    case "money":
-      return ColumnType.BIGINT_TYPE_NAME;
-    case "float":
-    case "real":
-      return ColumnType.FLOAT_TYPE_NAME;
-    case "double":
-    case "double precision":
-      return ColumnType.DOUBLE_TYPE_NAME;
-    case "decimal":
-    case "numeric":
-      return ColumnType.DECIMAL_TYPE_NAME;
-    case "date":
-      return ColumnType.DATE_TYPE_NAME;
-    case "datetime":
-      return ColumnType.DATETIME_TYPE_NAME;
-    case "timestamp":
-    case "time":
-    case "interval":
-      return ColumnType.TIMESTAMP_TYPE_NAME;
-    case "timestampz":
-    case "timez":
-      return ColumnType.TIMESTAMPTZ_TYPE_NAME;
-    case "boolean":
-      return ColumnType.BOOLEAN_TYPE_NAME;
     default:
-      return ColumnType.VOID_TYPE_NAME;
+      mappedType = ColumnType.VOID_TYPE_NAME;
     }
+    return mappedType;
   }
 }
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/PostgreSQLConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/PostgreSQLConnectorProvider.java
index 41e08e9..1e7c65a 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/PostgreSQLConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/PostgreSQLConnectorProvider.java
@@ -45,72 +45,23 @@ public class PostgreSQLConnectorProvider extends AbstractJDBCConnectorProvider {
     return null;
   }
 
-  private String wrapSize(int size) {
-    return "(" + size + ")";
-  }
-
   protected String getDataType(String dbDataType, int size) {
+    String mappedType = super.getDataType(dbDataType, size);
+    if (!mappedType.equalsIgnoreCase(ColumnType.VOID_TYPE_NAME)) {
+      return mappedType;
+    }
+
+    // map any db specific types here.
     //TODO: Geomentric, network, bit, array data types of postgresql needs to be supported.
-    switch(dbDataType.toLowerCase())
+    switch (dbDataType.toLowerCase())
     {
-    case "char":
     case "bpchar":
-      return ColumnType.CHAR_TYPE_NAME + wrapSize(size);
-    case "varchar":
-    case "tinytext":
-      return ColumnType.VARCHAR_TYPE_NAME + wrapSize(size);
-    case "text":
-    case "mediumtext":
-    case "enum":
-    case "set":
-    case "tsvector":
-    case "tsquery":
-    case "uuid":
-    case "json":
-      return ColumnType.STRING_TYPE_NAME;
-    case "blob":
-    case "mediumblob":
-    case "longblob":
-    case "bytea":
-      return ColumnType.BINARY_TYPE_NAME;
-    case "tinyint":
-      return ColumnType.TINYINT_TYPE_NAME;
-    case "smallint":
-    case "smallserial":
-      return ColumnType.SMALLINT_TYPE_NAME;
-    case "mediumint":
-    case "int":
-    case "serial":
-      return ColumnType.INT_TYPE_NAME;
-    case "bigint":
-    case "bigserial":
+      mappedType = ColumnType.CHAR_TYPE_NAME + wrapSize(size);
     case "int8":
-    case "money":
-      return ColumnType.BIGINT_TYPE_NAME;
-    case "float":
-    case "real":
-      return ColumnType.FLOAT_TYPE_NAME;
-    case "double":
-    case "double precision":
-      return ColumnType.DOUBLE_TYPE_NAME;
-    case "decimal":
-    case "numeric":
-      return ColumnType.DECIMAL_TYPE_NAME;
-    case "date":
-      return ColumnType.DATE_TYPE_NAME;
-    case "datetime":
-      return ColumnType.DATETIME_TYPE_NAME;
-    case "timestamp":
-    case "time":
-    case "interval":
-      return ColumnType.TIMESTAMP_TYPE_NAME;
-    case "timestampz":
-    case "timez":
-      return ColumnType.TIMESTAMPTZ_TYPE_NAME;
-    case "boolean":
-      return ColumnType.BOOLEAN_TYPE_NAME;
+      mappedType = ColumnType.BIGINT_TYPE_NAME;
     default:
-      return ColumnType.VOID_TYPE_NAME;
+      mappedType = ColumnType.VOID_TYPE_NAME;
     }
+    return mappedType;
   }
 }

[hive] 28/38: HIVE-24396: Database name for remote table should be set to hive dbname not the scoped dbname

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 2b4fa4e48f19f5c5ed6807ebcbe3d973b5398f88
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Tue Dec 1 15:59:57 2020 -0500

    HIVE-24396: Database name for remote table should be set to hive dbname not the scoped dbname
---
 .../hive/metastore/dataconnector/AbstractDataConnectorProvider.java      | 1 -
 1 file changed, 1 deletion(-)

diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/AbstractDataConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/AbstractDataConnectorProvider.java
index 64653b3..5375dfd 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/AbstractDataConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/AbstractDataConnectorProvider.java
@@ -114,7 +114,6 @@ public abstract class AbstractDataConnectorProvider implements IDataConnectorPro
     Table table = new Table();
     table.setTableName(tableName);
     table.setTableType(TableType.EXTERNAL_TABLE.toString());
-    table.setDbName(scoped_db);
     table.setSd(sd);
     // set table properties that subclasses can fill-in
     table.setParameters(new HashMap<String, String>());

[hive] 05/38: Deleted commented out code and fixed location and IO classes

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 80013b401ce13311d923896eff7e5fff96d5ec5e
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Mon Nov 16 14:13:38 2020 -0500

    Deleted commented out code and fixed location and IO classes
---
 .../apache/hadoop/hive/metastore/Warehouse.java    |  6 +--
 .../AbstractDataConnectorProvider.java             |  8 +--
 .../jdbc/AbstractJDBCConnectorProvider.java        | 60 ++++++----------------
 .../dataconnector/jdbc/MySQLConnectorProvider.java | 57 --------------------
 4 files changed, 22 insertions(+), 109 deletions(-)

diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java
index ef52ed9..608c56f 100755
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java
@@ -227,7 +227,7 @@ public class Warehouse {
    */
   public Path determineDatabasePath(Catalog cat, Database db) throws MetaException {
     if (db.getType() == DatabaseType.REMOTE) {
-      return getRemoteDatabasePath();
+      return getDefaultDatabasePath(db.getName(), true);
     }
     if (db.isSetLocationUri()) {
       return getDnsPath(new Path(db.getLocationUri()));
@@ -334,10 +334,6 @@ public class Warehouse {
     }
   }
 
-  public Path getRemoteDatabasePath() throws MetaException {
-    return new Path(getWhRootExternal(), "dummy_path_for_remote_database.db");
-  }
-
   private boolean hasExternalWarehouseRoot() {
     return !StringUtils.isBlank(whRootExternalString);
   }
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/AbstractDataConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/AbstractDataConnectorProvider.java
index 74ddbdd..04a5842 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/AbstractDataConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/AbstractDataConnectorProvider.java
@@ -89,9 +89,9 @@ public abstract class AbstractDataConnectorProvider implements IDataConnectorPro
     serdeInfo.setParameters(serdeParams);
 
     sd.setSerdeInfo(serdeInfo);
-    sd.setInputFormat("org.apache.hive.storage.jdbc.JdbcInputFormat"); // TODO
-    sd.setOutputFormat("org.apache.hive.storage.jdbc.JdbcOutputFormat"); // TODO
-    sd.setLocation("/tmp/some_dummy_path"); // TODO
+    sd.setInputFormat(getInputClass());
+    sd.setOutputFormat(getOutputClass());
+    sd.setLocation(getTableLocation(tableName));
     sd.setBucketCols(new ArrayList<String>());
     sd.setSortCols(new ArrayList<Order>());
 
@@ -113,4 +113,6 @@ public abstract class AbstractDataConnectorProvider implements IDataConnectorPro
   abstract protected String getInputClass();
 
   abstract protected String getOutputClass();
+
+  abstract protected String getTableLocation(String tblName);
 }
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
index d436123..62a7786 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
@@ -1,5 +1,6 @@
 package org.apache.hadoop.hive.metastore.dataconnector.jdbc;
 
+import org.apache.hadoop.hive.metastore.Warehouse;
 import org.apache.hadoop.hive.metastore.api.DataConnector;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.metastore.api.MetaException;
@@ -22,6 +23,7 @@ import java.util.Map;
 
 public abstract class AbstractJDBCConnectorProvider extends AbstractDataConnectorProvider {
   private static Logger LOG = LoggerFactory.getLogger(AbstractJDBCConnectorProvider.class);
+  protected static Warehouse warehouse = null;
 
   // duplicate constants from Constants.java to avoid a dependency on hive-common
   public static final String JDBC_HIVE_STORAGE_HANDLER_ID =
@@ -72,6 +74,10 @@ public abstract class AbstractJDBCConnectorProvider extends AbstractDataConnecto
         LOG.warn("Could not read key value from keystore");
       }
     }
+
+    try {
+      warehouse = new Warehouse(MetastoreConf.newMetastoreConf());
+    } catch (MetaException e) { /* ignore */ }
   }
 
   @Override public void open() throws ConnectException {
@@ -165,48 +171,17 @@ public abstract class AbstractJDBCConnectorProvider extends AbstractDataConnecto
     try {
       // rs = fetchTableMetadata(tableName);
       rs = fetchTableViaDBMetaData(tableName);
-      /*
-      Statement stmt = getConnection().createStatement();
-      rs = stmt.executeQuery(
-          "SELECT table_name, column_name, is_nullable, data_type, character_maximum_length FROM INFORMATION_SCHEMA.Columns where table_schema='"
-              + scoped_db + "' and table_name='" + tableName + "'");
-       */
       List<FieldSchema> cols = new ArrayList<>();
       // TODO throw exception is RS is empty
       while (rs.next()) {
         FieldSchema fs = new FieldSchema();
         fs.setName(rs.getString("COLUMN_NAME"));
-        // fs.setType(getDataType(rs.getString("DATA_TYPE"), rs.getInt("CHARACTER_MAXIMUM_LENGTH")));
         fs.setType(getDataType(rs.getString("TYPE_NAME"), rs.getInt("COLUMN_SIZE")));
         fs.setComment("inferred column type");
         cols.add(fs);
       }
 
       table = buildTableFromColsList(tableName, cols);
-      /*
-      //Setting the storage descriptor.
-      StorageDescriptor sd = new StorageDescriptor();
-      sd.setCols(cols);
-      // sd.se
-      SerDeInfo serdeInfo = new SerDeInfo();
-      serdeInfo.setName(tableName);
-      serdeInfo.setSerializationLib("org.apache.hive.storage.jdbc.JdbcSerDe");
-      Map<String, String> serdeParams = new HashMap<String, String>();
-      serdeParams.put("serialization.format", "1");
-      serdeInfo.setParameters(serdeParams);
-
-      // StorageHandler
-
-      // serdeInfo.setDeserializerClass();
-      sd.setSerdeInfo(serdeInfo);
-      // sd.getSerdeInfo().setName(tableName);
-      sd.setInputFormat("org.apache.hive.storage.jdbc.JdbcInputFormat"); // TODO
-      sd.setOutputFormat("org.apache.hive.storage.jdbc.JdbcOutputFormat"); // TODO
-      sd.setLocation("/tmp/some_dummy_path"); // TODO
-      sd.setBucketCols(new ArrayList<String>());
-      sd.setSortCols(new ArrayList<Order>());
-       */
-
       //Setting the table properties.
       table.getParameters().put(JDBC_DATABASE_TYPE, this.type);
       table.getParameters().put(JDBC_DRIVER, this.driverClassName);
@@ -220,19 +195,6 @@ public abstract class AbstractJDBCConnectorProvider extends AbstractDataConnecto
           table.getParameters().put(param, connectorParams.get(param));
         }
       }
-      // TODO: Need to include schema, catalog info in the parameters list.
-
-      //Setting the required table information
-      // Table table = new Table();
-      // table.setTableName(tableName);
-      // table.setTableType(TableType.EXTERNAL_TABLE.toString());
-      // table.setDbName(scoped_db);
-      // table.setSd(sd);
-      // set partition keys to empty
-      // table.setPartitionKeys(new
-          // ArrayList<FieldSchema>());
-
-      // table.setParameters(tblProps);
       return table;
     } catch (Exception e) {
       LOG.warn("Exception retrieving remote table " + scoped_db + "." + tableName + " via data connector "
@@ -335,4 +297,14 @@ public abstract class AbstractJDBCConnectorProvider extends AbstractDataConnecto
   @Override protected String getOutputClass() {
     return JDBC_INPUTFORMAT_CLASS;
   }
+  @Override protected String getTableLocation(String tableName) {
+    if (warehouse != null) {
+      try {
+        return warehouse.getDefaultTablePath(scoped_db, tableName, true).toString();
+      } catch (MetaException e) {
+        LOG.info("Error determining default table path, cause:" + e.getMessage());
+      }
+    }
+    return "some_dummy_path";
+  }
 }
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConnectorProvider.java
index cdeb6fa..f4f9b62 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConnectorProvider.java
@@ -61,63 +61,6 @@ public class MySQLConnectorProvider extends AbstractJDBCConnectorProvider {
       ResultSet rs = stmt.executeQuery(
           "SELECT table_name, column_name, is_nullable, data_type, character_maximum_length FROM INFORMATION_SCHEMA.Columns where table_schema='"
               + scoped_db + "' and table_name='" + tableName + "'");
-      /*
-      List<FieldSchema> cols = new ArrayList<>();
-      // TODO throw exception is RS is empty
-      while (rs.next()) {
-        FieldSchema fs = new FieldSchema();
-        fs.setName(rs.getString("COLUMN_NAME"));
-        fs.setType(getDataType(rs.getString("DATA_TYPE"), rs.getInt("CHARACTER_MAXIMUM_LENGTH")));
-        fs.setComment("inferred column type");
-        cols.add(fs);
-      }
-
-      //Setting the storage descriptor.
-      StorageDescriptor sd = new StorageDescriptor();
-      sd.setCols(cols);
-      // sd.se
-      SerDeInfo serdeInfo = new SerDeInfo();
-      serdeInfo.setName(tableName);
-      serdeInfo.setSerializationLib("org.apache.hive.storage.jdbc.JdbcSerDe");
-      Map<String, String> serdeParams = new HashMap<String, String>();
-      serdeParams.put("serialization.format", "1");
-      serdeInfo.setParameters(serdeParams);
-
-      // StorageHandler
-
-      // serdeInfo.setDeserializerClass();
-      sd.setSerdeInfo(serdeInfo);
-      // sd.getSerdeInfo().setName(tableName);
-      sd.setInputFormat("org.apache.hive.storage.jdbc.JdbcInputFormat"); // TODO
-      sd.setOutputFormat("org.apache.hive.storage.jdbc.JdbcOutputFormat"); // TODO
-      sd.setLocation("/tmp/some_dummy_path"); // TODO
-      sd.setBucketCols(new ArrayList<String>());
-      sd.setSortCols(new ArrayList<Order>());
-
-      //Setting the table properties.
-      Map<String, String> tblProps = new HashMap<>();
-      tblProps.put(Constants.JDBC_DATABASE_TYPE, this.type);
-      tblProps.put(Constants.JDBC_DRIVER, this.driverClassName);
-      tblProps.put(Constants.JDBC_URL, this.jdbcUrl); // "jdbc://localhost:3306/hive"
-      tblProps.put(Constants.JDBC_USERNAME, this.username);
-      tblProps.put(Constants.JDBC_PASSWORD, this.password);
-      tblProps.put(Constants.JDBC_TABLE, tableName);
-      tblProps.put(hive_metastoreConstants.META_TABLE_STORAGE, Constants.JDBC_HIVE_STORAGE_HANDLER_ID);
-      tblProps.put("EXTERNAL", "TRUE");
-      // TODO: Need to include schema, catalog info in the paramters list.
-
-      //Setting the required table information
-      Table table = new Table();
-      table.setTableName(tableName);
-      table.setTableType(TableType.EXTERNAL_TABLE.toString());
-      table.setDbName(scoped_db);
-      table.setSd(sd);
-      table.setParameters(tblProps);
-      // set partition keys to empty
-      table.setPartitionKeys(new ArrayList<FieldSchema>());
-
-      return table;
-       */
       return rs;
     } catch (Exception e) {
       LOG.warn("Exception retrieving remote table " + scoped_db + "." + tableName + " via data connector "

[hive] 23/38: HIVE-24396: Addressing test failures

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 60ae0139c75eafeb06984c3f7f1ca91c292d730f
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Mon Nov 30 18:38:50 2020 -0500

    HIVE-24396: Addressing test failures
---
 .../hadoop/hive/metastore/HiveMetaStore.java       | 10360 +++++++++++++++++++
 1 file changed, 10360 insertions(+)

diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
index 2af557e..88261e2 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
@@ -15,6 +15,10366 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.apache.hadoop.hive.metastore;
+
+import static org.apache.commons.lang3.StringUtils.join;
+import static org.apache.commons.lang3.StringUtils.isBlank;
+import static org.apache.hadoop.hive.metastore.Warehouse.DEFAULT_DATABASE_COMMENT;
+import static org.apache.hadoop.hive.metastore.Warehouse.DEFAULT_DATABASE_NAME;
+import static org.apache.hadoop.hive.metastore.Warehouse.DEFAULT_CATALOG_NAME;
+import static org.apache.hadoop.hive.metastore.Warehouse.getCatalogQualifiedTableName;
+import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.getDefaultCatalog;
+import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.parseDbName;
+import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.CAT_NAME;
+import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.DB_NAME;
+import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.prependCatalogToDbName;
+import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.prependNotNullCatToDbName;
+
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.nio.ByteBuffer;
+import java.security.PrivilegedExceptionAction;
+import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.regex.Pattern;
+
+import javax.jdo.JDOException;
+
+import com.codahale.metrics.Counter;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.collect.Lists;
+
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.common.AcidConstants;
+import org.apache.hadoop.hive.common.AcidMetaDataFile;
+import org.apache.hadoop.hive.common.StatsSetupConst;
+import org.apache.hadoop.hive.common.TableName;
+import org.apache.hadoop.hive.common.ValidReaderWriteIdList;
+import org.apache.hadoop.hive.common.ValidWriteIdList;
+import org.apache.hadoop.hive.common.ZooKeeperHiveHelper;
+import org.apache.hadoop.hive.common.ZKDeRegisterWatcher;
+import org.apache.hadoop.hive.common.repl.ReplConst;
+import org.apache.hadoop.hive.metastore.api.*;
+import org.apache.hadoop.hive.metastore.dataconnector.DataConnectorProviderFactory;
+import org.apache.hadoop.hive.metastore.events.*;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf.StatsUpdateMode;
+import org.apache.hadoop.hive.metastore.messaging.EventMessage.EventType;
+import org.apache.hadoop.hive.metastore.metrics.JvmPauseMonitor;
+import org.apache.hadoop.hive.metastore.metrics.Metrics;
+import org.apache.hadoop.hive.metastore.metrics.MetricsConstants;
+import org.apache.hadoop.hive.metastore.metrics.PerfLogger;
+import org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy;
+import org.apache.hadoop.hive.metastore.security.HadoopThriftAuthBridge;
+import org.apache.hadoop.hive.metastore.security.MetastoreDelegationTokenManager;
+import org.apache.hadoop.hive.metastore.txn.CompactionInfo;
+import org.apache.hadoop.hive.metastore.txn.TxnStore;
+import org.apache.hadoop.hive.metastore.txn.TxnUtils;
+import org.apache.hadoop.hive.metastore.utils.FilterUtils;
+import org.apache.hadoop.hive.metastore.utils.MetaStoreServerUtils;
+import org.apache.hadoop.security.SecurityUtil;
+import org.apache.hadoop.hive.metastore.utils.CommonCliOptions;
+import org.apache.hadoop.hive.metastore.utils.FileUtils;
+import org.apache.hadoop.hive.metastore.utils.HdfsUtils;
+import org.apache.hadoop.hive.metastore.utils.JavaUtils;
+import org.apache.hadoop.hive.metastore.utils.LogUtils;
+import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils;
+import org.apache.hadoop.hive.metastore.utils.MetastoreVersionInfo;
+import org.apache.hadoop.hive.metastore.utils.SecurityUtils;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.util.ReflectionUtils;
+import org.apache.hadoop.util.ShutdownHookManager;
+import org.apache.hadoop.util.StringUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.thrift.TException;
+import org.apache.thrift.TProcessor;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TCompactProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.protocol.TProtocolFactory;
+import org.apache.thrift.server.ServerContext;
+import org.apache.thrift.server.TServer;
+import org.apache.thrift.server.TServerEventHandler;
+import org.apache.thrift.server.TThreadPoolServer;
+import org.apache.thrift.transport.TServerSocket;
+import org.apache.thrift.transport.TTransport;
+import org.apache.thrift.transport.TTransportFactory;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.facebook.fb303.FacebookBase;
+import com.facebook.fb303.fb_status;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Splitter;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+
+/**
+ * TODO:pc remove application logic to a separate interface.
+ */
+public class HiveMetaStore extends ThriftHiveMetastore {
+  public static final Logger LOG = LoggerFactory.getLogger(HiveMetaStore.class);
+  public static final String PARTITION_NUMBER_EXCEED_LIMIT_MSG =
+      "Number of partitions scanned (=%d) on table '%s' exceeds limit (=%d). This is controlled on the metastore server by %s.";
+
+  // boolean that tells if the HiveMetaStore (remote) server is being used.
+  // Can be used to determine if the calls to metastore api (HMSHandler) are being made with
+  // embedded metastore or a remote one
+  private static boolean isMetaStoreRemote = false;
+
+  // Used for testing to simulate method timeout.
+  @VisibleForTesting
+  static boolean TEST_TIMEOUT_ENABLED = false;
+  @VisibleForTesting
+  static long TEST_TIMEOUT_VALUE = -1;
+
+  private static ShutdownHookManager shutdownHookMgr;
+
+  public static final String ADMIN = "admin";
+  public static final String PUBLIC = "public";
+  /** MM write states. */
+  public static final char MM_WRITE_OPEN = 'o', MM_WRITE_COMMITTED = 'c', MM_WRITE_ABORTED = 'a';
+
+  private static HadoopThriftAuthBridge.Server saslServer;
+  private static MetastoreDelegationTokenManager delegationTokenManager;
+  private static boolean useSasl;
+
+  static final String NO_FILTER_STRING = "";
+  static final int UNLIMITED_MAX_PARTITIONS = -1;
+  private static ZooKeeperHiveHelper zooKeeperHelper = null;
+  private static String msHost = null;
+
+  public static boolean isRenameAllowed(Database srcDB, Database destDB) {
+    if (!srcDB.getName().equalsIgnoreCase(destDB.getName())) {
+      if (ReplChangeManager.isSourceOfReplication(srcDB) || ReplChangeManager.isSourceOfReplication(destDB)) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  public static class HMSHandler extends FacebookBase implements IHMSHandler {
+    public static final Logger LOG = HiveMetaStore.LOG;
+    private final Configuration conf; // stores datastore (jpox) properties,
+                                     // right now they come from jpox.properties
+
+    // Flag to control that always threads are initialized only once
+    // instead of multiple times
+    private final static AtomicBoolean alwaysThreadsInitialized =
+        new AtomicBoolean(false);
+
+    private static String currentUrl;
+    private FileMetadataManager fileMetadataManager;
+    private PartitionExpressionProxy expressionProxy;
+    private StorageSchemaReader storageSchemaReader;
+    private IMetaStoreMetadataTransformer transformer;
+    private static DataConnectorProviderFactory dataconnectorFactory = null;
+
+    // Variables for metrics
+    // Package visible so that HMSMetricsListener can see them.
+    static AtomicInteger databaseCount, tableCount, partCount;
+
+    private Warehouse wh; // hdfs warehouse
+    private static final ThreadLocal<RawStore> threadLocalMS =
+        new ThreadLocal<RawStore>() {
+          @Override
+          protected RawStore initialValue() {
+            return null;
+          }
+        };
+
+    private static final ThreadLocal<TxnStore> threadLocalTxn = new ThreadLocal<TxnStore>() {
+      @Override
+      protected TxnStore initialValue() {
+        return null;
+      }
+    };
+
+    private static final ThreadLocal<Map<String, com.codahale.metrics.Timer.Context>> timerContexts =
+        new ThreadLocal<Map<String, com.codahale.metrics.Timer.Context>>() {
+      @Override
+      protected Map<String, com.codahale.metrics.Timer.Context> initialValue() {
+        return new HashMap<>();
+      }
+    };
+
+    public static RawStore getRawStore() {
+      return threadLocalMS.get();
+    }
+
+    static void removeRawStore() {
+      threadLocalMS.remove();
+    }
+
+    // Thread local configuration is needed as many threads could make changes
+    // to the conf using the connection hook
+    private static final ThreadLocal<Configuration> threadLocalConf =
+        new ThreadLocal<Configuration>() {
+          @Override
+          protected Configuration initialValue() {
+            return null;
+          }
+        };
+
+    /**
+     * Thread local HMSHandler used during shutdown to notify meta listeners
+     */
+    private static final ThreadLocal<HMSHandler> threadLocalHMSHandler = new ThreadLocal<>();
+
+    /**
+     * Thread local Map to keep track of modified meta conf keys
+     */
+    private static final ThreadLocal<Map<String, String>> threadLocalModifiedConfig =
+        new ThreadLocal<>();
+
+    private static ExecutorService threadPool;
+
+    static final Logger auditLog = LoggerFactory.getLogger(
+        HiveMetaStore.class.getName() + ".audit");
+
+    private static void logAuditEvent(String cmd) {
+      if (cmd == null) {
+        return;
+      }
+
+      UserGroupInformation ugi;
+      try {
+        ugi = SecurityUtils.getUGI();
+      } catch (Exception ex) {
+        throw new RuntimeException(ex);
+      }
+
+      String address = getIPAddress();
+      if (address == null) {
+        address = "unknown-ip-addr";
+      }
+
+      auditLog.info("ugi={}	ip={}	cmd={}	", ugi.getUserName(), address, cmd);
+    }
+
+    public static String getIPAddress() {
+      if (useSasl) {
+        if (saslServer != null && saslServer.getRemoteAddress() != null) {
+          return saslServer.getRemoteAddress().getHostAddress();
+        }
+      } else {
+        // if kerberos is not enabled
+        return getThreadLocalIpAddress();
+      }
+      return null;
+    }
+
+    private static AtomicInteger nextSerialNum = new AtomicInteger();
+    private static ThreadLocal<Integer> threadLocalId = new ThreadLocal<Integer>() {
+      @Override
+      protected Integer initialValue() {
+        return nextSerialNum.getAndIncrement();
+      }
+    };
+
+    // This will only be set if the metastore is being accessed from a metastore Thrift server,
+    // not if it is from the CLI. Also, only if the TTransport being used to connect is an
+    // instance of TSocket. This is also not set when kerberos is used.
+    private static ThreadLocal<String> threadLocalIpAddress = new ThreadLocal<String>() {
+      @Override
+      protected String initialValue() {
+        return null;
+      }
+    };
+
+    /**
+     * Internal function to notify listeners for meta config change events
+     */
+    private void notifyMetaListeners(String key, String oldValue, String newValue) throws MetaException {
+      for (MetaStoreEventListener listener : listeners) {
+        listener.onConfigChange(new ConfigChangeEvent(this, key, oldValue, newValue));
+      }
+
+      if (transactionalListeners.size() > 0) {
+        // All the fields of this event are final, so no reason to create a new one for each
+        // listener
+        ConfigChangeEvent cce = new ConfigChangeEvent(this, key, oldValue, newValue);
+        for (MetaStoreEventListener transactionalListener : transactionalListeners) {
+          transactionalListener.onConfigChange(cce);
+        }
+      }
+    }
+
+    /**
+     * Internal function to notify listeners to revert back to old values of keys
+     * that were modified during setMetaConf. This would get called from HiveMetaStore#cleanupRawStore
+     */
+    private void notifyMetaListenersOnShutDown() {
+      Map<String, String> modifiedConf = threadLocalModifiedConfig.get();
+      if (modifiedConf == null) {
+        // Nothing got modified
+        return;
+      }
+      try {
+        Configuration conf = threadLocalConf.get();
+        if (conf == null) {
+          throw new MetaException("Unexpected: modifiedConf is non-null but conf is null");
+        }
+        // Notify listeners of the changed value
+        for (Entry<String, String> entry : modifiedConf.entrySet()) {
+          String key = entry.getKey();
+          // curr value becomes old and vice-versa
+          String currVal = entry.getValue();
+          String oldVal = conf.get(key);
+          if (!Objects.equals(oldVal, currVal)) {
+            notifyMetaListeners(key, oldVal, currVal);
+          }
+        }
+        logAndAudit("Meta listeners shutdown notification completed.");
+      } catch (MetaException e) {
+        LOG.error("Failed to notify meta listeners on shutdown: ", e);
+      }
+    }
+
+    static void setThreadLocalIpAddress(String ipAddress) {
+      threadLocalIpAddress.set(ipAddress);
+    }
+
+    // This will return null if the metastore is not being accessed from a metastore Thrift server,
+    // or if the TTransport being used to connect is not an instance of TSocket, or if kereberos
+    // is used
+    static String getThreadLocalIpAddress() {
+      return threadLocalIpAddress.get();
+    }
+
+    // Make it possible for tests to check that the right type of PartitionExpressionProxy was
+    // instantiated.
+    @VisibleForTesting
+    PartitionExpressionProxy getExpressionProxy() {
+      return expressionProxy;
+    }
+
+    /**
+     * Use {@link #getThreadId()} instead.
+     * @return thread id
+     */
+    @Deprecated
+    public static Integer get() {
+      return threadLocalId.get();
+    }
+
+    @Override
+    public int getThreadId() {
+      return threadLocalId.get();
+    }
+
+    public HMSHandler(String name) throws MetaException {
+      this(name, MetastoreConf.newMetastoreConf(), true);
+    }
+
+    public HMSHandler(String name, Configuration conf) throws MetaException {
+      this(name, conf, true);
+    }
+
+    public HMSHandler(String name, Configuration conf, boolean init) throws MetaException {
+      super(name);
+      this.conf = conf;
+      isInTest = MetastoreConf.getBoolVar(this.conf, ConfVars.HIVE_IN_TEST);
+      if (threadPool == null) {
+        synchronized (HMSHandler.class) {
+          int numThreads = MetastoreConf.getIntVar(conf, ConfVars.FS_HANDLER_THREADS_COUNT);
+          threadPool = Executors.newFixedThreadPool(numThreads,
+              new ThreadFactoryBuilder().setDaemon(true)
+                  .setNameFormat("HMSHandler #%d").build());
+        }
+      }
+      if (init) {
+        init();
+      }
+    }
+
+    /**
+     * Use {@link #getConf()} instead.
+     * @return Configuration object
+     */
+    @Deprecated
+    public Configuration getHiveConf() {
+      return conf;
+    }
+
+    private ClassLoader classLoader;
+    private AlterHandler alterHandler;
+    private List<MetaStorePreEventListener> preListeners;
+    private List<MetaStoreEventListener> listeners;
+    private List<TransactionalMetaStoreEventListener> transactionalListeners;
+    private List<MetaStoreEndFunctionListener> endFunctionListeners;
+    private List<MetaStoreInitListener> initListeners;
+    private MetaStoreFilterHook filterHook;
+    private boolean isServerFilterEnabled = false;
+
+    private Pattern partitionValidationPattern;
+    private final boolean isInTest;
+
+    {
+      classLoader = Thread.currentThread().getContextClassLoader();
+      if (classLoader == null) {
+        classLoader = Configuration.class.getClassLoader();
+      }
+    }
+
+    @Override
+    public List<TransactionalMetaStoreEventListener> getTransactionalListeners() {
+      return transactionalListeners;
+    }
+
+    @Override
+    public List<MetaStoreEventListener> getListeners() {
+      return listeners;
+    }
+
+    @Override
+    public void init() throws MetaException {
+      initListeners = MetaStoreServerUtils.getMetaStoreListeners(
+          MetaStoreInitListener.class, conf, MetastoreConf.getVar(conf, ConfVars.INIT_HOOKS));
+      for (MetaStoreInitListener singleInitListener: initListeners) {
+          MetaStoreInitContext context = new MetaStoreInitContext();
+          singleInitListener.onInit(context);
+      }
+
+      String alterHandlerName = MetastoreConf.getVar(conf, ConfVars.ALTER_HANDLER);
+      alterHandler = ReflectionUtils.newInstance(JavaUtils.getClass(
+          alterHandlerName, AlterHandler.class), conf);
+      wh = new Warehouse(conf);
+
+      synchronized (HMSHandler.class) {
+        if (currentUrl == null || !currentUrl.equals(MetaStoreInit.getConnectionURL(conf))) {
+          createDefaultDB();
+          createDefaultRoles();
+          addAdminUsers();
+          currentUrl = MetaStoreInit.getConnectionURL(conf);
+        }
+      }
+
+      //Start Metrics
+      if (MetastoreConf.getBoolVar(conf, ConfVars.METRICS_ENABLED)) {
+        LOG.info("Begin calculating metadata count metrics.");
+        Metrics.initialize(conf);
+        databaseCount = Metrics.getOrCreateGauge(MetricsConstants.TOTAL_DATABASES);
+        tableCount = Metrics.getOrCreateGauge(MetricsConstants.TOTAL_TABLES);
+        partCount = Metrics.getOrCreateGauge(MetricsConstants.TOTAL_PARTITIONS);
+        updateMetrics();
+
+      }
+
+      preListeners = MetaStoreServerUtils.getMetaStoreListeners(MetaStorePreEventListener.class,
+          conf, MetastoreConf.getVar(conf, ConfVars.PRE_EVENT_LISTENERS));
+      preListeners.add(0, new TransactionalValidationListener(conf));
+      listeners = MetaStoreServerUtils.getMetaStoreListeners(MetaStoreEventListener.class, conf,
+          MetastoreConf.getVar(conf, ConfVars.EVENT_LISTENERS));
+      listeners.add(new SessionPropertiesListener(conf));
+      transactionalListeners = new ArrayList() {{
+          add(new AcidEventListener(conf));
+      }};
+      transactionalListeners.addAll(MetaStoreServerUtils.getMetaStoreListeners(
+              TransactionalMetaStoreEventListener.class, conf,
+              MetastoreConf.getVar(conf, ConfVars.TRANSACTIONAL_EVENT_LISTENERS)));
+      if (Metrics.getRegistry() != null) {
+        listeners.add(new HMSMetricsListener(conf));
+      }
+
+      boolean canCachedStoreCanUseEvent = false;
+      for (MetaStoreEventListener listener : transactionalListeners) {
+        if (listener.doesAddEventsToNotificationLogTable()) {
+          canCachedStoreCanUseEvent = true;
+          break;
+        }
+      }
+      if (conf.getBoolean(ConfVars.METASTORE_CACHE_CAN_USE_EVENT.getVarname(), false) &&
+              !canCachedStoreCanUseEvent) {
+        throw new MetaException("CahcedStore can not use events for invalidation as there is no " +
+                " TransactionalMetaStoreEventListener to add events to notification table");
+      }
+
+      endFunctionListeners = MetaStoreServerUtils.getMetaStoreListeners(
+          MetaStoreEndFunctionListener.class, conf, MetastoreConf.getVar(conf, ConfVars.END_FUNCTION_LISTENERS));
+
+      String partitionValidationRegex =
+          MetastoreConf.getVar(conf, ConfVars.PARTITION_NAME_WHITELIST_PATTERN);
+      if (partitionValidationRegex != null && !partitionValidationRegex.isEmpty()) {
+        partitionValidationPattern = Pattern.compile(partitionValidationRegex);
+      } else {
+        partitionValidationPattern = null;
+      }
+
+      // We only initialize once the tasks that need to be run periodically. For remote metastore
+      // these threads are started along with the other housekeeping threads only in the leader
+      // HMS.
+      String leaderHost = MetastoreConf.getVar(conf,
+              MetastoreConf.ConfVars.METASTORE_HOUSEKEEPING_LEADER_HOSTNAME);
+      if (!isMetaStoreRemote() && ((leaderHost == null) || leaderHost.trim().isEmpty())) {
+        startAlwaysTaskThreads(conf);
+      } else if (!isMetaStoreRemote()) {
+        LOG.info("Not starting tasks specified by " + ConfVars.TASK_THREADS_ALWAYS.getVarname() +
+                " since " + leaderHost + " is configured to run these tasks.");
+      }
+      expressionProxy = PartFilterExprUtil.createExpressionProxy(conf);
+      fileMetadataManager = new FileMetadataManager(this.getMS(), conf);
+
+      isServerFilterEnabled = getIfServerFilterenabled();
+      filterHook = isServerFilterEnabled ? loadFilterHooks() : null;
+
+      String className = MetastoreConf.getVar(conf, MetastoreConf.ConfVars.METASTORE_METADATA_TRANSFORMER_CLASS);
+      if (className != null && !className.trim().isEmpty()) {
+        Class<?> clazz;
+        try {
+          clazz = conf.getClassByName(className);
+        } catch (ClassNotFoundException e) {
+          LOG.error("Unable to load class " + className, e);
+          throw new IllegalArgumentException(e);
+        }
+        Constructor<?> constructor;
+        try {
+          constructor = clazz.getConstructor(IHMSHandler.class);
+          if (Modifier.isPrivate(constructor.getModifiers()))
+            throw new IllegalArgumentException("Illegal implementation for metadata transformer. Constructor is private");
+          transformer = (IMetaStoreMetadataTransformer) constructor.newInstance(this);
+        } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+          LOG.error("Unable to create instance of class " + className, e);
+          throw new IllegalArgumentException(e);
+        }
+      }
+      dataconnectorFactory = DataConnectorProviderFactory.getInstance(this);
+    }
+
+    private static void startAlwaysTaskThreads(Configuration conf) throws MetaException {
+      if (alwaysThreadsInitialized.compareAndSet(false, true)) {
+        ThreadPool.initialize(conf);
+        Collection<String> taskNames =
+                MetastoreConf.getStringCollection(conf, ConfVars.TASK_THREADS_ALWAYS);
+        for (String taskName : taskNames) {
+          MetastoreTaskThread task =
+                  JavaUtils.newInstance(JavaUtils.getClass(taskName, MetastoreTaskThread.class));
+          task.setConf(conf);
+          long freq = task.runFrequency(TimeUnit.MILLISECONDS);
+          LOG.info("Scheduling for " + task.getClass().getCanonicalName() + " service with " +
+                  "frequency " + freq + "ms.");
+          // For backwards compatibility, since some threads used to be hard coded but only run if
+          // frequency was > 0
+          if (freq > 0) {
+            ThreadPool.getPool().scheduleAtFixedRate(task, freq, freq, TimeUnit.MILLISECONDS);
+          }
+        }
+      }
+    }
+
+    /**
+     *
+     * Filter is actually enabled only when the configured filter hook is configured, not default, and
+     * enabled in configuration
+     * @return
+     */
+    private boolean getIfServerFilterenabled() throws MetaException{
+      boolean isEnabled = MetastoreConf.getBoolVar(conf, ConfVars.METASTORE_SERVER_FILTER_ENABLED);
+
+      if (!isEnabled) {
+        LOG.info("HMS server filtering is disabled by configuration");
+        return false;
+      }
+
+      String filterHookClassName = MetastoreConf.getVar(conf, ConfVars.FILTER_HOOK);
+
+      if (isBlank(filterHookClassName)) {
+        throw new MetaException("HMS server filtering is enabled but no filter hook is configured");
+      }
+
+      if (filterHookClassName.trim().equalsIgnoreCase(DefaultMetaStoreFilterHookImpl.class.getName())) {
+        throw new MetaException("HMS server filtering is enabled but the filter hook is DefaultMetaStoreFilterHookImpl, which does no filtering");
+      }
+
+      LOG.info("HMS server filtering is enabled. The filter class is " + filterHookClassName);
+      return true;
+    }
+
+    private MetaStoreFilterHook loadFilterHooks() throws IllegalStateException  {
+      String errorMsg = "Unable to load filter hook at HMS server. ";
+
+      String filterHookClassName = MetastoreConf.getVar(conf, ConfVars.FILTER_HOOK);
+      Preconditions.checkState(!isBlank(filterHookClassName));
+
+      try {
+        return (MetaStoreFilterHook)Class.forName(
+            filterHookClassName.trim(), true, JavaUtils.getClassLoader()).getConstructor(
+            Configuration.class).newInstance(conf);
+      } catch (Exception e) {
+        LOG.error(errorMsg, e);
+        throw new IllegalStateException(errorMsg + e.getMessage(), e);
+      }
+    }
+
+    /**
+     * Check if user can access the table associated with the partition. If not, then throw exception
+     * so user cannot access partitions associated with this table
+     * We are not calling Pre event listener for authorization because it requires getting the
+     * table object from DB, more overhead. Instead ,we call filter hook to filter out table if user
+     * has no access. Filter hook only requires table name, not table object. That saves DB access for
+     * table object, and still achieve the same purpose: checking if user can access the specified
+     * table
+     *
+     * @param catName catalog name of the table
+     * @param dbName database name of the table
+     * @param tblName table name
+     * @throws NoSuchObjectException
+     * @throws MetaException
+     */
+    private void authorizeTableForPartitionMetadata(
+        final String catName, final String dbName, final String tblName)
+        throws NoSuchObjectException, MetaException {
+
+      FilterUtils.checkDbAndTableFilters(
+          isServerFilterEnabled, filterHook, catName, dbName, tblName);
+    }
+
+    private static String addPrefix(String s) {
+      return threadLocalId.get() + ": " + s;
+    }
+
+    /**
+     * Set copy of invoking HMSHandler on thread local
+     */
+    private static void setHMSHandler(HMSHandler handler) {
+      if (threadLocalHMSHandler.get() == null) {
+        threadLocalHMSHandler.set(handler);
+      }
+    }
+    @Override
+    public void setConf(Configuration conf) {
+      threadLocalConf.set(conf);
+      RawStore ms = threadLocalMS.get();
+      if (ms != null) {
+        ms.setConf(conf); // reload if DS related configuration is changed
+      }
+    }
+
+    @Override
+    public Configuration getConf() {
+      Configuration conf = threadLocalConf.get();
+      if (conf == null) {
+        conf = new Configuration(this.conf);
+        threadLocalConf.set(conf);
+      }
+      return conf;
+    }
+
+    private Map<String, String> getModifiedConf() {
+      Map<String, String> modifiedConf = threadLocalModifiedConfig.get();
+      if (modifiedConf == null) {
+        modifiedConf = new HashMap<>();
+        threadLocalModifiedConfig.set(modifiedConf);
+      }
+      return modifiedConf;
+    }
+
+    @Override
+    public Warehouse getWh() {
+      return wh;
+    }
+
+    @Override
+    public void setMetaConf(String key, String value) throws MetaException {
+      ConfVars confVar = MetastoreConf.getMetaConf(key);
+      if (confVar == null) {
+        throw new MetaException("Invalid configuration key " + key);
+      }
+      try {
+        confVar.validate(value);
+      } catch (IllegalArgumentException e) {
+        throw new MetaException("Invalid configuration value " + value + " for key " + key +
+            " by " + e.getMessage());
+      }
+      Configuration configuration = getConf();
+      String oldValue = MetastoreConf.get(configuration, key);
+      // Save prev val of the key on threadLocal
+      Map<String, String> modifiedConf = getModifiedConf();
+      if (!modifiedConf.containsKey(key)) {
+        modifiedConf.put(key, oldValue);
+      }
+      // Set invoking HMSHandler on threadLocal, this will be used later to notify
+      // metaListeners in HiveMetaStore#cleanupRawStore
+      setHMSHandler(this);
+      configuration.set(key, value);
+      notifyMetaListeners(key, oldValue, value);
+
+      if (ConfVars.TRY_DIRECT_SQL == confVar) {
+        HMSHandler.LOG.info("Direct SQL optimization = {}",  value);
+      }
+    }
+
+    @Override
+    public String getMetaConf(String key) throws MetaException {
+      ConfVars confVar = MetastoreConf.getMetaConf(key);
+      if (confVar == null) {
+        throw new MetaException("Invalid configuration key " + key);
+      }
+      return getConf().get(key, confVar.getDefaultVal().toString());
+    }
+
+    /**
+     * Get a cached RawStore.
+     *
+     * @return the cached RawStore
+     * @throws MetaException
+     */
+    @Override
+    public RawStore getMS() throws MetaException {
+      Configuration conf = getConf();
+      return getMSForConf(conf);
+    }
+
+    public static RawStore getMSForConf(Configuration conf) throws MetaException {
+      RawStore ms = threadLocalMS.get();
+      if (ms == null) {
+        ms = newRawStoreForConf(conf);
+        try {
+          ms.verifySchema();
+        } catch (MetaException e) {
+          ms.shutdown();
+          throw e;
+        }
+        threadLocalMS.set(ms);
+        ms = threadLocalMS.get();
+        LOG.info("Created RawStore: " + ms + " from thread id: " + Thread.currentThread().getId());
+      }
+      return ms;
+    }
+
+    @Override
+    public TxnStore getTxnHandler() {
+      return getMsThreadTxnHandler(conf);
+    }
+
+    public static TxnStore getMsThreadTxnHandler(Configuration conf) {
+      TxnStore txn = threadLocalTxn.get();
+      if (txn == null) {
+        txn = TxnUtils.getTxnStore(conf);
+        threadLocalTxn.set(txn);
+      }
+      return txn;
+    }
+
+    static RawStore newRawStoreForConf(Configuration conf) throws MetaException {
+      Configuration newConf = new Configuration(conf);
+      String rawStoreClassName = MetastoreConf.getVar(newConf, ConfVars.RAW_STORE_IMPL);
+      LOG.info(addPrefix("Opening raw store with implementation class:" + rawStoreClassName));
+      return RawStoreProxy.getProxy(newConf, conf, rawStoreClassName, threadLocalId.get());
+    }
+
+    @VisibleForTesting
+    public static void createDefaultCatalog(RawStore ms, Warehouse wh) throws MetaException,
+        InvalidOperationException {
+      try {
+        Catalog defaultCat = ms.getCatalog(DEFAULT_CATALOG_NAME);
+        // Null check because in some test cases we get a null from ms.getCatalog.
+        if (defaultCat !=null && defaultCat.getLocationUri().equals("TBD")) {
+          // One time update issue.  When the new 'hive' catalog is created in an upgrade the
+          // script does not know the location of the warehouse.  So we need to update it.
+          LOG.info("Setting location of default catalog, as it hasn't been done after upgrade");
+          defaultCat.setLocationUri(wh.getWhRoot().toString());
+          ms.alterCatalog(defaultCat.getName(), defaultCat);
+        }
+
+      } catch (NoSuchObjectException e) {
+        Catalog cat = new Catalog(DEFAULT_CATALOG_NAME, wh.getWhRoot().toString());
+        long time = System.currentTimeMillis() / 1000;
+        cat.setCreateTime((int) time);
+        cat.setDescription(Warehouse.DEFAULT_CATALOG_COMMENT);
+        ms.createCatalog(cat);
+      }
+    }
+
+    private void createDefaultDB_core(RawStore ms) throws MetaException, InvalidObjectException {
+      try {
+        ms.getDatabase(DEFAULT_CATALOG_NAME, DEFAULT_DATABASE_NAME);
+      } catch (NoSuchObjectException e) {
+        LOG.info("Started creating a default database with name: "+DEFAULT_DATABASE_NAME);
+        Database db = new Database(DEFAULT_DATABASE_NAME, DEFAULT_DATABASE_COMMENT,
+            wh.getDefaultDatabasePath(DEFAULT_DATABASE_NAME, true).toString(), null);
+        db.setOwnerName(PUBLIC);
+        db.setOwnerType(PrincipalType.ROLE);
+        db.setCatalogName(DEFAULT_CATALOG_NAME);
+        long time = System.currentTimeMillis() / 1000;
+        db.setCreateTime((int) time);
+        ms.createDatabase(db);
+        LOG.info("Successfully created a default database with name: "+DEFAULT_DATABASE_NAME);
+      }
+    }
+
+    /**
+     * create default database if it doesn't exist.
+     *
+     * This is a potential contention when HiveServer2 using embedded metastore and Metastore
+     * Server try to concurrently invoke createDefaultDB. If one failed, JDOException was caught
+     * for one more time try, if failed again, simply ignored by warning, which meant another
+     * succeeds.
+     *
+     * @throws MetaException
+     */
+    private void createDefaultDB() throws MetaException {
+      try {
+        RawStore ms = getMS();
+        createDefaultCatalog(ms, wh);
+        createDefaultDB_core(ms);
+      } catch (JDOException e) {
+        LOG.warn("Retrying creating default database after error: " + e.getMessage(), e);
+        try {
+          RawStore ms = getMS();
+          createDefaultCatalog(ms, wh);
+          createDefaultDB_core(ms);
+        } catch (InvalidObjectException | InvalidOperationException e1) {
+          throw new MetaException(e1.getMessage());
+        }
+      } catch (InvalidObjectException|InvalidOperationException e) {
+        throw new MetaException(e.getMessage());
+      }
+    }
+
+    /**
+     * create default roles if they don't exist.
+     *
+     * This is a potential contention when HiveServer2 using embedded metastore and Metastore
+     * Server try to concurrently invoke createDefaultRoles. If one failed, JDOException was caught
+     * for one more time try, if failed again, simply ignored by warning, which meant another
+     * succeeds.
+     *
+     * @throws MetaException
+     */
+    private void createDefaultRoles() throws MetaException {
+      try {
+        createDefaultRoles_core();
+      } catch (JDOException e) {
+        LOG.warn("Retrying creating default roles after error: " + e.getMessage(), e);
+        createDefaultRoles_core();
+      }
+    }
+
+    private void createDefaultRoles_core() throws MetaException {
+
+      RawStore ms = getMS();
+      try {
+        ms.addRole(ADMIN, ADMIN);
+      } catch (InvalidObjectException e) {
+        LOG.debug(ADMIN +" role already exists",e);
+      } catch (NoSuchObjectException e) {
+        // This should never be thrown.
+        LOG.warn("Unexpected exception while adding " +ADMIN+" roles" , e);
+      }
+      LOG.info("Added "+ ADMIN+ " role in metastore");
+      try {
+        ms.addRole(PUBLIC, PUBLIC);
+      } catch (InvalidObjectException e) {
+        LOG.debug(PUBLIC + " role already exists",e);
+      } catch (NoSuchObjectException e) {
+        // This should never be thrown.
+        LOG.warn("Unexpected exception while adding "+PUBLIC +" roles" , e);
+      }
+      LOG.info("Added "+PUBLIC+ " role in metastore");
+      // now grant all privs to admin
+      PrivilegeBag privs = new PrivilegeBag();
+      privs.addToPrivileges(new HiveObjectPrivilege( new HiveObjectRef(HiveObjectType.GLOBAL, null,
+        null, null, null), ADMIN, PrincipalType.ROLE, new PrivilegeGrantInfo("All", 0, ADMIN,
+          PrincipalType.ROLE, true), "SQL"));
+      try {
+        ms.grantPrivileges(privs);
+      } catch (InvalidObjectException e) {
+        // Surprisingly these privs are already granted.
+        LOG.debug("Failed while granting global privs to admin", e);
+      } catch (NoSuchObjectException e) {
+        // Unlikely to be thrown.
+        LOG.warn("Failed while granting global privs to admin", e);
+      }
+    }
+
+    /**
+     * add admin users if they don't exist.
+     *
+     * This is a potential contention when HiveServer2 using embedded metastore and Metastore
+     * Server try to concurrently invoke addAdminUsers. If one failed, JDOException was caught for
+     * one more time try, if failed again, simply ignored by warning, which meant another succeeds.
+     *
+     * @throws MetaException
+     */
+    private void addAdminUsers() throws MetaException {
+      try {
+        addAdminUsers_core();
+      } catch (JDOException e) {
+        LOG.warn("Retrying adding admin users after error: " + e.getMessage(), e);
+        addAdminUsers_core();
+      }
+    }
+
+    private void addAdminUsers_core() throws MetaException {
+
+      // now add pre-configured users to admin role
+      String userStr = MetastoreConf.getVar(conf,ConfVars.USERS_IN_ADMIN_ROLE,"").trim();
+      if (userStr.isEmpty()) {
+        LOG.info("No user is added in admin role, since config is empty");
+        return;
+      }
+      // Since user names need to be valid unix user names, per IEEE Std 1003.1-2001 they cannot
+      // contain comma, so we can safely split above string on comma.
+
+     Iterator<String> users = Splitter.on(",").trimResults().omitEmptyStrings().split(userStr).iterator();
+      if (!users.hasNext()) {
+        LOG.info("No user is added in admin role, since config value "+ userStr +
+          " is in incorrect format. We accept comma separated list of users.");
+        return;
+      }
+      Role adminRole;
+      RawStore ms = getMS();
+      try {
+        adminRole = ms.getRole(ADMIN);
+      } catch (NoSuchObjectException e) {
+        LOG.error("Failed to retrieve just added admin role",e);
+        return;
+      }
+      while (users.hasNext()) {
+        String userName = users.next();
+        try {
+          ms.grantRole(adminRole, userName, PrincipalType.USER, ADMIN, PrincipalType.ROLE, true);
+          LOG.info("Added " + userName + " to admin role");
+        } catch (NoSuchObjectException e) {
+          LOG.error("Failed to add "+ userName + " in admin role",e);
+        } catch (InvalidObjectException e) {
+          LOG.debug(userName + " already in admin role", e);
+        }
+      }
+    }
+
+    private static void logAndAudit(final String m) {
+      LOG.debug("{}: {}", threadLocalId.get(), m);
+      logAuditEvent(m);
+    }
+
+    private String startFunction(String function, String extraLogInfo) {
+      incrementCounter(function);
+      logAndAudit((getThreadLocalIpAddress() == null ? "" : "source:" + getThreadLocalIpAddress() + " ") +
+          function + extraLogInfo);
+      com.codahale.metrics.Timer timer =
+          Metrics.getOrCreateTimer(MetricsConstants.API_PREFIX + function);
+      if (timer != null) {
+        // Timer will be null we aren't using the metrics
+        timerContexts.get().put(function, timer.time());
+      }
+      Counter counter = Metrics.getOrCreateCounter(MetricsConstants.ACTIVE_CALLS + function);
+      if (counter != null) {
+        counter.inc();
+      }
+      return function;
+    }
+
+    private String startFunction(String function) {
+      return startFunction(function, "");
+    }
+
+    private void startTableFunction(String function, String catName, String db, String tbl) {
+      startFunction(function, " : tbl=" +
+          TableName.getQualified(catName, db, tbl));
+    }
+
+    private void startMultiTableFunction(String function, String db, List<String> tbls) {
+      String tableNames = join(tbls, ",");
+      startFunction(function, " : db=" + db + " tbls=" + tableNames);
+    }
+
+    private void startPartitionFunction(String function, String cat, String db, String tbl,
+                                        List<String> partVals) {
+      startFunction(function, " : tbl=" +
+          TableName.getQualified(cat, db, tbl) + "[" + join(partVals, ",") + "]");
+    }
+
+    private void startPartitionFunction(String function, String catName, String db, String tbl,
+                                        Map<String, String> partName) {
+      startFunction(function, " : tbl=" +
+          TableName.getQualified(catName, db, tbl) + "partition=" + partName);
+    }
+
+    private void endFunction(String function, boolean successful, Exception e) {
+      endFunction(function, successful, e, null);
+    }
+    private void endFunction(String function, boolean successful, Exception e,
+                            String inputTableName) {
+      endFunction(function, new MetaStoreEndFunctionContext(successful, e, inputTableName));
+    }
+
+    private void endFunction(String function, MetaStoreEndFunctionContext context) {
+      com.codahale.metrics.Timer.Context timerContext = timerContexts.get().remove(function);
+      if (timerContext != null) {
+        long timeTaken = timerContext.stop();
+        LOG.debug((getThreadLocalIpAddress() == null ? "" : "source:" + getThreadLocalIpAddress() + " ") +
+            function + "time taken(ns): " + timeTaken);
+      }
+      Counter counter = Metrics.getOrCreateCounter(MetricsConstants.ACTIVE_CALLS + function);
+      if (counter != null) {
+        counter.dec();
+      }
+
+      for (MetaStoreEndFunctionListener listener : endFunctionListeners) {
+        listener.onEndFunction(function, context);
+      }
+    }
+
+    @Override
+    public fb_status getStatus() {
+      return fb_status.ALIVE;
+    }
+
+    @Override
+    public void shutdown() {
+      cleanupRawStore();
+      PerfLogger.getPerfLogger(false).cleanupPerfLogMetrics();
+      ThreadPool.shutdown();
+    }
+
+    @Override
+    public AbstractMap<String, Long> getCounters() {
+      AbstractMap<String, Long> counters = super.getCounters();
+
+      // Allow endFunctionListeners to add any counters they have collected
+      if (endFunctionListeners != null) {
+        for (MetaStoreEndFunctionListener listener : endFunctionListeners) {
+          listener.exportCounters(counters);
+        }
+      }
+
+      return counters;
+    }
+
+    @Override
+    public void create_catalog(CreateCatalogRequest rqst)
+        throws AlreadyExistsException, InvalidObjectException, MetaException {
+      Catalog catalog = rqst.getCatalog();
+      startFunction("create_catalog", ": " + catalog.toString());
+      boolean success = false;
+      Exception ex = null;
+      try {
+        try {
+          getMS().getCatalog(catalog.getName());
+          throw new AlreadyExistsException("Catalog " + catalog.getName() + " already exists");
+        } catch (NoSuchObjectException e) {
+          // expected
+        }
+
+        if (!MetaStoreUtils.validateName(catalog.getName(), null)) {
+          throw new InvalidObjectException(catalog.getName() + " is not a valid catalog name");
+        }
+
+        if (catalog.getLocationUri() == null) {
+          throw new InvalidObjectException("You must specify a path for the catalog");
+        }
+
+        RawStore ms = getMS();
+        Path catPath = new Path(catalog.getLocationUri());
+        boolean madeDir = false;
+        Map<String, String> transactionalListenersResponses = Collections.emptyMap();
+        try {
+          firePreEvent(new PreCreateCatalogEvent(this, catalog));
+          if (!wh.isDir(catPath)) {
+            if (!wh.mkdirs(catPath)) {
+              throw new MetaException("Unable to create catalog path " + catPath +
+                  ", failed to create catalog " + catalog.getName());
+            }
+            madeDir = true;
+          }
+          // set the create time of catalog
+          long time = System.currentTimeMillis() / 1000;
+          catalog.setCreateTime((int) time);
+          ms.openTransaction();
+          ms.createCatalog(catalog);
+
+          // Create a default database inside the catalog
+          Database db = new Database(DEFAULT_DATABASE_NAME,
+              "Default database for catalog " + catalog.getName(), catalog.getLocationUri(),
+              Collections.emptyMap());
+          db.setCatalogName(catalog.getName());
+          create_database_core(ms, db);
+
+          if (!transactionalListeners.isEmpty()) {
+            transactionalListenersResponses =
+                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                    EventType.CREATE_CATALOG,
+                    new CreateCatalogEvent(true, this, catalog));
+          }
+
+          success = ms.commitTransaction();
+        } finally {
+          if (!success) {
+            ms.rollbackTransaction();
+            if (madeDir) {
+              wh.deleteDir(catPath, true, false, false);
+            }
+          }
+
+          if (!listeners.isEmpty()) {
+            MetaStoreListenerNotifier.notifyEvent(listeners,
+                EventType.CREATE_CATALOG,
+                new CreateCatalogEvent(success, this, catalog),
+                null,
+                transactionalListenersResponses, ms);
+          }
+        }
+        success = true;
+      } catch (AlreadyExistsException|InvalidObjectException|MetaException e) {
+        ex = e;
+        throw e;
+      } finally {
+        endFunction("create_catalog", success, ex);
+      }
+    }
+
+    @Override
+    public void alter_catalog(AlterCatalogRequest rqst) throws TException {
+      startFunction("alter_catalog " + rqst.getName());
+      boolean success = false;
+      Exception ex = null;
+      RawStore ms = getMS();
+      Map<String, String> transactionalListenersResponses = Collections.emptyMap();
+      GetCatalogResponse oldCat = null;
+
+      try {
+        oldCat = get_catalog(new GetCatalogRequest(rqst.getName()));
+        // Above should have thrown NoSuchObjectException if there is no such catalog
+        assert oldCat != null && oldCat.getCatalog() != null;
+        firePreEvent(new PreAlterCatalogEvent(oldCat.getCatalog(), rqst.getNewCat(), this));
+
+        ms.openTransaction();
+        ms.alterCatalog(rqst.getName(), rqst.getNewCat());
+
+        if (!transactionalListeners.isEmpty()) {
+          transactionalListenersResponses =
+              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                  EventType.ALTER_CATALOG,
+                  new AlterCatalogEvent(oldCat.getCatalog(), rqst.getNewCat(), true, this));
+        }
+
+        success = ms.commitTransaction();
+      } catch (MetaException|NoSuchObjectException e) {
+        ex = e;
+        throw e;
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        }
+
+        if ((null != oldCat) && (!listeners.isEmpty())) {
+          MetaStoreListenerNotifier.notifyEvent(listeners,
+              EventType.ALTER_CATALOG,
+              new AlterCatalogEvent(oldCat.getCatalog(), rqst.getNewCat(), success, this),
+              null, transactionalListenersResponses, ms);
+        }
+        endFunction("alter_catalog", success, ex);
+      }
+
+    }
+
+    @Override
+    public GetCatalogResponse get_catalog(GetCatalogRequest rqst)
+        throws NoSuchObjectException, TException {
+      String catName = rqst.getName();
+      startFunction("get_catalog", ": " + catName);
+      Catalog cat = null;
+      Exception ex = null;
+      try {
+        cat = getMS().getCatalog(catName);
+        firePreEvent(new PreReadCatalogEvent(this, cat));
+        return new GetCatalogResponse(cat);
+      } catch (MetaException|NoSuchObjectException e) {
+        ex = e;
+        throw e;
+      } finally {
+        endFunction("get_catalog", cat != null, ex);
+      }
+    }
+
+    @Override
+    public GetCatalogsResponse get_catalogs() throws MetaException {
+      startFunction("get_catalogs");
+
+      List<String> ret = null;
+      Exception ex = null;
+      try {
+        ret = getMS().getCatalogs();
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } finally {
+        endFunction("get_catalog", ret != null, ex);
+      }
+      return new GetCatalogsResponse(ret == null ? Collections.emptyList() : ret);
+
+    }
+
+    @Override
+    public void drop_catalog(DropCatalogRequest rqst)
+        throws NoSuchObjectException, InvalidOperationException, MetaException {
+      String catName = rqst.getName();
+      startFunction("drop_catalog", ": " + catName);
+      if (DEFAULT_CATALOG_NAME.equalsIgnoreCase(catName)) {
+        endFunction("drop_catalog", false, null);
+        throw new MetaException("Can not drop " + DEFAULT_CATALOG_NAME + " catalog");
+      }
+
+      boolean success = false;
+      Exception ex = null;
+      try {
+        dropCatalogCore(catName);
+        success = true;
+      } catch (NoSuchObjectException|InvalidOperationException|MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("drop_catalog", success, ex);
+      }
+
+    }
+
+    private void dropCatalogCore(String catName)
+        throws MetaException, NoSuchObjectException, InvalidOperationException {
+      boolean success = false;
+      Catalog cat = null;
+      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
+      RawStore ms = getMS();
+      try {
+        ms.openTransaction();
+        cat = ms.getCatalog(catName);
+
+        firePreEvent(new PreDropCatalogEvent(this, cat));
+
+        List<String> allDbs = get_databases(prependNotNullCatToDbName(catName, null));
+        if (allDbs != null && !allDbs.isEmpty()) {
+          // It might just be the default, in which case we can drop that one if it's empty
+          if (allDbs.size() == 1 && allDbs.get(0).equals(DEFAULT_DATABASE_NAME)) {
+            try {
+              drop_database_core(ms, catName, DEFAULT_DATABASE_NAME, true, false);
+            } catch (InvalidOperationException e) {
+              // This means there are tables of something in the database
+              throw new InvalidOperationException("There are still objects in the default " +
+                  "database for catalog " + catName);
+            } catch (InvalidObjectException|IOException|InvalidInputException e) {
+              MetaException me = new MetaException("Error attempt to drop default database for " +
+                  "catalog " + catName);
+              me.initCause(e);
+              throw me;
+            }
+          } else {
+            throw new InvalidOperationException("There are non-default databases in the catalog " +
+                catName + " so it cannot be dropped.");
+          }
+        }
+
+        ms.dropCatalog(catName) ;
+        if (!transactionalListeners.isEmpty()) {
+          transactionalListenerResponses =
+              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                  EventType.DROP_CATALOG,
+                  new DropCatalogEvent(true, this, cat));
+        }
+
+        success = ms.commitTransaction();
+      } finally {
+        if (success) {
+          wh.deleteDir(wh.getDnsPath(new Path(cat.getLocationUri())), false, false, false);
+        } else {
+          ms.rollbackTransaction();
+        }
+
+        if (!listeners.isEmpty()) {
+          MetaStoreListenerNotifier.notifyEvent(listeners,
+              EventType.DROP_CATALOG,
+              new DropCatalogEvent(success, this, cat),
+              null,
+              transactionalListenerResponses, ms);
+        }
+      }
+    }
+
+    static boolean isDbReplicationTarget(Database db) {
+      if (db.getParameters() == null) {
+        return false;
+      }
+
+      if (!db.getParameters().containsKey(ReplConst.REPL_TARGET_DB_PROPERTY)) {
+        return false;
+      }
+
+      return !db.getParameters().get(ReplConst.REPL_TARGET_DB_PROPERTY).trim().isEmpty();
+    }
+
+    // Assumes that the catalog has already been set.
+    private void create_database_core(RawStore ms, final Database db)
+        throws AlreadyExistsException, InvalidObjectException, MetaException {
+      if (!MetaStoreUtils.validateName(db.getName(), conf)) {
+        throw new InvalidObjectException(db.getName() + " is not a valid database name");
+      }
+
+      Catalog cat = null;
+      try {
+        cat = getMS().getCatalog(db.getCatalogName());
+      } catch (NoSuchObjectException e) {
+        LOG.error("No such catalog " + db.getCatalogName());
+        throw new InvalidObjectException("No such catalog " + db.getCatalogName());
+      }
+      boolean skipAuthorization = false;
+      String passedInURI = db.getLocationUri();
+      String passedInManagedURI = db.getManagedLocationUri();
+      if (passedInURI == null && passedInManagedURI == null) {
+        skipAuthorization = true;
+      }
+      final Path defaultDbExtPath = wh.getDefaultDatabasePath(db.getName(), true);
+      final Path defaultDbMgdPath = wh.getDefaultDatabasePath(db.getName(), false);
+      final Path dbExtPath = (passedInURI != null) ? wh.getDnsPath(new Path(passedInURI)) : wh.determineDatabasePath(cat, db);
+      final Path dbMgdPath = (passedInManagedURI != null) ? wh.getDnsPath(new Path(passedInManagedURI)) : null;
+
+      if ((defaultDbExtPath.equals(dbExtPath) && defaultDbMgdPath.equals(dbMgdPath)) &&
+          ((dbMgdPath == null) || dbMgdPath.equals(defaultDbMgdPath))) {
+        skipAuthorization = true;
+      }
+
+      if ( skipAuthorization ) {
+        //null out to skip authorizer URI check
+        db.setLocationUri(null);
+        db.setManagedLocationUri(null);
+      }else{
+        db.setLocationUri(dbExtPath.toString());
+        if (dbMgdPath != null) {
+          db.setManagedLocationUri(dbMgdPath.toString());
+        }
+      }
+      if (db.getOwnerName() == null){
+        try {
+          db.setOwnerName(SecurityUtils.getUGI().getShortUserName());
+        }catch (Exception e){
+          LOG.warn("Failed to get owner name for create database operation.", e);
+        }
+      }
+      long time = System.currentTimeMillis()/1000;
+      db.setCreateTime((int) time);
+      boolean success = false;
+      boolean madeManagedDir = false;
+      boolean madeExternalDir = false;
+      boolean isReplicated = isDbReplicationTarget(db);
+      Map<String, String> transactionalListenersResponses = Collections.emptyMap();
+      try {
+        firePreEvent(new PreCreateDatabaseEvent(db, this));
+        //reinstate location uri for metastore db.
+        if (skipAuthorization == true){
+          db.setLocationUri(dbExtPath.toString());
+          if (dbMgdPath != null)
+            db.setManagedLocationUri(dbMgdPath.toString());
+        }
+        if (db.getCatalogName() != null && !db.getCatalogName().
+            equals(Warehouse.DEFAULT_CATALOG_NAME)) {
+          if (!wh.isDir(dbExtPath)) {
+            LOG.debug("Creating database path " + dbExtPath);
+            if (!wh.mkdirs(dbExtPath)) {
+              throw new MetaException("Unable to create database path " + dbExtPath +
+                  ", failed to create database " + db.getName());
+            }
+            madeExternalDir = true;
+          }
+        } else {
+          if (dbMgdPath != null) {
+            try {
+              // Since this may be done as random user (if doAs=true) he may not have access
+              // to the managed directory. We run this as an admin user
+              madeManagedDir = UserGroupInformation.getLoginUser().doAs(new PrivilegedExceptionAction<Boolean>() {
+                @Override public Boolean run() throws MetaException {
+                  if (!wh.isDir(dbMgdPath)) {
+                    LOG.info("Creating database path in managed directory " + dbMgdPath);
+                    if (!wh.mkdirs(dbMgdPath)) {
+                      throw new MetaException("Unable to create database managed path " + dbMgdPath + ", failed to create database " + db.getName());
+                    }
+                    return true;
+                  }
+                  return false;
+                }
+              });
+              if (madeManagedDir) {
+                LOG.info("Created database path in managed directory " + dbMgdPath);
+              } else {
+                throw new MetaException(
+                    "Unable to create database managed directory " + dbMgdPath + ", failed to create database " + db.getName());
+              }
+            } catch (IOException | InterruptedException e) {
+              throw new MetaException(
+                  "Unable to create database managed directory " + dbMgdPath + ", failed to create database " + db.getName() + ":" + e.getMessage());
+            }
+          }
+          if (dbExtPath != null) {
+            try {
+              madeExternalDir = UserGroupInformation.getCurrentUser().doAs(new PrivilegedExceptionAction<Boolean>() {
+                @Override public Boolean run() throws MetaException {
+                  if (!wh.isDir(dbExtPath)) {
+                    LOG.info("Creating database path in external directory " + dbExtPath);
+                    return wh.mkdirs(dbExtPath);
+                  }
+                  return false;
+                }
+              });
+              if (madeExternalDir) {
+                LOG.info("Created database path in external directory " + dbExtPath);
+              } else {
+                LOG.warn("Failed to create external path " + dbExtPath + " for database " + db.getName() + ". This may result in access not being allowed if the "
+                    + "StorageBasedAuthorizationProvider is enabled");
+              }
+            } catch (IOException | InterruptedException | UndeclaredThrowableException e) {
+              throw new MetaException("Failed to create external path " + dbExtPath + " for database " + db.getName() + ". This may result in access not being allowed if the "
+                  + "StorageBasedAuthorizationProvider is enabled: " + e.getMessage());
+            }
+          } else {
+            LOG.info("Database external path won't be created since the external warehouse directory is not defined");
+          }
+        }
+
+        ms.openTransaction();
+        ms.createDatabase(db);
+
+        if (!transactionalListeners.isEmpty()) {
+          transactionalListenersResponses =
+              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                                                    EventType.CREATE_DATABASE,
+                                                    new CreateDatabaseEvent(db, true, this, isReplicated));
+        }
+
+        success = ms.commitTransaction();
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+
+          if (db.getCatalogName() != null && !db.getCatalogName().
+              equals(Warehouse.DEFAULT_CATALOG_NAME)) {
+            if (madeManagedDir) {
+              wh.deleteDir(dbMgdPath, true, db);
+            }
+          } else {
+            if (madeManagedDir) {
+              try {
+                UserGroupInformation.getLoginUser().doAs(new PrivilegedExceptionAction<Void>() {
+                  @Override public Void run() throws Exception {
+                    wh.deleteDir(dbMgdPath, true, db);
+                    return null;
+                  }
+                });
+              } catch (IOException | InterruptedException e) {
+                LOG.error(
+                    "Couldn't delete managed directory " + dbMgdPath + " after " + "it was created for database " + db.getName() + " " + e.getMessage());
+              }
+            }
+
+            if (madeExternalDir) {
+              try {
+                UserGroupInformation.getCurrentUser().doAs(new PrivilegedExceptionAction<Void>() {
+                  @Override public Void run() throws Exception {
+                    wh.deleteDir(dbExtPath, true, db);
+                    return null;
+                  }
+                });
+              } catch (IOException | InterruptedException e) {
+                LOG.error("Couldn't delete external directory " + dbExtPath + " after " + "it was created for database "
+                    + db.getName() + " " + e.getMessage());
+              }
+            }
+          }
+        }
+
+        if (!listeners.isEmpty()) {
+          MetaStoreListenerNotifier.notifyEvent(listeners,
+                                                EventType.CREATE_DATABASE,
+                                                new CreateDatabaseEvent(db, success, this, isReplicated),
+                                                null,
+                                                transactionalListenersResponses, ms);
+        }
+      }
+    }
+
+    @Override
+    public void create_database(final Database db)
+        throws AlreadyExistsException, InvalidObjectException, MetaException {
+      startFunction("create_database", ": " + db.toString());
+      boolean success = false;
+      Exception ex = null;
+      if (!db.isSetCatalogName()) {
+        db.setCatalogName(getDefaultCatalog(conf));
+      }
+      try {
+        try {
+          if (null != get_database_core(db.getCatalogName(), db.getName())) {
+            throw new AlreadyExistsException("Database " + db.getName() + " already exists");
+          }
+        } catch (NoSuchObjectException e) {
+          // expected
+        }
+
+        if (TEST_TIMEOUT_ENABLED) {
+          try {
+            Thread.sleep(TEST_TIMEOUT_VALUE);
+          } catch (InterruptedException e) {
+            // do nothing
+          }
+          Deadline.checkTimeout();
+        }
+        create_database_core(getMS(), db);
+        success = true;
+      } catch (MetaException | InvalidObjectException | AlreadyExistsException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("create_database", success, ex);
+      }
+    }
+
+    @Override
+    public Database get_database(final String name)
+        throws NoSuchObjectException, MetaException {
+      GetDatabaseRequest request = new GetDatabaseRequest();
+      String[] parsedDbName = parseDbName(name, conf);
+      request.setName(parsedDbName[DB_NAME]);
+      if (parsedDbName[CAT_NAME] != null)
+          request.setCatalogName(parsedDbName[CAT_NAME]);
+        return get_database_req(request);
+    }
+
+    @Override
+    public Database get_database_core(String catName, final String name) throws NoSuchObjectException, MetaException {
+      Database db = null;
+      if (name == null) {
+        throw new MetaException("Database name cannot be null.");
+      }
+      try {
+        db = getMS().getDatabase(catName, name);
+      } catch (MetaException | NoSuchObjectException e) {
+        throw e;
+      } catch (Exception e) {
+        assert (e instanceof RuntimeException);
+        throw (RuntimeException) e;
+      }
+      return db;
+    }
+
+    @Override
+    public Database get_database_req(GetDatabaseRequest request) throws NoSuchObjectException, MetaException {
+      startFunction("get_database", ": " + request.getName());
+      Database db = null;
+      Exception ex = null;
+      if (request.getName() == null) {
+        throw new MetaException("Database name cannot be null.");
+      }
+      List<String> processorCapabilities = request.getProcessorCapabilities();
+      String processorId = request.getProcessorIdentifier();
+      try {
+        db = getMS().getDatabase(request.getCatalogName(), request.getName());
+        firePreEvent(new PreReadDatabaseEvent(db, this));
+        if (processorCapabilities != null && transformer != null) {
+          db = transformer.transformDatabase(db, processorCapabilities, processorId);
+        }
+      } catch (MetaException | NoSuchObjectException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        assert (e instanceof RuntimeException);
+        throw (RuntimeException) e;
+      } finally {
+        endFunction("get_database", db != null, ex);
+      }
+      return db;
+    }
+
+    @Override
+    public void alter_database(final String dbName, final Database newDB) throws TException {
+      startFunction("alter_database " + dbName);
+      boolean success = false;
+      Exception ex = null;
+      RawStore ms = getMS();
+      Database oldDB = null;
+      Map<String, String> transactionalListenersResponses = Collections.emptyMap();
+
+      // Perform the same URI normalization as create_database_core.
+      if (newDB.getLocationUri() != null) {
+        newDB.setLocationUri(wh.getDnsPath(new Path(newDB.getLocationUri())).toString());
+      }
+
+      String[] parsedDbName = parseDbName(dbName, conf);
+
+      // We can replicate into an empty database, in which case newDB will have indication that
+      // it's target of replication but not oldDB. But replication flow will never alter a
+      // database so that oldDB indicates that it's target or replication but not the newDB. So,
+      // relying solely on newDB to check whether the database is target of replication works.
+      boolean isReplicated = isDbReplicationTarget(newDB);
+      try {
+        oldDB = get_database_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]);
+        if (oldDB == null) {
+          throw new MetaException("Could not alter database \"" + parsedDbName[DB_NAME] +
+              "\". Could not retrieve old definition.");
+        }
+        firePreEvent(new PreAlterDatabaseEvent(oldDB, newDB, this));
+
+        ms.openTransaction();
+        ms.alterDatabase(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], newDB);
+
+        if (!transactionalListeners.isEmpty()) {
+          transactionalListenersResponses =
+              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                  EventType.ALTER_DATABASE,
+                  new AlterDatabaseEvent(oldDB, newDB, true, this, isReplicated));
+        }
+
+        success = ms.commitTransaction();
+      } catch (MetaException|NoSuchObjectException e) {
+        ex = e;
+        throw e;
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        }
+
+        if ((null != oldDB) && (!listeners.isEmpty())) {
+          MetaStoreListenerNotifier.notifyEvent(listeners,
+              EventType.ALTER_DATABASE,
+              new AlterDatabaseEvent(oldDB, newDB, success, this, isReplicated),
+              null,
+              transactionalListenersResponses, ms);
+        }
+        endFunction("alter_database", success, ex);
+      }
+    }
+
+    private void drop_database_core(RawStore ms, String catName,
+        final String name, final boolean deleteData, final boolean cascade)
+        throws NoSuchObjectException, InvalidOperationException, MetaException,
+        IOException, InvalidObjectException, InvalidInputException {
+      boolean success = false;
+      Database db = null;
+      List<Path> tablePaths = new ArrayList<>();
+      List<Path> partitionPaths = new ArrayList<>();
+      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
+      if (name == null) {
+        throw new MetaException("Database name cannot be null.");
+      }
+      boolean isReplicated = false;
+      try {
+        ms.openTransaction();
+        db = ms.getDatabase(catName, name);
+        if (db.getType() == DatabaseType.REMOTE) {
+          success = drop_remote_database_core(ms, db);
+          return;
+        }
+        isReplicated = isDbReplicationTarget(db);
+
+        if (!isInTest && ReplChangeManager.isSourceOfReplication(db)) {
+          throw new InvalidOperationException("can not drop a database which is a source of replication");
+        }
+
+        firePreEvent(new PreDropDatabaseEvent(db, this));
+        String catPrependedName = MetaStoreUtils.prependCatalogToDbName(catName, name, conf);
+
+        Set<String> uniqueTableNames = new HashSet<>(get_all_tables(catPrependedName));
+        List<String> allFunctions = get_functions(catPrependedName, "*");
+        ListStoredProcedureRequest request = new ListStoredProcedureRequest(catName);
+        request.setDbName(name);
+        List<String> allProcedures = get_all_stored_procedures(request);
+
+        if (!cascade) {
+          if (!uniqueTableNames.isEmpty()) {
+            throw new InvalidOperationException(
+                "Database " + db.getName() + " is not empty. One or more tables exist.");
+          }
+          if (!allFunctions.isEmpty()) {
+            throw new InvalidOperationException(
+                "Database " + db.getName() + " is not empty. One or more functions exist.");
+          }
+          if (!allProcedures.isEmpty()) {
+            throw new InvalidOperationException(
+                    "Database " + db.getName() + " is not empty. One or more stored procedures exist.");
+          }
+        }
+        Path path = new Path(db.getLocationUri()).getParent();
+        if (!wh.isWritable(path)) {
+          throw new MetaException("Database not dropped since " +
+              path + " is not writable by " +
+              SecurityUtils.getUser());
+        }
+
+        Path databasePath = wh.getDnsPath(wh.getDatabasePath(db));
+
+        // drop any functions before dropping db
+        for (String funcName : allFunctions) {
+          drop_function(catPrependedName, funcName);
+        }
+
+        for (String procName : allProcedures) {
+          drop_stored_procedure(new StoredProcedureRequest(catName, name, procName));
+        }
+
+        final int tableBatchSize = MetastoreConf.getIntVar(conf,
+            ConfVars.BATCH_RETRIEVE_MAX);
+
+        // First pass will drop the materialized views
+        List<String> materializedViewNames = getTablesByTypeCore(catName, name, ".*",
+            TableType.MATERIALIZED_VIEW.toString());
+        int startIndex = 0;
+        // retrieve the tables from the metastore in batches to alleviate memory constraints
+        while (startIndex < materializedViewNames.size()) {
+          int endIndex = Math.min(startIndex + tableBatchSize, materializedViewNames.size());
+
+          List<Table> materializedViews;
+          try {
+            materializedViews = ms.getTableObjectsByName(catName, name, materializedViewNames.subList(startIndex, endIndex));
+          } catch (UnknownDBException e) {
+            throw new MetaException(e.getMessage());
+          }
+
+          if (materializedViews != null && !materializedViews.isEmpty()) {
+            for (Table materializedView : materializedViews) {
+              if (materializedView.getSd().getLocation() != null) {
+                Path materializedViewPath = wh.getDnsPath(new Path(materializedView.getSd().getLocation()));
+                if (!wh.isWritable(materializedViewPath.getParent())) {
+                  throw new MetaException("Database metadata not deleted since table: " +
+                      materializedView.getTableName() + " has a parent location " + materializedViewPath.getParent() +
+                      " which is not writable by " + SecurityUtils.getUser());
+                }
+
+                if (!FileUtils.isSubdirectory(databasePath.toString(),
+                    materializedViewPath.toString())) {
+                  tablePaths.add(materializedViewPath);
+                }
+              }
+              // Drop the materialized view but not its data
+              drop_table(name, materializedView.getTableName(), false);
+              // Remove from all tables
+              uniqueTableNames.remove(materializedView.getTableName());
+            }
+          }
+          startIndex = endIndex;
+        }
+
+        // drop tables before dropping db
+        List<String> allTables = new ArrayList<>(uniqueTableNames);
+        startIndex = 0;
+        // retrieve the tables from the metastore in batches to alleviate memory constraints
+        while (startIndex < allTables.size()) {
+          int endIndex = Math.min(startIndex + tableBatchSize, allTables.size());
+
+          List<Table> tables;
+          try {
+            tables = ms.getTableObjectsByName(catName, name, allTables.subList(startIndex, endIndex));
+          } catch (UnknownDBException e) {
+            throw new MetaException(e.getMessage());
+          }
+
+          if (tables != null && !tables.isEmpty()) {
+            for (Table table : tables) {
+
+              // If the table is not external and it might not be in a subdirectory of the database
+              // add it's locations to the list of paths to delete
+              Path tablePath = null;
+              boolean tableDataShouldBeDeleted = checkTableDataShouldBeDeleted(table, deleteData);
+              if (table.getSd().getLocation() != null && tableDataShouldBeDeleted) {
+                tablePath = wh.getDnsPath(new Path(table.getSd().getLocation()));
+                if (!wh.isWritable(tablePath.getParent())) {
+                  throw new MetaException("Database metadata not deleted since table: " +
+                      table.getTableName() + " has a parent location " + tablePath.getParent() +
+                      " which is not writable by " + SecurityUtils.getUser());
+                }
+
+                if (!FileUtils.isSubdirectory(databasePath.toString(), tablePath.toString())) {
+                  tablePaths.add(tablePath);
+                }
+              }
+
+              // For each partition in each table, drop the partitions and get a list of
+              // partitions' locations which might need to be deleted
+              partitionPaths = dropPartitionsAndGetLocations(ms, catName, name, table.getTableName(),
+                  tablePath, tableDataShouldBeDeleted);
+
+              // Drop the table but not its data
+              drop_table(MetaStoreUtils.prependCatalogToDbName(table.getCatName(), table.getDbName(), conf),
+                  table.getTableName(), false);
+            }
+          }
+
+          startIndex = endIndex;
+        }
+
+        if (ms.dropDatabase(catName, name)) {
+          if (!transactionalListeners.isEmpty()) {
+            transactionalListenerResponses =
+                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                                                      EventType.DROP_DATABASE,
+                                                      new DropDatabaseEvent(db, true, this, isReplicated));
+          }
+
+          success = ms.commitTransaction();
+        }
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        } else if (deleteData) {
+          // Delete the data in the partitions which have other locations
+          deletePartitionData(partitionPaths, false, db);
+          // Delete the data in the tables which have other locations
+          for (Path tablePath : tablePaths) {
+            deleteTableData(tablePath, false, db);
+          }
+          // Delete the data in the database
+          try {
+            if (db.getManagedLocationUri() != null) {
+              wh.deleteDir(new Path(db.getManagedLocationUri()), true, db);
+            }
+          } catch (Exception e) {
+            LOG.error("Failed to delete database directory: " + db.getManagedLocationUri() +
+                " " + e.getMessage());
+          }
+          // Delete the data in the database's location only if it is a legacy db path?
+          try {
+            wh.deleteDir(new Path(db.getLocationUri()), true, db);
+          } catch (Exception e) {
+            LOG.error("Failed to delete database directory: " + db.getLocationUri() +
+                " " + e.getMessage());
+          }
+          // it is not a terrible thing even if the data is not deleted
+        }
+
+        if (!listeners.isEmpty()) {
+          MetaStoreListenerNotifier.notifyEvent(listeners,
+                                                EventType.DROP_DATABASE,
+                                                new DropDatabaseEvent(db, success, this, isReplicated),
+                                                null,
+                                                transactionalListenerResponses, ms);
+        }
+      }
+    }
+
+    private boolean drop_remote_database_core(RawStore ms, final Database db) throws MetaException, NoSuchObjectException {
+      boolean success = false;
+      firePreEvent(new PreDropDatabaseEvent(db, this));
+
+      if (ms.dropDatabase(db.getCatalogName(), db.getName())) {
+        success = ms.commitTransaction();
+      }
+      return success;
+    }
+
+    @Override
+    public void drop_database(final String dbName, final boolean deleteData, final boolean cascade)
+        throws NoSuchObjectException, InvalidOperationException, MetaException {
+      startFunction("drop_database", ": " + dbName);
+      String[] parsedDbName = parseDbName(dbName, conf);
+      if (DEFAULT_CATALOG_NAME.equalsIgnoreCase(parsedDbName[CAT_NAME]) &&
+          DEFAULT_DATABASE_NAME.equalsIgnoreCase(parsedDbName[DB_NAME])) {
+        endFunction("drop_database", false, null);
+        throw new MetaException("Can not drop " + DEFAULT_DATABASE_NAME + " database in catalog "
+            + DEFAULT_CATALOG_NAME);
+      }
+
+      boolean success = false;
+      Exception ex = null;
+      try {
+        drop_database_core(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME], deleteData,
+            cascade);
+        success = true;
+      } catch (NoSuchObjectException|InvalidOperationException|MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("drop_database", success, ex);
+      }
+    }
+
+
+    @Override
+    public List<String> get_databases(final String pattern) throws MetaException {
+      startFunction("get_databases", ": " + pattern);
+
+      String[] parsedDbNamed = parseDbName(pattern, conf);
+      List<String> ret = null;
+      Exception ex = null;
+      try {
+        if (parsedDbNamed[DB_NAME] == null) {
+          ret = getMS().getAllDatabases(parsedDbNamed[CAT_NAME]);
+          ret = FilterUtils.filterDbNamesIfEnabled(isServerFilterEnabled, filterHook, ret);
+        } else {
+          ret = getMS().getDatabases(parsedDbNamed[CAT_NAME], parsedDbNamed[DB_NAME]);
+          ret = FilterUtils.filterDbNamesIfEnabled(isServerFilterEnabled, filterHook, ret);
+        }
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_databases", ret != null, ex);
+      }
+      return ret;
+    }
+
+    @Override
+    public List<String> get_all_databases() throws MetaException {
+      // get_databases filters results already. No need to filter here
+      return get_databases(MetaStoreUtils.prependCatalogToDbName(null, null, conf));
+    }
+
+    private void create_type_core(final RawStore ms, final Type type)
+        throws AlreadyExistsException, MetaException, InvalidObjectException {
+      if (!MetaStoreUtils.validateName(type.getName(), null)) {
+        throw new InvalidObjectException("Invalid type name");
+      }
+
+      boolean success = false;
+      try {
+        ms.openTransaction();
+        if (is_type_exists(ms, type.getName())) {
+          throw new AlreadyExistsException("Type " + type.getName() + " already exists");
+        }
+        ms.createType(type);
+        success = ms.commitTransaction();
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        }
+      }
+    }
+
+    private void create_dataconnector_core(RawStore ms, final DataConnector connector)
+        throws AlreadyExistsException, InvalidObjectException, MetaException {
+      if (!MetaStoreUtils.validateName(connector.getName(), conf)) {
+        throw new InvalidObjectException(connector.getName() + " is not a valid dataconnector name");
+      }
+
+      if (connector.getOwnerName() == null){
+        try {
+          connector.setOwnerName(SecurityUtils.getUGI().getShortUserName());
+        }catch (Exception e){
+          LOG.warn("Failed to get owner name for create dataconnector operation.", e);
+        }
+      }
+      long time = System.currentTimeMillis()/1000;
+      connector.setCreateTime((int) time);
+      boolean success = false;
+      Map<String, String> transactionalListenersResponses = Collections.emptyMap();
+      try {
+        firePreEvent(new PreCreateDataConnectorEvent(connector, this));
+
+        ms.openTransaction();
+        ms.createDataConnector(connector);
+
+        if (!transactionalListeners.isEmpty()) {
+          transactionalListenersResponses =
+              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                  EventType.CREATE_DATACONNECTOR,
+                  new CreateDataConnectorEvent(connector, true, this));
+        }
+
+        success = ms.commitTransaction();
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        }
+
+        if (!listeners.isEmpty()) {
+          MetaStoreListenerNotifier.notifyEvent(listeners,
+              EventType.CREATE_DATACONNECTOR,
+              new CreateDataConnectorEvent(connector, success, this),
+              null,
+              transactionalListenersResponses, ms);
+        }
+      }
+    }
+
+    @Override
+    public void create_dataconnector(final DataConnector connector)
+        throws AlreadyExistsException, InvalidObjectException, MetaException {
+      startFunction("create_dataconnector", ": " + connector.toString());
+      boolean success = false;
+      Exception ex = null;
+      try {
+        try {
+          if (null != get_dataconnector_core(connector.getName())) {
+            throw new AlreadyExistsException("DataConnector " + connector.getName() + " already exists");
+          }
+        } catch (NoSuchObjectException e) {
+          // expected
+        }
+
+        if (TEST_TIMEOUT_ENABLED) {
+          try {
+            Thread.sleep(TEST_TIMEOUT_VALUE);
+          } catch (InterruptedException e) {
+            // do nothing
+          }
+          Deadline.checkTimeout();
+        }
+        create_dataconnector_core(getMS(), connector);
+        success = true;
+      } catch (MetaException | InvalidObjectException | AlreadyExistsException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("create_connector", success, ex);
+      }
+    }
+
+    @Override
+    public DataConnector get_dataconnector_core(final String name) throws NoSuchObjectException, MetaException {
+      DataConnector connector = null;
+      if (name == null) {
+        throw new MetaException("Data connector name cannot be null.");
+      }
+      try {
+        connector = getMS().getDataConnector(name);
+      } catch (MetaException | NoSuchObjectException e) {
+        throw e;
+      } catch (Exception e) {
+        assert (e instanceof RuntimeException);
+        throw (RuntimeException) e;
+      }
+      return connector;
+    }
+
+    @Override
+    public DataConnector get_dataconnector_req(GetDataConnectorRequest request) throws NoSuchObjectException, MetaException {
+      startFunction("get_dataconnector", ": " + request.getConnectorName());
+      DataConnector connector = null;
+      Exception ex = null;
+      try {
+        connector = get_dataconnector_core(request.getConnectorName());
+      } catch (MetaException | NoSuchObjectException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        assert (e instanceof RuntimeException);
+        throw (RuntimeException) e;
+      } finally {
+        endFunction("get_dataconnector", connector != null, ex);
+      }
+      return connector;
+    }
+
+    @Override
+    public void alter_dataconnector(final String dcName, final DataConnector newDC) throws TException {
+      startFunction("alter_dataconnector " + dcName);
+      boolean success = false;
+      Exception ex = null;
+      RawStore ms = getMS();
+      DataConnector oldDC = null;
+      Map<String, String> transactionalListenersResponses = Collections.emptyMap();
+
+      try {
+        oldDC = get_dataconnector_core(dcName);
+        if (oldDC == null) {
+          throw new MetaException("Could not alter dataconnector \"" + dcName +
+              "\". Could not retrieve old definition.");
+        }
+        // firePreEvent(new PreAlterDatabaseEvent(oldDC, newDC, this));
+
+        ms.openTransaction();
+        ms.alterDataConnector(dcName, newDC);
+
+        /*
+        if (!transactionalListeners.isEmpty()) {
+          transactionalListenersResponses =
+              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                  EventType.ALTER_DATACONNECTOR,
+                  new AlterDataConnectorEvent(oldDC, newDC, true, this));
+        }
+         */
+
+        success = ms.commitTransaction();
+      } catch (MetaException|NoSuchObjectException e) {
+        ex = e;
+        throw e;
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        }
+/*
+        if ((null != oldDC) && (!listeners.isEmpty())) {
+          MetaStoreListenerNotifier.notifyEvent(listeners,
+              EventType.ALTER_DATACONNECTOR,
+              new AlterDataConnectorEvent(oldDC, newDC, success, this),
+              null,
+              transactionalListenersResponses, ms);
+        }
+ */
+        endFunction("alter_database", success, ex);
+      }
+    }
+
+    @Override
+    public List<String> get_dataconnectors() throws MetaException {
+      startFunction("get_dataconnectors");
+
+      List<String> ret = null;
+      Exception ex = null;
+      try {
+          ret = getMS().getAllDataConnectors();
+          ret = FilterUtils.filterDataConnectorsIfEnabled(isServerFilterEnabled, filterHook, ret);
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_dataconnectors", ret != null, ex);
+      }
+      return ret;
+    }
+
+    @Override
+    public void drop_dataconnector(final String dcName, boolean ifNotExists, boolean checkReferences) throws NoSuchObjectException, InvalidOperationException, MetaException {
+      startFunction("drop_dataconnector", ": " + dcName);
+      boolean success = false;
+      DataConnector connector = null;
+      Exception ex = null;
+      RawStore ms = getMS();
+      try {
+        ms.openTransaction();
+        connector = getMS().getDataConnector(dcName);
+
+        if (connector == null) {
+          if (!ifNotExists) {
+            throw new NoSuchObjectException("DataConnector " + dcName + " doesn't exist");
+          } else {
+            return;
+          }
+        }
+        // TODO find DBs with references to this connector
+        // if any existing references and checkReferences=true, do not drop
+
+        // firePreEvent(new PreDropTableEvent(tbl, deleteData, this));
+
+        if (!ms.dropDataConnector(dcName)) {
+          throw new MetaException("Unable to drop dataconnector " + dcName);
+        } else {
+/*
+          if (!transactionalListeners.isEmpty()) {
+            transactionalListenerResponses =
+                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                    EventType.DROP_TABLE,
+                    new DropTableEvent(tbl, true, deleteData,
+                        this, isReplicated),
+                    envContext);
+          }
+
+ */
+          success = ms.commitTransaction();
+        }
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        }
+/*
+        if (!listeners.isEmpty()) {
+          MetaStoreListenerNotifier.notifyEvent(listeners,
+              EventType.DROP_TABLE,
+              new DropTableEvent(tbl, success, deleteData, this, isReplicated),
+              envContext,
+              transactionalListenerResponses, ms);
+        }
+
+ */
+        endFunction("drop_dataconnector", success, ex);
+      }
+    }
+
+
+
+    @Override
+    public boolean create_type(final Type type) throws AlreadyExistsException,
+        MetaException, InvalidObjectException {
+      startFunction("create_type", ": " + type.toString());
+      boolean success = false;
+      Exception ex = null;
+      try {
+        create_type_core(getMS(), type);
+        success = true;
+      } catch (MetaException | InvalidObjectException | AlreadyExistsException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("create_type", success, ex);
+      }
+
+      return success;
+    }
+
+    @Override
+    public Type get_type(final String name) throws MetaException, NoSuchObjectException {
+      startFunction("get_type", ": " + name);
+
+      Type ret = null;
+      Exception ex = null;
+      try {
+        ret = getMS().getType(name);
+        if (null == ret) {
+          throw new NoSuchObjectException("Type \"" + name + "\" not found.");
+        }
+      } catch (Exception e) {
+        ex = e;
+        throwMetaException(e);
+      } finally {
+        endFunction("get_type", ret != null, ex);
+      }
+      return ret;
+    }
+
+    private boolean is_type_exists(RawStore ms, String typeName)
+        throws MetaException {
+      return (ms.getType(typeName) != null);
+    }
+
+    @Override
+    public boolean drop_type(final String name) throws MetaException, NoSuchObjectException {
+      startFunction("drop_type", ": " + name);
+
+      boolean success = false;
+      Exception ex = null;
+      try {
+        // TODO:pc validate that there are no types that refer to this
+        success = getMS().dropType(name);
+      } catch (Exception e) {
+        ex = e;
+        throwMetaException(e);
+      } finally {
+        endFunction("drop_type", success, ex);
+      }
+      return success;
+    }
+
+    @Override
+    public Map<String, Type> get_type_all(String name) throws MetaException {
+      // TODO Auto-generated method stub
+      startFunction("get_type_all", ": " + name);
+      endFunction("get_type_all", false, null);
+      throw new MetaException("Not yet implemented");
+    }
+
+    private void create_table_core(final RawStore ms, final Table tbl,
+        final EnvironmentContext envContext)
+            throws AlreadyExistsException, MetaException,
+            InvalidObjectException, NoSuchObjectException, InvalidInputException {
+      CreateTableRequest req = new CreateTableRequest(tbl);
+      req.setEnvContext(envContext);
+      create_table_core(ms, req);
+    }
+
+    private void create_table_core(final RawStore ms, final Table tbl,
+        final EnvironmentContext envContext, List<SQLPrimaryKey> primaryKeys,
+        List<SQLForeignKey> foreignKeys, List<SQLUniqueConstraint> uniqueConstraints,
+        List<SQLNotNullConstraint> notNullConstraints, List<SQLDefaultConstraint> defaultConstraints,
+                                   List<SQLCheckConstraint> checkConstraints,
+                                   List<String> processorCapabilities, String processorIdentifier)
+        throws AlreadyExistsException, MetaException,
+        InvalidObjectException, NoSuchObjectException, InvalidInputException {
+      CreateTableRequest req = new CreateTableRequest(tbl);
+      if (envContext != null)
+        req.setEnvContext(envContext);
+      if (primaryKeys != null)
+        req.setPrimaryKeys(primaryKeys);
+      if (foreignKeys != null)
+        req.setForeignKeys(foreignKeys);
+      if (uniqueConstraints != null)
+        req.setUniqueConstraints(uniqueConstraints);
+      if (notNullConstraints != null)
+        req.setNotNullConstraints(notNullConstraints);
+      if (defaultConstraints != null)
+        req.setDefaultConstraints(defaultConstraints);
+      if (checkConstraints != null)
+        req.setCheckConstraints(checkConstraints);
+      if (processorCapabilities != null) {
+        req.setProcessorCapabilities(processorCapabilities);
+        req.setProcessorIdentifier(processorIdentifier);
+      }
+      create_table_core(ms, req);
+    }
+
+    private void create_table_core(final RawStore ms, final CreateTableRequest req)
+        throws AlreadyExistsException, MetaException,
+              InvalidObjectException, NoSuchObjectException, InvalidInputException {
+      ColumnStatistics colStats = null;
+      Table tbl = req.getTable();
+      EnvironmentContext envContext = req.getEnvContext();
+      SQLAllTableConstraints constraints = new SQLAllTableConstraints();
+      constraints.setPrimaryKeys(req.getPrimaryKeys());
+      constraints.setForeignKeys(req.getForeignKeys());
+      constraints.setUniqueConstraints(req.getUniqueConstraints());
+      constraints.setDefaultConstraints(req.getDefaultConstraints());
+      constraints.setCheckConstraints(req.getCheckConstraints());
+      constraints.setNotNullConstraints(req.getNotNullConstraints());
+      List<String> processorCapabilities = req.getProcessorCapabilities();
+      String processorId = req.getProcessorIdentifier();
+
+      Database db = null;
+      try {
+        db = ms.getDatabase(tbl.getCatName(), tbl.getDbName());
+      } catch (Exception e) {
+        LOG.info("Database {} does exist, exception: {}", tbl.getDbName(), e.getMessage());
+        return;
+      }
+      if (db != null && db.getType().equals(DatabaseType.REMOTE)) {
+        boolean success = DataConnectorProviderFactory.getDataConnectorProvider(db).createTable(tbl);
+        return;
+      }
+
+      if (transformer != null && !isInTest) {
+        tbl = transformer.transformCreateTable(tbl, processorCapabilities, processorId);
+      }
+
+      // If the given table has column statistics, save it here. We will update it later.
+      // We don't want it to be part of the Table object being created, lest the create table
+      // event will also have the col stats which we don't want.
+      if (tbl.isSetColStats()) {
+        colStats = tbl.getColStats();
+        tbl.unsetColStats();
+      }
+
+      // To preserve backward compatibility throw MetaException in case of null database
+      if (tbl.getDbName() == null) {
+        throw new MetaException("Null database name is not allowed");
+      }
+
+      if (!MetaStoreUtils.validateName(tbl.getTableName(), conf)) {
+        throw new InvalidObjectException(tbl.getTableName()
+            + " is not a valid object name");
+      }
+      String validate = MetaStoreServerUtils.validateTblColumns(tbl.getSd().getCols());
+      if (validate != null) {
+        throw new InvalidObjectException("Invalid column " + validate);
+      }
+      if (tbl.getPartitionKeys() != null) {
+        validate = MetaStoreServerUtils.validateTblColumns(tbl.getPartitionKeys());
+        if (validate != null) {
+          throw new InvalidObjectException("Invalid partition column " + validate);
+        }
+      }
+      if (tbl.isSetId()) {
+        LOG.debug("Id shouldn't be set but table {}.{} has the Id set to {}. Id is ignored.", tbl.getDbName(),
+            tbl.getTableName(), tbl.getId());
+        tbl.unsetId();
+      }
+      SkewedInfo skew = tbl.getSd().getSkewedInfo();
+      if (skew != null) {
+        validate = MetaStoreServerUtils.validateSkewedColNames(skew.getSkewedColNames());
+        if (validate != null) {
+          throw new InvalidObjectException("Invalid skew column " + validate);
+        }
+        validate = MetaStoreServerUtils.validateSkewedColNamesSubsetCol(
+            skew.getSkewedColNames(), tbl.getSd().getCols());
+        if (validate != null) {
+          throw new InvalidObjectException("Invalid skew column " + validate);
+        }
+      }
+
+      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
+      Path tblPath = null;
+      boolean success = false, madeDir = false;
+      boolean isReplicated = false;
+      try {
+        if (!tbl.isSetCatName()) {
+          tbl.setCatName(getDefaultCatalog(conf));
+        }
+        firePreEvent(new PreCreateTableEvent(tbl, this));
+
+        ms.openTransaction();
+        isReplicated = isDbReplicationTarget(db);
+
+        // get_table checks whether database exists, it should be moved here
+        if (is_table_exists(ms, tbl.getCatName(), tbl.getDbName(), tbl.getTableName())) {
+          throw new AlreadyExistsException("Table " + getCatalogQualifiedTableName(tbl)
+              + " already exists");
+        }
+
+        if (!TableType.VIRTUAL_VIEW.toString().equals(tbl.getTableType())) {
+          if (tbl.getSd().getLocation() == null
+              || tbl.getSd().getLocation().isEmpty()) {
+            tblPath = wh.getDefaultTablePath(db, tbl);
+          } else {
+            if (!isExternal(tbl) && !MetaStoreUtils.isNonNativeTable(tbl)) {
+              LOG.warn("Location: " + tbl.getSd().getLocation()
+                  + " specified for non-external table:" + tbl.getTableName());
+            }
+            tblPath = wh.getDnsPath(new Path(tbl.getSd().getLocation()));
+          }
+          tbl.getSd().setLocation(tblPath.toString());
+        }
+
+        if (tblPath != null) {
+          if (!wh.isDir(tblPath)) {
+            if (!wh.mkdirs(tblPath)) {
+              throw new MetaException(tblPath
+                  + " is not a directory or unable to create one");
+            }
+            madeDir = true;
+          }
+        }
+        if (MetastoreConf.getBoolVar(conf, ConfVars.STATS_AUTO_GATHER) &&
+            !MetaStoreUtils.isView(tbl)) {
+          MetaStoreServerUtils.updateTableStatsSlow(db, tbl, wh, madeDir, false, envContext);
+        }
+
+        // set create time
+        long time = System.currentTimeMillis() / 1000;
+        tbl.setCreateTime((int) time);
+        if (tbl.getParameters() == null ||
+            tbl.getParameters().get(hive_metastoreConstants.DDL_TIME) == null) {
+          tbl.putToParameters(hive_metastoreConstants.DDL_TIME, Long.toString(time));
+        }
+
+        if (CollectionUtils.isEmpty(constraints.getPrimaryKeys()) && CollectionUtils.isEmpty(constraints.getForeignKeys())
+                && CollectionUtils.isEmpty(constraints.getUniqueConstraints())&& CollectionUtils.isEmpty(constraints.getNotNullConstraints())&& CollectionUtils.isEmpty(constraints.getDefaultConstraints())
+            && CollectionUtils.isEmpty(constraints.getCheckConstraints())) {
+          ms.createTable(tbl);
+        } else {
+          final String catName = tbl.getCatName();
+          // Check that constraints have catalog name properly set first
+          if (CollectionUtils.isNotEmpty(constraints.getPrimaryKeys()) && !constraints.getPrimaryKeys().get(0).isSetCatName()) {
+            constraints.getPrimaryKeys().forEach(constraint -> constraint.setCatName(catName));
+          }
+          if (CollectionUtils.isNotEmpty(constraints.getForeignKeys()) && !constraints.getForeignKeys().get(0).isSetCatName()) {
+            constraints.getForeignKeys().forEach(constraint -> constraint.setCatName(catName));
+          }
+          if (CollectionUtils.isNotEmpty(constraints.getUniqueConstraints()) && !constraints.getUniqueConstraints().get(0).isSetCatName()) {
+            constraints.getUniqueConstraints().forEach(constraint -> constraint.setCatName(catName));
+          }
+          if (CollectionUtils.isNotEmpty(constraints.getNotNullConstraints()) && !constraints.getNotNullConstraints().get(0).isSetCatName()) {
+            constraints.getNotNullConstraints().forEach(constraint -> constraint.setCatName(catName));
+          }
+          if (CollectionUtils.isNotEmpty(constraints.getDefaultConstraints()) && !constraints.getDefaultConstraints().get(0).isSetCatName()) {
+            constraints.getDefaultConstraints().forEach(constraint -> constraint.setCatName(catName));
+          }
+          if (CollectionUtils.isNotEmpty(constraints.getCheckConstraints()) && !constraints.getCheckConstraints().get(0).isSetCatName()) {
+            constraints.getCheckConstraints().forEach(constraint -> constraint.setCatName(catName));
+          }
+          // Set constraint name if null before sending to listener
+          constraints = ms.createTableWithConstraints(tbl, constraints);
+
+        }
+
+        if (!transactionalListeners.isEmpty()) {
+          transactionalListenerResponses = MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+              EventType.CREATE_TABLE, new CreateTableEvent(tbl, true, this, isReplicated), envContext);
+          if (CollectionUtils.isNotEmpty(constraints.getPrimaryKeys())) {
+            MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.ADD_PRIMARYKEY,
+                new AddPrimaryKeyEvent(constraints.getPrimaryKeys(), true, this), envContext);
+          }
+          if (CollectionUtils.isNotEmpty(constraints.getForeignKeys())) {
+            MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.ADD_FOREIGNKEY,
+                new AddForeignKeyEvent(constraints.getForeignKeys(), true, this), envContext);
+          }
+          if (CollectionUtils.isNotEmpty(constraints.getUniqueConstraints())) {
+            MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.ADD_UNIQUECONSTRAINT,
+                new AddUniqueConstraintEvent(constraints.getUniqueConstraints(), true, this), envContext);
+          }
+          if (CollectionUtils.isNotEmpty(constraints.getNotNullConstraints())) {
+            MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.ADD_NOTNULLCONSTRAINT,
+                new AddNotNullConstraintEvent(constraints.getNotNullConstraints(), true, this), envContext);
+          }
+          if (CollectionUtils.isNotEmpty(constraints.getCheckConstraints())) {
+            MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.ADD_CHECKCONSTRAINT,
+                new AddCheckConstraintEvent(constraints.getCheckConstraints(), true, this), envContext);
+          }
+          if (CollectionUtils.isNotEmpty(constraints.getDefaultConstraints())) {
+            MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.ADD_DEFAULTCONSTRAINT,
+                new AddDefaultConstraintEvent(constraints.getDefaultConstraints(), true, this), envContext);
+          }
+        }
+
+        success = ms.commitTransaction();
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+          if (madeDir) {
+            wh.deleteDir(tblPath, true, false, ReplChangeManager.shouldEnableCm(db, tbl));
+          }
+        }
+
+        if (!listeners.isEmpty()) {
+          MetaStoreListenerNotifier.notifyEvent(listeners, EventType.CREATE_TABLE,
+              new CreateTableEvent(tbl, success, this, isReplicated), envContext,
+                  transactionalListenerResponses, ms);
+          if (CollectionUtils.isNotEmpty(constraints.getPrimaryKeys())) {
+            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ADD_PRIMARYKEY,
+                new AddPrimaryKeyEvent(constraints.getPrimaryKeys(), success, this), envContext);
+          }
+          if (CollectionUtils.isNotEmpty(constraints.getForeignKeys())) {
+            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ADD_FOREIGNKEY,
+                new AddForeignKeyEvent(constraints.getForeignKeys(), success, this), envContext);
+          }
+          if (CollectionUtils.isNotEmpty(constraints.getUniqueConstraints())) {
+            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ADD_UNIQUECONSTRAINT,
+                new AddUniqueConstraintEvent(constraints.getUniqueConstraints(), success, this), envContext);
+          }
+          if (CollectionUtils.isNotEmpty(constraints.getNotNullConstraints())) {
+            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ADD_NOTNULLCONSTRAINT,
+                new AddNotNullConstraintEvent(constraints.getNotNullConstraints(), success, this), envContext);
+          }
+          if (CollectionUtils.isNotEmpty(constraints.getDefaultConstraints())) {
+            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ADD_DEFAULTCONSTRAINT,
+                new AddDefaultConstraintEvent(constraints.getDefaultConstraints(), success, this), envContext);
+          }
+          if (CollectionUtils.isNotEmpty(constraints.getCheckConstraints())) {
+            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ADD_CHECKCONSTRAINT,
+                new AddCheckConstraintEvent(constraints.getCheckConstraints(), success, this), envContext);
+          }
+        }
+      }
+
+      // If the table has column statistics, update it into the metastore. We need a valid
+      // writeId list to update column statistics for a transactional table. But during bootstrap
+      // replication, where we use this feature, we do not have a valid writeId list which was
+      // used to update the stats. But we know for sure that the writeId associated with the
+      // stats was valid then (otherwise stats update would have failed on the source). So, craft
+      // a valid transaction list with only that writeId and use it to update the stats.
+      if (colStats != null) {
+        long writeId = tbl.getWriteId();
+        String validWriteIds = null;
+        if (writeId > 0) {
+          ValidWriteIdList validWriteIdList =
+                  new ValidReaderWriteIdList(TableName.getDbTable(tbl.getDbName(),
+                                                                  tbl.getTableName()),
+                                              new long[0], new BitSet(), writeId);
+          validWriteIds = validWriteIdList.toString();
+        }
+        updateTableColumnStatsInternal(colStats, validWriteIds, tbl.getWriteId());
+      }
+    }
+
+    @Override
+    public void create_table(final Table tbl) throws AlreadyExistsException,
+        MetaException, InvalidObjectException, InvalidInputException {
+      create_table_with_environment_context(tbl, null);
+    }
+
+    @Override
+    public void create_table_with_environment_context(final Table tbl,
+        final EnvironmentContext envContext)
+        throws AlreadyExistsException, MetaException, InvalidObjectException,
+            InvalidInputException {
+      startFunction("create_table", ": " + tbl.toString());
+      boolean success = false;
+      Exception ex = null;
+      try {
+        create_table_core(getMS(), tbl, envContext);
+        success = true;
+      } catch (NoSuchObjectException e) {
+        LOG.warn("create_table_with_environment_context got ", e);
+        ex = e;
+        throw new InvalidObjectException(e.getMessage());
+      } catch (MetaException | InvalidObjectException | AlreadyExistsException | InvalidInputException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("create_table", success, ex, tbl.getTableName());
+      }
+    }
+
+    @Override
+    public void create_table_req(final CreateTableRequest req)
+            throws AlreadyExistsException, MetaException, InvalidObjectException,
+            InvalidInputException {
+      Table tbl = req.getTable();
+      startFunction("create_table_req", ": " + tbl.toString());
+      boolean success = false;
+      Exception ex = null;
+      try {
+        create_table_core(getMS(), req);
+        success = true;
+      } catch (NoSuchObjectException e) {
+        LOG.warn("create_table_req got ", e);
+        ex = e;
+        throw new InvalidObjectException(e.getMessage());
+      } catch (MetaException | InvalidObjectException | AlreadyExistsException | InvalidInputException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("create_table_req", success, ex, tbl.getTableName());
+      }
+    }
+
+    @Override
+    public void create_table_with_constraints(final Table tbl,
+        final List<SQLPrimaryKey> primaryKeys, final List<SQLForeignKey> foreignKeys,
+        List<SQLUniqueConstraint> uniqueConstraints,
+        List<SQLNotNullConstraint> notNullConstraints,
+        List<SQLDefaultConstraint> defaultConstraints,
+        List<SQLCheckConstraint> checkConstraints)
+        throws AlreadyExistsException, MetaException, InvalidObjectException,
+            InvalidInputException {
+      startFunction("create_table", ": " + tbl.toString());
+      boolean success = false;
+      Exception ex = null;
+      try {
+        CreateTableRequest req = new CreateTableRequest(tbl);
+        req.setPrimaryKeys(primaryKeys);
+        req.setForeignKeys(foreignKeys);
+        req.setUniqueConstraints(uniqueConstraints);
+        req.setNotNullConstraints(notNullConstraints);
+        req.setDefaultConstraints(defaultConstraints);
+        req.setCheckConstraints(checkConstraints);
+        create_table_req(req);
+        success = true;
+      } catch (MetaException | InvalidObjectException | AlreadyExistsException |
+              InvalidInputException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("create_table_with_constraints", success, ex, tbl.getTableName());
+      }
+    }
+
+    @Override
+    public void drop_constraint(DropConstraintRequest req)
+        throws MetaException, InvalidObjectException {
+      String catName = req.isSetCatName() ? req.getCatName() : getDefaultCatalog(conf);
+      String dbName = req.getDbname();
+      String tableName = req.getTablename();
+      String constraintName = req.getConstraintname();
+      startFunction("drop_constraint", ": " + constraintName);
+      boolean success = false;
+      Exception ex = null;
+      RawStore ms = getMS();
+      try {
+        ms.openTransaction();
+        ms.dropConstraint(catName, dbName, tableName, constraintName);
+        if (transactionalListeners.size() > 0) {
+          DropConstraintEvent dropConstraintEvent = new DropConstraintEvent(catName, dbName,
+              tableName, constraintName, true, this);
+          for (MetaStoreEventListener transactionalListener : transactionalListeners) {
+            transactionalListener.onDropConstraint(dropConstraintEvent);
+          }
+        }
+        success = ms.commitTransaction();
+      } catch (NoSuchObjectException e) {
+        ex = e;
+        throw new InvalidObjectException(e.getMessage());
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        } else {
+          for (MetaStoreEventListener listener : listeners) {
+            DropConstraintEvent dropConstraintEvent = new DropConstraintEvent(catName, dbName,
+                tableName, constraintName, true, this);
+            listener.onDropConstraint(dropConstraintEvent);
+          }
+        }
+        endFunction("drop_constraint", success, ex, constraintName);
+      }
+    }
+
+    @Override
+    public void add_primary_key(AddPrimaryKeyRequest req)
+      throws MetaException, InvalidObjectException {
+      List<SQLPrimaryKey> primaryKeyCols = req.getPrimaryKeyCols();
+      String constraintName = (CollectionUtils.isNotEmpty(primaryKeyCols)) ?
+        primaryKeyCols.get(0).getPk_name() : "null";
+      startFunction("add_primary_key", ": " + constraintName);
+      boolean success = false;
+      Exception ex = null;
+      if (CollectionUtils.isNotEmpty(primaryKeyCols) && !primaryKeyCols.get(0).isSetCatName()) {
+        String defaultCat = getDefaultCatalog(conf);
+        primaryKeyCols.forEach(pk -> pk.setCatName(defaultCat));
+      }
+      RawStore ms = getMS();
+      try {
+        ms.openTransaction();
+        List<SQLPrimaryKey> primaryKeys = ms.addPrimaryKeys(primaryKeyCols);
+        if (transactionalListeners.size() > 0) {
+          if (CollectionUtils.isNotEmpty(primaryKeys)) {
+            AddPrimaryKeyEvent addPrimaryKeyEvent = new AddPrimaryKeyEvent(primaryKeys, true, this);
+            for (MetaStoreEventListener transactionalListener : transactionalListeners) {
+              transactionalListener.onAddPrimaryKey(addPrimaryKeyEvent);
+            }
+          }
+        }
+        success = ms.commitTransaction();
+      } catch (MetaException | InvalidObjectException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        } else if (primaryKeyCols != null && primaryKeyCols.size() > 0) {
+          for (MetaStoreEventListener listener : listeners) {
+            AddPrimaryKeyEvent addPrimaryKeyEvent = new AddPrimaryKeyEvent(primaryKeyCols, true, this);
+            listener.onAddPrimaryKey(addPrimaryKeyEvent);
+          }
+        }
+        endFunction("add_primary_key", success, ex, constraintName);
+      }
+    }
+
+    @Override
+    public void add_foreign_key(AddForeignKeyRequest req)
+      throws MetaException, InvalidObjectException {
+      List<SQLForeignKey> foreignKeys = req.getForeignKeyCols();
+      String constraintName = CollectionUtils.isNotEmpty(foreignKeys) ?
+        foreignKeys.get(0).getFk_name() : "null";
+      startFunction("add_foreign_key", ": " + constraintName);
+      boolean success = false;
+      Exception ex = null;
+      if (CollectionUtils.isNotEmpty(foreignKeys) && !foreignKeys.get(0).isSetCatName()) {
+        String defaultCat = getDefaultCatalog(conf);
+        foreignKeys.forEach(pk -> pk.setCatName(defaultCat));
+      }
+      RawStore ms = getMS();
+      try {
+        ms.openTransaction();
+        foreignKeys = ms.addForeignKeys(foreignKeys);
+        if (transactionalListeners.size() > 0) {
+          if (CollectionUtils.isNotEmpty(foreignKeys)) {
+            AddForeignKeyEvent addForeignKeyEvent = new AddForeignKeyEvent(foreignKeys, true, this);
+            for (MetaStoreEventListener transactionalListener : transactionalListeners) {
+              transactionalListener.onAddForeignKey(addForeignKeyEvent);
+            }
+          }
+        }
+        success = ms.commitTransaction();
+      } catch (MetaException | InvalidObjectException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        } else if (CollectionUtils.isNotEmpty(foreignKeys)) {
+          for (MetaStoreEventListener listener : listeners) {
+            AddForeignKeyEvent addForeignKeyEvent = new AddForeignKeyEvent(foreignKeys, true, this);
+            listener.onAddForeignKey(addForeignKeyEvent);
+          }
+        }
+        endFunction("add_foreign_key", success, ex, constraintName);
+      }
+    }
+
+    @Override
+    public void add_unique_constraint(AddUniqueConstraintRequest req)
+      throws MetaException, InvalidObjectException {
+      List<SQLUniqueConstraint> uniqueConstraints = req.getUniqueConstraintCols();
+      String constraintName = (uniqueConstraints != null && uniqueConstraints.size() > 0) ?
+              uniqueConstraints.get(0).getUk_name() : "null";
+      startFunction("add_unique_constraint", ": " + constraintName);
+      boolean success = false;
+      Exception ex = null;
+      if (!uniqueConstraints.isEmpty() && !uniqueConstraints.get(0).isSetCatName()) {
+        String defaultCat = getDefaultCatalog(conf);
+        uniqueConstraints.forEach(pk -> pk.setCatName(defaultCat));
+      }
+      RawStore ms = getMS();
+      try {
+        ms.openTransaction();
+        uniqueConstraints = ms.addUniqueConstraints(uniqueConstraints);
+        if (transactionalListeners.size() > 0) {
+          if (CollectionUtils.isNotEmpty(uniqueConstraints)) {
+            AddUniqueConstraintEvent addUniqueConstraintEvent = new AddUniqueConstraintEvent(uniqueConstraints, true, this);
+            for (MetaStoreEventListener transactionalListener : transactionalListeners) {
+              transactionalListener.onAddUniqueConstraint(addUniqueConstraintEvent);
+            }
+          }
+        }
+        success = ms.commitTransaction();
+      } catch (MetaException | InvalidObjectException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        } else if (CollectionUtils.isNotEmpty(uniqueConstraints)) {
+          for (MetaStoreEventListener listener : listeners) {
+            AddUniqueConstraintEvent addUniqueConstraintEvent = new AddUniqueConstraintEvent(uniqueConstraints, true, this);
+            listener.onAddUniqueConstraint(addUniqueConstraintEvent);
+          }
+        }
+        endFunction("add_unique_constraint", success, ex, constraintName);
+      }
+    }
+
+    @Override
+    public void add_not_null_constraint(AddNotNullConstraintRequest req)
+      throws MetaException, InvalidObjectException {
+      List<SQLNotNullConstraint> notNullConstraints = req.getNotNullConstraintCols();
+      String constraintName = (notNullConstraints != null && notNullConstraints.size() > 0) ?
+              notNullConstraints.get(0).getNn_name() : "null";
+      startFunction("add_not_null_constraint", ": " + constraintName);
+      boolean success = false;
+      Exception ex = null;
+      if (!notNullConstraints.isEmpty() && !notNullConstraints.get(0).isSetCatName()) {
+        String defaultCat = getDefaultCatalog(conf);
+        notNullConstraints.forEach(pk -> pk.setCatName(defaultCat));
+      }
+      RawStore ms = getMS();
+      try {
+        ms.openTransaction();
+        notNullConstraints = ms.addNotNullConstraints(notNullConstraints);
+
+        if (transactionalListeners.size() > 0) {
+          if (CollectionUtils.isNotEmpty(notNullConstraints)) {
+            AddNotNullConstraintEvent addNotNullConstraintEvent = new AddNotNullConstraintEvent(notNullConstraints, true, this);
+            for (MetaStoreEventListener transactionalListener : transactionalListeners) {
+              transactionalListener.onAddNotNullConstraint(addNotNullConstraintEvent);
+            }
+          }
+        }
+        success = ms.commitTransaction();
+      } catch (MetaException | InvalidObjectException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        } else if (CollectionUtils.isNotEmpty(notNullConstraints)) {
+          for (MetaStoreEventListener listener : listeners) {
+            AddNotNullConstraintEvent addNotNullConstraintEvent = new AddNotNullConstraintEvent(notNullConstraints, true, this);
+            listener.onAddNotNullConstraint(addNotNullConstraintEvent);
+          }
+        }
+        endFunction("add_not_null_constraint", success, ex, constraintName);
+      }
+    }
+
+    @Override
+    public void add_default_constraint(AddDefaultConstraintRequest req) throws MetaException, InvalidObjectException {
+      List<SQLDefaultConstraint> defaultConstraints = req.getDefaultConstraintCols();
+      String constraintName =
+          CollectionUtils.isNotEmpty(defaultConstraints) ? defaultConstraints.get(0).getDc_name() : "null";
+      startFunction("add_default_constraint", ": " + constraintName);
+      boolean success = false;
+      Exception ex = null;
+      if (!defaultConstraints.isEmpty() && !defaultConstraints.get(0).isSetCatName()) {
+        String defaultCat = getDefaultCatalog(conf);
+        defaultConstraints.forEach(pk -> pk.setCatName(defaultCat));
+      }
+      RawStore ms = getMS();
+      try {
+        ms.openTransaction();
+        defaultConstraints = ms.addDefaultConstraints(defaultConstraints);
+        if (transactionalListeners.size() > 0) {
+          if (CollectionUtils.isNotEmpty(defaultConstraints)) {
+            AddDefaultConstraintEvent addDefaultConstraintEvent =
+                new AddDefaultConstraintEvent(defaultConstraints, true, this);
+            for (MetaStoreEventListener transactionalListener : transactionalListeners) {
+              transactionalListener.onAddDefaultConstraint(addDefaultConstraintEvent);
+            }
+          }
+        }
+        success = ms.commitTransaction();
+      } catch (MetaException | InvalidObjectException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        } else if (CollectionUtils.isNotEmpty(defaultConstraints)) {
+          for (MetaStoreEventListener listener : listeners) {
+            AddDefaultConstraintEvent addDefaultConstraintEvent =
+                new AddDefaultConstraintEvent(defaultConstraints, true, this);
+            listener.onAddDefaultConstraint(addDefaultConstraintEvent);
+          }
+        }
+        endFunction("add_default_constraint", success, ex, constraintName);
+      }
+    }
+
+    @Override
+    public void add_check_constraint(AddCheckConstraintRequest req)
+        throws MetaException, InvalidObjectException {
+      List<SQLCheckConstraint> checkConstraints= req.getCheckConstraintCols();
+      String constraintName = CollectionUtils.isNotEmpty(checkConstraints) ?
+          checkConstraints.get(0).getDc_name() : "null";
+      startFunction("add_check_constraint", ": " + constraintName);
+      boolean success = false;
+      Exception ex = null;
+      if (!checkConstraints.isEmpty() && !checkConstraints.get(0).isSetCatName()) {
+        String defaultCat = getDefaultCatalog(conf);
+        checkConstraints.forEach(pk -> pk.setCatName(defaultCat));
+      }
+      RawStore ms = getMS();
+      try {
+        ms.openTransaction();
+        checkConstraints = ms.addCheckConstraints(checkConstraints);
+        if (transactionalListeners.size() > 0) {
+          if (CollectionUtils.isNotEmpty(checkConstraints)) {
+            AddCheckConstraintEvent addcheckConstraintEvent = new AddCheckConstraintEvent(checkConstraints, true, this);
+            for (MetaStoreEventListener transactionalListener : transactionalListeners) {
+             transactionalListener.onAddCheckConstraint(addcheckConstraintEvent);
+            }
+          }
+        }
+        success = ms.commitTransaction();
+      } catch (MetaException | InvalidObjectException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        } else if (CollectionUtils.isNotEmpty(checkConstraints)) {
+          for (MetaStoreEventListener listener : listeners) {
+            AddCheckConstraintEvent addCheckConstraintEvent = new AddCheckConstraintEvent(checkConstraints, true, this);
+            listener.onAddCheckConstraint(addCheckConstraintEvent);
+          }
+        }
+        endFunction("add_check_constraint", success, ex, constraintName);
+      }
+    }
+
+    private boolean is_table_exists(RawStore ms, String catName, String dbname, String name)
+        throws MetaException {
+      return (ms.getTable(catName, dbname, name, null) != null);
+    }
+
+    private boolean drop_table_core(final RawStore ms, final String catName, final String dbname,
+                                    final String name, final boolean deleteData,
+                                    final EnvironmentContext envContext, final String indexName)
+        throws NoSuchObjectException, MetaException, IOException, InvalidObjectException,
+        InvalidInputException {
+      boolean success = false;
+      boolean tableDataShouldBeDeleted = false;
+      Path tblPath = null;
+      List<Path> partPaths = null;
+      Table tbl = null;
+      boolean ifPurge = false;
+      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
+      Database db = null;
+      boolean isReplicated = false;
+      try {
+        ms.openTransaction();
+        db = ms.getDatabase(catName, dbname);
+        if (db.getType() == DatabaseType.REMOTE) {
+          return DataConnectorProviderFactory.getDataConnectorProvider(db).dropTable(name);
+        }
+        isReplicated = isDbReplicationTarget(db);
+
+        // drop any partitions
+        tbl = get_table_core(catName, dbname, name, null);
+        if (tbl == null) {
+          throw new NoSuchObjectException(name + " doesn't exist");
+        }
+
+        // Check if table is part of a materialized view.
+        // If it is, it cannot be dropped.
+        List<String> isPartOfMV = ms.isPartOfMaterializedView(catName, dbname, name);
+        if (!isPartOfMV.isEmpty()) {
+            throw new MetaException(String.format("Cannot drop table as it is used in the following materialized" +
+                    " views %s%n", isPartOfMV));
+        }
+
+        if (tbl.getSd() == null) {
+          throw new MetaException("Table metadata is corrupted");
+        }
+        ifPurge = isMustPurge(envContext, tbl);
+
+        firePreEvent(new PreDropTableEvent(tbl, deleteData, this));
+
+        tableDataShouldBeDeleted = checkTableDataShouldBeDeleted(tbl, deleteData);
+        if (tbl.getSd().getLocation() != null) {
+          tblPath = new Path(tbl.getSd().getLocation());
+          if (!wh.isWritable(tblPath.getParent())) {
+            String target = indexName == null ? "Table" : "Index table";
+            throw new MetaException(target + " metadata not deleted since " +
+                tblPath.getParent() + " is not writable by " +
+                SecurityUtils.getUser());
+          }
+        }
+
+        // Drop the partitions and get a list of locations which need to be deleted
+        partPaths = dropPartitionsAndGetLocations(ms, catName, dbname, name, tblPath,
+            tableDataShouldBeDeleted);
+
+        // Drop any constraints on the table
+        ms.dropConstraint(catName, dbname, name, null, true);
+
+        if (!ms.dropTable(catName, dbname, name)) {
+          String tableName = TableName.getQualified(catName, dbname, name);
+          throw new MetaException(indexName == null ? "Unable to drop table " + tableName:
+              "Unable to drop index table " + tableName + " for index " + indexName);
+        } else {
+          if (!transactionalListeners.isEmpty()) {
+            transactionalListenerResponses =
+                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                                                      EventType.DROP_TABLE,
+                                                      new DropTableEvent(tbl, true, deleteData,
+                                                              this, isReplicated),
+                                                      envContext);
+          }
+          success = ms.commitTransaction();
+        }
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        } else if (tableDataShouldBeDeleted) {
+          // Data needs deletion. Check if trash may be skipped.
+          // Delete the data in the partitions which have other locations
+          deletePartitionData(partPaths, ifPurge, ReplChangeManager.shouldEnableCm(db, tbl));
+          // Delete the data in the table
+          deleteTableData(tblPath, ifPurge, ReplChangeManager.shouldEnableCm(db, tbl));
+        }
+
+        if (!listeners.isEmpty()) {
+          MetaStoreListenerNotifier.notifyEvent(listeners,
+                                                EventType.DROP_TABLE,
+                                                new DropTableEvent(tbl, success, deleteData, this, isReplicated),
+                                                envContext,
+                                                transactionalListenerResponses, ms);
+        }
+      }
+      return success;
+    }
+
+    private boolean checkTableDataShouldBeDeleted(Table tbl, boolean deleteData) {
+      if (deleteData && isExternal(tbl)) {
+        // External table data can be deleted if EXTERNAL_TABLE_PURGE is true
+        return isExternalTablePurge(tbl);
+      }
+      return deleteData;
+    }
+
+    /**
+     * Deletes the data in a table's location, if it fails logs an error
+     *
+     * @param tablePath
+     * @param ifPurge completely purge the table (skipping trash) while removing
+     *                data from warehouse
+     * @param shouldEnableCm If cm should be enabled
+     */
+    private void deleteTableData(Path tablePath, boolean ifPurge, boolean shouldEnableCm) {
+      if (tablePath != null) {
+        deleteDataExcludeCmroot(tablePath, ifPurge, shouldEnableCm);
+      }
+    }
+
+    /**
+     * Deletes the data in a table's location, if it fails logs an error.
+     *
+     * @param tablePath
+     * @param ifPurge completely purge the table (skipping trash) while removing
+     *                data from warehouse
+     * @param db Database
+     */
+    private void deleteTableData(Path tablePath, boolean ifPurge, Database db) {
+      if (tablePath != null) {
+        try {
+          wh.deleteDir(tablePath, true, ifPurge, db);
+        } catch (Exception e) {
+          LOG.error("Failed to delete table directory: " + tablePath +
+                  " " + e.getMessage());
+        }
+      }
+    }
+
+    /**
+    * Give a list of partitions' locations, tries to delete each one
+    * and for each that fails logs an error.
+    *
+    * @param partPaths
+    * @param ifPurge completely purge the partition (skipping trash) while
+    *                removing data from warehouse
+    * @param shouldEnableCm If cm should be enabled
+    */
+    private void deletePartitionData(List<Path> partPaths, boolean ifPurge, boolean shouldEnableCm) {
+      if (partPaths != null && !partPaths.isEmpty()) {
+        for (Path partPath : partPaths) {
+          deleteDataExcludeCmroot(partPath, ifPurge, shouldEnableCm);
+        }
+      }
+    }
+
+    /**
+     * Give a list of partitions' locations, tries to delete each one
+     * and for each that fails logs an error.
+     *
+     * @param partPaths
+     * @param ifPurge completely purge the partition (skipping trash) while
+     *                removing data from warehouse
+     * @param db Database
+     */
+    private void deletePartitionData(List<Path> partPaths, boolean ifPurge, Database db) {
+      if (partPaths != null && !partPaths.isEmpty()) {
+        for (Path partPath : partPaths) {
+          try {
+            wh.deleteDir(partPath, true, ifPurge, db);
+          } catch (Exception e) {
+            LOG.error("Failed to delete partition directory: " + partPath +
+                    " " + e.getMessage());
+          }
+        }
+      }
+    }
+
+    /**
+     * Delete data from path excluding cmdir
+     * and for each that fails logs an error.
+     *
+     * @param path
+     * @param ifPurge completely purge the partition (skipping trash) while
+     *                removing data from warehouse
+     * @param shouldEnableCm If cm should be enabled
+     */
+    private void deleteDataExcludeCmroot(Path path, boolean ifPurge, boolean shouldEnableCm) {
+      try {
+        if (shouldEnableCm) {
+          //Don't delete cmdir if its inside the partition path
+          FileStatus[] statuses = path.getFileSystem(conf).listStatus(path,
+                  ReplChangeManager.CMROOT_PATH_FILTER);
+          for (final FileStatus status : statuses) {
+            wh.deleteDir(status.getPath(), true, ifPurge, shouldEnableCm);
+          }
+          //Check if table directory is empty, delete it
+          FileStatus[] statusWithoutFilter = path.getFileSystem(conf).listStatus(path);
+          if (statusWithoutFilter.length == 0) {
+            wh.deleteDir(path, true, ifPurge, shouldEnableCm);
+          }
+        } else {
+          //If no cm delete the complete table directory
+          wh.deleteDir(path, true, ifPurge, shouldEnableCm);
+        }
+      } catch (Exception e) {
+        LOG.error("Failed to delete directory: " + path +
+                " " + e.getMessage());
+      }
+    }
+
+    /**
+     * Deletes the partitions specified by catName, dbName, tableName. If checkLocation is true, for
+     * locations of partitions which may not be subdirectories of tablePath checks to make sure the
+     * locations are writable.
+     *
+     * Drops the metadata for each partition.
+     *
+     * Provides a list of locations of partitions which may not be subdirectories of tablePath.
+     *
+     * @param ms RawStore to use for metadata retrieval and delete
+     * @param catName The catName
+     * @param dbName The dbName
+     * @param tableName The tableName
+     * @param tablePath The tablePath of which subdirectories does not have to be checked
+     * @param checkLocation Should we check the locations at all
+     * @return The list of the Path objects to delete (only in case checkLocation is true)
+     * @throws MetaException
+     * @throws IOException
+     * @throws NoSuchObjectException
+     */
+    private List<Path> dropPartitionsAndGetLocations(RawStore ms, String catName, String dbName,
+        String tableName, Path tablePath, boolean checkLocation)
+        throws MetaException, IOException, NoSuchObjectException {
+      int batchSize = MetastoreConf.getIntVar(conf, ConfVars.BATCH_RETRIEVE_OBJECTS_MAX);
+      String tableDnsPath = null;
+      if (tablePath != null) {
+        tableDnsPath = wh.getDnsPath(tablePath).toString();
+      }
+
+      List<Path> partPaths = new ArrayList<>();
+      while (true) {
+        Map<String, String> partitionLocations = ms.getPartitionLocations(catName, dbName, tableName,
+            tableDnsPath, batchSize);
+        if (partitionLocations == null || partitionLocations.isEmpty()) {
+          // No more partitions left to drop. Return with the collected path list to delete.
+          return partPaths;
+        }
+
+        if (checkLocation) {
+          for (String partName : partitionLocations.keySet()) {
+            String pathString = partitionLocations.get(partName);
+            if (pathString != null) {
+              Path partPath = wh.getDnsPath(new Path(pathString));
+              // Double check here. Maybe Warehouse.getDnsPath revealed relationship between the
+              // path objects
+              if (tableDnsPath == null ||
+                      !FileUtils.isSubdirectory(tableDnsPath, partPath.toString())) {
+                if (!wh.isWritable(partPath.getParent())) {
+                  throw new MetaException("Table metadata not deleted since the partition "
+                      + partName + " has parent location " + partPath.getParent()
+                      + " which is not writable by " + SecurityUtils.getUser());
+                }
+                partPaths.add(partPath);
+              }
+            }
+          }
+        }
+
+        for (MetaStoreEventListener listener : listeners) {
+          //No drop part listener events fired for public listeners historically, for drop table case.
+          //Limiting to internal listeners for now, to avoid unexpected calls for public listeners.
+          if (listener instanceof HMSMetricsListener) {
+            for (@SuppressWarnings("unused") String partName : partitionLocations.keySet()) {
+              listener.onDropPartition(null);
+            }
+          }
+        }
+
+        ms.dropPartitions(catName, dbName, tableName, new ArrayList<>(partitionLocations.keySet()));
+      }
+    }
+
+    @Override
+    public void drop_table(final String dbname, final String name, final boolean deleteData)
+        throws NoSuchObjectException, MetaException {
+      drop_table_with_environment_context(dbname, name, deleteData, null);
+    }
+
+    @Override
+    public void drop_table_with_environment_context(final String dbname, final String name,
+        final boolean deleteData, final EnvironmentContext envContext)
+        throws NoSuchObjectException, MetaException {
+      String[] parsedDbName = parseDbName(dbname, conf);
+      startTableFunction("drop_table", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], name);
+
+      boolean success = false;
+      Exception ex = null;
+      try {
+        success = drop_table_core(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME], name,
+            deleteData, envContext, null);
+      } catch (IOException e) {
+        ex = e;
+        throw new MetaException(e.getMessage());
+      } catch (Exception e) {
+        ex = e;
+        throwMetaException(e);
+      } finally {
+        endFunction("drop_table", success, ex, name);
+      }
+
+    }
+
+    private void updateStatsForTruncate(Map<String,String> props, EnvironmentContext environmentContext) {
+      if (null == props) {
+        return;
+      }
+      for (String stat : StatsSetupConst.SUPPORTED_STATS) {
+        String statVal = props.get(stat);
+        if (statVal != null) {
+          //In the case of truncate table, we set the stats to be 0.
+          props.put(stat, "0");
+        }
+      }
+      //first set basic stats to true
+      StatsSetupConst.setBasicStatsState(props, StatsSetupConst.TRUE);
+      environmentContext.putToProperties(StatsSetupConst.STATS_GENERATED, StatsSetupConst.TASK);
+      environmentContext.putToProperties(StatsSetupConst.DO_NOT_POPULATE_QUICK_STATS, StatsSetupConst.TRUE);
+      //then invalidate column stats
+      StatsSetupConst.clearColumnStatsState(props);
+      return;
+    }
+
+    private void alterPartitionForTruncate(RawStore ms, String catName, String dbName, String tableName,
+        Table table, Partition partition, String validWriteIds, long writeId) throws Exception {
+      EnvironmentContext environmentContext = new EnvironmentContext();
+      updateStatsForTruncate(partition.getParameters(), environmentContext);
+
+      if (!transactionalListeners.isEmpty()) {
+        MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                EventType.ALTER_PARTITION,
+                new AlterPartitionEvent(partition, partition, table, true, true,
+                        writeId, this));
+      }
+
+      if (!listeners.isEmpty()) {
+        MetaStoreListenerNotifier.notifyEvent(listeners,
+                EventType.ALTER_PARTITION,
+                new AlterPartitionEvent(partition, partition, table, true, true,
+                        writeId, this));
+      }
+
+      if (writeId > 0) {
+        partition.setWriteId(writeId);
+      }
+      alterHandler.alterPartition(ms, wh, catName, dbName, tableName, null, partition,
+          environmentContext, this, validWriteIds);
+    }
+
+    private void alterTableStatsForTruncate(RawStore ms, String catName, String dbName,
+        String tableName, Table table, List<String> partNames,
+        String validWriteIds, long writeId) throws Exception {
+      if (partNames == null) {
+        if (0 != table.getPartitionKeysSize()) {
+          for (Partition partition : ms.getPartitions(catName, dbName, tableName, -1)) {
+            alterPartitionForTruncate(ms, catName, dbName, tableName, table, partition,
+                validWriteIds, writeId);
+          }
+        } else {
+          EnvironmentContext environmentContext = new EnvironmentContext();
+          updateStatsForTruncate(table.getParameters(), environmentContext);
+
+          boolean isReplicated = isDbReplicationTarget(ms.getDatabase(catName, dbName));
+          if (!transactionalListeners.isEmpty()) {
+            MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                    EventType.ALTER_TABLE,
+                    new AlterTableEvent(table, table, true, true,
+                            writeId, this, isReplicated));
+          }
+
+          if (!listeners.isEmpty()) {
+            MetaStoreListenerNotifier.notifyEvent(listeners,
+                    EventType.ALTER_TABLE,
+                    new AlterTableEvent(table, table, true, true,
+                            writeId, this, isReplicated));
+          }
+
+          // TODO: this should actually pass thru and set writeId for txn stats.
+          if (writeId > 0) {
+            table.setWriteId(writeId);
+          }
+          alterHandler.alterTable(ms, wh, catName, dbName, tableName, table,
+              environmentContext, this, validWriteIds);
+        }
+      } else {
+        for (Partition partition : ms.getPartitionsByNames(catName, dbName, tableName, partNames)) {
+          alterPartitionForTruncate(ms, catName, dbName, tableName, table, partition,
+              validWriteIds, writeId);
+        }
+      }
+      return;
+    }
+
+    private List<Path> getLocationsForTruncate(final RawStore ms,
+                                               final String catName,
+                                               final String dbName,
+                                               final String tableName,
+                                               final Table table,
+                                               final List<String> partNames) throws Exception {
+      List<Path> locations = new ArrayList<>();
+      if (partNames == null) {
+        if (0 != table.getPartitionKeysSize()) {
+          for (Partition partition : ms.getPartitions(catName, dbName, tableName, -1)) {
+            locations.add(new Path(partition.getSd().getLocation()));
+          }
+        } else {
+          locations.add(new Path(table.getSd().getLocation()));
+        }
+      } else {
+        for (Partition partition : ms.getPartitionsByNames(catName, dbName, tableName, partNames)) {
+          locations.add(new Path(partition.getSd().getLocation()));
+        }
+      }
+      return locations;
+    }
+
+    @Override
+    public CmRecycleResponse cm_recycle(final CmRecycleRequest request) throws MetaException {
+      wh.recycleDirToCmPath(new Path(request.getDataPath()), request.isPurge());
+      return new CmRecycleResponse();
+    }
+
+    @Override
+    public void truncate_table(final String dbName, final String tableName, List<String> partNames)
+      throws NoSuchObjectException, MetaException {
+      // Deprecated path, won't work for txn tables.
+      truncateTableInternal(dbName, tableName, partNames, null, -1);
+    }
+
+    @Override
+    public TruncateTableResponse truncate_table_req(TruncateTableRequest req)
+        throws MetaException, TException {
+      truncateTableInternal(req.getDbName(), req.getTableName(), req.getPartNames(),
+          req.getValidWriteIdList(), req.getWriteId());
+      return new TruncateTableResponse();
+    }
+
+    private void truncateTableInternal(String dbName, String tableName, List<String> partNames,
+        String validWriteIds, long writeId) throws MetaException, NoSuchObjectException {
+      try {
+        String[] parsedDbName = parseDbName(dbName, conf);
+        Table tbl = get_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName);
+
+        boolean truncateFiles = !TxnUtils.isTransactionalTable(tbl) ||
+            !MetastoreConf.getBoolVar(getConf(), MetastoreConf.ConfVars.TRUNCATE_ACID_USE_BASE);
+        // This is not transactional
+        for (Path location : getLocationsForTruncate(getMS(), parsedDbName[CAT_NAME],
+            parsedDbName[DB_NAME], tableName, tbl, partNames)) {
+          FileSystem fs = location.getFileSystem(getConf());
+          if (truncateFiles) {
+            truncateDataFiles(tbl, parsedDbName, location, fs);
+          } else {
+            // For Acid tables we don't need to delete the old files, only write an empty baseDir.
+            // Compaction and cleaner will take care of the rest
+            addTruncateBaseFile(location, writeId, fs);
+          }
+        }
+
+        // Alter the table/partition stats and also notify truncate table event
+        alterTableStatsForTruncate(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+            tableName, tbl, partNames, validWriteIds, writeId);
+      } catch (IOException e) {
+        throw new MetaException(e.getMessage());
+      } catch (MetaException | NoSuchObjectException e) {
+        throw e;
+      } catch (Exception e) {
+        throw newMetaException(e);
+      }
+    }
+
+    /**
+     * Add an empty baseDir with a truncate metadatafile
+     * @param location partition or table directory
+     * @param writeId allocated writeId
+     * @param fs FileSystem
+     * @throws Exception
+     */
+    private void addTruncateBaseFile(Path location, long writeId, FileSystem fs) throws Exception {
+      Path basePath = new Path(location, AcidConstants.baseDir(writeId));
+      fs.mkdirs(basePath);
+      // We can not leave the folder empty, otherwise it will be skipped at some file listing in AcidUtils
+      // No need for a data file, a simple metadata is enough
+      AcidMetaDataFile.writeToFile(fs, basePath, AcidMetaDataFile.DataFormat.TRUNCATED);
+    }
+
+    private void truncateDataFiles(Table tbl, String[] parsedDbName, Path location, FileSystem fs)
+        throws IOException, MetaException, NoSuchObjectException {
+      boolean isSkipTrash = MetaStoreUtils.isSkipTrash(tbl.getParameters());
+      Database db = get_database_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]);
+      if (!HdfsUtils.isPathEncrypted(getConf(), fs.getUri(), location) &&
+          !FileUtils.pathHasSnapshotSubDir(location, fs)) {
+        HdfsUtils.HadoopFileStatus status = new HdfsUtils.HadoopFileStatus(getConf(), fs, location);
+        FileStatus targetStatus = fs.getFileStatus(location);
+        String targetGroup = targetStatus == null ? null : targetStatus.getGroup();
+        wh.deleteDir(location, true, isSkipTrash, ReplChangeManager.shouldEnableCm(db, tbl));
+        fs.mkdirs(location);
+        HdfsUtils.setFullFileStatus(getConf(), status, targetGroup, fs, location, false);
+      } else {
+        FileStatus[] statuses = fs.listStatus(location, FileUtils.HIDDEN_FILES_PATH_FILTER);
+        if (statuses == null || statuses.length == 0) {
+          return;
+        }
+        for (final FileStatus status : statuses) {
+          wh.deleteDir(status.getPath(), true, isSkipTrash, ReplChangeManager.shouldEnableCm(db, tbl));
+        }
+      }
+    }
+
+    /**
+     * Is this an external table?
+     *
+     * @param table
+     *          Check if this table is external.
+     * @return True if the table is external, otherwise false.
+     */
+    private boolean isExternal(Table table) {
+      return MetaStoreUtils.isExternalTable(table);
+    }
+
+    private boolean isExternalTablePurge(Table table) {
+      return MetaStoreUtils.isExternalTablePurge(table);
+    }
+
+    @Override
+    @Deprecated
+    public Table get_table(final String dbname, final String name) throws MetaException,
+        NoSuchObjectException {
+      String[] parsedDbName = parseDbName(dbname, conf);
+      return getTableInternal(
+            parsedDbName[CAT_NAME], parsedDbName[DB_NAME], name, null, null, false, null, null, null);
+    }
+
+    @Override
+    public List<ExtendedTableInfo> get_tables_ext(final GetTablesExtRequest req) throws MetaException {
+      List<String> tables = new ArrayList<String>();
+      List<ExtendedTableInfo> ret = new ArrayList<ExtendedTableInfo>();
+      String catalog  = req.getCatalog();
+      String database = req.getDatabase();
+      String pattern  = req.getTableNamePattern();
+      List<String> processorCapabilities = req.getProcessorCapabilities();
+      int limit = req.getLimit();
+      String processorId  = req.getProcessorIdentifier();
+      List<Table> tObjects = new ArrayList<>();
+
+      startTableFunction("get_tables_ext", catalog, database, pattern);
+      Exception ex = null;
+      try {
+        tables = getMS().getTables(catalog, database, pattern, null, limit);
+        LOG.debug("get_tables_ext:getTables() returned " + tables.size());
+        tables = FilterUtils.filterTableNamesIfEnabled(isServerFilterEnabled, filterHook,
+                catalog, database, tables);
+
+        if (tables.size() > 0) {
+          tObjects = getMS().getTableObjectsByName(catalog, database, tables);
+          LOG.debug("get_tables_ext:getTableObjectsByName() returned " + tObjects.size());
+          if (processorCapabilities == null || processorCapabilities.size() == 0 ||
+                processorCapabilities.contains("MANAGERAWMETADATA")) {
+            LOG.info("Skipping translation for processor with " + processorId);
+          } else {
+            if (transformer != null) {
+              Map<Table, List<String>> retMap = transformer.transform(tObjects, processorCapabilities, processorId);
+
+              for (Map.Entry<Table, List<String>> entry : retMap.entrySet())  {
+                LOG.debug("Table " + entry.getKey().getTableName() + " requires " + Arrays.toString((entry.getValue()).toArray()));
+                ret.add(convertTableToExtendedTable(entry.getKey(), entry.getValue(), req.getRequestedFields()));
+              }
+            } else {
+              for (Table table : tObjects) {
+                ret.add(convertTableToExtendedTable(table, processorCapabilities, req.getRequestedFields()));
+              }
+            }
+          }
+        }
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_tables_ext", ret != null, ex);
+      }
+      return ret;
+    }
+
+    private ExtendedTableInfo convertTableToExtendedTable (Table table,
+          List<String> processorCapabilities, int mask) {
+      ExtendedTableInfo extTable = new ExtendedTableInfo(table.getTableName());
+      if ((mask & GetTablesExtRequestFields.ACCESS_TYPE.getValue()) == GetTablesExtRequestFields.ACCESS_TYPE.getValue())
+        extTable.setAccessType(table.getAccessType());
+
+      if ((mask & GetTablesExtRequestFields.PROCESSOR_CAPABILITIES.getValue())
+             == GetTablesExtRequestFields.PROCESSOR_CAPABILITIES.getValue()) {
+        extTable.setRequiredReadCapabilities(table.getRequiredReadCapabilities());
+        extTable.setRequiredWriteCapabilities(table.getRequiredWriteCapabilities());
+      }
+
+      return extTable;
+    }
+
+    @Override
+    public GetTableResult get_table_req(GetTableRequest req) throws MetaException,
+        NoSuchObjectException {
+      String catName = req.isSetCatName() ? req.getCatName() : getDefaultCatalog(conf);
+      return new GetTableResult(getTableInternal(catName, req.getDbName(), req.getTblName(),
+          req.getCapabilities(), req.getValidWriteIdList(), req.isGetColumnStats(), req.getEngine(),
+          req.getProcessorCapabilities(), req.getProcessorIdentifier()));
+    }
+
+    /**
+     * This function retrieves table from metastore. If getColumnStats flag is true,
+     * then engine should be specified so the table is retrieve with the column stats
+     * for that engine.
+     */
+    private Table getTableInternal(String catName, String dbname, String name,
+        ClientCapabilities capabilities, String writeIdList, boolean getColumnStats, String engine,
+        List<String> processorCapabilities, String processorId)
+        throws MetaException, NoSuchObjectException {
+      Preconditions.checkArgument(!getColumnStats || engine != null,
+          "To retrieve column statistics with a table, engine parameter cannot be null");
+
+      if (isInTest) {
+        assertClientHasCapability(capabilities, ClientCapability.TEST_CAPABILITY,
+            "Hive tests", "get_table_req");
+      }
+
+      Table t = null;
+      startTableFunction("get_table", catName, dbname, name);
+      Exception ex = null;
+      try {
+        t = get_table_core(catName, dbname, name, writeIdList, getColumnStats, engine);
+        if (MetaStoreUtils.isInsertOnlyTableParam(t.getParameters())) {
+          assertClientHasCapability(capabilities, ClientCapability.INSERT_ONLY_TABLES,
+              "insert-only tables", "get_table_req");
+        }
+
+        if (processorCapabilities == null || processorCapabilities.size() == 0 ||
+              processorCapabilities.contains("MANAGERAWMETADATA")) {
+          LOG.info("Skipping translation for processor with " + processorId);
+        } else {
+          if (transformer != null) {
+            List<Table> tList = new ArrayList<>();
+            tList.add(t);
+            Map<Table, List<String>> ret = transformer.transform(tList, processorCapabilities, processorId);
+            if (ret.size() > 1) {
+              LOG.warn("Unexpected resultset size:" + ret.size());
+              throw new MetaException("Unexpected result from metadata transformer:return list size is " + ret.size());
+            }
+            t = (Table)(ret.keySet().iterator().next());
+          }
+        }
+
+        firePreEvent(new PreReadTableEvent(t, this));
+      } catch (MetaException | NoSuchObjectException e) {
+        ex = e;
+        throw e;
+      } finally {
+        endFunction("get_table", t != null, ex, name);
+      }
+      return t;
+    }
+
+    @Override
+    public List<TableMeta> get_table_meta(String dbnames, String tblNames, List<String> tblTypes)
+        throws MetaException, NoSuchObjectException {
+      List<TableMeta> t = null;
+      String[] parsedDbName = parseDbName(dbnames, conf);
+      startTableFunction("get_table_metas", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblNames);
+      Exception ex = null;
+      try {
+        t = getMS().getTableMeta(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblNames, tblTypes);
+        t = FilterUtils.filterTableMetasIfEnabled(isServerFilterEnabled, filterHook,
+            parsedDbName[CAT_NAME], parsedDbName[DB_NAME], t);
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_table_metas", t != null, ex);
+      }
+      return t;
+    }
+
+    @Override
+    public Table get_table_core(
+        final String catName,
+        final String dbname,
+        final String name)
+        throws MetaException, NoSuchObjectException {
+      return get_table_core(catName, dbname, name, null);
+    }
+
+    @Override
+    public Table get_table_core(
+        final String catName,
+        final String dbname,
+        final String name,
+        final String writeIdList)
+        throws MetaException, NoSuchObjectException {
+      return get_table_core(catName, dbname, name, writeIdList, false, null);
+    }
+
+    /**
+     * This function retrieves table from metastore. If getColumnStats flag is true,
+     * then engine should be specified so the table is retrieve with the column stats
+     * for that engine.
+     */
+    public Table get_table_core(final String catName,
+        final String dbname,
+        final String name,
+        final String writeIdList,
+        boolean getColumnStats, String engine)
+        throws MetaException, NoSuchObjectException {
+      Preconditions.checkArgument(!getColumnStats || engine != null,
+          "To retrieve column statistics with a table, engine parameter cannot be null");
+
+      Database db = null;
+      Table t = null;
+      try {
+        db = get_database_core(catName, dbname);
+        if (db != null) {
+          if (db.getType().equals(DatabaseType.REMOTE)) {
+            return DataConnectorProviderFactory.getDataConnectorProvider(db).getTable(name);
+          }
+        }
+      } catch (Exception e) { /* appears exception is not thrown currently if db doesnt exist */ }
+
+      try {
+        t = getMS().getTable(catName, dbname, name, writeIdList);
+        if (t == null) {
+          throw new NoSuchObjectException(TableName.getQualified(catName, dbname, name) +
+            " table not found");
+        }
+
+        // If column statistics was requested and is valid fetch it.
+        if (getColumnStats) {
+          ColumnStatistics colStats = getMS().getTableColumnStatistics(catName, dbname, name,
+                  StatsSetupConst.getColumnsHavingStats(t.getParameters()), engine, writeIdList);
+          if (colStats != null) {
+            t.setColStats(colStats);
+          }
+        }
+      } catch (Exception e) {
+        throwMetaException(e);
+      }
+      return t;
+    }
+
+    /**
+     * Gets multiple tables from the hive metastore.
+     *
+     * @param dbName
+     *          The name of the database in which the tables reside
+     * @param tableNames
+     *          The names of the tables to get.
+     *
+     * @return A list of tables whose names are in the the list "names" and
+     *         are retrievable from the database specified by "dbnames."
+     *         There is no guarantee of the order of the returned tables.
+     *         If there are duplicate names, only one instance of the table will be returned.
+     * @throws MetaException
+     * @throws InvalidOperationException
+     * @throws UnknownDBException
+     */
+    @Override
+    @Deprecated
+    public List<Table> get_table_objects_by_name(final String dbName, final List<String> tableNames)
+        throws MetaException, InvalidOperationException, UnknownDBException {
+      String[] parsedDbName = parseDbName(dbName, conf);
+      return getTableObjectsInternal(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableNames, null);
+    }
+
+    @Override
+    public GetTablesResult get_table_objects_by_name_req(GetTablesRequest req) throws TException {
+      String catName = req.isSetCatName() ? req.getCatName() : getDefaultCatalog(conf);
+      return new GetTablesResult(getTableObjectsInternal(catName, req.getDbName(),
+          req.getTblNames(), req.getCapabilities()));
+    }
+
+    private List<Table> getTableObjectsInternal(String catName, String dbName,
+                                                List<String> tableNames,
+                                                ClientCapabilities capabilities)
+            throws MetaException, InvalidOperationException, UnknownDBException {
+      if (isInTest) {
+        assertClientHasCapability(capabilities, ClientCapability.TEST_CAPABILITY,
+            "Hive tests", "get_table_objects_by_name_req");
+      }
+      List<Table> tables = new ArrayList<>();
+      startMultiTableFunction("get_multi_table", dbName, tableNames);
+      Exception ex = null;
+      int tableBatchSize = MetastoreConf.getIntVar(conf,
+          ConfVars.BATCH_RETRIEVE_MAX);
+
+      try {
+        if (dbName == null || dbName.isEmpty()) {
+          throw new UnknownDBException("DB name is null or empty");
+        }
+        if (tableNames == null) {
+          throw new InvalidOperationException(dbName + " cannot find null tables");
+        }
+
+        // The list of table names could contain duplicates. RawStore.getTableObjectsByName()
+        // only guarantees returning no duplicate table objects in one batch. If we need
+        // to break into multiple batches, remove duplicates first.
+        List<String> distinctTableNames = tableNames;
+        if (distinctTableNames.size() > tableBatchSize) {
+          List<String> lowercaseTableNames = new ArrayList<>();
+          for (String tableName : tableNames) {
+            lowercaseTableNames.add(org.apache.hadoop.hive.metastore.utils.StringUtils.normalizeIdentifier(tableName));
+          }
+          distinctTableNames = new ArrayList<>(new HashSet<>(lowercaseTableNames));
+        }
+
+        RawStore ms = getMS();
+        int startIndex = 0;
+        // Retrieve the tables from the metastore in batches. Some databases like
+        // Oracle cannot have over 1000 expressions in a in-list
+        while (startIndex < distinctTableNames.size()) {
+          int endIndex = Math.min(startIndex + tableBatchSize, distinctTableNames.size());
+          tables.addAll(ms.getTableObjectsByName(catName, dbName, distinctTableNames.subList(
+              startIndex, endIndex)));
+          startIndex = endIndex;
+        }
+        for (Table t : tables) {
+          if (MetaStoreUtils.isInsertOnlyTableParam(t.getParameters())) {
+            assertClientHasCapability(capabilities, ClientCapability.INSERT_ONLY_TABLES,
+                "insert-only tables", "get_table_req");
+          }
+        }
+
+        FilterUtils.filterTablesIfEnabled(isServerFilterEnabled, filterHook, tables);
+      } catch (MetaException | InvalidOperationException | UnknownDBException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_multi_table", tables != null, ex, join(tableNames, ","));
+      }
+      return tables;
+    }
+
+    @Override
+    public Materialization get_materialization_invalidation_info(final CreationMetadata cm, final String validTxnList) throws MetaException {
+      return getTxnHandler().getMaterializationInvalidationInfo(cm, validTxnList);
+    }
+
+    @Override
+    public void update_creation_metadata(String catName, final String dbName, final String tableName, CreationMetadata cm) throws MetaException {
+      getMS().updateCreationMetadata(catName, dbName, tableName, cm);
+    }
+
+    private void assertClientHasCapability(ClientCapabilities client,
+        ClientCapability value, String what, String call) throws MetaException {
+      if (!doesClientHaveCapability(client, value)) {
+        throw new MetaException("Your client does not appear to support " + what + ". To skip"
+            + " capability checks, please set " + ConfVars.CAPABILITY_CHECK.toString()
+            + " to false. This setting can be set globally, or on the client for the current"
+            + " metastore session. Note that this may lead to incorrect results, data loss,"
+            + " undefined behavior, etc. if your client is actually incompatible. You can also"
+            + " specify custom client capabilities via " + call + " API.");
+      }
+    }
+
+    private boolean doesClientHaveCapability(ClientCapabilities client, ClientCapability value) {
+      if (!MetastoreConf.getBoolVar(getConf(), ConfVars.CAPABILITY_CHECK)) {
+        return true;
+      }
+      return (client != null && client.isSetValues() && client.getValues().contains(value));
+    }
+
+    @Override
+    public List<String> get_table_names_by_filter(
+        final String dbName, final String filter, final short maxTables)
+        throws MetaException, InvalidOperationException, UnknownDBException {
+      List<String> tables = null;
+      startFunction("get_table_names_by_filter", ": db = " + dbName + ", filter = " + filter);
+      Exception ex = null;
+      String[] parsedDbName = parseDbName(dbName, conf);
+      try {
+        if (parsedDbName[CAT_NAME] == null || parsedDbName[CAT_NAME].isEmpty() ||
+            parsedDbName[DB_NAME] == null || parsedDbName[DB_NAME].isEmpty()) {
+          throw new UnknownDBException("DB name is null or empty");
+        }
+        if (filter == null) {
+          throw new InvalidOperationException(filter + " cannot apply null filter");
+        }
+        tables = getMS().listTableNamesByFilter(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], filter, maxTables);
+        tables = FilterUtils.filterTableNamesIfEnabled(
+            isServerFilterEnabled, filterHook, parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tables);
+
+      } catch (MetaException | InvalidOperationException | UnknownDBException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_table_names_by_filter", tables != null, ex, join(tables, ","));
+      }
+      return tables;
+    }
+
+    private Partition append_partition_common(RawStore ms, String catName, String dbName,
+                                              String tableName, List<String> part_vals,
+                                              EnvironmentContext envContext)
+            throws InvalidObjectException, AlreadyExistsException, MetaException, NoSuchObjectException {
+
+      Partition part = new Partition();
+      boolean success = false, madeDir = false;
+      Path partLocation = null;
+      Table tbl = null;
+      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
+      Database db = null;
+      try {
+        ms.openTransaction();
+        part.setCatName(catName);
+        part.setDbName(dbName);
+        part.setTableName(tableName);
+        part.setValues(part_vals);
+
+        MetaStoreServerUtils.validatePartitionNameCharacters(part_vals, partitionValidationPattern);
+
+        tbl = ms.getTable(part.getCatName(), part.getDbName(), part.getTableName(), null);
+        if (tbl == null) {
+          throw new InvalidObjectException(
+              "Unable to add partition because table or database do not exist");
+        }
+        if (tbl.getSd().getLocation() == null) {
+          throw new MetaException(
+              "Cannot append a partition to a view");
+        }
+
+        db = get_database_core(catName, dbName);
+
+        firePreEvent(new PreAddPartitionEvent(tbl, part, this));
+
+        part.setSd(tbl.getSd().deepCopy());
+        partLocation = new Path(tbl.getSd().getLocation(), Warehouse
+            .makePartName(tbl.getPartitionKeys(), part_vals));
+        part.getSd().setLocation(partLocation.toString());
+
+        Partition old_part;
+        try {
+          old_part = ms.getPartition(part.getCatName(), part.getDbName(), part
+              .getTableName(), part.getValues());
+        } catch (NoSuchObjectException e) {
+          // this means there is no existing partition
+          old_part = null;
+        }
+        if (old_part != null) {
+          throw new AlreadyExistsException("Partition already exists:" + part);
+        }
+
+        if (!wh.isDir(partLocation)) {
+          if (!wh.mkdirs(partLocation)) {
+            throw new MetaException(partLocation
+                + " is not a directory or unable to create one");
+          }
+          madeDir = true;
+        }
+
+        // set create time
+        long time = System.currentTimeMillis() / 1000;
+        part.setCreateTime((int) time);
+        part.putToParameters(hive_metastoreConstants.DDL_TIME, Long.toString(time));
+
+        if (canUpdateStats(tbl)) {
+          MetaStoreServerUtils.updatePartitionStatsFast(part, tbl, wh, madeDir, false, envContext, true);
+        }
+
+        if (ms.addPartition(part)) {
+          if (!transactionalListeners.isEmpty()) {
+            transactionalListenerResponses =
+                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                                                      EventType.ADD_PARTITION,
+                                                      new AddPartitionEvent(tbl, part, true, this),
+                                                      envContext);
+          }
+
+          success = ms.commitTransaction();
+        }
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+          if (madeDir) {
+            wh.deleteDir(partLocation, true, false, ReplChangeManager.shouldEnableCm(db, tbl));
+          }
+        }
+
+        if (!listeners.isEmpty()) {
+          MetaStoreListenerNotifier.notifyEvent(listeners,
+                                                EventType.ADD_PARTITION,
+                                                new AddPartitionEvent(tbl, part, success, this),
+                                                envContext,
+                                                transactionalListenerResponses, ms);
+        }
+      }
+      return part;
+    }
+
+    private void firePreEvent(PreEventContext event) throws MetaException {
+      for (MetaStorePreEventListener listener : preListeners) {
+        try {
+          listener.onEvent(event);
+        } catch (NoSuchObjectException e) {
+          throw new MetaException(e.getMessage());
+        } catch (InvalidOperationException e) {
+          throw new MetaException(e.getMessage());
+        }
+      }
+    }
+
+    @Override
+    public Partition append_partition(final String dbName, final String tableName,
+        final List<String> part_vals) throws InvalidObjectException,
+        AlreadyExistsException, MetaException {
+      return append_partition_with_environment_context(dbName, tableName, part_vals, null);
+    }
+
+    @Override
+    public Partition append_partition_with_environment_context(final String dbName,
+        final String tableName, final List<String> part_vals, final EnvironmentContext envContext)
+        throws InvalidObjectException, AlreadyExistsException, MetaException {
+      if (part_vals == null || part_vals.isEmpty()) {
+        throw new MetaException("The partition values must not be null or empty.");
+      }
+      String[] parsedDbName = parseDbName(dbName, conf);
+      startPartitionFunction("append_partition", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName, part_vals);
+      if (LOG.isDebugEnabled()) {
+        for (String part : part_vals) {
+          LOG.debug(part);
+        }
+      }
+
+      Partition ret = null;
+      Exception ex = null;
+      try {
+        ret = append_partition_common(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName, part_vals, envContext);
+      } catch (MetaException | InvalidObjectException | AlreadyExistsException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("append_partition", ret != null, ex, tableName);
+      }
+      return ret;
+    }
+
+    private static class PartValEqWrapperLite {
+      List<String> values;
+      String location;
+
+      PartValEqWrapperLite(Partition partition) {
+        this.values = partition.isSetValues()? partition.getValues() : null;
+        if (partition.getSd() != null) {
+          this.location = partition.getSd().getLocation();
+        }
+      }
+
+      @Override
+      public int hashCode() {
+        return values == null ? 0 : values.hashCode();
+      }
+
+      @Override
+      public boolean equals(Object obj) {
+        if (this == obj) {
+          return true;
+        }
+        if (obj == null || !(obj instanceof PartValEqWrapperLite)) {
+          return false;
+        }
+
+        List<String> lhsValues = this.values;
+        List<String> rhsValues = ((PartValEqWrapperLite)obj).values;
+
+        if (lhsValues == null || rhsValues == null) {
+          return lhsValues == rhsValues;
+        }
+
+        if (lhsValues.size() != rhsValues.size()) {
+          return false;
+        }
+
+        for (int i=0; i<lhsValues.size(); ++i) {
+          String lhsValue = lhsValues.get(i);
+          String rhsValue = rhsValues.get(i);
+
+          if ((lhsValue == null && rhsValue != null)
+              || (lhsValue != null && !lhsValue.equals(rhsValue))) {
+            return false;
+          }
+        }
+
+        return true;
+      }
+    }
+
+    private List<Partition> add_partitions_core(final RawStore ms, String catName,
+        String dbName, String tblName, List<Partition> parts, final boolean ifNotExists)
+        throws TException {
+      logAndAudit("add_partitions");
+      boolean success = false;
+      // Ensures that the list doesn't have dups, and keeps track of directories we have created.
+      final Map<PartValEqWrapperLite, Boolean> addedPartitions = new ConcurrentHashMap<>();
+      final List<Partition> newParts = new ArrayList<>();
+      final List<Partition> existingParts = new ArrayList<>();
+      Table tbl = null;
+      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
+      Database db = null;
+
+      List<ColumnStatistics> partsColStats = new ArrayList<>(parts.size());
+      List<Long> partsWriteIds = new ArrayList<>(parts.size());
+
+      throwUnsupportedExceptionIfRemoteDB(dbName, "add_partitions");
+
+      try {
+        ms.openTransaction();
+        tbl = ms.getTable(catName, dbName, tblName, null);
+        if (tbl == null) {
+          throw new InvalidObjectException("Unable to add partitions because "
+              + TableName.getQualified(catName, dbName, tblName) +
+              " does not exist");
+        }
+
+        db = ms.getDatabase(catName, dbName);
+
+        if (!parts.isEmpty()) {
+          firePreEvent(new PreAddPartitionEvent(tbl, parts, this));
+        }
+
+        Set<PartValEqWrapperLite> partsToAdd = new HashSet<>(parts.size());
+        List<Partition> partitionsToAdd = new ArrayList<>(parts.size());
+        List<FieldSchema> partitionKeys = tbl.getPartitionKeys();
+        for (final Partition part : parts) {
+          // Collect partition column stats to be updated if present. Partition objects passed down
+          // here at the time of replication may have statistics in them, which is required to be
+          // updated in the metadata. But we don't want it to be part of the Partition object when
+          // it's being created or altered, lest it becomes part of the notification event.
+          if (part.isSetColStats()) {
+            partsColStats.add(part.getColStats());
+            part.unsetColStats();
+            partsWriteIds.add(part.getWriteId());
+          }
+
+          // Iterate through the partitions and validate them. If one of the partitions is
+          // incorrect, an exception will be thrown before the threads which create the partition
+          // folders are submitted. This way we can be sure that no partition and no partition
+          // folder will be created if the list contains an invalid partition.
+          if (validatePartition(part, catName, tblName, dbName, partsToAdd, ms, ifNotExists,
+              partitionKeys)) {
+            partitionsToAdd.add(part);
+          } else {
+            existingParts.add(part);
+          }
+        }
+
+        newParts.addAll(createPartitionFolders(partitionsToAdd, tbl, addedPartitions));
+
+        if (!newParts.isEmpty()) {
+          ms.addPartitions(catName, dbName, tblName, newParts);
+        }
+
+        // Notification is generated for newly created partitions only. The subset of partitions
+        // that already exist (existingParts), will not generate notifications.
+        if (!transactionalListeners.isEmpty()) {
+          transactionalListenerResponses =
+              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                                                    EventType.ADD_PARTITION,
+                                                    new AddPartitionEvent(tbl, newParts, true, this));
+        }
+
+        if (!listeners.isEmpty()) {
+          MetaStoreListenerNotifier.notifyEvent(listeners,
+                  EventType.ADD_PARTITION,
+                  new AddPartitionEvent(tbl, newParts, true, this),
+                  null,
+                  transactionalListenerResponses, ms);
+
+          if (!existingParts.isEmpty()) {
+            // The request has succeeded but we failed to add these partitions.
+            MetaStoreListenerNotifier.notifyEvent(listeners,
+                    EventType.ADD_PARTITION,
+                    new AddPartitionEvent(tbl, existingParts, false, this),
+                    null, null, ms);
+          }
+        }
+
+        // Update partition column statistics if available. We need a valid writeId list to
+        // update column statistics for a transactional table. But during bootstrap replication,
+        // where we use this feature, we do not have a valid writeId list which was used to
+        // update the stats. But we know for sure that the writeId associated with the stats was
+        // valid then (otherwise stats update would have failed on the source). So, craft a valid
+        // transaction list with only that writeId and use it to update the stats.
+        int cnt = 0;
+        for (ColumnStatistics partColStats: partsColStats) {
+          long writeId = partsWriteIds.get(cnt++);
+          String validWriteIds = null;
+          if (writeId > 0) {
+            ValidWriteIdList validWriteIdList =
+                    new ValidReaderWriteIdList(TableName.getDbTable(tbl.getDbName(),
+                            tbl.getTableName()),
+                            new long[0], new BitSet(), writeId);
+            validWriteIds = validWriteIdList.toString();
+          }
+          updatePartitonColStatsInternal(tbl, partColStats, validWriteIds, writeId);
+        }
+
+        success = ms.commitTransaction();
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+          cleanupPartitionFolders(addedPartitions, db);
+
+          if (!listeners.isEmpty()) {
+            MetaStoreListenerNotifier.notifyEvent(listeners,
+                                                  EventType.ADD_PARTITION,
+                                                  new AddPartitionEvent(tbl, parts, false, this),
+                                                  null, null, ms);
+          }
+        }
+      }
+
+      return newParts;
+    }
+
+    /**
+     * Remove the newly created partition folders. The values in the addedPartitions map indicates
+     * whether or not the location of the partition was newly created. If the value is false, the
+     * partition folder will not be removed.
+     * @param addedPartitions
+     * @throws MetaException
+     * @throws IllegalArgumentException
+     */
+    private void cleanupPartitionFolders(final Map<PartValEqWrapperLite, Boolean> addedPartitions,
+        Database db) throws MetaException, IllegalArgumentException {
+      for (Map.Entry<PartValEqWrapperLite, Boolean> e : addedPartitions.entrySet()) {
+        if (e.getValue()) {
+          // we just created this directory - it's not a case of pre-creation, so we nuke.
+          wh.deleteDir(new Path(e.getKey().location), true, db);
+        }
+      }
+    }
+
+    /**
+     * Validate a partition before creating it. The validation checks
+     * <ul>
+     * <li>if the database and table names set in the partition are not null and they are matching
+     * with the expected values set in the tblName and dbName parameters.</li>
+     * <li>if the partition values are set.</li>
+     * <li>if none of the partition values is null.</li>
+     * <li>if the partition values are matching with the pattern set in the
+     * 'metastore.partition.name.whitelist.pattern' configuration property.</li>
+     * <li>if the partition doesn't already exist. If the partition already exists, an exception
+     * will be thrown if the ifNotExists parameter is false, otherwise it will be just ignored.</li>
+     * <li>if the partsToAdd set doesn't contain the partition. The partsToAdd set contains the
+     * partitions which are already validated. If the set contains the current partition, it means
+     * that the partition is tried to be added multiple times in the same batch. Please note that
+     * the set will be updated with the current partition if the validation was successful.</li>
+     * </ul>
+     * @param part
+     * @param catName
+     * @param tblName
+     * @param dbName
+     * @param partsToAdd
+     * @param ms
+     * @param ifNotExists
+     * @return
+     * @throws MetaException
+     * @throws TException
+     */
+    private boolean validatePartition(final Partition part, final String catName,
+        final String tblName, final String dbName, final Set<PartValEqWrapperLite> partsToAdd,
+        final RawStore ms, final boolean ifNotExists, List<FieldSchema> partitionKeys) throws MetaException, TException {
+
+      if (part.getDbName() == null || part.getTableName() == null) {
+        throw new MetaException("The database and table name must be set in the partition.");
+      }
+
+      if (!part.getTableName().equalsIgnoreCase(tblName)
+          || !part.getDbName().equalsIgnoreCase(dbName)) {
+        String errorMsg = String.format(
+            "Partition does not belong to target table %s. It belongs to the table %s.%s : %s",
+            TableName.getQualified(catName, dbName, tblName), part.getDbName(),
+            part.getTableName(), part.toString());
+        throw new MetaException(errorMsg);
+      }
+
+      if (part.getValues() == null || part.getValues().isEmpty()) {
+        throw new MetaException("The partition values cannot be null or empty.");
+      }
+
+      if (part.getValues().contains(null)) {
+        throw new MetaException("Partition value cannot be null.");
+      }
+
+      boolean shouldAdd = startAddPartition(ms, part, partitionKeys, ifNotExists);
+      if (!shouldAdd) {
+        LOG.info("Not adding partition {} as it already exists", part);
+        return false;
+      }
+
+      if (!partsToAdd.add(new PartValEqWrapperLite(part))) {
+        // Technically, for ifNotExists case, we could insert one and discard the other
+        // because the first one now "exists", but it seems better to report the problem
+        // upstream as such a command doesn't make sense.
+        throw new MetaException("Duplicate partitions in the list: " + part);
+      }
+      return true;
+    }
+
+    /**
+     * Create the location folders for the partitions. For each partition a separate thread will be
+     * started to create the folder. The method will wait until all threads are finished and returns
+     * the partitions whose folders were created successfully. If an error occurs during the
+     * execution of a thread, a MetaException will be thrown.
+     * @param partitionsToAdd
+     * @param table
+     * @param addedPartitions
+     * @return
+     * @throws MetaException
+     */
+    private List<Partition> createPartitionFolders(final List<Partition> partitionsToAdd,
+        final Table table, final Map<PartValEqWrapperLite, Boolean> addedPartitions)
+        throws MetaException {
+
+      final AtomicBoolean failureOccurred = new AtomicBoolean(false);
+      final List<Future<Partition>> partFutures = new ArrayList<>(partitionsToAdd.size());
+      final Map<PartValEqWrapperLite, Boolean> addedParts = new ConcurrentHashMap<>();
+
+      final UserGroupInformation ugi;
+      try {
+        ugi = UserGroupInformation.getCurrentUser();
+      } catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+
+      for (final Partition partition : partitionsToAdd) {
+        initializePartitionParameters(table, partition);
+
+        partFutures.add(threadPool.submit(() -> {
+          if (failureOccurred.get()) {
+            return null;
+          }
+          ugi.doAs((PrivilegedExceptionAction<Partition>) () -> {
+            try {
+              boolean madeDir = createLocationForAddedPartition(table, partition);
+              addedParts.put(new PartValEqWrapperLite(partition), madeDir);
+              initializeAddedPartition(table, partition, madeDir, null);
+            } catch (MetaException e) {
+              throw new IOException(e.getMessage(), e);
+            }
+            return null;
+          });
+          return partition;
+        }));
+      }
+
+      List<Partition> newParts = new ArrayList<>(partitionsToAdd.size());
+      String errorMessage = null;
+      for (Future<Partition> partFuture : partFutures) {
+        try {
+          Partition part = partFuture.get();
+          if (part != null && !failureOccurred.get()) {
+            newParts.add(part);
+          }
+        } catch (ExecutionException e) {
+          // If an exception is thrown in the execution of a task, set the failureOccurred flag to
+          // true. This flag is visible in the tasks and if its value is true, the partition
+          // folders won't be created.
+          // Then iterate through the remaining tasks and wait for them to finish. The tasks which
+          // are started before the flag got set will then finish creating the partition folders.
+          // The tasks which are started after the flag got set, won't create the partition
+          // folders, to avoid unnecessary work.
+          // This way it is sure that all tasks are finished, when entering the finally part where
+          // the partition folders are cleaned up. It won't happen that a task is still running
+          // when cleaning up the folders, so it is sure we won't have leftover folders.
+          // Canceling the other tasks would be also an option but during testing it turned out
+          // that it is not a trustworthy solution to avoid leftover folders.
+          failureOccurred.compareAndSet(false, true);
+          errorMessage = e.getMessage();
+        } catch (InterruptedException e) {
+          failureOccurred.compareAndSet(false, true);
+          errorMessage = e.getMessage();
+          // Restore interruption status of the corresponding thread
+          Thread.currentThread().interrupt();
+        }
+      }
+
+      addedPartitions.putAll(addedParts);
+      if (failureOccurred.get()) {
+        throw new MetaException(errorMessage);
+      }
+
+      return newParts;
+    }
+
+    @Override
+    public AddPartitionsResult add_partitions_req(AddPartitionsRequest request)
+        throws TException {
+      AddPartitionsResult result = new AddPartitionsResult();
+      if (request.getParts().isEmpty()) {
+        return result;
+      }
+      try {
+        if (!request.isSetCatName()) {
+          request.setCatName(getDefaultCatalog(conf));
+        }
+        // Make sure all of the partitions have the catalog set as well
+        request.getParts().forEach(p -> {
+          if (!p.isSetCatName()) {
+            p.setCatName(getDefaultCatalog(conf));
+          }
+        });
+        List<Partition> parts = add_partitions_core(getMS(), request.getCatName(), request.getDbName(),
+            request.getTblName(), request.getParts(), request.isIfNotExists());
+        if (request.isNeedResult()) {
+          result.setPartitions(parts);
+        }
+      } catch (TException te) {
+        throw te;
+      } catch (Exception e) {
+        throw newMetaException(e);
+      }
+      return result;
+    }
+
+    @Override
+    public int add_partitions(final List<Partition> parts) throws MetaException,
+        InvalidObjectException, AlreadyExistsException {
+      startFunction("add_partition");
+      if (parts == null) {
+        throw new MetaException("Partition list cannot be null.");
+      }
+      if (parts.isEmpty()) {
+        return 0;
+      }
+
+      Integer ret = null;
+      Exception ex = null;
+      try {
+        // Old API assumed all partitions belong to the same table; keep the same assumption
+        if (!parts.get(0).isSetCatName()) {
+          String defaultCat = getDefaultCatalog(conf);
+          for (Partition p : parts) {
+            p.setCatName(defaultCat);
+          }
+        }
+        ret = add_partitions_core(getMS(), parts.get(0).getCatName(), parts.get(0).getDbName(),
+            parts.get(0).getTableName(), parts, false).size();
+        assert ret == parts.size();
+      } catch (MetaException | InvalidObjectException | AlreadyExistsException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        String tableName = parts.get(0).getTableName();
+        endFunction("add_partition", ret != null, ex, tableName);
+      }
+      return ret;
+    }
+
+    @Override
+    public int add_partitions_pspec(final List<PartitionSpec> partSpecs)
+        throws TException {
+      logAndAudit("add_partitions_pspec");
+
+      if (partSpecs.isEmpty()) {
+        return 0;
+      }
+
+      String dbName = partSpecs.get(0).getDbName();
+      String tableName = partSpecs.get(0).getTableName();
+      // If the catalog name isn't set, we need to go through and set it.
+      String catName;
+      if (!partSpecs.get(0).isSetCatName()) {
+        catName = getDefaultCatalog(conf);
+        partSpecs.forEach(ps -> ps.setCatName(catName));
+      } else {
+        catName = partSpecs.get(0).getCatName();
+      }
+
+      return add_partitions_pspec_core(getMS(), catName, dbName, tableName, partSpecs, false);
+    }
+
+    private int add_partitions_pspec_core(RawStore ms, String catName, String dbName,
+                                          String tblName, List<PartitionSpec> partSpecs,
+                                          boolean ifNotExists)
+        throws TException {
+      boolean success = false;
+      if (dbName == null || tblName == null) {
+        throw new MetaException("The database and table name cannot be null.");
+      }
+      // Ensures that the list doesn't have dups, and keeps track of directories we have created.
+      final Map<PartValEqWrapperLite, Boolean> addedPartitions = new ConcurrentHashMap<>();
+      PartitionSpecProxy partitionSpecProxy = PartitionSpecProxy.Factory.get(partSpecs);
+      final PartitionSpecProxy.PartitionIterator partitionIterator = partitionSpecProxy
+          .getPartitionIterator();
+      Table tbl = null;
+      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
+      Database db = null;
+      try {
+        ms.openTransaction();
+        db = ms.getDatabase(catName, dbName);
+        if (db.getType() == DatabaseType.REMOTE)
+          throw new MetaException("Operation add_partitions_pspec not supported on tables in REMOTE database");
+        tbl = ms.getTable(catName, dbName, tblName, null);
+        if (tbl == null) {
+          throw new InvalidObjectException("Unable to add partitions because "
+              + "database or table " + dbName + "." + tblName + " does not exist");
+        }
+        firePreEvent(new PreAddPartitionEvent(tbl, partitionSpecProxy, this));
+        Set<PartValEqWrapperLite> partsToAdd = new HashSet<>(partitionSpecProxy.size());
+        List<Partition> partitionsToAdd = new ArrayList<>(partitionSpecProxy.size());
+        List<FieldSchema> partitionKeys = tbl.getPartitionKeys();
+        while (partitionIterator.hasNext()) {
+          // Iterate through the partitions and validate them. If one of the partitions is
+          // incorrect, an exception will be thrown before the threads which create the partition
+          // folders are submitted. This way we can be sure that no partition or partition folder
+          // will be created if the list contains an invalid partition.
+          final Partition part = partitionIterator.getCurrent();
+          if (validatePartition(part, catName, tblName, dbName, partsToAdd, ms, ifNotExists,
+              partitionKeys)) {
+            partitionsToAdd.add(part);
+          }
+          partitionIterator.next();
+        }
+
+        createPartitionFolders(partitionsToAdd, tbl, addedPartitions);
+
+        ms.addPartitions(catName, dbName, tblName, partitionSpecProxy, ifNotExists);
+
+        if (!transactionalListeners.isEmpty()) {
+          transactionalListenerResponses =
+              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                                                    EventType.ADD_PARTITION,
+                                                    new AddPartitionEvent(tbl, partitionSpecProxy, true, this));
+        }
+
+        success = ms.commitTransaction();
+        return addedPartitions.size();
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+          cleanupPartitionFolders(addedPartitions, db);
+        }
+
+        if (!listeners.isEmpty()) {
+          MetaStoreListenerNotifier.notifyEvent(listeners,
+                                                EventType.ADD_PARTITION,
+                                                new AddPartitionEvent(tbl, partitionSpecProxy, true, this),
+                                                null,
+                                                transactionalListenerResponses, ms);
+        }
+      }
+    }
+
+    private boolean startAddPartition(
+        RawStore ms, Partition part, List<FieldSchema> partitionKeys, boolean ifNotExists)
+        throws TException {
+      MetaStoreServerUtils.validatePartitionNameCharacters(part.getValues(),
+          partitionValidationPattern);
+      boolean doesExist = ms.doesPartitionExist(part.getCatName(),
+          part.getDbName(), part.getTableName(), partitionKeys, part.getValues());
+      if (doesExist && !ifNotExists) {
+        throw new AlreadyExistsException("Partition already exists: " + part);
+      }
+      return !doesExist;
+    }
+
+    /**
+     * Handles the location for a partition being created.
+     * @param tbl Table.
+     * @param part Partition.
+     * @return Whether the partition SD location is set to a newly created directory.
+     */
+    private boolean createLocationForAddedPartition(
+        final Table tbl, final Partition part) throws MetaException {
+      Path partLocation = null;
+      String partLocationStr = null;
+      if (part.getSd() != null) {
+        partLocationStr = part.getSd().getLocation();
+      }
+
+      if (partLocationStr == null || partLocationStr.isEmpty()) {
+        // set default location if not specified and this is
+        // a physical table partition (not a view)
+        if (tbl.getSd().getLocation() != null) {
+          partLocation = new Path(tbl.getSd().getLocation(), Warehouse
+              .makePartName(tbl.getPartitionKeys(), part.getValues()));
+        }
+      } else {
+        if (tbl.getSd().getLocation() == null) {
+          throw new MetaException("Cannot specify location for a view partition");
+        }
+        partLocation = wh.getDnsPath(new Path(partLocationStr));
+      }
+
+      boolean result = false;
+      if (partLocation != null) {
+        part.getSd().setLocation(partLocation.toString());
+
+        // Check to see if the directory already exists before calling
+        // mkdirs() because if the file system is read-only, mkdirs will
+        // throw an exception even if the directory already exists.
+        if (!wh.isDir(partLocation)) {
+          if (!wh.mkdirs(partLocation)) {
+            throw new MetaException(partLocation
+                + " is not a directory or unable to create one");
+          }
+          result = true;
+        }
+      }
+      return result;
+    }
+
+    /**
+     * Verify if update stats while altering partition(s)
+     * For the following three cases HMS will not update partition stats
+     * 1) Table property 'DO_NOT_UPDATE_STATS' = True
+     * 2) HMS configuration property 'STATS_AUTO_GATHER' = False
+     * 3) Is View
+     */
+    private boolean canUpdateStats(Table tbl) {
+        Map<String,String> tblParams = tbl.getParameters();
+        boolean updateStatsTbl = true;
+        if ((tblParams != null) && tblParams.containsKey(StatsSetupConst.DO_NOT_UPDATE_STATS)) {
+            updateStatsTbl = !Boolean.valueOf(tblParams.get(StatsSetupConst.DO_NOT_UPDATE_STATS));
+        }
+        if (!MetastoreConf.getBoolVar(conf, ConfVars.STATS_AUTO_GATHER) ||
+            MetaStoreUtils.isView(tbl) ||
+            !updateStatsTbl) {
+          return false;
+        }
+        return true;
+    }
+
+    private void initializeAddedPartition(final Table tbl, final Partition part, boolean madeDir,
+                                          EnvironmentContext environmentContext) throws MetaException {
+      initializeAddedPartition(tbl,
+              new PartitionSpecProxy.SimplePartitionWrapperIterator(part), madeDir, environmentContext);
+    }
+
+    private void initializeAddedPartition(
+        final Table tbl, final PartitionSpecProxy.PartitionIterator part, boolean madeDir,
+        EnvironmentContext environmentContext) throws MetaException {
+      if (canUpdateStats(tbl)) {
+        MetaStoreServerUtils.updatePartitionStatsFast(part, tbl, wh, madeDir,
+                false, environmentContext, true);
+      }
+
+      // set create time
+      long time = System.currentTimeMillis() / 1000;
+      part.setCreateTime((int) time);
+      if (part.getParameters() == null ||
+          part.getParameters().get(hive_metastoreConstants.DDL_TIME) == null) {
+        part.putToParameters(hive_metastoreConstants.DDL_TIME, Long.toString(time));
+      }
+    }
+
+    private void initializePartitionParameters(final Table tbl, final Partition part)
+        throws MetaException {
+      initializePartitionParameters(tbl,
+          new PartitionSpecProxy.SimplePartitionWrapperIterator(part));
+    }
+
+    private void initializePartitionParameters(final Table tbl,
+        final PartitionSpecProxy.PartitionIterator part) throws MetaException {
+
+      // Inherit table properties into partition properties.
+      Map<String, String> tblParams = tbl.getParameters();
+      String inheritProps = MetastoreConf.getVar(conf, ConfVars.PART_INHERIT_TBL_PROPS).trim();
+      // Default value is empty string in which case no properties will be inherited.
+      // * implies all properties needs to be inherited
+      Set<String> inheritKeys = new HashSet<>(Arrays.asList(inheritProps.split(",")));
+      if (inheritKeys.contains("*")) {
+        inheritKeys = tblParams.keySet();
+      }
+
+      for (String key : inheritKeys) {
+        String paramVal = tblParams.get(key);
+        if (null != paramVal) { // add the property only if it exists in table properties
+          part.putToParameters(key, paramVal);
+        }
+      }
+    }
+
+    private Partition add_partition_core(final RawStore ms,
+        final Partition part, final EnvironmentContext envContext)
+        throws TException {
+      boolean success = false;
+      Table tbl = null;
+      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
+      if (!part.isSetCatName()) {
+        part.setCatName(getDefaultCatalog(conf));
+      }
+
+      throwUnsupportedExceptionIfRemoteDB(part.getDbName(), "add_partition");
+      try {
+        ms.openTransaction();
+        tbl = ms.getTable(part.getCatName(), part.getDbName(), part.getTableName(), null);
+        if (tbl == null) {
+          throw new InvalidObjectException(
+              "Unable to add partition because table or database do not exist");
+        }
+
+        firePreEvent(new PreAddPartitionEvent(tbl, part, this));
+
+        if (part.getValues() == null || part.getValues().isEmpty()) {
+          throw new MetaException("The partition values cannot be null or empty.");
+        }
+        boolean shouldAdd = startAddPartition(ms, part, tbl.getPartitionKeys(), false);
+        assert shouldAdd; // start would throw if it already existed here
+        boolean madeDir = createLocationForAddedPartition(tbl, part);
+        try {
+          initializeAddedPartition(tbl, part, madeDir, envContext);
+          initializePartitionParameters(tbl, part);
+          success = ms.addPartition(part);
+        } finally {
+          if (!success && madeDir) {
+            wh.deleteDir(new Path(part.getSd().getLocation()), true, false,
+                    ReplChangeManager.shouldEnableCm(ms.getDatabase(part.getCatName(), part.getDbName()), tbl));
+          }
+        }
+
+        // Setting success to false to make sure that if the listener fails, rollback happens.
+        success = false;
+
+        if (!transactionalListeners.isEmpty()) {
+          transactionalListenerResponses =
+              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                                                    EventType.ADD_PARTITION,
+                                                    new AddPartitionEvent(tbl, Arrays.asList(part), true, this),
+                                                    envContext);
+
+        }
+
+        // we proceed only if we'd actually succeeded anyway, otherwise,
+        // we'd have thrown an exception
+        success = ms.commitTransaction();
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        }
+
+        if (!listeners.isEmpty()) {
+          MetaStoreListenerNotifier.notifyEvent(listeners,
+                                                EventType.ADD_PARTITION,
+                                                new AddPartitionEvent(tbl, Arrays.asList(part), success, this),
+                                                envContext,
+                                                transactionalListenerResponses, ms);
+
+        }
+      }
+      return part;
+    }
+
+    @Override
+    public Partition add_partition(final Partition part)
+        throws InvalidObjectException, AlreadyExistsException, MetaException {
+      return add_partition_with_environment_context(part, null);
+    }
+
+    @Override
+    public Partition add_partition_with_environment_context(
+        final Partition part, EnvironmentContext envContext)
+        throws InvalidObjectException, AlreadyExistsException,
+        MetaException {
+      if (part == null) {
+        throw new MetaException("Partition cannot be null.");
+      }
+      startTableFunction("add_partition",
+          part.getCatName(), part.getDbName(), part.getTableName());
+      Partition ret = null;
+      Exception ex = null;
+      try {
+        ret = add_partition_core(getMS(), part, envContext);
+      } catch (MetaException | InvalidObjectException | AlreadyExistsException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("add_partition", ret != null, ex, part != null ?  part.getTableName(): null);
+      }
+      return ret;
+    }
+
+    @Override
+    public Partition exchange_partition(Map<String, String> partitionSpecs,
+        String sourceDbName, String sourceTableName, String destDbName,
+        String destTableName) throws TException {
+      exchange_partitions(partitionSpecs, sourceDbName, sourceTableName, destDbName, destTableName);
+      // Wouldn't it make more sense to return the first element of the list returned by the
+      // previous call?
+      return new Partition();
+    }
+
+    @Override
+    public List<Partition> exchange_partitions(Map<String, String> partitionSpecs,
+        String sourceDbName, String sourceTableName, String destDbName,
+        String destTableName) throws TException {
+      String[] parsedDestDbName = parseDbName(destDbName, conf);
+      String[] parsedSourceDbName = parseDbName(sourceDbName, conf);
+      // No need to check catalog for null as parseDbName() will never return null for the catalog.
+      if (partitionSpecs == null || parsedSourceDbName[DB_NAME] == null || sourceTableName == null
+          || parsedDestDbName[DB_NAME] == null || destTableName == null) {
+        throw new MetaException("The DB and table name for the source and destination tables,"
+            + " and the partition specs must not be null.");
+      }
+      if (!parsedDestDbName[CAT_NAME].equals(parsedSourceDbName[CAT_NAME])) {
+        throw new MetaException("You cannot move a partition across catalogs");
+      }
+
+      boolean success = false;
+      boolean pathCreated = false;
+      RawStore ms = getMS();
+      ms.openTransaction();
+
+      Table destinationTable =
+          ms.getTable(
+              parsedDestDbName[CAT_NAME], parsedDestDbName[DB_NAME], destTableName, null);
+      if (destinationTable == null) {
+        throw new MetaException( "The destination table " +
+            TableName.getQualified(parsedDestDbName[CAT_NAME],
+                parsedDestDbName[DB_NAME], destTableName) + " not found");
+      }
+      Table sourceTable =
+          ms.getTable(
+              parsedSourceDbName[CAT_NAME], parsedSourceDbName[DB_NAME], sourceTableName, null);
+      if (sourceTable == null) {
+        throw new MetaException("The source table " +
+            TableName.getQualified(parsedSourceDbName[CAT_NAME],
+                parsedSourceDbName[DB_NAME], sourceTableName) + " not found");
+      }
+
+      List<String> partVals = MetaStoreUtils.getPvals(sourceTable.getPartitionKeys(),
+          partitionSpecs);
+      List<String> partValsPresent = new ArrayList<> ();
+      List<FieldSchema> partitionKeysPresent = new ArrayList<> ();
+      int i = 0;
+      for (FieldSchema fs: sourceTable.getPartitionKeys()) {
+        String partVal = partVals.get(i);
+        if (partVal != null && !partVal.equals("")) {
+          partValsPresent.add(partVal);
+          partitionKeysPresent.add(fs);
+        }
+        i++;
+      }
+      // Passed the unparsed DB name here, as get_partitions_ps expects to parse it
+      List<Partition> partitionsToExchange = get_partitions_ps(sourceDbName, sourceTableName,
+          partVals, (short)-1);
+      if (partitionsToExchange == null || partitionsToExchange.isEmpty()) {
+        throw new MetaException("No partition is found with the values " + partitionSpecs
+            + " for the table " + sourceTableName);
+      }
+      boolean sameColumns = MetaStoreUtils.compareFieldColumns(
+          sourceTable.getSd().getCols(), destinationTable.getSd().getCols());
+      boolean samePartitions = MetaStoreUtils.compareFieldColumns(
+          sourceTable.getPartitionKeys(), destinationTable.getPartitionKeys());
+      if (!sameColumns || !samePartitions) {
+        throw new MetaException("The tables have different schemas." +
+            " Their partitions cannot be exchanged.");
+      }
+      Path sourcePath = new Path(sourceTable.getSd().getLocation(),
+          Warehouse.makePartName(partitionKeysPresent, partValsPresent));
+      Path destPath = new Path(destinationTable.getSd().getLocation(),
+          Warehouse.makePartName(partitionKeysPresent, partValsPresent));
+      List<Partition> destPartitions = new ArrayList<>();
+
+      Map<String, String> transactionalListenerResponsesForAddPartition = Collections.emptyMap();
+      List<Map<String, String>> transactionalListenerResponsesForDropPartition =
+          Lists.newArrayListWithCapacity(partitionsToExchange.size());
+
+      // Check if any of the partitions already exists in destTable.
+      List<String> destPartitionNames = ms.listPartitionNames(parsedDestDbName[CAT_NAME],
+          parsedDestDbName[DB_NAME], destTableName, (short) -1);
+      if (destPartitionNames != null && !destPartitionNames.isEmpty()) {
+        for (Partition partition : partitionsToExchange) {
+          String partToExchangeName =
+              Warehouse.makePartName(destinationTable.getPartitionKeys(), partition.getValues());
+          if (destPartitionNames.contains(partToExchangeName)) {
+            throw new MetaException("The partition " + partToExchangeName
+                + " already exists in the table " + destTableName);
+          }
+        }
+      }
+
+      Database srcDb = ms.getDatabase(parsedSourceDbName[CAT_NAME], parsedSourceDbName[DB_NAME]);
+      Database destDb = ms.getDatabase(parsedDestDbName[CAT_NAME], parsedDestDbName[DB_NAME]);
+      if (!isRenameAllowed(srcDb, destDb)) {
+        throw new MetaException("Exchange partition not allowed for " +
+                TableName.getQualified(parsedSourceDbName[CAT_NAME],
+                parsedSourceDbName[DB_NAME], sourceTableName) + " Dest db : " + destDbName);
+      }
+      try {
+        for (Partition partition: partitionsToExchange) {
+          Partition destPartition = new Partition(partition);
+          destPartition.setDbName(parsedDestDbName[DB_NAME]);
+          destPartition.setTableName(destinationTable.getTableName());
+          Path destPartitionPath = new Path(destinationTable.getSd().getLocation(),
+              Warehouse.makePartName(destinationTable.getPartitionKeys(), partition.getValues()));
+          destPartition.getSd().setLocation(destPartitionPath.toString());
+          ms.addPartition(destPartition);
+          destPartitions.add(destPartition);
+          ms.dropPartition(parsedSourceDbName[CAT_NAME], partition.getDbName(), sourceTable.getTableName(),
+            partition.getValues());
+        }
+        Path destParentPath = destPath.getParent();
+        if (!wh.isDir(destParentPath)) {
+          if (!wh.mkdirs(destParentPath)) {
+              throw new MetaException("Unable to create path " + destParentPath);
+          }
+        }
+        /*
+         * TODO: Use the hard link feature of hdfs
+         * once https://issues.apache.org/jira/browse/HDFS-3370 is done
+         */
+        pathCreated = wh.renameDir(sourcePath, destPath, false);
+
+        // Setting success to false to make sure that if the listener fails, rollback happens.
+        success = false;
+
+        if (!transactionalListeners.isEmpty()) {
+          transactionalListenerResponsesForAddPartition =
+              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                                                    EventType.ADD_PARTITION,
+                                                    new AddPartitionEvent(destinationTable, destPartitions, true, this));
+
+          for (Partition partition : partitionsToExchange) {
+            DropPartitionEvent dropPartitionEvent =
+                new DropPartitionEvent(sourceTable, partition, true, true, this);
+            transactionalListenerResponsesForDropPartition.add(
+                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                                                      EventType.DROP_PARTITION,
+                                                      dropPartitionEvent));
+          }
+        }
+
+        success = ms.commitTransaction();
+        return destPartitions;
+      } finally {
+        if (!success || !pathCreated) {
+          ms.rollbackTransaction();
+          if (pathCreated) {
+            wh.renameDir(destPath, sourcePath, false);
+          }
+        }
+
+        if (!listeners.isEmpty()) {
+          AddPartitionEvent addPartitionEvent = new AddPartitionEvent(destinationTable, destPartitions, success, this);
+          MetaStoreListenerNotifier.notifyEvent(listeners,
+                                                EventType.ADD_PARTITION,
+                                                addPartitionEvent,
+                                                null,
+                                                transactionalListenerResponsesForAddPartition, ms);
+
+          i = 0;
+          for (Partition partition : partitionsToExchange) {
+            DropPartitionEvent dropPartitionEvent =
+                new DropPartitionEvent(sourceTable, partition, success, true, this);
+            Map<String, String> parameters =
+                (transactionalListenerResponsesForDropPartition.size() > i)
+                    ? transactionalListenerResponsesForDropPartition.get(i)
+                    : null;
+
+            MetaStoreListenerNotifier.notifyEvent(listeners,
+                                                  EventType.DROP_PARTITION,
+                                                  dropPartitionEvent,
+                                                  null,
+                                                  parameters, ms);
+            i++;
+          }
+        }
+      }
+    }
+
+    private boolean drop_partition_common(RawStore ms, String catName, String db_name,
+                                          String tbl_name, List<String> part_vals,
+                                          final boolean deleteData, final EnvironmentContext envContext)
+        throws MetaException, NoSuchObjectException, IOException, InvalidObjectException,
+      InvalidInputException {
+      boolean success = false;
+      Path partPath = null;
+      Table tbl = null;
+      Partition part = null;
+      boolean isArchived = false;
+      Path archiveParentDir = null;
+      boolean mustPurge = false;
+      boolean tableDataShouldBeDeleted = false;
+      boolean needsCm = false;
+      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
+
+      if (db_name == null) {
+        throw new MetaException("The DB name cannot be null.");
+      }
+      if (tbl_name == null) {
+        throw new MetaException("The table name cannot be null.");
+      }
+      if (part_vals == null) {
+        throw new MetaException("The partition values cannot be null.");
+      }
+
+      try {
+        ms.openTransaction();
+        part = ms.getPartition(catName, db_name, tbl_name, part_vals);
+        tbl = get_table_core(catName, db_name, tbl_name, null);
+        tableDataShouldBeDeleted = checkTableDataShouldBeDeleted(tbl, deleteData);
+        firePreEvent(new PreDropPartitionEvent(tbl, part, deleteData, this));
+        mustPurge = isMustPurge(envContext, tbl);
+
+        if (part == null) {
+          throw new NoSuchObjectException("Partition doesn't exist. "
+              + part_vals);
+        }
+
+        isArchived = MetaStoreUtils.isArchived(part);
+        if (isArchived) {
+          archiveParentDir = MetaStoreUtils.getOriginalLocation(part);
+          verifyIsWritablePath(archiveParentDir);
+        }
+
+        if ((part.getSd() != null) && (part.getSd().getLocation() != null)) {
+          partPath = new Path(part.getSd().getLocation());
+          verifyIsWritablePath(partPath);
+        }
+
+        if (!ms.dropPartition(catName, db_name, tbl_name, part_vals)) {
+          throw new MetaException("Unable to drop partition");
+        } else {
+          if (!transactionalListeners.isEmpty()) {
+
+            transactionalListenerResponses =
+                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                                                      EventType.DROP_PARTITION,
+                                                      new DropPartitionEvent(tbl, part, true, deleteData, this),
+                                                      envContext);
+          }
+          needsCm = ReplChangeManager.shouldEnableCm(ms.getDatabase(catName, db_name), tbl);
+          success = ms.commitTransaction();
+        }
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        } else if (deleteData && ((partPath != null) || (archiveParentDir != null))) {
+          if (tableDataShouldBeDeleted) {
+            if (mustPurge) {
+              LOG.info("dropPartition() will purge " + partPath + " directly, skipping trash.");
+            }
+            else {
+              LOG.info("dropPartition() will move " + partPath + " to trash-directory.");
+            }
+            // Archived partitions have har:/to_har_file as their location.
+            // The original directory was saved in params
+
+            if (isArchived) {
+              assert (archiveParentDir != null);
+              wh.deleteDir(archiveParentDir, true, mustPurge, needsCm);
+            } else {
+              assert (partPath != null);
+              wh.deleteDir(partPath, true, mustPurge, needsCm);
+              deleteParentRecursive(partPath.getParent(), part_vals.size() - 1, mustPurge, needsCm);
+            }
+            // ok even if the data is not deleted
+          }
+        }
+        if (!listeners.isEmpty()) {
+          MetaStoreListenerNotifier.notifyEvent(listeners,
+                                                EventType.DROP_PARTITION,
+                                                new DropPartitionEvent(tbl, part, success, deleteData, this),
+                                                envContext,
+                                                transactionalListenerResponses, ms);
+        }
+      }
+      return true;
+    }
+
+    private static boolean isMustPurge(EnvironmentContext envContext, Table tbl) {
+      // Data needs deletion. Check if trash may be skipped.
+      // Trash may be skipped iff:
+      //  1. deleteData == true, obviously.
+      //  2. tbl is external.
+      //  3. Either
+      //    3.1. User has specified PURGE from the commandline, and if not,
+      //    3.2. User has set the table to auto-purge.
+      return ((envContext != null) && Boolean.parseBoolean(envContext.getProperties().get("ifPurge")))
+          || MetaStoreUtils.isSkipTrash(tbl.getParameters());
+    }
+
+    private void throwUnsupportedExceptionIfRemoteDB(String dbName, String operationName) throws MetaException {
+      if (isDatabaseRemote(dbName)) {
+        throw new MetaException("Operation " + operationName + " not supported for REMOTE database " + dbName);
+      }
+    }
+
+    private boolean isDatabaseRemote(String name) {
+      try {
+        String[] parsedDbName = parseDbName(name, conf);
+        Database db = get_database_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]);
+        if (db != null && db.getType() == DatabaseType.REMOTE) {
+          return true;
+        }
+      } catch (Exception e) {
+        return false;
+      }
+      return false;
+    }
+
+    private void deleteParentRecursive(Path parent, int depth, boolean mustPurge, boolean needRecycle)
+            throws IOException, MetaException {
+      if (depth > 0 && parent != null && wh.isWritable(parent)) {
+        if (wh.isDir(parent) && wh.isEmptyDir(parent)) {
+          wh.deleteDir(parent, true, mustPurge, needRecycle);
+        }
+        deleteParentRecursive(parent.getParent(), depth - 1, mustPurge, needRecycle);
+      }
+    }
+
+    @Override
+    public boolean drop_partition(final String db_name, final String tbl_name,
+        final List<String> part_vals, final boolean deleteData)
+        throws TException {
+      return drop_partition_with_environment_context(db_name, tbl_name, part_vals, deleteData,
+          null);
+    }
+
+    private static class PathAndPartValSize {
+      PathAndPartValSize(Path path, int partValSize) {
+        this.path = path;
+        this.partValSize = partValSize;
+      }
+      public Path path;
+      int partValSize;
+    }
+
+    @Override
+    public DropPartitionsResult drop_partitions_req(
+        DropPartitionsRequest request) throws TException {
+      RawStore ms = getMS();
+      String dbName = request.getDbName(), tblName = request.getTblName();
+      String catName = request.isSetCatName() ? request.getCatName() : getDefaultCatalog(conf);
+      boolean ifExists = request.isSetIfExists() && request.isIfExists();
+      boolean deleteData = request.isSetDeleteData() && request.isDeleteData();
+      boolean ignoreProtection = request.isSetIgnoreProtection() && request.isIgnoreProtection();
+      boolean needResult = !request.isSetNeedResult() || request.isNeedResult();
+      List<PathAndPartValSize> dirsToDelete = new ArrayList<>();
+      List<Path> archToDelete = new ArrayList<>();
+      EnvironmentContext envContext = request.isSetEnvironmentContext()
+          ? request.getEnvironmentContext() : null;
+
+      boolean success = false;
+      ms.openTransaction();
+      Table tbl = null;
+      List<Partition> parts = null;
+      boolean mustPurge = false;
+      List<Map<String, String>> transactionalListenerResponses = Lists.newArrayList();
+      boolean needsCm = ReplChangeManager.shouldEnableCm(ms.getDatabase(catName, dbName),
+              ms.getTable(catName, dbName, tblName));
+
+      try {
+        // We need Partition-s for firing events and for result; DN needs MPartition-s to drop.
+        // Great... Maybe we could bypass fetching MPartitions by issuing direct SQL deletes.
+        tbl = get_table_core(catName, dbName, tblName);
+        isExternal(tbl);
+        mustPurge = isMustPurge(envContext, tbl);
+        int minCount = 0;
+        RequestPartsSpec spec = request.getParts();
+        List<String> partNames = null;
+        if (spec.isSetExprs()) {
+          // Dropping by expressions.
+          parts = new ArrayList<>(spec.getExprs().size());
+          for (DropPartitionsExpr expr : spec.getExprs()) {
+            ++minCount; // At least one partition per expression, if not ifExists
+            List<Partition> result = new ArrayList<>();
+            boolean hasUnknown = ms.getPartitionsByExpr(
+                catName, dbName, tblName, expr.getExpr(), null, (short)-1, result);
+            if (hasUnknown) {
+              // Expr is built by DDLSA, it should only contain part cols and simple ops
+              throw new MetaException("Unexpected unknown partitions to drop");
+            }
+            // this is to prevent dropping archived partition which is archived in a
+            // different level the drop command specified.
+            if (!ignoreProtection && expr.isSetPartArchiveLevel()) {
+              for (Partition part : parts) {
+                if (MetaStoreUtils.isArchived(part)
+                    && MetaStoreUtils.getArchivingLevel(part) < expr.getPartArchiveLevel()) {
+                  throw new MetaException("Cannot drop a subset of partitions "
+                      + " in an archive, partition " + part);
+                }
+              }
+            }
+            parts.addAll(result);
+          }
+        } else if (spec.isSetNames()) {
+          partNames = spec.getNames();
+          minCount = partNames.size();
+          parts = ms.getPartitionsByNames(catName, dbName, tblName, partNames);
+        } else {
+          throw new MetaException("Partition spec is not set");
+        }
+
+        if ((parts.size() < minCount) && !ifExists) {
+          throw new NoSuchObjectException("Some partitions to drop are missing");
+        }
+
+        List<String> colNames = null;
+        if (partNames == null) {
+          partNames = new ArrayList<>(parts.size());
+          colNames = new ArrayList<>(tbl.getPartitionKeys().size());
+          for (FieldSchema col : tbl.getPartitionKeys()) {
+            colNames.add(col.getName());
+          }
+        }
+
+        for (Partition part : parts) {
+
+          // TODO - we need to speed this up for the normal path where all partitions are under
+          // the table and we don't have to stat every partition
+
+          firePreEvent(new PreDropPartitionEvent(tbl, part, deleteData, this));
+          if (colNames != null) {
+            partNames.add(FileUtils.makePartName(colNames, part.getValues()));
+          }
+          // Preserve the old behavior of failing when we cannot write, even w/o deleteData,
+          // and even if the table is external. That might not make any sense.
+          if (MetaStoreUtils.isArchived(part)) {
+            Path archiveParentDir = MetaStoreUtils.getOriginalLocation(part);
+            verifyIsWritablePath(archiveParentDir);
+            archToDelete.add(archiveParentDir);
+          }
+          if ((part.getSd() != null) && (part.getSd().getLocation() != null)) {
+            Path partPath = new Path(part.getSd().getLocation());
+            verifyIsWritablePath(partPath);
+            dirsToDelete.add(new PathAndPartValSize(partPath, part.getValues().size()));
+          }
+        }
+
+        ms.dropPartitions(catName, dbName, tblName, partNames);
+        if (parts != null && !transactionalListeners.isEmpty()) {
+          for (Partition part : parts) {
+            transactionalListenerResponses.add(
+                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                                                      EventType.DROP_PARTITION,
+                                                      new DropPartitionEvent(tbl, part, true, deleteData, this),
+                                                      envContext));
+          }
+        }
+
+        success = ms.commitTransaction();
+        DropPartitionsResult result = new DropPartitionsResult();
+        if (needResult) {
+          result.setPartitions(parts);
+        }
+
+        return result;
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        } else if (checkTableDataShouldBeDeleted(tbl, deleteData)) {
+          LOG.info( mustPurge?
+                      "dropPartition() will purge partition-directories directly, skipping trash."
+                    :  "dropPartition() will move partition-directories to trash-directory.");
+          // Archived partitions have har:/to_har_file as their location.
+          // The original directory was saved in params
+          for (Path path : archToDelete) {
+            wh.deleteDir(path, true, mustPurge, needsCm);
+          }
+          for (PathAndPartValSize p : dirsToDelete) {
+            wh.deleteDir(p.path, true, mustPurge, needsCm);
+            try {
+              deleteParentRecursive(p.path.getParent(), p.partValSize - 1, mustPurge, needsCm);
+            } catch (IOException ex) {
+              LOG.warn("Error from deleteParentRecursive", ex);
+              throw new MetaException("Failed to delete parent: " + ex.getMessage());
+            }
+          }
+        }
+        if (parts != null) {
+          int i = 0;
+          if (parts != null && !listeners.isEmpty()) {
+            for (Partition part : parts) {
+              Map<String, String> parameters =
+                  (!transactionalListenerResponses.isEmpty()) ? transactionalListenerResponses.get(i) : null;
+
+              MetaStoreListenerNotifier.notifyEvent(listeners,
+                                                    EventType.DROP_PARTITION,
+                                                    new DropPartitionEvent(tbl, part, success, deleteData, this),
+                                                    envContext,
+                                                    parameters, ms);
+
+              i++;
+            }
+          }
+        }
+      }
+    }
+
+    private void verifyIsWritablePath(Path dir) throws MetaException {
+      try {
+        if (!wh.isWritable(dir.getParent())) {
+          throw new MetaException("Table partition not deleted since " + dir.getParent()
+              + " is not writable by " + SecurityUtils.getUser());
+        }
+      } catch (IOException ex) {
+        LOG.warn("Error from isWritable", ex);
+        throw new MetaException("Table partition not deleted since " + dir.getParent()
+            + " access cannot be checked: " + ex.getMessage());
+      }
+    }
+
+    @Override
+    public boolean drop_partition_with_environment_context(final String db_name,
+        final String tbl_name, final List<String> part_vals, final boolean deleteData,
+        final EnvironmentContext envContext)
+        throws TException {
+      String[] parsedDbName = parseDbName(db_name, conf);
+      startPartitionFunction("drop_partition", parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+          tbl_name, part_vals);
+      LOG.info("Partition values:" + part_vals);
+
+      boolean ret = false;
+      Exception ex = null;
+      try {
+        ret = drop_partition_common(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+            tbl_name, part_vals, deleteData, envContext);
+      } catch (IOException e) {
+        ex = e;
+        throw new MetaException(e.getMessage());
+      } catch (Exception e) {
+        ex = e;
+        rethrowException(e);
+      } finally {
+        endFunction("drop_partition", ret, ex, tbl_name);
+      }
+      return ret;
+
+    }
+
+    /**
+     * Use {@link #get_partition_req(GetPartitionRequest)} ()} instead.
+     *
+     */
+    @Override
+    @Deprecated
+    public Partition get_partition(final String db_name, final String tbl_name,
+        final List<String> part_vals) throws MetaException, NoSuchObjectException {
+      String[] parsedDbName = parseDbName(db_name, conf);
+      startPartitionFunction("get_partition", parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+          tbl_name, part_vals);
+
+      Partition ret = null;
+      Exception ex = null;
+      try {
+        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
+        fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
+        ret = getMS().getPartition(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name, part_vals);
+        ret = FilterUtils.filterPartitionIfEnabled(isServerFilterEnabled, filterHook, ret);
+      } catch (Exception e) {
+        ex = e;
+        throwMetaException(e);
+      } finally {
+        endFunction("get_partition", ret != null, ex, tbl_name);
+      }
+      return ret;
+    }
+
+    @Override
+    public GetPartitionResponse get_partition_req(GetPartitionRequest req)
+        throws MetaException, NoSuchObjectException, TException {
+      // TODO Move the logic from get_partition to here, as that method is getting deprecated
+      String dbName = MetaStoreUtils.prependCatalogToDbName(req.getCatName(), req.getDbName(), conf);
+      Partition p = get_partition(dbName, req.getTblName(), req.getPartVals());
+      GetPartitionResponse res = new GetPartitionResponse();
+      res.setPartition(p);
+      return res;
+    }
+
+    /**
+     * Fire a pre-event for read table operation, if there are any
+     * pre-event listeners registered
+     */
+    private void fireReadTablePreEvent(String catName, String dbName, String tblName)
+        throws MetaException, NoSuchObjectException {
+      if(preListeners.size() > 0) {
+        Supplier<Table> tableSupplier = Suppliers.memoize(new Supplier<Table>() {
+          @Override public Table get() {
+            try {
+              Table t = getMS().getTable(catName, dbName, tblName, null);
+              if (t == null) {
+                throw new NoSuchObjectException(TableName.getQualified(catName, dbName, tblName)
+                    + " table not found");
+              }
+              return t;
+            } catch(MetaException | NoSuchObjectException e) {
+              throw new RuntimeException(e);
+            }
+          }
+        });
+        firePreEvent(new PreReadTableEvent(tableSupplier, this));
+      }
+    }
+
+    @Override
+    @Deprecated
+    public Partition get_partition_with_auth(final String db_name,
+        final String tbl_name, final List<String> part_vals,
+        final String user_name, final List<String> group_names)
+        throws TException {
+      String[] parsedDbName = parseDbName(db_name, conf);
+      startPartitionFunction("get_partition_with_auth", parsedDbName[CAT_NAME],
+          parsedDbName[DB_NAME], tbl_name, part_vals);
+      fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
+      Partition ret = null;
+      Exception ex = null;
+      try {
+        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
+
+        ret = getMS().getPartitionWithAuth(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+            tbl_name, part_vals, user_name, group_names);
+        ret = FilterUtils.filterPartitionIfEnabled(isServerFilterEnabled, filterHook, ret);
+      } catch (InvalidObjectException e) {
+        ex = e;
+        throw new NoSuchObjectException(e.getMessage());
+      } catch (Exception e) {
+        ex = e;
+        rethrowException(e);
+      } finally {
+        endFunction("get_partition_with_auth", ret != null, ex, tbl_name);
+      }
+      return ret;
+    }
+
+    /**
+     * Use {@link #get_partitions_req(PartitionsRequest)} ()} instead.
+     *
+     */
+    @Override
+    @Deprecated
+    public List<Partition> get_partitions(final String db_name, final String tbl_name,
+        final short max_parts) throws NoSuchObjectException, MetaException {
+      String[] parsedDbName = parseDbName(db_name, conf);
+      startTableFunction("get_partitions", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
+      fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
+      List<Partition> ret = null;
+      Exception ex = null;
+      try {
+        checkLimitNumberOfPartitionsByFilter(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+            tbl_name, NO_FILTER_STRING, max_parts);
+
+        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
+
+        ret = getMS().getPartitions(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name,
+            max_parts);
+        ret = FilterUtils.filterPartitionsIfEnabled(isServerFilterEnabled, filterHook, ret);
+      } catch (Exception e) {
+        ex = e;
+        throwMetaException(e);
+      } finally {
+        endFunction("get_partitions", ret != null, ex, tbl_name);
+      }
+      return ret;
+
+    }
+
+    @Override
+    public PartitionsResponse get_partitions_req(PartitionsRequest req)
+        throws NoSuchObjectException, MetaException, TException {
+      String dbName = MetaStoreUtils.prependCatalogToDbName(req.getCatName(), req.getDbName(), conf);
+      List<Partition> partitions = get_partitions(dbName, req.getTblName(), req.getMaxParts());
+      PartitionsResponse res = new PartitionsResponse();
+      res.setPartitions(partitions);
+      return res;
+    }
+
+    @Override
+    @Deprecated
+    public List<Partition> get_partitions_with_auth(final String dbName,
+        final String tblName, final short maxParts, final String userName,
+        final List<String> groupNames) throws TException {
+      String[] parsedDbName = parseDbName(dbName, conf);
+      startTableFunction("get_partitions_with_auth", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName);
+
+      List<Partition> ret = null;
+      Exception ex = null;
+      try {
+        checkLimitNumberOfPartitionsByFilter(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+            tblName, NO_FILTER_STRING, maxParts);
+
+        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName);
+
+        ret = getMS().getPartitionsWithAuth(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName,
+            maxParts, userName, groupNames);
+        ret = FilterUtils.filterPartitionsIfEnabled(isServerFilterEnabled, filterHook, ret);
+      } catch (InvalidObjectException e) {
+        ex = e;
+        throw new NoSuchObjectException(e.getMessage());
+      } catch (Exception e) {
+        ex = e;
+        rethrowException(e);
+      } finally {
+        endFunction("get_partitions_with_auth", ret != null, ex, tblName);
+      }
+      return ret;
+
+    }
+
+    private void checkLimitNumberOfPartitionsByFilter(String catName, String dbName,
+                                                      String tblName, String filterString,
+                                                      int maxParts) throws TException {
+      if (isPartitionLimitEnabled()) {
+        checkLimitNumberOfPartitions(tblName, get_num_partitions_by_filter(prependCatalogToDbName(
+            catName, dbName, conf), tblName, filterString), maxParts);
+      }
+    }
+
+    private void checkLimitNumberOfPartitionsByExpr(String catName, String dbName, String tblName,
+                                                    byte[] filterExpr, int maxParts)
+        throws TException {
+      if (isPartitionLimitEnabled()) {
+        checkLimitNumberOfPartitions(tblName, get_num_partitions_by_expr(catName, dbName, tblName,
+            filterExpr), maxParts);
+      }
+    }
+
+    private boolean isPartitionLimitEnabled() {
+      int partitionLimit = MetastoreConf.getIntVar(conf, ConfVars.LIMIT_PARTITION_REQUEST);
+      return partitionLimit > -1;
+    }
+
+    private void checkLimitNumberOfPartitions(String tblName, int numPartitions, int maxToFetch) throws MetaException {
+      if (isPartitionLimitEnabled()) {
+        int partitionLimit = MetastoreConf.getIntVar(conf, ConfVars.LIMIT_PARTITION_REQUEST);
+        int partitionRequest = (maxToFetch < 0) ? numPartitions : maxToFetch;
+        if (partitionRequest > partitionLimit) {
+          String configName = ConfVars.LIMIT_PARTITION_REQUEST.toString();
+          throw new MetaException(String.format(PARTITION_NUMBER_EXCEED_LIMIT_MSG, partitionRequest,
+              tblName, partitionLimit, configName));
+        }
+      }
+    }
+
+    @Override
+    @Deprecated
+    public List<PartitionSpec> get_partitions_pspec(final String db_name, final String tbl_name, final int max_parts)
+      throws NoSuchObjectException, MetaException  {
+
+      String[] parsedDbName = parseDbName(db_name, conf);
+      String tableName = tbl_name.toLowerCase();
+
+      startTableFunction("get_partitions_pspec", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName);
+
+      List<PartitionSpec> partitionSpecs = null;
+      try {
+        Table table = get_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName);
+        // get_partitions will parse out the catalog and db names itself
+        List<Partition> partitions = get_partitions(db_name, tableName, (short) max_parts);
+
+        if (is_partition_spec_grouping_enabled(table)) {
+          partitionSpecs = MetaStoreServerUtils
+              .getPartitionspecsGroupedByStorageDescriptor(table, partitions);
+        }
+        else {
+          PartitionSpec pSpec = new PartitionSpec();
+          pSpec.setPartitionList(new PartitionListComposingSpec(partitions));
+          pSpec.setCatName(parsedDbName[CAT_NAME]);
+          pSpec.setDbName(parsedDbName[DB_NAME]);
+          pSpec.setTableName(tableName);
+          pSpec.setRootPath(table.getSd().getLocation());
+          partitionSpecs = Arrays.asList(pSpec);
+        }
+
+        return partitionSpecs;
+      }
+      finally {
+        endFunction("get_partitions_pspec", partitionSpecs != null && !partitionSpecs.isEmpty(), null, tbl_name);
+      }
+    }
+
+    @Override
+    public GetPartitionsResponse get_partitions_with_specs(GetPartitionsRequest request)
+        throws MetaException, TException {
+      String catName = null;
+      if (request.isSetCatName()) {
+        catName = request.getCatName();
+      }
+      String[] parsedDbName = parseDbName(request.getDbName(), conf);
+      String tableName = request.getTblName();
+      if (catName == null) {
+        // if catName is not provided in the request use the catName parsed from the dbName
+        catName = parsedDbName[CAT_NAME];
+      }
+      startTableFunction("get_partitions_with_specs", catName, parsedDbName[DB_NAME],
+          tableName);
+      GetPartitionsResponse response = null;
+      Exception ex = null;
+      try {
+        Table table = get_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName);
+        List<Partition> partitions = getMS()
+            .getPartitionSpecsByFilterAndProjection(table, request.getProjectionSpec(),
+                request.getFilterSpec());
+        List<String> processorCapabilities = request.getProcessorCapabilities();
+        String processorId = request.getProcessorIdentifier();
+        if (processorCapabilities == null || processorCapabilities.size() == 0 ||
+              processorCapabilities.contains("MANAGERAWMETADATA")) {
+          LOG.info("Skipping translation for processor with " + processorId);
+        } else {
+          if (transformer != null) {
+            partitions = transformer.transformPartitions(partitions, table, processorCapabilities, processorId);
+          }
+        }
+        List<PartitionSpec> partitionSpecs =
+            MetaStoreServerUtils.getPartitionspecsGroupedByStorageDescriptor(table, partitions);
+        response = new GetPartitionsResponse();
+        response.setPartitionSpec(partitionSpecs);
+      } catch (Exception e) {
+        ex = e;
+        rethrowException(e);
+      } finally {
+        endFunction("get_partitions_with_specs", response != null, ex, tableName);
+      }
+      return response;
+    }
+
+    private static boolean is_partition_spec_grouping_enabled(Table table) {
+
+      Map<String, String> parameters = table.getParameters();
+      return parameters.containsKey("hive.hcatalog.partition.spec.grouping.enabled")
+          && parameters.get("hive.hcatalog.partition.spec.grouping.enabled").equalsIgnoreCase("true");
+    }
+
+    @Override
+    @Deprecated
+    public List<String> get_partition_names(final String db_name, final String tbl_name,
+        final short max_parts) throws NoSuchObjectException, MetaException {
+      String[] parsedDbName = parseDbName(db_name, conf);
+      startTableFunction("get_partition_names", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
+      fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
+      List<String> ret = null;
+      Exception ex = null;
+      try {
+        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
+        ret = getMS().listPartitionNames(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name,
+            max_parts);
+        ret = FilterUtils.filterPartitionNamesIfEnabled(isServerFilterEnabled,
+            filterHook, parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name, ret);
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_partition_names", ret != null, ex, tbl_name);
+      }
+      return ret;
+    }
+
+    @Override
+    public PartitionValuesResponse get_partition_values(PartitionValuesRequest request)
+        throws MetaException {
+      String catName = request.isSetCatName() ? request.getCatName() : getDefaultCatalog(conf);
+      String dbName = request.getDbName();
+      String tblName = request.getTblName();
+
+      try {
+        authorizeTableForPartitionMetadata(catName, dbName, tblName);
+
+        // This is serious black magic, as the following 2 lines do nothing AFAICT but without them
+        // the subsequent call to listPartitionValues fails.
+        List<FieldSchema> partCols = new ArrayList<FieldSchema>();
+        partCols.add(request.getPartitionKeys().get(0));
+        return getMS().listPartitionValues(catName, dbName, tblName, request.getPartitionKeys(),
+            request.isApplyDistinct(), request.getFilter(), request.isAscending(),
+            request.getPartitionOrder(), request.getMaxParts());
+      } catch (NoSuchObjectException e) {
+        LOG.error(String.format("Unable to get partition for %s.%s.%s", catName, dbName, tblName), e);
+        throw new MetaException(e.getMessage());
+      }
+    }
+
+    @Deprecated
+    @Override
+    public void alter_partition(final String db_name, final String tbl_name,
+        final Partition new_part)
+        throws TException {
+      rename_partition(db_name, tbl_name, null, new_part);
+    }
+
+    @Deprecated
+    @Override
+    public void alter_partition_with_environment_context(final String dbName,
+        final String tableName, final Partition newPartition,
+        final EnvironmentContext envContext)
+        throws TException {
+      String[] parsedDbName = parseDbName(dbName, conf);
+      // TODO: this method name is confusing, it actually does full alter (sortof)
+      rename_partition(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName, null, newPartition,
+          envContext, null);
+    }
+
+    @Deprecated
+    @Override
+    public void rename_partition(final String db_name, final String tbl_name,
+        final List<String> part_vals, final Partition new_part)
+        throws TException {
+      // Call rename_partition without an environment context.
+      String[] parsedDbName = parseDbName(db_name, conf);
+      rename_partition(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name, part_vals, new_part,
+          null, null);
+    }
+
+    @Override
+    public RenamePartitionResponse rename_partition_req(
+        RenamePartitionRequest req) throws InvalidOperationException ,MetaException ,TException {
+      rename_partition(req.getCatName(), req.getDbName(), req.getTableName(), req.getPartVals(),
+          req.getNewPart(), null, req.getValidWriteIdList());
+      return new RenamePartitionResponse();
+    };
+
+    private void rename_partition(String catName, String db_name, String tbl_name,
+        List<String> part_vals, Partition new_part, EnvironmentContext envContext,
+        String validWriteIds) throws TException {
+      startTableFunction("alter_partition", catName, db_name, tbl_name);
+
+      if (LOG.isInfoEnabled()) {
+        LOG.info("New partition values:" + new_part.getValues());
+        if (part_vals != null && part_vals.size() > 0) {
+          LOG.info("Old Partition values:" + part_vals);
+        }
+      }
+
+      // Adds the missing scheme/authority for the new partition location
+      if (new_part.getSd() != null) {
+        String newLocation = new_part.getSd().getLocation();
+        if (org.apache.commons.lang3.StringUtils.isNotEmpty(newLocation)) {
+          Path tblPath = wh.getDnsPath(new Path(newLocation));
+          new_part.getSd().setLocation(tblPath.toString());
+        }
+      }
+
+      // Make sure the new partition has the catalog value set
+      if (!new_part.isSetCatName()) {
+        new_part.setCatName(catName);
+      }
+
+      Partition oldPart = null;
+      Exception ex = null;
+      try {
+        firePreEvent(new PreAlterPartitionEvent(db_name, tbl_name, part_vals, new_part, this));
+        if (part_vals != null && !part_vals.isEmpty()) {
+          MetaStoreServerUtils.validatePartitionNameCharacters(new_part.getValues(),
+              partitionValidationPattern);
+        }
+
+        oldPart = alterHandler.alterPartition(getMS(), wh, catName, db_name, tbl_name,
+            part_vals, new_part, envContext, this, validWriteIds);
+
+        // Only fetch the table if we actually have a listener
+        Table table = null;
+        if (!listeners.isEmpty()) {
+          if (table == null) {
+            table = getMS().getTable(catName, db_name, tbl_name, null);
+          }
+
+          MetaStoreListenerNotifier.notifyEvent(listeners,
+                                                EventType.ALTER_PARTITION,
+                                                new AlterPartitionEvent(oldPart, new_part, table, false,
+                                                        true, new_part.getWriteId(), this),
+                                                envContext);
+        }
+      } catch (InvalidObjectException e) {
+        ex = e;
+        throw new InvalidOperationException(e.getMessage());
+      } catch (AlreadyExistsException e) {
+        ex = e;
+        throw new InvalidOperationException(e.getMessage());
+      } catch (MetaException | InvalidOperationException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("alter_partition", oldPart != null, ex, tbl_name);
+      }
+    }
+
+    @Override
+    public void alter_partitions(final String db_name, final String tbl_name,
+        final List<Partition> new_parts)
+        throws TException {
+      String[] o = parseDbName(db_name, conf);
+      alter_partitions_with_environment_context(o[0], o[1],
+          tbl_name, new_parts, null, null, -1);
+    }
+
+    @Override
+    public AlterPartitionsResponse alter_partitions_req(AlterPartitionsRequest req) throws TException {
+      alter_partitions_with_environment_context(req.getCatName(),
+          req.getDbName(), req.getTableName(), req.getPartitions(), req.getEnvironmentContext(),
+          req.isSetValidWriteIdList() ? req.getValidWriteIdList() : null,
+          req.isSetWriteId() ? req.getWriteId() : -1);
+      return new AlterPartitionsResponse();
+    }
+
+    // The old API we are keeping for backward compat. Not used within Hive.
+    @Deprecated
+    @Override
+    public void alter_partitions_with_environment_context(final String db_name, final String tbl_name,
+        final List<Partition> new_parts, EnvironmentContext environmentContext)
+            throws TException {
+      String[] o = parseDbName(db_name, conf);
+      alter_partitions_with_environment_context(o[0], o[1], tbl_name, new_parts, environmentContext,
+          null, -1);
+    }
+
+    private void alter_partitions_with_environment_context(String catName, String db_name, final String tbl_name,
+        final List<Partition> new_parts, EnvironmentContext environmentContext,
+        String writeIdList, long writeId)
+        throws TException {
+      if (environmentContext == null) {
+        environmentContext = new EnvironmentContext();
+      }
+      if (catName == null) {
+        catName = MetaStoreUtils.getDefaultCatalog(conf);
+      }
+
+      startTableFunction("alter_partitions", catName, db_name, tbl_name);
+
+      if (LOG.isInfoEnabled()) {
+        for (Partition tmpPart : new_parts) {
+          LOG.info("New partition values:" + tmpPart.getValues());
+        }
+      }
+      // all partitions are altered atomically
+      // all prehooks are fired together followed by all post hooks
+      List<Partition> oldParts = null;
+      Exception ex = null;
+      try {
+        for (Partition tmpPart : new_parts) {
+          // Make sure the catalog name is set in the new partition
+          if (!tmpPart.isSetCatName()) {
+            tmpPart.setCatName(getDefaultCatalog(conf));
+          }
+          firePreEvent(new PreAlterPartitionEvent(db_name, tbl_name, null, tmpPart, this));
+        }
+        oldParts = alterHandler.alterPartitions(getMS(), wh,
+            catName, db_name, tbl_name, new_parts, environmentContext, writeIdList, writeId, this);
+        Iterator<Partition> olditr = oldParts.iterator();
+        // Only fetch the table if we have a listener that needs it.
+        Table table = null;
+        for (Partition tmpPart : new_parts) {
+          Partition oldTmpPart;
+          if (olditr.hasNext()) {
+            oldTmpPart = olditr.next();
+          }
+          else {
+            throw new InvalidOperationException("failed to alterpartitions");
+          }
+
+          if (table == null) {
+            table = getMS().getTable(catName, db_name, tbl_name,  null);
+          }
+
+          if (!listeners.isEmpty()) {
+            MetaStoreListenerNotifier.notifyEvent(listeners,
+                                                  EventType.ALTER_PARTITION,
+                                                  new AlterPartitionEvent(oldTmpPart, tmpPart, table, false,
+                                                   true, writeId, this));
+          }
+        }
+      } catch (InvalidObjectException e) {
+        ex = e;
+        throw new InvalidOperationException(e.getMessage());
+      } catch (AlreadyExistsException e) {
+        ex = e;
+        throw new InvalidOperationException(e.getMessage());
+      } catch (MetaException | InvalidOperationException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("alter_partition", oldParts != null, ex, tbl_name);
+      }
+    }
+
+    @Override
+    public String getVersion() throws TException {
+      String version = MetastoreVersionInfo.getVersion();
+      endFunction(startFunction("getVersion"), version != null, null);
+      return version;
+    }
+
+    @Override
+    public void alter_table(final String dbname, final String name,
+        final Table newTable)
+        throws InvalidOperationException, MetaException {
+      // Do not set an environment context.
+      String[] parsedDbName = parseDbName(dbname, conf);
+      alter_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], name, newTable,
+          null, null, null, null);
+    }
+
+    @Override
+    public void alter_table_with_cascade(final String dbname, final String name,
+        final Table newTable, final boolean cascade)
+        throws InvalidOperationException, MetaException {
+      EnvironmentContext envContext = null;
+      if (cascade) {
+        envContext = new EnvironmentContext();
+        envContext.putToProperties(StatsSetupConst.CASCADE, StatsSetupConst.TRUE);
+      }
+      String[] parsedDbName = parseDbName(dbname, conf);
+      alter_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], name, newTable,
+          envContext, null, null, null);
+    }
+
+    @Override
+    public AlterTableResponse alter_table_req(AlterTableRequest req)
+        throws InvalidOperationException, MetaException, TException {
+      alter_table_core(req.getCatName(), req.getDbName(), req.getTableName(),
+          req.getTable(), req.getEnvironmentContext(), req.getValidWriteIdList(),
+          req.getProcessorCapabilities(), req.getProcessorIdentifier());
+      return new AlterTableResponse();
+    }
+
+    @Override
+    public void alter_table_with_environment_context(final String dbname,
+        final String name, final Table newTable,
+        final EnvironmentContext envContext)
+        throws InvalidOperationException, MetaException {
+      String[] parsedDbName = parseDbName(dbname, conf);
+      alter_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+          name, newTable, envContext, null, null, null);
+    }
+
+    private void alter_table_core(String catName, String dbname, String name, Table newTable,
+        EnvironmentContext envContext, String validWriteIdList, List<String> processorCapabilities, String processorId)
+        throws InvalidOperationException, MetaException {
+      startFunction("alter_table", ": " + TableName.getQualified(catName, dbname, name)
+          + " newtbl=" + newTable.getTableName());
+      if (envContext == null) {
+        envContext = new EnvironmentContext();
+      }
+      if (catName == null) {
+        catName = MetaStoreUtils.getDefaultCatalog(conf);
+      }
+
+      // Update the time if it hasn't been specified.
+      if (newTable.getParameters() == null ||
+          newTable.getParameters().get(hive_metastoreConstants.DDL_TIME) == null) {
+        newTable.putToParameters(hive_metastoreConstants.DDL_TIME, Long.toString(System
+            .currentTimeMillis() / 1000));
+      }
+
+      // Adds the missing scheme/authority for the new table location
+      if (newTable.getSd() != null) {
+        String newLocation = newTable.getSd().getLocation();
+        if (org.apache.commons.lang3.StringUtils.isNotEmpty(newLocation)) {
+          Path tblPath = wh.getDnsPath(new Path(newLocation));
+          newTable.getSd().setLocation(tblPath.toString());
+        }
+      }
+      // Set the catalog name if it hasn't been set in the new table
+      if (!newTable.isSetCatName()) {
+        newTable.setCatName(catName);
+      }
+
+      boolean success = false;
+      Exception ex = null;
+      try {
+        Table oldt = get_table_core(catName, dbname, name, null);
+        if (transformer != null && !isInTest) {
+          newTable = transformer.transformAlterTable(newTable, processorCapabilities, processorId);
+        }
+        firePreEvent(new PreAlterTableEvent(oldt, newTable, this));
+        alterHandler.alterTable(getMS(), wh, catName, dbname, name, newTable,
+                envContext, this, validWriteIdList);
+        success = true;
+      } catch (NoSuchObjectException e) {
+        // thrown when the table to be altered does not exist
+        ex = e;
+        throw new InvalidOperationException(e.getMessage());
+      } catch (MetaException | InvalidOperationException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("alter_table", success, ex, name);
+      }
+    }
+
+    @Override
+    public List<String> get_tables(final String dbname, final String pattern)
+        throws MetaException {
+      startFunction("get_tables", ": db=" + dbname + " pat=" + pattern);
+
+      List<String> ret = null;
+      Exception ex = null;
+      Database db = null;
+      String[] parsedDbName = parseDbName(dbname, conf);
+      try {
+        db = get_database_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]);
+        if (db != null && db.getType() != null) {
+          if (db.getType().equals(DatabaseType.REMOTE)) {
+            return DataConnectorProviderFactory.getDataConnectorProvider(db).getTableNames();
+          }
+        }
+      } catch (Exception e) { /* appears we return empty set instead of throwing an exception */ }
+
+      try {
+        ret = getMS().getTables(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], pattern);
+        if(ret !=  null && !ret.isEmpty()) {
+          List<Table> tableInfo = new ArrayList<>();
+          tableInfo = getMS().getTableObjectsByName(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], ret);
+          tableInfo = FilterUtils.filterTablesIfEnabled(isServerFilterEnabled, filterHook, tableInfo);// tableInfo object has the owner information of the table which is being passed to FilterUtils.
+          ret = new ArrayList<>();
+          for (Table tbl : tableInfo) {
+            ret.add(tbl.getTableName());
+          }
+        }
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_tables", ret != null, ex);
+      }
+      return ret;
+    }
+
+    @Override
+    public List<String> get_tables_by_type(final String dbname, final String pattern, final String tableType)
+        throws MetaException {
+      startFunction("get_tables_by_type", ": db=" + dbname + " pat=" + pattern + ",type=" + tableType);
+
+      List<String> ret = null;
+      Exception ex = null;
+      String[] parsedDbName = parseDbName(dbname, conf);
+      try {
+        ret = getTablesByTypeCore(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], pattern, tableType);
+        ret = FilterUtils.filterTableNamesIfEnabled(isServerFilterEnabled, filterHook,
+            parsedDbName[CAT_NAME], parsedDbName[DB_NAME], ret);
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_tables_by_type", ret != null, ex);
+      }
+      return ret;
+    }
+
+    private List<String> getTablesByTypeCore(final String catName, final String dbname,
+        final String pattern, final String tableType) throws MetaException {
+      startFunction("getTablesByTypeCore", ": catName=" + catName +
+          ": db=" + dbname + " pat=" + pattern + ",type=" + tableType);
+
+      List<String> ret = null;
+      Exception ex = null;
+      Database db = null;
+      try {
+        db = get_database_core(catName, dbname);
+        if (db != null) {
+          if (db.getType().equals(DatabaseType.REMOTE)) {
+            return DataConnectorProviderFactory.getDataConnectorProvider(db).getTableNames();
+          }
+        }
+      } catch (Exception e) { /* ignore */ }
+
+      try {
+        ret = getMS().getTables(catName, dbname, pattern, TableType.valueOf(tableType), -1);
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("getTablesByTypeCore", ret != null, ex);
+      }
+      return ret;
+    }
+
+    @Override
+    public List<Table> get_all_materialized_view_objects_for_rewriting()
+        throws MetaException {
+      startFunction("get_all_materialized_view_objects_for_rewriting");
+
+      List<Table> ret = null;
+      Exception ex = null;
+      try {
+        ret = getMS().getAllMaterializedViewObjectsForRewriting(DEFAULT_CATALOG_NAME);
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_all_materialized_view_objects_for_rewriting", ret != null, ex);
+      }
+      return ret;
+    }
+
+    @Override
+    public List<String> get_materialized_views_for_rewriting(final String dbname)
+        throws MetaException {
+      startFunction("get_materialized_views_for_rewriting", ": db=" + dbname);
+
+      List<String> ret = null;
+      Exception ex = null;
+      String[] parsedDbName = parseDbName(dbname, conf);
+      try {
+        ret = getMS().getMaterializedViewsForRewriting(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]);
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_materialized_views_for_rewriting", ret != null, ex);
+      }
+      return ret;
+    }
+
+    @Override
+    public List<String> get_all_tables(final String dbname) throws MetaException {
+      startFunction("get_all_tables", ": db=" + dbname);
+
+      List<String> ret = null;
+      Exception ex = null;
+      String[] parsedDbName = parseDbName(dbname, conf);
+      try {
+        ret = getMS().getAllTables(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]);
+        ret = FilterUtils.filterTableNamesIfEnabled(isServerFilterEnabled, filterHook,
+            parsedDbName[CAT_NAME], parsedDbName[DB_NAME], ret);
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_all_tables", ret != null, ex);
+      }
+      return ret;
+    }
+
+    /**
+     * Use {@link #get_fields_req(GetFieldsRequest)} ()} instead.
+     *
+     */
+    @Override
+    @Deprecated
+    public List<FieldSchema> get_fields(String db, String tableName)
+        throws MetaException, UnknownTableException, UnknownDBException {
+      return get_fields_with_environment_context(db, tableName, null);
+    }
+
+    @Override
+    @Deprecated
+    public List<FieldSchema> get_fields_with_environment_context(String db, String tableName,
+        final EnvironmentContext envContext)
+        throws MetaException, UnknownTableException, UnknownDBException {
+      startFunction("get_fields_with_environment_context", ": db=" + db + "tbl=" + tableName);
+      String[] names = tableName.split("\\.");
+      String base_table_name = names[0];
+      String[] parsedDbName = parseDbName(db, conf);
+
+      Table tbl;
+      List<FieldSchema> ret = null;
+      Exception ex = null;
+      ClassLoader orgHiveLoader = null;
+      try {
+        try {
+          tbl = get_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], base_table_name);
+          firePreEvent(new PreReadTableEvent(tbl, this));
+        } catch (NoSuchObjectException e) {
+          throw new UnknownTableException(e.getMessage());
+        }
+        if (null == tbl.getSd().getSerdeInfo().getSerializationLib() ||
+          MetastoreConf.getStringCollection(conf,
+              ConfVars.SERDES_USING_METASTORE_FOR_SCHEMA).contains(
+                  tbl.getSd().getSerdeInfo().getSerializationLib())) {
+          ret = tbl.getSd().getCols();
+        } else {
+          StorageSchemaReader schemaReader = getStorageSchemaReader();
+          ret = schemaReader.readSchema(tbl, envContext, getConf());
+        }
+      } catch (UnknownTableException | MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        if (orgHiveLoader != null) {
+          conf.setClassLoader(orgHiveLoader);
+        }
+        endFunction("get_fields_with_environment_context", ret != null, ex, tableName);
+      }
+
+      return ret;
+    }
+
+    @Override
+    public GetFieldsResponse get_fields_req(GetFieldsRequest req)
+        throws MetaException, UnknownTableException, UnknownDBException, TException {
+      String dbName = MetaStoreUtils.prependCatalogToDbName(req.getCatName(), req.getDbName(), conf);
+      List<FieldSchema> fields = get_fields_with_environment_context(
+          dbName, req.getTblName(), req.getEnvContext());
+      GetFieldsResponse res = new GetFieldsResponse();
+      res.setFields(fields);
+      return res;
+    }
+
+    private StorageSchemaReader getStorageSchemaReader() throws MetaException {
+      if (storageSchemaReader == null) {
+        String className =
+            MetastoreConf.getVar(conf, MetastoreConf.ConfVars.STORAGE_SCHEMA_READER_IMPL);
+        Class<? extends StorageSchemaReader> readerClass =
+            JavaUtils.getClass(className, StorageSchemaReader.class);
+        try {
+          storageSchemaReader = readerClass.newInstance();
+        } catch (InstantiationException|IllegalAccessException e) {
+          LOG.error("Unable to instantiate class " + className, e);
+          throw new MetaException(e.getMessage());
+        }
+      }
+      return storageSchemaReader;
+    }
+
+    /**
+     * Use {@link #get_schema_req(GetSchemaRequest)} ()} instead.
+     *
+     */
+    @Override
+    @Deprecated
+    public List<FieldSchema> get_schema(String db, String tableName)
+        throws MetaException, UnknownTableException, UnknownDBException {
+      return get_schema_with_environment_context(db,tableName, null);
+    }
+
+    /**
+     * Return the schema of the table. This function includes partition columns
+     * in addition to the regular columns.
+     *
+     * @param db
+     *          Name of the database
+     * @param tableName
+     *          Name of the table
+     * @param envContext
+     *          Store session based properties
+     * @return List of columns, each column is a FieldSchema structure
+     * @throws MetaException
+     * @throws UnknownTableException
+     * @throws UnknownDBException
+     */
+    @Override
+    @Deprecated
+    public List<FieldSchema> get_schema_with_environment_context(String db, String tableName,
+          final EnvironmentContext envContext)
+        throws MetaException, UnknownTableException, UnknownDBException {
+      startFunction("get_schema_with_environment_context", ": db=" + db + "tbl=" + tableName);
+      boolean success = false;
+      Exception ex = null;
+      try {
+        String[] names = tableName.split("\\.");
+        String base_table_name = names[0];
+        String[] parsedDbName = parseDbName(db, conf);
+
+        Table tbl;
+        try {
+          tbl = get_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], base_table_name);
+        } catch (NoSuchObjectException e) {
+          throw new UnknownTableException(e.getMessage());
+        }
+        // Pass unparsed db name here
+        List<FieldSchema> fieldSchemas = get_fields_with_environment_context(db, base_table_name,
+            envContext);
+
+        if (tbl == null || fieldSchemas == null) {
+          throw new UnknownTableException(tableName + " doesn't exist");
+        }
+
+        if (tbl.getPartitionKeys() != null) {
+          // Combine the column field schemas and the partition keys to create the
+          // whole schema
+          fieldSchemas.addAll(tbl.getPartitionKeys());
+        }
+        success = true;
+        return fieldSchemas;
+      } catch (UnknownDBException | UnknownTableException | MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        MetaException me = new MetaException(e.toString());
+        me.initCause(e);
+        throw me;
+      } finally {
+        endFunction("get_schema_with_environment_context", success, ex, tableName);
+      }
+    }
+
+    @Override
+    public GetSchemaResponse get_schema_req(GetSchemaRequest req)
+        throws MetaException, UnknownTableException, UnknownDBException, TException {
+      String dbName = MetaStoreUtils.prependCatalogToDbName(req.getCatName(), req.getDbName(), conf);
+      List<FieldSchema> fields = get_schema_with_environment_context(
+          dbName, req.getTblName(), req.getEnvContext());
+      GetSchemaResponse res = new GetSchemaResponse();
+      res.setFields(fields);
+      return res;
+    }
+
+    @Override
+    public String getCpuProfile(int profileDurationInSec) throws TException {
+      return "";
+    }
+
+    /**
+     * Returns the value of the given configuration variable name. If the
+     * configuration variable with the given name doesn't exist, or if there
+     * were an exception thrown while retrieving the variable, or if name is
+     * null, defaultValue is returned.
+     */
+    @Override
+    public String get_config_value(String name, String defaultValue)
+        throws TException {
+      startFunction("get_config_value", ": name=" + name + " defaultValue="
+          + defaultValue);
+      boolean success = false;
+      Exception ex = null;
+      try {
+        if (name == null) {
+          success = true;
+          return defaultValue;
+        }
+        // Allow only keys that start with hive.*, hdfs.*, mapred.* for security
+        // i.e. don't allow access to db password
+        if (!Pattern.matches("(hive|hdfs|mapred|metastore).*", name)) {
+          throw new ConfigValSecurityException("For security reasons, the "
+              + "config key " + name + " cannot be accessed");
+        }
+
+        String toReturn = defaultValue;
+        try {
+          toReturn = MetastoreConf.get(conf, name);
+          if (toReturn == null) {
+            toReturn = defaultValue;
+          }
+        } catch (RuntimeException e) {
+          LOG.error(threadLocalId.get().toString() + ": "
+              + "RuntimeException thrown in get_config_value - msg: "
+              + e.getMessage() + " cause: " + e.getCause());
+        }
+        success = true;
+        return toReturn;
+      } catch (ConfigValSecurityException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw new TException(e);
+      } finally {
+        endFunction("get_config_value", success, ex);
+      }
+    }
+
+    private List<String> getPartValsFromName(Table t, String partName)
+        throws MetaException, InvalidObjectException {
+      Preconditions.checkArgument(t != null, "Table can not be null");
+      // Unescape the partition name
+      LinkedHashMap<String, String> hm = Warehouse.makeSpecFromName(partName);
+
+      List<String> partVals = new ArrayList<>();
+      for (FieldSchema field : t.getPartitionKeys()) {
+        String key = field.getName();
+        String val = hm.get(key);
+        if (val == null) {
+          throw new InvalidObjectException("incomplete partition name - missing " + key);
+        }
+        partVals.add(val);
+      }
+      return partVals;
+    }
+
+    private List<String> getPartValsFromName(RawStore ms, String catName, String dbName,
+                                             String tblName, String partName)
+        throws MetaException, InvalidObjectException {
+      Table t = ms.getTable(catName, dbName, tblName,  null);
+      if (t == null) {
+        throw new InvalidObjectException(dbName + "." + tblName
+            + " table not found");
+      }
+      return getPartValsFromName(t, partName);
+    }
+
+    private Partition get_partition_by_name_core(final RawStore ms, final String catName,
+                                                 final String db_name, final String tbl_name,
+                                                 final String part_name) throws TException {
+      fireReadTablePreEvent(catName, db_name, tbl_name);
+      List<String> partVals;
+      try {
+        partVals = getPartValsFromName(ms, catName, db_name, tbl_name, part_name);
+      } catch (InvalidObjectException e) {
+        throw new NoSuchObjectException(e.getMessage());
+      }
+      Partition p = ms.getPartition(catName, db_name, tbl_name, partVals);
+      p = FilterUtils.filterPartitionIfEnabled(isServerFilterEnabled, filterHook, p);
+
+      if (p == null) {
+        throw new NoSuchObjectException(TableName.getQualified(catName, db_name, tbl_name)
+            + " partition (" + part_name + ") not found");
+      }
+      return p;
+    }
+
+    @Override
+    @Deprecated
+    public Partition get_partition_by_name(final String db_name, final String tbl_name,
+        final String part_name) throws TException {
+
+      String[] parsedDbName = parseDbName(db_name, conf);
+      startFunction("get_partition_by_name", ": tbl=" +
+          TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name)
+          + " part=" + part_name);
+      Partition ret = null;
+      Exception ex = null;
+      try {
+        ret = get_partition_by_name_core(getMS(), parsedDbName[CAT_NAME],
+            parsedDbName[DB_NAME], tbl_name, part_name);
+        ret = FilterUtils.filterPartitionIfEnabled(isServerFilterEnabled, filterHook, ret);
+      } catch (Exception e) {
+        ex = e;
+        rethrowException(e);
+      } finally {
+        endFunction("get_partition_by_name", ret != null, ex, tbl_name);
+      }
+      return ret;
+    }
+
+    @Override
+    public Partition append_partition_by_name(final String db_name, final String tbl_name,
+        final String part_name) throws TException {
+      return append_partition_by_name_with_environment_context(db_name, tbl_name, part_name, null);
+    }
+
+    @Override
+    public Partition append_partition_by_name_with_environment_context(final String db_name,
+        final String tbl_name, final String part_name, final EnvironmentContext env_context)
+        throws TException {
+      String[] parsedDbName = parseDbName(db_name, conf);
+      startFunction("append_partition_by_name", ": tbl="
+          + TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+          tbl_name) + " part=" + part_name);
+
+      Partition ret = null;
+      Exception ex = null;
+      try {
+        RawStore ms = getMS();
+        List<String> partVals = getPartValsFromName(ms, parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name, part_name);
+        ret = append_partition_common(ms, parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name, partVals, env_context);
+      } catch (InvalidObjectException | AlreadyExistsException | MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("append_partition_by_name", ret != null, ex, tbl_name);
+      }
+      return ret;
+    }
+
+    private boolean drop_partition_by_name_core(final RawStore ms, final String catName,
+                                                final String db_name, final String tbl_name,
+                                                final String part_name, final boolean deleteData,
+                                                final EnvironmentContext envContext)
+        throws TException, IOException {
+
+      List<String> partVals;
+      try {
+        partVals = getPartValsFromName(ms, catName, db_name, tbl_name, part_name);
+      } catch (InvalidObjectException e) {
+        throw new NoSuchObjectException(e.getMessage());
+      }
+
+      return drop_partition_common(ms, catName, db_name, tbl_name, partVals, deleteData, envContext);
+    }
+
+    @Override
+    public boolean drop_partition_by_name(final String db_name, final String tbl_name,
+        final String part_name, final boolean deleteData) throws TException {
+      return drop_partition_by_name_with_environment_context(db_name, tbl_name, part_name,
+          deleteData, null);
+    }
+
+    @Override
+    public boolean drop_partition_by_name_with_environment_context(final String db_name,
+        final String tbl_name, final String part_name, final boolean deleteData,
+        final EnvironmentContext envContext) throws TException {
+      String[] parsedDbName = parseDbName(db_name, conf);
+      startFunction("drop_partition_by_name", ": tbl=" +
+          TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name)
+          + " part=" + part_name);
+
+      boolean ret = false;
+      Exception ex = null;
+      try {
+        ret = drop_partition_by_name_core(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+            tbl_name, part_name, deleteData, envContext);
+      } catch (IOException e) {
+        ex = e;
+        throw new MetaException(e.getMessage());
+      } catch (Exception e) {
+        ex = e;
+        rethrowException(e);
+      } finally {
+        endFunction("drop_partition_by_name", ret, ex, tbl_name);
+      }
+
+      return ret;
+    }
+
+    @Override
+    @Deprecated
+    public List<Partition> get_partitions_ps(final String db_name,
+        final String tbl_name, final List<String> part_vals,
+        final short max_parts) throws TException {
+      String[] parsedDbName = parseDbName(db_name, conf);
+      startPartitionFunction("get_partitions_ps", parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+          tbl_name, part_vals);
+
+      List<Partition> ret = null;
+      Exception ex = null;
+      try {
+        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
+        // Don't send the parsedDbName, as this method will parse itself.
+        ret = get_partitions_ps_with_auth(db_name, tbl_name, part_vals,
+            max_parts, null, null);
+        ret = FilterUtils.filterPartitionsIfEnabled(isServerFilterEnabled, filterHook, ret);
+      } catch (Exception e) {
+        ex = e;
+        rethrowException(e);
+      } finally {
+        endFunction("get_partitions_ps", ret != null, ex, tbl_name);
+      }
+
+      return ret;
+    }
+
+    /**
+     * Use {@link #get_partitions_ps_with_auth_req(GetPartitionsPsWithAuthRequest)} ()} instead.
+     *
+     */
+    @Override
+    @Deprecated
+    public List<Partition> get_partitions_ps_with_auth(final String db_name,
+        final String tbl_name, final List<String> part_vals,
+        final short max_parts, final String userName,
+        final List<String> groupNames) throws TException {
+      String[] parsedDbName = parseDbName(db_name, conf);
+      startPartitionFunction("get_partitions_ps_with_auth", parsedDbName[CAT_NAME],
+          parsedDbName[DB_NAME], tbl_name, part_vals);
+      fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
+      List<Partition> ret = null;
+      Exception ex = null;
+      try {
+        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
+        ret = getMS().listPartitionsPsWithAuth(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+            tbl_name, part_vals, max_parts, userName, groupNames);
+        ret = FilterUtils.filterPartitionsIfEnabled(isServerFilterEnabled, filterHook, ret);
+      } catch (InvalidObjectException e) {
+        ex = e;
+        throw new MetaException(e.getMessage());
+      } catch (Exception e) {
+        ex = e;
+        rethrowException(e);
+      } finally {
+        endFunction("get_partitions_ps_with_auth", ret != null, ex, tbl_name);
+      }
+      return ret;
+    }
+
+    @Override
+    public GetPartitionsPsWithAuthResponse get_partitions_ps_with_auth_req(GetPartitionsPsWithAuthRequest req)
+            throws MetaException, NoSuchObjectException, TException {
+      String dbName = MetaStoreUtils.prependCatalogToDbName(req.getCatName(), req.getDbName(), conf);
+      List<Partition> partitions = null;
+      if (req.getPartVals() == null) {
+        partitions = get_partitions_with_auth(dbName, req.getTblName(), req.getMaxParts(), req.getUserName(),
+            req.getGroupNames());
+      } else {
+        partitions =
+            get_partitions_ps_with_auth(dbName, req.getTblName(), req.getPartVals(), req.getMaxParts(),
+                req.getUserName(), req.getGroupNames());
+      }
+      GetPartitionsPsWithAuthResponse res = new GetPartitionsPsWithAuthResponse();
+      res.setPartitions(partitions);
+      return res;
+    }
+
+    /**
+     * Use {@link #get_partition_names_ps_req(GetPartitionNamesPsRequest)} ()} instead.
+     *
+     */
+    @Override
+    @Deprecated
+    public List<String> get_partition_names_ps(final String db_name,
+        final String tbl_name, final List<String> part_vals, final short max_parts)
+        throws TException {
+      String[] parsedDbName = parseDbName(db_name, conf);
+      startPartitionFunction("get_partitions_names_ps", parsedDbName[CAT_NAME],
+          parsedDbName[DB_NAME], tbl_name, part_vals);
+      fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
+      List<String> ret = null;
+      Exception ex = null;
+      try {
+        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name);
+        ret = getMS().listPartitionNamesPs(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name,
+            part_vals, max_parts);
+        ret = FilterUtils.filterPartitionNamesIfEnabled(isServerFilterEnabled,
+            filterHook, parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name, ret);
+      } catch (Exception e) {
+        ex = e;
+        rethrowException(e);
+      } finally {
+        endFunction("get_partitions_names_ps", ret != null, ex, tbl_name);
+      }
+      return ret;
+    }
+
+    @Override
+    public GetPartitionNamesPsResponse get_partition_names_ps_req(GetPartitionNamesPsRequest req)
+            throws MetaException, NoSuchObjectException, TException {
+      String dbName = MetaStoreUtils.prependCatalogToDbName(req.getCatName(), req.getDbName(), conf);
+      List<String> names = get_partition_names_ps(dbName, req.getTblName(), req.getPartValues(),
+              req.getMaxParts());
+      GetPartitionNamesPsResponse res = new GetPartitionNamesPsResponse();
+      res.setNames(names);
+      return res;
+    }
+
+    @Override
+    public List<String> get_partition_names_req(PartitionsByExprRequest req)
+        throws MetaException, NoSuchObjectException, TException {
+      String catName = req.isSetCatName() ? req.getCatName() : getDefaultCatalog(conf);
+      String dbName = req.getDbName(), tblName = req.getTblName();
+      startTableFunction("get_partition_names_req", catName,
+          dbName, tblName);
+      fireReadTablePreEvent(catName, dbName, tblName);
+      List<String> ret = null;
+      Exception ex = null;
+      try {
+        authorizeTableForPartitionMetadata(catName, dbName, tblName);
+        ret = getMS().listPartitionNames(catName, dbName, tblName,
+            req.getDefaultPartitionName(), req.getExpr(), req.getOrder(), req.getMaxParts());
+        ret = FilterUtils.filterPartitionNamesIfEnabled(isServerFilterEnabled,
+            filterHook, catName, dbName, tblName, ret);
+      } catch (Exception e) {
+        ex = e;
+        rethrowException(e);
+      } finally {
+        endFunction("get_partition_names_req", ret != null, ex, tblName);
+      }
+      return ret;
+    }
+
+    @Override
+    public List<String> partition_name_to_vals(String part_name) throws TException {
+      if (part_name.length() == 0) {
+        return Collections.emptyList();
+      }
+      LinkedHashMap<String, String> map = Warehouse.makeSpecFromName(part_name);
+      return new ArrayList<>(map.values());
+    }
+
+    @Override
+    public Map<String, String> partition_name_to_spec(String part_name) throws TException {
+      if (part_name.length() == 0) {
+        return new HashMap<>();
+      }
+      return Warehouse.makeSpecFromName(part_name);
+    }
+
+    private String lowerCaseConvertPartName(String partName) throws MetaException {
+      if (partName == null) return partName;
+      boolean isFirst = true;
+      Map<String, String> partSpec = Warehouse.makeEscSpecFromName(partName);
+      String convertedPartName = new String();
+
+      for (Map.Entry<String, String> entry : partSpec.entrySet()) {
+        String partColName = entry.getKey();
+        String partColVal = entry.getValue();
+
+        if (!isFirst) {
+          convertedPartName += "/";
+        } else {
+          isFirst = false;
+        }
+        convertedPartName += partColName.toLowerCase() + "=" + partColVal;
+      }
+      return convertedPartName;
+    }
+
+    @Override
+    @Deprecated
+    public ColumnStatistics get_table_column_statistics(String dbName, String tableName,
+      String colName) throws TException {
+      String[] parsedDbName = parseDbName(dbName, conf);
+      parsedDbName[CAT_NAME] = parsedDbName[CAT_NAME].toLowerCase();
+      parsedDbName[DB_NAME] = parsedDbName[DB_NAME].toLowerCase();
+      tableName = tableName.toLowerCase();
+      colName = colName.toLowerCase();
+      startFunction("get_column_statistics_by_table", ": table=" +
+          TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+              tableName) + " column=" + colName);
+      ColumnStatistics statsObj = null;
+      try {
+        statsObj = getMS().getTableColumnStatistics(
+            parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName, Lists.newArrayList(colName),
+            "hive", null);
+        if (statsObj != null) {
+          assert statsObj.getStatsObjSize() <= 1;
+        }
+        return statsObj;
+      } finally {
+        endFunction("get_column_statistics_by_table", statsObj != null, null, tableName);
+      }
+    }
+
+    @Override
+    public TableStatsResult get_table_statistics_req(TableStatsRequest request) throws TException {
+      String catName = request.isSetCatName() ? request.getCatName().toLowerCase() :
+          getDefaultCatalog(conf);
+      String dbName = request.getDbName().toLowerCase();
+      String tblName = request.getTblName().toLowerCase();
+      startFunction("get_table_statistics_req", ": table=" +
+          TableName.getQualified(catName, dbName, tblName));
+      TableStatsResult result = null;
+      List<String> lowerCaseColNames = new ArrayList<>(request.getColNames().size());
+      for (String colName : request.getColNames()) {
+        lowerCaseColNames.add(colName.toLowerCase());
+      }
+      try {
+        ColumnStatistics cs = getMS().getTableColumnStatistics(
+            catName, dbName, tblName, lowerCaseColNames,
+            request.getEngine(), request.getValidWriteIdList());
+        // Note: stats compliance is not propagated to the client; instead, we just return nothing
+        //       if stats are not compliant for now. This won't work for stats merging, but that
+        //       is currently only done on metastore size (see set_aggr...).
+        //       For some optimizations we might make use of incorrect stats that are "better than
+        //       nothing", so this may change in future.
+        result = new TableStatsResult((cs == null || cs.getStatsObj() == null
+            || (cs.isSetIsStatsCompliant() && !cs.isIsStatsCompliant()))
+            ? Lists.newArrayList() : cs.getStatsObj());
+      } finally {
+        endFunction("get_table_statistics_req", result == null, null, tblName);
+      }
+      return result;
+    }
+
+    @Override
+    @Deprecated
+    public ColumnStatistics get_partition_column_statistics(String dbName, String tableName,
+      String partName, String colName) throws TException {
+      // Note: this method appears to be unused within Hive.
+      //       It doesn't take txn stats into account.
+      dbName = dbName.toLowerCase();
+      String[] parsedDbName = parseDbName(dbName, conf);
+      tableName = tableName.toLowerCase();
+      colName = colName.toLowerCase();
+      String convertedPartName = lowerCaseConvertPartName(partName);
+      startFunction("get_column_statistics_by_partition", ": table=" +
+          TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+          tableName) + " partition=" + convertedPartName + " column=" + colName);
+      ColumnStatistics statsObj = null;
+
+      try {
+        List<ColumnStatistics> list = getMS().getPartitionColumnStatistics(
+            parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName,
+            Lists.newArrayList(convertedPartName), Lists.newArrayList(colName),
+            "hive");
+        if (list.isEmpty()) {
+          return null;
+        }
+        if (list.size() != 1) {
+          throw new MetaException(list.size() + " statistics for single column and partition");
+        }
+        statsObj = list.get(0);
+      } finally {
+        endFunction("get_column_statistics_by_partition", statsObj != null, null, tableName);
+      }
+      return statsObj;
+    }
+
+    @Override
+    public PartitionsStatsResult get_partitions_statistics_req(PartitionsStatsRequest request)
+        throws TException {
+      String catName = request.isSetCatName() ? request.getCatName().toLowerCase() : getDefaultCatalog(conf);
+      String dbName = request.getDbName().toLowerCase();
+      String tblName = request.getTblName().toLowerCase();
+      startFunction("get_partitions_statistics_req", ": table=" +
+          TableName.getQualified(catName, dbName, tblName));
+
+      PartitionsStatsResult result = null;
+      List<String> lowerCaseColNames = new ArrayList<>(request.getColNames().size());
+      for (String colName : request.getColNames()) {
+        lowerCaseColNames.add(colName.toLowerCase());
+      }
+      List<String> lowerCasePartNames = new ArrayList<>(request.getPartNames().size());
+      for (String partName : request.getPartNames()) {
+        lowerCasePartNames.add(lowerCaseConvertPartName(partName));
+      }
+      try {
+        List<ColumnStatistics> stats = getMS().getPartitionColumnStatistics(
+            catName, dbName, tblName, lowerCasePartNames, lowerCaseColNames,
+            request.getEngine(), request.isSetValidWriteIdList() ? request.getValidWriteIdList() : null);
+        Map<String, List<ColumnStatisticsObj>> map = new HashMap<>();
+        if (stats != null) {
+          for (ColumnStatistics stat : stats) {
+            // Note: stats compliance is not propagated to the client; instead, we just return nothing
+            //       if stats are not compliant for now. This won't work for stats merging, but that
+            //       is currently only done on metastore size (see set_aggr...).
+            //       For some optimizations we might make use of incorrect stats that are "better than
+            //       nothing", so this may change in future.
+            if (stat.isSetIsStatsCompliant() && !stat.isIsStatsCompliant()) continue;
+            map.put(stat.getStatsDesc().getPartName(), stat.getStatsObj());
+          }
+        }
+        result = new PartitionsStatsResult(map);
+      } finally {
+        endFunction("get_partitions_statistics_req", result == null, null, tblName);
+      }
+      return result;
+    }
+
+    @Override
+    public boolean update_table_column_statistics(ColumnStatistics colStats) throws TException {
+      // Deprecated API, won't work for transactional tables
+      return updateTableColumnStatsInternal(colStats, null, -1);
+    }
+
+    @Override
+    public SetPartitionsStatsResponse update_table_column_statistics_req(
+        SetPartitionsStatsRequest req) throws NoSuchObjectException,
+        InvalidObjectException, MetaException, InvalidInputException,
+        TException {
+      if (req.getColStatsSize() != 1) {
+        throw new InvalidInputException("Only one stats object expected");
+      }
+      if (req.isNeedMerge()) {
+        throw new InvalidInputException("Merge is not supported for non-aggregate stats");
+      }
+      ColumnStatistics colStats = req.getColStatsIterator().next();
+      boolean ret = updateTableColumnStatsInternal(colStats,
+          req.getValidWriteIdList(), req.getWriteId());
+      return new SetPartitionsStatsResponse(ret);
+    }
+
+    private boolean updateTableColumnStatsInternal(ColumnStatistics colStats,
+        String validWriteIds, long writeId)
+        throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException {
+      normalizeColStatsInput(colStats);
+
+      startFunction("write_column_statistics", ":  table=" + TableName.getQualified(
+          colStats.getStatsDesc().getCatName(), colStats.getStatsDesc().getDbName(),
+          colStats.getStatsDesc().getTableName()));
+
+      Map<String, String> parameters = null;
+      getMS().openTransaction();
+      boolean committed = false;
+      try {
+        parameters = getMS().updateTableColumnStatistics(colStats, validWriteIds, writeId);
+        if (parameters != null) {
+          Table tableObj = getMS().getTable(colStats.getStatsDesc().getCatName(),
+                                            colStats.getStatsDesc().getDbName(),
+                                            colStats.getStatsDesc().getTableName(), validWriteIds);
+          if (transactionalListeners != null && !transactionalListeners.isEmpty()) {
+            MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                    EventType.UPDATE_TABLE_COLUMN_STAT,
+                    new UpdateTableColumnStatEvent(colStats, tableObj, parameters,
+                            writeId, this));
+          }
+          if (!listeners.isEmpty()) {
+            MetaStoreListenerNotifier.notifyEvent(listeners,
+                    EventType.UPDATE_TABLE_COLUMN_STAT,
+                    new UpdateTableColumnStatEvent(colStats, tableObj, parameters,
+                            writeId,this));
+          }
+        }
+        committed = getMS().commitTransaction();
+      } finally {
+        if (!committed) {
+          getMS().rollbackTransaction();
+        }
+        endFunction("write_column_statistics", parameters != null, null,
+            colStats.getStatsDesc().getTableName());
+      }
+
+      return parameters != null;
+    }
+
+    private void normalizeColStatsInput(ColumnStatistics colStats) throws MetaException {
+      // TODO: is this really needed? this code is propagated from HIVE-1362 but most of it is useless.
+      ColumnStatisticsDesc statsDesc = colStats.getStatsDesc();
+      statsDesc.setCatName(statsDesc.isSetCatName() ? statsDesc.getCatName().toLowerCase() : getDefaultCatalog(conf));
+      statsDesc.setDbName(statsDesc.getDbName().toLowerCase());
+      statsDesc.setTableName(statsDesc.getTableName().toLowerCase());
+      statsDesc.setPartName(lowerCaseConvertPartName(statsDesc.getPartName()));
+      long time = System.currentTimeMillis() / 1000;
+      statsDesc.setLastAnalyzed(time);
+
+      for (ColumnStatisticsObj statsObj : colStats.getStatsObj()) {
+        statsObj.setColName(statsObj.getColName().toLowerCase());
+        statsObj.setColType(statsObj.getColType().toLowerCase());
+      }
+      colStats.setStatsDesc(statsDesc);
+      colStats.setStatsObj(colStats.getStatsObj());
+    }
+
+    private boolean updatePartitonColStatsInternal(Table tbl, ColumnStatistics colStats,
+        String validWriteIds, long writeId)
+        throws MetaException, InvalidObjectException, NoSuchObjectException, InvalidInputException {
+      normalizeColStatsInput(colStats);
+
+      ColumnStatisticsDesc csd = colStats.getStatsDesc();
+      String catName = csd.getCatName(), dbName = csd.getDbName(), tableName = csd.getTableName();
+      startFunction("write_partition_column_statistics", ":  db=" + dbName  + " table=" + tableName
+              + " part=" + csd.getPartName());
+
+      boolean ret = false;
+
+      Map<String, String> parameters;
+      List<String> partVals;
+      boolean committed = false;
+      getMS().openTransaction();
+      try {
+        if (tbl == null) {
+          tbl = getTable(catName, dbName, tableName);
+        }
+        partVals = getPartValsFromName(tbl, csd.getPartName());
+        parameters = getMS().updatePartitionColumnStatistics(colStats, partVals, validWriteIds, writeId);
+        if (parameters != null) {
+          if (transactionalListeners != null && !transactionalListeners.isEmpty()) {
+            MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+              EventType.UPDATE_PARTITION_COLUMN_STAT,
+              new UpdatePartitionColumnStatEvent(colStats, partVals, parameters, tbl,
+                      writeId, this));
+          }
+          if (!listeners.isEmpty()) {
+            MetaStoreListenerNotifier.notifyEvent(listeners,
+              EventType.UPDATE_PARTITION_COLUMN_STAT,
+              new UpdatePartitionColumnStatEvent(colStats, partVals, parameters, tbl,
+                      writeId, this));
+          }
+        }
+        committed = getMS().commitTransaction();
+      } finally {
+        if (!committed) {
+          getMS().rollbackTransaction();
+        }
+        endFunction("write_partition_column_statistics", ret != false, null, tableName);
+      }
+
+      return parameters != null;
+    }
+
+    @Override
+    public boolean update_partition_column_statistics(ColumnStatistics colStats) throws TException {
+      // Deprecated API.
+      return updatePartitonColStatsInternal(null, colStats, null, -1);
+    }
+
+
+    @Override
+    public SetPartitionsStatsResponse update_partition_column_statistics_req(
+        SetPartitionsStatsRequest req) throws NoSuchObjectException,
+        InvalidObjectException, MetaException, InvalidInputException,
+        TException {
+      if (req.getColStatsSize() != 1) {
+        throw new InvalidInputException("Only one stats object expected");
+      }
+      if (req.isNeedMerge()) {
+        throw new InvalidInputException("Merge is not supported for non-aggregate stats");
+      }
+      ColumnStatistics colStats = req.getColStatsIterator().next();
+      boolean ret = updatePartitonColStatsInternal(null, colStats,
+          req.getValidWriteIdList(), req.getWriteId());
+      return new SetPartitionsStatsResponse(ret);
+    }
+
+    @Override
+    public boolean delete_partition_column_statistics(String dbName, String tableName,
+        String partName, String colName, String engine) throws TException {
+      dbName = dbName.toLowerCase();
+      String[] parsedDbName = parseDbName(dbName, conf);
+      tableName = tableName.toLowerCase();
+      if (colName != null) {
+        colName = colName.toLowerCase();
+      }
+      String convertedPartName = lowerCaseConvertPartName(partName);
+      startFunction("delete_column_statistics_by_partition",": table=" +
+          TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName) +
+          " partition=" + convertedPartName + " column=" + colName);
+      boolean ret = false, committed = false;
+
+      getMS().openTransaction();
+      try {
+        List<String> partVals = getPartValsFromName(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName, convertedPartName);
+        Table table = getMS().getTable(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName);
+        // This API looks unused; if it were used we'd need to update stats state and write ID.
+        // We cannot just randomly nuke some txn stats.
+        if (TxnUtils.isTransactionalTable(table)) {
+          throw new MetaException("Cannot delete stats via this API for a transactional table");
+        }
+
+        ret = getMS().deletePartitionColumnStatistics(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName,
+            convertedPartName, partVals, colName, engine);
+        if (ret) {
+          if (transactionalListeners != null && !transactionalListeners.isEmpty()) {
+            MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                    EventType.DELETE_PARTITION_COLUMN_STAT,
+                    new DeletePartitionColumnStatEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName,
+                            convertedPartName, partVals, colName, engine, this));
+          }
+          if (!listeners.isEmpty()) {
+            MetaStoreListenerNotifier.notifyEvent(listeners,
+                    EventType.DELETE_PARTITION_COLUMN_STAT,
+                    new DeletePartitionColumnStatEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName,
+                            convertedPartName, partVals, colName, engine, this));
+          }
+        }
+        committed = getMS().commitTransaction();
+      } finally {
+        if (!committed) {
+          getMS().rollbackTransaction();
+        }
+        endFunction("delete_column_statistics_by_partition", ret != false, null, tableName);
+      }
+      return ret;
+    }
+
+    @Override
+    public boolean delete_table_column_statistics(String dbName, String tableName, String colName, String engine)
+        throws TException {
+      dbName = dbName.toLowerCase();
+      tableName = tableName.toLowerCase();
+
+      String[] parsedDbName = parseDbName(dbName, conf);
+
+      if (colName != null) {
+        colName = colName.toLowerCase();
+      }
+      startFunction("delete_column_statistics_by_table", ": table=" +
+          TableName.getQualified(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName) + " column=" +
+          colName);
+
+
+      boolean ret = false, committed = false;
+      getMS().openTransaction();
+      try {
+        Table table = getMS().getTable(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName);
+        // This API looks unused; if it were used we'd need to update stats state and write ID.
+        // We cannot just randomly nuke some txn stats.
+        if (TxnUtils.isTransactionalTable(table)) {
+          throw new MetaException("Cannot delete stats via this API for a transactional table");
+        }
+
+        ret = getMS().deleteTableColumnStatistics(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName, colName, engine);
+        if (ret) {
+          if (transactionalListeners != null && !transactionalListeners.isEmpty()) {
+            MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                    EventType.DELETE_TABLE_COLUMN_STAT,
+                    new DeleteTableColumnStatEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+                            tableName, colName, engine, this));
+          }
+          if (!listeners.isEmpty()) {
+            MetaStoreListenerNotifier.notifyEvent(listeners,
+                    EventType.DELETE_TABLE_COLUMN_STAT,
+                    new DeleteTableColumnStatEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+                            tableName, colName, engine, this));
+          }
+        }
+        committed = getMS().commitTransaction();
+      } finally {
+        if (!committed) {
+          getMS().rollbackTransaction();
+        }
+        endFunction("delete_column_statistics_by_table", ret != false, null, tableName);
+      }
+      return ret;
+    }
+
+    @Override
+    @Deprecated
+    public List<Partition> get_partitions_by_filter(final String dbName, final String tblName,
+                                                    final String filter, final short maxParts)
+        throws TException {
+      String[] parsedDbName = parseDbName(dbName, conf);
+      startTableFunction("get_partitions_by_filter", parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+          tblName);
+      fireReadTablePreEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName);
+      List<Partition> ret = null;
+      Exception ex = null;
+      try {
+        checkLimitNumberOfPartitionsByFilter(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+            tblName, filter, maxParts);
+
+        authorizeTableForPartitionMetadata(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName);
+
+        ret = getMS().getPartitionsByFilter(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName,
+            filter, maxParts);
+        ret = FilterUtils.filterPartitionsIfEnabled(isServerFilterEnabled, filterHook, ret);
+      } catch (Exception e) {
+        ex = e;
+        rethrowException(e);
+      } finally {
+        endFunction("get_partitions_by_filter", ret != null, ex, tblName);
+      }
+      return ret;
+    }
+
+    @Override
+    @Deprecated
+    public List<PartitionSpec> get_part_specs_by_filter(final String dbName, final String tblName,
+                                                        final String filter, final int maxParts)
+        throws TException {
+
+      String[] parsedDbName = parseDbName(dbName, conf);
+      startTableFunction("get_partitions_by_filter_pspec", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName);
+
+      List<PartitionSpec> partitionSpecs = null;
+      try {
+        Table table = get_table_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblName);
+        // Don't pass the parsed db name, as get_partitions_by_filter will parse it itself
+        List<Partition> partitions = get_partitions_by_filter(dbName, tblName, filter, (short) maxParts);
+
+        if (is_partition_spec_grouping_enabled(table)) {
+          partitionSpecs = MetaStoreServerUtils
+              .getPartitionspecsGroupedByStorageDescriptor(table, partitions);
+        }
+        else {
+          PartitionSpec pSpec = new PartitionSpec();
+          pSpec.setPartitionList(new PartitionListComposingSpec(partitions));
+          pSpec.setRootPath(table.getSd().getLocation());
+          pSpec.setCatName(parsedDbName[CAT_NAME]);
+          pSpec.setDbName(parsedDbName[DB_NAME]);
+          pSpec.setTableName(tblName);
+          partitionSpecs = Arrays.asList(pSpec);
+        }
+
+        return partitionSpecs;
+      }
+      finally {
+        endFunction("get_partitions_by_filter_pspec", partitionSpecs != null && !partitionSpecs.isEmpty(), null, tblName);
+      }
+    }
+
+    @Override
+    public PartitionsSpecByExprResult get_partitions_spec_by_expr(
+        PartitionsByExprRequest req) throws TException {
+      String dbName = req.getDbName(), tblName = req.getTblName();
+      String catName = req.isSetCatName() ? req.getCatName() : getDefaultCatalog(conf);
+      startTableFunction("get_partitions_spec_by_expr", catName, dbName, tblName);
+      fireReadTablePreEvent(catName, dbName, tblName);
+      PartitionsSpecByExprResult ret = null;
+      Exception ex = null;
+      try {
+        checkLimitNumberOfPartitionsByExpr(catName, dbName, tblName, req.getExpr(), UNLIMITED_MAX_PARTITIONS);
+        List<Partition> partitions = new LinkedList<>();
+        boolean hasUnknownPartitions = getMS().getPartitionsByExpr(catName, dbName, tblName,
+            req.getExpr(), req.getDefaultPartitionName(), req.getMaxParts(), partitions);
+        Table table = get_table_core(catName, dbName, tblName);
+        List<PartitionSpec> partitionSpecs =
+            MetaStoreServerUtils.getPartitionspecsGroupedByStorageDescriptor(table, partitions);
+        ret = new PartitionsSpecByExprResult(partitionSpecs, hasUnknownPartitions);
+      } catch (Exception e) {
+        ex = e;
+        rethrowException(e);
+      } finally {
+        endFunction("get_partitions_spec_by_expr", ret != null, ex, tblName);
+      }
+      return ret;
+    }
+
+    @Override
+    public PartitionsByExprResult get_partitions_by_expr(
+        PartitionsByExprRequest req) throws TException {
+      String dbName = req.getDbName(), tblName = req.getTblName();
+      String catName = req.isSetCatName() ? req.getCatName() : getDefaultCatalog(conf);
+      startTableFunction("get_partitions_by_expr", catName, dbName, tblName);
+      fireReadTablePreEvent(catName, dbName, tblName);
+      PartitionsByExprResult ret = null;
+      Exception ex = null;
+      try {
+        checkLimitNumberOfPartitionsByExpr(catName, dbName, tblName, req.getExpr(), UNLIMITED_MAX_PARTITIONS);
+        List<Partition> partitions = new LinkedList<>();
+        boolean hasUnknownPartitions = getMS().getPartitionsByExpr(catName, dbName, tblName,
+            req.getExpr(), req.getDefaultPartitionName(), req.getMaxParts(), partitions);
+        ret = new PartitionsByExprResult(partitions, hasUnknownPartitions);
+      } catch (Exception e) {
+        ex = e;
+        rethrowException(e);
+      } finally {
+        endFunction("get_partitions_by_expr", ret != null, ex, tblName);
+      }
+      return ret;
+    }
+
+    private void rethrowException(Exception e) throws TException {
+      // TODO: Both of these are TException, why do we need these separate clauses?
+      if (e instanceof MetaException) {
+        throw (MetaException) e;
+      } else if (e instanceof NoSuchObjectException) {
+        throw (NoSuchObjectException) e;
+      } else if (e instanceof TException) {
+        throw (TException) e;
+      } else {
+        throw newMetaException(e);
+      }
+    }
+
+    @Override
+    @Deprecated
+    public int get_num_partitions_by_filter(final String dbName,
+                                            final String tblName, final String filter)
+            throws TException {
+      String[] parsedDbName = parseDbName(dbName, conf);
+      if (parsedDbName[DB_NAME] == null || tblName == null) {
+        throw new MetaException("The DB and table name cannot be null.");
+      }
+      startTableFunction("get_num_partitions_by_filter", parsedDbName[CAT_NAME],
+          parsedDbName[DB_NAME], tblName);
+
+      int ret = -1;
+      Exception ex = null;
+      try {
+        ret = getMS().getNumPartitionsByFilter(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+            tblName, filter);
+      } catch (Exception e) {
+        ex = e;
+        rethrowException(e);
+      } finally {
+        endFunction("get_num_partitions_by_filter", ret != -1, ex, tblName);
+      }
+      return ret;
+    }
+
+    private int get_num_partitions_by_expr(final String catName, final String dbName,
+                                           final String tblName, final byte[] expr)
+        throws TException {
+      int ret = -1;
+      Exception ex = null;
+      try {
+        ret = getMS().getNumPartitionsByExpr(catName, dbName, tblName, expr);
+      } catch (Exception e) {
+        ex = e;
+        rethrowException(e);
+      } finally {
+        endFunction("get_num_partitions_by_expr", ret != -1, ex, tblName);
+      }
+      return ret;
+    }
+
+    @Override
+    @Deprecated
+    public List<Partition> get_partitions_by_names(final String dbName, final String tblName,
+                                                   final List<String> partNames)
+            throws TException {
+      return get_partitions_by_names(dbName, tblName, partNames);
+    }
+
+    @Override
+    public GetPartitionsByNamesResult get_partitions_by_names_req(GetPartitionsByNamesRequest gpbnr)
+            throws TException {
+      List<Partition> partitions = get_partitions_by_names(gpbnr.getDb_name(),
+              gpbnr.getTbl_name(), gpbnr.getNames(),
+              gpbnr.isSetGet_col_stats() && gpbnr.isGet_col_stats(), gpbnr.getEngine(),
+              gpbnr.getProcessorCapabilities(), gpbnr.getProcessorIdentifier());
+      return new GetPartitionsByNamesResult(partitions);
+    }
+
+    public List<Partition> get_partitions_by_names(final String dbName, final String tblName,
+           final List<String> partNames, boolean getColStats, String engine, String validWriteIdList)
+        throws TException {
+      return get_partitions_by_names(
+          dbName, tblName, partNames, getColStats, engine, null, null);
+    }
+
+    public List<Partition> get_partitions_by_names(final String dbName, final String tblName,
+           final List<String> partNames, boolean getColStats, String engine,
+           List<String> processorCapabilities, String processorId) throws TException {
+
+      String[] dbNameParts = parseDbName(dbName, conf);
+      String parsedCatName = dbNameParts[CAT_NAME];
+      String parsedDbName = dbNameParts[DB_NAME];
+      List<Partition> ret = null;
+      Table table = null;
+      Exception ex = null;
+      boolean success = false;
+      startTableFunction("get_partitions_by_names", parsedCatName, parsedDbName,
+              tblName);
+      try {
+        getMS().openTransaction();
+        authorizeTableForPartitionMetadata(parsedCatName, parsedDbName, tblName);
+
+        fireReadTablePreEvent(parsedCatName, parsedDbName, tblName);
+
+        ret = getMS().getPartitionsByNames(parsedCatName, parsedDbName, tblName, partNames);
+        ret = FilterUtils.filterPartitionsIfEnabled(isServerFilterEnabled, filterHook, ret);
+        table = getTable(parsedCatName, parsedDbName, tblName);
+
+        // If requested add column statistics in each of the partition objects
+        if (getColStats) {
+          // Since each partition may have stats collected for different set of columns, we
+          // request them separately.
+          for (Partition part: ret) {
+            String partName = Warehouse.makePartName(table.getPartitionKeys(), part.getValues());
+            List<ColumnStatistics> partColStatsList =
+                    getMS().getPartitionColumnStatistics(parsedCatName, parsedDbName, tblName,
+                            Collections.singletonList(partName),
+                            StatsSetupConst.getColumnsHavingStats(part.getParameters()),
+                            engine);
+            if (partColStatsList != null && !partColStatsList.isEmpty()) {
+              ColumnStatistics partColStats = partColStatsList.get(0);
+              if (partColStats != null) {
+                part.setColStats(partColStats);
+              }
+            }
+          }
+        }
+
+        if (processorCapabilities == null || processorCapabilities.size() == 0 ||
+              processorCapabilities.contains("MANAGERAWMETADATA")) {
+          LOG.info("Skipping translation for processor with " + processorId);
+        } else {
+          if (transformer != null) {
+            ret = transformer.transformPartitions(ret, table, processorCapabilities, processorId);
+          }
+        }
+        success = getMS().commitTransaction();
+      } catch (Exception e) {
+        ex = e;
+        rethrowException(e);
+      } finally {
+        if (!success) {
+          getMS().rollbackTransaction();
+        }
+        endFunction("get_partitions_by_names", ret != null, ex, tblName);
+      }
+      return ret;
+    }
+
+    @Override
+    public PrincipalPrivilegeSet get_privilege_set(HiveObjectRef hiveObject, String userName,
+                                                   List<String> groupNames) throws TException {
+      firePreEvent(new PreAuthorizationCallEvent(this));
+      String catName = hiveObject.isSetCatName() ? hiveObject.getCatName() : getDefaultCatalog(conf);
+      if (hiveObject.getObjectType() == HiveObjectType.COLUMN) {
+        String partName = getPartName(hiveObject);
+        return this.get_column_privilege_set(catName, hiveObject.getDbName(), hiveObject
+            .getObjectName(), partName, hiveObject.getColumnName(), userName,
+            groupNames);
+      } else if (hiveObject.getObjectType() == HiveObjectType.PARTITION) {
+        String partName = getPartName(hiveObject);
+        return this.get_partition_privilege_set(catName, hiveObject.getDbName(),
+            hiveObject.getObjectName(), partName, userName, groupNames);
+      } else if (hiveObject.getObjectType() == HiveObjectType.DATABASE) {
+        return this.get_db_privilege_set(catName, hiveObject.getDbName(), userName,
+            groupNames);
+      } else if (hiveObject.getObjectType() == HiveObjectType.TABLE) {
+        return this.get_table_privilege_set(catName, hiveObject.getDbName(), hiveObject
+            .getObjectName(), userName, groupNames);
+      } else if (hiveObject.getObjectType() == HiveObjectType.GLOBAL) {
+        return this.get_user_privilege_set(userName, groupNames);
+      }
+      return null;
+    }
+
+    private String getPartName(HiveObjectRef hiveObject) throws MetaException {
+      String partName = null;
+      List<String> partValue = hiveObject.getPartValues();
+      if (partValue != null && partValue.size() > 0) {
+        try {
+          String catName = hiveObject.isSetCatName() ? hiveObject.getCatName() :
+              getDefaultCatalog(conf);
+          Table table = get_table_core(catName, hiveObject.getDbName(), hiveObject
+              .getObjectName());
+          partName = Warehouse
+              .makePartName(table.getPartitionKeys(), partValue);
+        } catch (NoSuchObjectException e) {
+          throw new MetaException(e.getMessage());
+        }
+      }
+      return partName;
+    }
+
+    private PrincipalPrivilegeSet get_column_privilege_set(String catName, final String dbName,
+        final String tableName, final String partName, final String columnName,
+        final String userName, final List<String> groupNames) throws TException {
+      incrementCounter("get_column_privilege_set");
+
+      PrincipalPrivilegeSet ret;
+      try {
+        ret = getMS().getColumnPrivilegeSet(
+            catName, dbName, tableName, partName, columnName, userName, groupNames);
+      } catch (MetaException e) {
+        throw e;
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
+      return ret;
+    }
+
+    private PrincipalPrivilegeSet get_db_privilege_set(String catName, final String dbName,
+        final String userName, final List<String> groupNames) throws TException {
+      incrementCounter("get_db_privilege_set");
+
+      PrincipalPrivilegeSet ret;
+      try {
+        ret = getMS().getDBPrivilegeSet(catName, dbName, userName, groupNames);
+      } catch (MetaException e) {
+        throw e;
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
+      return ret;
+    }
+
+    private PrincipalPrivilegeSet get_partition_privilege_set(
+        String catName, final String dbName, final String tableName, final String partName,
+        final String userName, final List<String> groupNames)
+        throws TException {
+      incrementCounter("get_partition_privilege_set");
+
+      PrincipalPrivilegeSet ret;
+      try {
+        ret = getMS().getPartitionPrivilegeSet(catName, dbName, tableName, partName,
+            userName, groupNames);
+      } catch (MetaException e) {
+        throw e;
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
+      return ret;
+    }
+
+    private PrincipalPrivilegeSet get_table_privilege_set(String catName, final String dbName,
+        final String tableName, final String userName,
+        final List<String> groupNames) throws TException {
+      incrementCounter("get_table_privilege_set");
+
+      PrincipalPrivilegeSet ret;
+      try {
+        ret = getMS().getTablePrivilegeSet(catName, dbName, tableName, userName,
+            groupNames);
+      } catch (MetaException e) {
+        throw e;
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
+      return ret;
+    }
+
+    @Override
+    public boolean grant_role(final String roleName,
+        final String principalName, final PrincipalType principalType,
+        final String grantor, final PrincipalType grantorType, final boolean grantOption)
+        throws TException {
+      incrementCounter("add_role_member");
+      firePreEvent(new PreAuthorizationCallEvent(this));
+      if (PUBLIC.equals(roleName)) {
+        throw new MetaException("No user can be added to " + PUBLIC +". Since all users implicitly"
+        + " belong to " + PUBLIC + " role.");
+      }
+      Boolean ret;
+      try {
+        RawStore ms = getMS();
+        Role role = ms.getRole(roleName);
+        if(principalType == PrincipalType.ROLE){
+          //check if this grant statement will end up creating a cycle
+          if(isNewRoleAParent(principalName, roleName)){
+            throw new MetaException("Cannot grant role " + principalName + " to " + roleName +
+                " as " + roleName + " already belongs to the role " + principalName +
+                ". (no cycles allowed)");
+          }
+        }
+        ret = ms.grantRole(role, principalName, principalType, grantor, grantorType, grantOption);
+      } catch (MetaException e) {
+        throw e;
+      } catch (InvalidObjectException | NoSuchObjectException e) {
+        ret = false;
+        MetaStoreUtils.logAndThrowMetaException(e);
+      } catch (Exception e) {
+        throw new TException(e);
+      }
+      return ret;
+    }
+
+
+
+    /**
+     * Check if newRole is in parent hierarchy of curRole
+     * @param newRole
+     * @param curRole
+     * @return true if newRole is curRole or present in its hierarchy
+     * @throws MetaException
+     */
+    private boolean isNewRoleAParent(String newRole, String curRole) throws MetaException {
+      if(newRole.equals(curRole)){
+        return true;
+      }
+      //do this check recursively on all the parent roles of curRole
+      List<Role> parentRoleMaps = getMS().listRoles(curRole, PrincipalType.ROLE);
+      for(Role parentRole : parentRoleMaps){
+        if(isNewRoleAParent(newRole, parentRole.getRoleName())){
+          return true;
+        }
+      }
+      return false;
+    }
+
+    @Override
+    public List<Role> list_roles(final String principalName,
+        final PrincipalType principalType) throws TException {
+      incrementCounter("list_roles");
+      firePreEvent(new PreAuthorizationCallEvent(this));
+      return getMS().listRoles(principalName, principalType);
+    }
+
+    @Override
+    public boolean create_role(final Role role) throws TException {
+      incrementCounter("create_role");
+      firePreEvent(new PreAuthorizationCallEvent(this));
+      if (PUBLIC.equals(role.getRoleName())) {
+         throw new MetaException(PUBLIC + " role implicitly exists. It can't be created.");
+      }
+      Boolean ret;
+      try {
+        ret = getMS().addRole(role.getRoleName(), role.getOwnerName());
+      } catch (MetaException e) {
+        throw e;
+      } catch (InvalidObjectException | NoSuchObjectException e) {
+        ret = false;
+        MetaStoreUtils.logAndThrowMetaException(e);
+      } catch (Exception e) {
+        throw new TException(e);
+      }
+      return ret;
+    }
+
+    @Override
+    public boolean drop_role(final String roleName) throws TException {
+      incrementCounter("drop_role");
+      firePreEvent(new PreAuthorizationCallEvent(this));
+      if (ADMIN.equals(roleName) || PUBLIC.equals(roleName)) {
+        throw new MetaException(PUBLIC + "," + ADMIN + " roles can't be dropped.");
+      }
+      Boolean ret;
+      try {
+        ret = getMS().removeRole(roleName);
+      } catch (MetaException e) {
+        throw e;
+      } catch (NoSuchObjectException e) {
+        ret = false;
+        MetaStoreUtils.logAndThrowMetaException(e);
+      } catch (Exception e) {
+        throw new TException(e);
+      }
+      return ret;
+    }
+
+    @Override
+    public List<String> get_role_names() throws TException {
+      incrementCounter("get_role_names");
+      firePreEvent(new PreAuthorizationCallEvent(this));
+      List<String> ret;
+      try {
+        ret = getMS().listRoleNames();
+        return ret;
+      } catch (MetaException e) {
+        throw e;
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
+    }
+
+    @Override
+    public boolean grant_privileges(final PrivilegeBag privileges) throws TException {
+      incrementCounter("grant_privileges");
+      firePreEvent(new PreAuthorizationCallEvent(this));
+      Boolean ret;
+      try {
+        ret = getMS().grantPrivileges(privileges);
+      } catch (MetaException e) {
+        throw e;
+      } catch (InvalidObjectException | NoSuchObjectException e) {
+        ret = false;
+        MetaStoreUtils.logAndThrowMetaException(e);
+      } catch (Exception e) {
+        throw new TException(e);
+      }
+      return ret;
+    }
+
+    @Override
+    public boolean revoke_role(final String roleName, final String userName,
+        final PrincipalType principalType) throws TException {
+      return revoke_role(roleName, userName, principalType, false);
+    }
+
+    private boolean revoke_role(final String roleName, final String userName,
+        final PrincipalType principalType, boolean grantOption) throws TException {
+      incrementCounter("remove_role_member");
+      firePreEvent(new PreAuthorizationCallEvent(this));
+      if (PUBLIC.equals(roleName)) {
+        throw new MetaException(PUBLIC + " role can't be revoked.");
+      }
+      Boolean ret;
+      try {
+        RawStore ms = getMS();
+        Role mRole = ms.getRole(roleName);
+        ret = ms.revokeRole(mRole, userName, principalType, grantOption);
+      } catch (MetaException e) {
+        throw e;
+      } catch (NoSuchObjectException e) {
+        ret = false;
+        MetaStoreUtils.logAndThrowMetaException(e);
+      } catch (Exception e) {
+        throw new TException(e);
+      }
+      return ret;
+    }
+
+    @Override
+    public GrantRevokeRoleResponse grant_revoke_role(GrantRevokeRoleRequest request)
+        throws TException {
+      GrantRevokeRoleResponse response = new GrantRevokeRoleResponse();
+      boolean grantOption = false;
+      if (request.isSetGrantOption()) {
+        grantOption = request.isGrantOption();
+      }
+      switch (request.getRequestType()) {
+        case GRANT: {
+          boolean result = grant_role(request.getRoleName(),
+              request.getPrincipalName(), request.getPrincipalType(),
+              request.getGrantor(), request.getGrantorType(), grantOption);
+          response.setSuccess(result);
+          break;
+        }
+        case REVOKE: {
+          boolean result = revoke_role(request.getRoleName(), request.getPrincipalName(),
+              request.getPrincipalType(), grantOption);
+          response.setSuccess(result);
+          break;
+        }
+        default:
+          throw new MetaException("Unknown request type " + request.getRequestType());
+      }
+
+      return response;
+    }
+
+    @Override
+    public GrantRevokePrivilegeResponse grant_revoke_privileges(GrantRevokePrivilegeRequest request)
+        throws TException {
+      GrantRevokePrivilegeResponse response = new GrantRevokePrivilegeResponse();
+      switch (request.getRequestType()) {
+        case GRANT: {
+          boolean result = grant_privileges(request.getPrivileges());
+          response.setSuccess(result);
+          break;
+        }
+        case REVOKE: {
+          boolean revokeGrantOption = false;
+          if (request.isSetRevokeGrantOption()) {
+            revokeGrantOption = request.isRevokeGrantOption();
+          }
+          boolean result = revoke_privileges(request.getPrivileges(), revokeGrantOption);
+          response.setSuccess(result);
+          break;
+        }
+        default:
+          throw new MetaException("Unknown request type " + request.getRequestType());
+      }
+
+      return response;
+    }
+
+    @Override
+    public GrantRevokePrivilegeResponse refresh_privileges(HiveObjectRef objToRefresh, String authorizer,
+        GrantRevokePrivilegeRequest grantRequest)
+        throws TException {
+      incrementCounter("refresh_privileges");
+      firePreEvent(new PreAuthorizationCallEvent(this));
+      GrantRevokePrivilegeResponse response = new GrantRevokePrivilegeResponse();
+      try {
+        boolean result = getMS().refreshPrivileges(objToRefresh, authorizer, grantRequest.getPrivileges());
+        response.setSuccess(result);
+      } catch (MetaException e) {
+        throw e;
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
+      return response;
+    }
+
+    @Override
+    public boolean revoke_privileges(final PrivilegeBag privileges) throws TException {
+      return revoke_privileges(privileges, false);
+    }
+
+    public boolean revoke_privileges(final PrivilegeBag privileges, boolean grantOption)
+        throws TException {
+      incrementCounter("revoke_privileges");
+      firePreEvent(new PreAuthorizationCallEvent(this));
+      Boolean ret;
+      try {
+        ret = getMS().revokePrivileges(privileges, grantOption);
+      } catch (MetaException e) {
+        throw e;
+      } catch (InvalidObjectException | NoSuchObjectException e) {
+        ret = false;
+        MetaStoreUtils.logAndThrowMetaException(e);
+      } catch (Exception e) {
+        throw new TException(e);
+      }
+      return ret;
+    }
+
+    private PrincipalPrivilegeSet get_user_privilege_set(final String userName,
+        final List<String> groupNames) throws TException {
+      incrementCounter("get_user_privilege_set");
+      PrincipalPrivilegeSet ret;
+      try {
+        ret = getMS().getUserPrivilegeSet(userName, groupNames);
+      } catch (MetaException e) {
+        throw e;
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
+      return ret;
+    }
+
+    @Override
+    public List<HiveObjectPrivilege> list_privileges(String principalName,
+        PrincipalType principalType, HiveObjectRef hiveObject)
+        throws TException {
+      firePreEvent(new PreAuthorizationCallEvent(this));
+      String catName = hiveObject.isSetCatName() ? hiveObject.getCatName() : getDefaultCatalog(conf);
+      if (hiveObject.getObjectType() == null) {
+        return getAllPrivileges(principalName, principalType, catName);
+      }
+      if (hiveObject.getObjectType() == HiveObjectType.GLOBAL) {
+        return list_global_privileges(principalName, principalType);
+      }
+      if (hiveObject.getObjectType() == HiveObjectType.DATABASE) {
+        return list_db_privileges(principalName, principalType, catName, hiveObject
+            .getDbName());
+      }
+      if (hiveObject.getObjectType() == HiveObjectType.TABLE) {
+        return list_table_privileges(principalName, principalType,
+            catName, hiveObject.getDbName(), hiveObject.getObjectName());
+      }
+      if (hiveObject.getObjectType() == HiveObjectType.PARTITION) {
+        return list_partition_privileges(principalName, principalType,
+            catName, hiveObject.getDbName(), hiveObject.getObjectName(), hiveObject
+            .getPartValues());
+      }
+      if (hiveObject.getObjectType() == HiveObjectType.COLUMN) {
+        if (hiveObject.getPartValues() == null || hiveObject.getPartValues().isEmpty()) {
+          return list_table_column_privileges(principalName, principalType,
+              catName, hiveObject.getDbName(), hiveObject.getObjectName(), hiveObject.getColumnName());
+        }
+        return list_partition_column_privileges(principalName, principalType,
+            catName, hiveObject.getDbName(), hiveObject.getObjectName(), hiveObject
+            .getPartValues(), hiveObject.getColumnName());
+      }
+      return null;
+    }
+
+    private List<HiveObjectPrivilege> getAllPrivileges(String principalName,
+        PrincipalType principalType, String catName) throws TException {
+      List<HiveObjectPrivilege> privs = new ArrayList<>();
+      privs.addAll(list_global_privileges(principalName, principalType));
+      privs.addAll(list_db_privileges(principalName, principalType, catName, null));
+      privs.addAll(list_table_privileges(principalName, principalType, catName, null, null));
+      privs.addAll(list_partition_privileges(principalName, principalType, catName, null, null, null));
+      privs.addAll(list_table_column_privileges(principalName, principalType, catName, null, null, null));
+      privs.addAll(list_partition_column_privileges(principalName, principalType,
+          catName, null, null, null, null));
+      return privs;
+    }
+
+    private List<HiveObjectPrivilege> list_table_column_privileges(
+        final String principalName, final PrincipalType principalType, String catName,
+        final String dbName, final String tableName, final String columnName) throws TException {
+      incrementCounter("list_table_column_privileges");
+
+      try {
+        if (dbName == null) {
+          return getMS().listPrincipalTableColumnGrantsAll(principalName, principalType);
+        }
+        if (principalName == null) {
+          return getMS().listTableColumnGrantsAll(catName, dbName, tableName, columnName);
+        }
+        return getMS().listPrincipalTableColumnGrants(principalName, principalType,
+                catName, dbName, tableName, columnName);
+      } catch (MetaException e) {
+        throw e;
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
+    }
+
+    private List<HiveObjectPrivilege> list_partition_column_privileges(
+        final String principalName, final PrincipalType principalType,
+        String catName, final String dbName, final String tableName, final List<String> partValues,
+        final String columnName) throws TException {
+      incrementCounter("list_partition_column_privileges");
+
+      try {
+        if (dbName == null) {
+          return getMS().listPrincipalPartitionColumnGrantsAll(principalName, principalType);
+        }
+        Table tbl = get_table_core(catName, dbName, tableName);
+        String partName = Warehouse.makePartName(tbl.getPartitionKeys(), partValues);
+        if (principalName == null) {
+          return getMS().listPartitionColumnGrantsAll(catName, dbName, tableName, partName, columnName);
+        }
+
+        return getMS().listPrincipalPartitionColumnGrants(principalName, principalType, catName, dbName,
+                tableName, partValues, partName, columnName);
+      } catch (MetaException e) {
+        throw e;
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
+    }
+
+    private List<HiveObjectPrivilege> list_db_privileges(final String principalName,
+        final PrincipalType principalType, String catName, final String dbName) throws TException {
+      incrementCounter("list_security_db_grant");
+
+      try {
+        if (dbName == null) {
+          return getMS().listPrincipalDBGrantsAll(principalName, principalType);
+        }
+        if (principalName == null) {
+          return getMS().listDBGrantsAll(catName, dbName);
+        } else {
+          return getMS().listPrincipalDBGrants(principalName, principalType, catName, dbName);
+        }
+      } catch (MetaException e) {
+        throw e;
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
+    }
+
+    private List<HiveObjectPrivilege> list_partition_privileges(
+        final String principalName, final PrincipalType principalType,
+        String catName, final String dbName, final String tableName, final List<String> partValues)
+        throws TException {
+      incrementCounter("list_security_partition_grant");
+
+      try {
+        if (dbName == null) {
+          return getMS().listPrincipalPartitionGrantsAll(principalName, principalType);
+        }
+        Table tbl = get_table_core(catName, dbName, tableName);
+        String partName = Warehouse.makePartName(tbl.getPartitionKeys(), partValues);
+        if (principalName == null) {
+          return getMS().listPartitionGrantsAll(catName, dbName, tableName, partName);
+        }
+        return getMS().listPrincipalPartitionGrants(
+            principalName, principalType, catName, dbName, tableName, partValues, partName);
+      } catch (MetaException e) {
+        throw e;
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
+    }
+
+    private List<HiveObjectPrivilege> list_table_privileges(
+        final String principalName, final PrincipalType principalType,
+        String catName, final String dbName, final String tableName) throws TException {
+      incrementCounter("list_security_table_grant");
+
+      try {
+        if (dbName == null) {
+          return getMS().listPrincipalTableGrantsAll(principalName, principalType);
+        }
+        if (principalName == null) {
+          return getMS().listTableGrantsAll(catName, dbName, tableName);
+        }
+        return getMS().listAllTableGrants(principalName, principalType, catName, dbName, tableName);
+      } catch (MetaException e) {
+        throw e;
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
+    }
+
+    private List<HiveObjectPrivilege> list_global_privileges(
+        final String principalName, final PrincipalType principalType) throws TException {
+      incrementCounter("list_security_user_grant");
+
+      try {
+        if (principalName == null) {
+          return getMS().listGlobalGrantsAll();
+        }
+        return getMS().listPrincipalGlobalGrants(principalName, principalType);
+      } catch (MetaException e) {
+        throw e;
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
+    }
+
+    @Override
+    public void cancel_delegation_token(String token_str_form) throws TException {
+      startFunction("cancel_delegation_token");
+      boolean success = false;
+      Exception ex = null;
+      try {
+        HiveMetaStore.cancelDelegationToken(token_str_form);
+        success = true;
+      } catch (IOException e) {
+        ex = e;
+        throw new MetaException(e.getMessage());
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("cancel_delegation_token", success, ex);
+      }
+    }
+
+    @Override
+    public long renew_delegation_token(String token_str_form) throws TException {
+      startFunction("renew_delegation_token");
+      Long ret = null;
+      Exception ex = null;
+      try {
+        ret = HiveMetaStore.renewDelegationToken(token_str_form);
+      } catch (IOException e) {
+        ex = e;
+        throw new MetaException(e.getMessage());
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("renew_delegation_token", ret != null, ex);
+      }
+      return ret;
+    }
+
+    @Override
+    public String get_delegation_token(String token_owner, String renewer_kerberos_principal_name)
+        throws TException {
+      startFunction("get_delegation_token");
+      String ret = null;
+      Exception ex = null;
+      try {
+        ret =
+            HiveMetaStore.getDelegationToken(token_owner,
+                renewer_kerberos_principal_name, getIPAddress());
+      } catch (IOException | InterruptedException e) {
+        ex = e;
+        throw new MetaException(e.getMessage());
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_delegation_token", ret != null, ex);
+      }
+      return ret;
+    }
+
+    @Override
+    public boolean add_token(String token_identifier, String delegation_token) throws TException {
+      startFunction("add_token", ": " + token_identifier);
+      boolean ret = false;
+      Exception ex = null;
+      try {
+        ret = getMS().addToken(token_identifier, delegation_token);
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("add_token", ret == true, ex);
+      }
+      return ret;
+    }
+
+    @Override
+    public boolean remove_token(String token_identifier) throws TException {
+      startFunction("remove_token", ": " + token_identifier);
+      boolean ret = false;
+      Exception ex = null;
+      try {
+        ret = getMS().removeToken(token_identifier);
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("remove_token", ret == true, ex);
+      }
+      return ret;
+    }
+
+    @Override
+    public String get_token(String token_identifier) throws TException {
+      startFunction("get_token for", ": " + token_identifier);
+      String ret = null;
+      Exception ex = null;
+      try {
+        ret = getMS().getToken(token_identifier);
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_token", ret != null, ex);
+      }
+      //Thrift cannot return null result
+      return ret == null ? "" : ret;
+    }
+
+    @Override
+    public List<String> get_all_token_identifiers() throws TException {
+      startFunction("get_all_token_identifiers.");
+      List<String> ret;
+      Exception ex = null;
+      try {
+        ret = getMS().getAllTokenIdentifiers();
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_all_token_identifiers.", ex == null, ex);
+      }
+      return ret;
+    }
+
+    @Override
+    public int add_master_key(String key) throws TException {
+      startFunction("add_master_key.");
+      int ret;
+      Exception ex = null;
+      try {
+        ret = getMS().addMasterKey(key);
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("add_master_key.", ex == null, ex);
+      }
+      return ret;
+    }
+
+    @Override
+    public void update_master_key(int seq_number, String key) throws TException {
+      startFunction("update_master_key.");
+      Exception ex = null;
+      try {
+        getMS().updateMasterKey(seq_number, key);
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("update_master_key.", ex == null, ex);
+      }
+    }
+
+    @Override
+    public boolean remove_master_key(int key_seq) throws TException {
+      startFunction("remove_master_key.");
+      Exception ex = null;
+      boolean ret;
+      try {
+        ret = getMS().removeMasterKey(key_seq);
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("remove_master_key.", ex == null, ex);
+      }
+      return ret;
+    }
+
+    @Override
+    public List<String> get_master_keys() throws TException {
+      startFunction("get_master_keys.");
+      Exception ex = null;
+      String [] ret = null;
+      try {
+        ret = getMS().getMasterKeys();
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_master_keys.", ret != null, ex);
+      }
+      return Arrays.asList(ret);
+    }
+
+    @Override
+    public void markPartitionForEvent(final String db_name, final String tbl_name,
+        final Map<String, String> partName, final PartitionEventType evtType) throws TException {
+
+      Table tbl = null;
+      Exception ex = null;
+      RawStore ms  = getMS();
+      boolean success = false;
+      try {
+        String[] parsedDbName = parseDbName(db_name, conf);
+        ms.openTransaction();
+        startPartitionFunction("markPartitionForEvent", parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+            tbl_name, partName);
+        firePreEvent(new PreLoadPartitionDoneEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+            tbl_name, partName, this));
+        tbl = ms.markPartitionForEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tbl_name,
+            partName, evtType);
+        if (null == tbl) {
+          throw new UnknownTableException("Table: " + tbl_name + " not found.");
+        }
+
+        if (transactionalListeners.size() > 0) {
+          LoadPartitionDoneEvent lpde = new LoadPartitionDoneEvent(true, tbl, partName, this);
+          for (MetaStoreEventListener transactionalListener : transactionalListeners) {
+            transactionalListener.onLoadPartitionDone(lpde);
+          }
+        }
+
+        success = ms.commitTransaction();
+        for (MetaStoreEventListener listener : listeners) {
+          listener.onLoadPartitionDone(new LoadPartitionDoneEvent(true, tbl, partName, this));
+        }
+      } catch (UnknownTableException | InvalidPartitionException | MetaException e) {
+        ex = e;
+        LOG.error("Exception caught in mark partition event ", e);
+        throw e;
+      } catch (Exception original) {
+        ex = original;
+        LOG.error("Exception caught in mark partition event ", original);
+        throw newMetaException(original);
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        }
+
+        endFunction("markPartitionForEvent", tbl != null, ex, tbl_name);
+      }
+    }
+
+    @Override
+    public boolean isPartitionMarkedForEvent(final String db_name, final String tbl_name,
+        final Map<String, String> partName, final PartitionEventType evtType) throws TException {
+
+      String[] parsedDbName = parseDbName(db_name, conf);
+      startPartitionFunction("isPartitionMarkedForEvent", parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+          tbl_name, partName);
+      Boolean ret = null;
+      Exception ex = null;
+      try {
+        ret = getMS().isPartitionMarkedForEvent(parsedDbName[CAT_NAME], parsedDbName[DB_NAME],
+            tbl_name, partName, evtType);
+      } catch (UnknownTableException | UnknownPartitionException | InvalidPartitionException | MetaException e) {
+        ex = e;
+        LOG.error("Exception caught for isPartitionMarkedForEvent ", e);
+        throw e;
+      } catch (Exception original) {
+        LOG.error("Exception caught for isPartitionMarkedForEvent ", original);
+        ex = original;
+        throw newMetaException(original);
+      } finally {
+                endFunction("isPartitionMarkedForEvent", ret != null, ex, tbl_name);
+      }
+
+      return ret;
+    }
+
+    @Override
+    public List<String> set_ugi(String username, List<String> groupNames) throws TException {
+      Collections.addAll(groupNames, username);
+      return groupNames;
+    }
+
+    @Override
+    public boolean partition_name_has_valid_characters(List<String> part_vals,
+        boolean throw_exception) throws TException {
+      startFunction("partition_name_has_valid_characters");
+      boolean ret;
+      Exception ex = null;
+      try {
+        if (throw_exception) {
+          MetaStoreServerUtils.validatePartitionNameCharacters(part_vals, partitionValidationPattern);
+          ret = true;
+        } else {
+          ret = MetaStoreServerUtils.partitionNameHasValidCharacters(part_vals,
+              partitionValidationPattern);
+        }
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("partition_name_has_valid_characters", true, ex);
+      }
+      return ret;
+    }
+
+    private static MetaException newMetaException(Exception e) {
+      if (e instanceof MetaException) {
+        return (MetaException)e;
+      }
+      MetaException me = new MetaException(e.toString());
+      me.initCause(e);
+      return me;
+    }
+
+    private void validateFunctionInfo(Function func) throws InvalidObjectException, MetaException {
+      if (func == null) {
+        throw new MetaException("Function cannot be null.");
+      }
+      if (func.getFunctionName() == null) {
+        throw new MetaException("Function name cannot be null.");
+      }
+      if (func.getDbName() == null) {
+        throw new MetaException("Database name in Function cannot be null.");
+      }
+      if (!MetaStoreUtils.validateName(func.getFunctionName(), null)) {
+        throw new InvalidObjectException(func.getFunctionName() + " is not a valid object name");
+      }
+      String className = func.getClassName();
+      if (className == null) {
+        throw new InvalidObjectException("Function class name cannot be null");
+      }
+      if (func.getOwnerType() == null) {
+        throw new MetaException("Function owner type cannot be null.");
+      }
+      if (func.getFunctionType() == null) {
+        throw new MetaException("Function type cannot be null.");
+      }
+    }
+
+    @Override
+    public void create_function(Function func) throws TException {
+      validateFunctionInfo(func);
+      boolean success = false;
+      RawStore ms = getMS();
+      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
+      try {
+        String catName = func.isSetCatName() ? func.getCatName() : getDefaultCatalog(conf);
+        ms.openTransaction();
+        Database db = ms.getDatabase(catName, func.getDbName());
+        if (db == null) {
+          throw new NoSuchObjectException("The database " + func.getDbName() + " does not exist");
+        }
+
+        if (db.getType() == DatabaseType.REMOTE) {
+          throw new MetaException("Operation create_function not support for REMOTE database");
+        }
+
+        Function existingFunc = ms.getFunction(catName, func.getDbName(), func.getFunctionName());
+        if (existingFunc != null) {
+          throw new AlreadyExistsException(
+              "Function " + func.getFunctionName() + " already exists");
+        }
+
+        long time = System.currentTimeMillis() / 1000;
+        func.setCreateTime((int) time);
+        ms.createFunction(func);
+        if (!transactionalListeners.isEmpty()) {
+          transactionalListenerResponses =
+              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                                                    EventType.CREATE_FUNCTION,
+                                                    new CreateFunctionEvent(func, true, this));
+        }
+
+        success = ms.commitTransaction();
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        }
+
+        if (!listeners.isEmpty()) {
+          MetaStoreListenerNotifier.notifyEvent(listeners,
+                                                EventType.CREATE_FUNCTION,
+                                                new CreateFunctionEvent(func, success, this),
+                                                null,
+                                                transactionalListenerResponses, ms);
+        }
+      }
+    }
+
+    @Override
+    public void drop_function(String dbName, String funcName)
+        throws NoSuchObjectException, MetaException,
+        InvalidObjectException, InvalidInputException {
+      if (funcName == null) {
+        throw new MetaException("Function name cannot be null.");
+      }
+      boolean success = false;
+      Function func = null;
+      RawStore ms = getMS();
+      Map<String, String> transactionalListenerResponses = Collections.emptyMap();
+      String[] parsedDbName = parseDbName(dbName, conf);
+      if (parsedDbName[DB_NAME] == null) {
+        throw new MetaException("Database name cannot be null.");
+      }
+      try {
+        ms.openTransaction();
+        func = ms.getFunction(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], funcName);
+        if (func == null) {
+          throw new NoSuchObjectException("Function " + funcName + " does not exist");
+        }
+        Boolean needsCm =
+              ReplChangeManager.isSourceOfReplication(get_database_core(parsedDbName[CAT_NAME], parsedDbName[DB_NAME]));
+
+        // if copy of jar to change management fails we fail the metastore transaction, since the
+        // user might delete the jars on HDFS externally after dropping the function, hence having
+        // a copy is required to allow incremental replication to work correctly.
+        if (func.getResourceUris() != null && !func.getResourceUris().isEmpty()) {
+          for (ResourceUri uri : func.getResourceUris()) {
+            if (uri.getUri().toLowerCase().startsWith("hdfs:") && needsCm) {
+              wh.addToChangeManagement(new Path(uri.getUri()));
+            }
+          }
+        }
+
+        // if the operation on metastore fails, we don't do anything in change management, but fail
+        // the metastore transaction, as having a copy of the jar in change management is not going
+        // to cause any problem, the cleaner thread will remove this when this jar expires.
+        ms.dropFunction(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], funcName);
+        if (transactionalListeners.size() > 0) {
+          transactionalListenerResponses =
+              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                                                    EventType.DROP_FUNCTION,
+                                                    new DropFunctionEvent(func, true, this));
+        }
+        success = ms.commitTransaction();
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        }
+
+        if (listeners.size() > 0) {
+          MetaStoreListenerNotifier.notifyEvent(listeners,
+                                                EventType.DROP_FUNCTION,
+                                                new DropFunctionEvent(func, success, this),
+                                                null,
+                                                transactionalListenerResponses, ms);
+        }
+      }
+    }
+
+    @Override
+    public void alter_function(String dbName, String funcName, Function newFunc) throws TException {
+      String[] parsedDbName = parseDbName(dbName, conf);
+      validateForAlterFunction(parsedDbName[DB_NAME], funcName, newFunc);
+      boolean success = false;
+      RawStore ms = getMS();
+      try {
+        ms.openTransaction();
+        ms.alterFunction(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], funcName, newFunc);
+        success = ms.commitTransaction();
+      } catch (InvalidObjectException e) {
+        // Throwing MetaException instead of InvalidObjectException as the InvalidObjectException
+        // is not defined for the alter_function method in the Thrift interface.
+        throwMetaException(e);
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        }
+      }
+    }
+
+    private void validateForAlterFunction(String dbName, String funcName, Function newFunc)
+        throws MetaException {
+      if (dbName == null || funcName == null) {
+        throw new MetaException("Database and function name cannot be null.");
+      }
+      try {
+        validateFunctionInfo(newFunc);
+      } catch (InvalidObjectException e) {
+        // The validateFunctionInfo method is used by the create and alter function methods as well
+        // and it can throw InvalidObjectException. But the InvalidObjectException is not defined
+        // for the alter_function method in the Thrift interface, therefore a TApplicationException
+        // will occur at the caller side. Re-throwing the InvalidObjectException as MetaException
+        // would eliminate the TApplicationException at caller side.
+        throw newMetaException(e);
+      }
+    }
+
+    @Override
+    public List<String> get_functions(String dbName, String pattern)
+        throws MetaException {
+      startFunction("get_functions", ": db=" + dbName + " pat=" + pattern);
+
+      RawStore ms = getMS();
+      Exception ex = null;
+      List<String> funcNames = null;
+      String[] parsedDbName = parseDbName(dbName, conf);
+
+      try {
+        funcNames = ms.getFunctions(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], pattern);
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_functions", funcNames != null, ex);
+      }
+
+      return funcNames;
+    }
+
+    @Override
+    public GetAllFunctionsResponse get_all_functions()
+            throws MetaException {
+      GetAllFunctionsResponse response = new GetAllFunctionsResponse();
+      startFunction("get_all_functions");
+      RawStore ms = getMS();
+      List<Function> allFunctions = null;
+      Exception ex = null;
+      try {
+        // Leaving this as the 'hive' catalog (rather than choosing the default from the
+        // configuration) because all the default UDFs are in that catalog, and I think that's
+        // would people really want here.
+        allFunctions = ms.getAllFunctions(DEFAULT_CATALOG_NAME);
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_all_functions", allFunctions != null, ex);
+      }
+      response.setFunctions(allFunctions);
+      return response;
+    }
+
+    @Override
+    public Function get_function(String dbName, String funcName) throws TException {
+      if (dbName == null || funcName == null) {
+        throw new MetaException("Database and function name cannot be null.");
+      }
+      startFunction("get_function", ": " + dbName + "." + funcName);
+
+      RawStore ms = getMS();
+      Function func = null;
+      Exception ex = null;
+      String[] parsedDbName = parseDbName(dbName, conf);
+
+      try {
+        func = ms.getFunction(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], funcName);
+        if (func == null) {
+          throw new NoSuchObjectException(
+              "Function " + dbName + "." + funcName + " does not exist");
+        }
+      } catch (NoSuchObjectException e) {
+        ex = e;
+        rethrowException(e);
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_function", func != null, ex);
+      }
+
+      return func;
+    }
+
+    // Transaction and locking methods
+    @Override
+    public GetOpenTxnsResponse get_open_txns() throws TException {
+      return getTxnHandler().getOpenTxns();
+    }
+
+    @Override
+    public GetOpenTxnsResponse get_open_txns_req(GetOpenTxnsRequest getOpenTxnsRequest) throws TException {
+      return getTxnHandler().getOpenTxns(getOpenTxnsRequest.getExcludeTxnTypes());
+    }
+
+    // Transaction and locking methods
+    @Override
+    public GetOpenTxnsInfoResponse get_open_txns_info() throws TException {
+      return getTxnHandler().getOpenTxnsInfo();
+    }
+
+    @Override
+    public OpenTxnsResponse open_txns(OpenTxnRequest rqst) throws TException {
+      OpenTxnsResponse response = getTxnHandler().openTxns(rqst);
+      List<Long> txnIds = response.getTxn_ids();
+      if (txnIds != null && listeners != null && !listeners.isEmpty()) {
+        MetaStoreListenerNotifier.notifyEvent(listeners, EventType.OPEN_TXN,
+            new OpenTxnEvent(txnIds, this));
+      }
+      return response;
+    }
+
+    @Override
+    public void abort_txn(AbortTxnRequest rqst) throws TException {
+      getTxnHandler().abortTxn(rqst);
+      if (listeners != null && !listeners.isEmpty()) {
+        MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ABORT_TXN,
+                new AbortTxnEvent(rqst.getTxnid(), this));
+      }
+    }
+
+    @Override
+    public void abort_txns(AbortTxnsRequest rqst) throws TException {
+      getTxnHandler().abortTxns(rqst);
+      if (listeners != null && !listeners.isEmpty()) {
+        for (Long txnId : rqst.getTxn_ids()) {
+          MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ABORT_TXN,
+                  new AbortTxnEvent(txnId, this));
+        }
+      }
+    }
+
+    @Override
+    public long get_latest_txnid_in_conflict(long txnId) throws MetaException {
+      return getTxnHandler().getLatestTxnIdInConflict(txnId);
+    }
+
+    @Override
+    public void commit_txn(CommitTxnRequest rqst) throws TException {
+      // in replication flow, the write notification log table will be updated here.
+      if (rqst.isSetWriteEventInfos()) {
+        long targetTxnId = getTxnHandler().getTargetTxnId(rqst.getReplPolicy(), rqst.getTxnid());
+        if (targetTxnId < 0) {
+          //looks like a retry
+          return;
+        }
+        for (WriteEventInfo writeEventInfo : rqst.getWriteEventInfos()) {
+          String[] filesAdded = ReplChangeManager.getListFromSeparatedString(writeEventInfo.getFiles());
+          List<String> partitionValue = null;
+          Partition ptnObj = null;
+          String root;
+          Table tbl = getTblObject(writeEventInfo.getDatabase(), writeEventInfo.getTable());
+
+          if (writeEventInfo.getPartition() != null && !writeEventInfo.getPartition().isEmpty()) {
+            partitionValue = Warehouse.getPartValuesFromPartName(writeEventInfo.getPartition());
+            ptnObj = getPartitionObj(writeEventInfo.getDatabase(), writeEventInfo.getTable(), partitionValue, tbl);
+            root = ptnObj.getSd().getLocation();
+          } else {
+            root = tbl.getSd().getLocation();
+          }
+
+          InsertEventRequestData insertData = new InsertEventRequestData();
+          insertData.setReplace(true);
+
+          // The files in the commit txn message during load will have files with path corresponding to source
+          // warehouse. Need to transform them to target warehouse using table or partition object location.
+          for (String file : filesAdded) {
+            String[] decodedPath = ReplChangeManager.decodeFileUri(file);
+            String name = (new Path(decodedPath[0])).getName();
+            Path newPath = FileUtils.getTransformedPath(name, decodedPath[3], root);
+            insertData.addToFilesAdded(newPath.toUri().toString());
+            insertData.addToSubDirectoryList(decodedPath[3]);
+            try {
+              insertData.addToFilesAddedChecksum(ReplChangeManager.checksumFor(newPath, newPath.getFileSystem(conf)));
+            } catch (IOException e) {
+              LOG.error("failed to get checksum for the file " + newPath + " with error: " + e.getMessage());
+              throw new TException(e.getMessage());
+            }
+          }
+
+          WriteNotificationLogRequest wnRqst = new WriteNotificationLogRequest(targetTxnId,
+                  writeEventInfo.getWriteId(), writeEventInfo.getDatabase(), writeEventInfo.getTable(), insertData);
+          if (partitionValue != null) {
+            wnRqst.setPartitionVals(partitionValue);
+          }
+          addTxnWriteNotificationLog(tbl, ptnObj, wnRqst);
+        }
+      }
+      getTxnHandler().commitTxn(rqst);
+      if (listeners != null && !listeners.isEmpty()) {
+        MetaStoreListenerNotifier.notifyEvent(listeners, EventType.COMMIT_TXN,
+                new CommitTxnEvent(rqst.getTxnid(), this));
+        Optional<CompactionInfo> compactionInfo = getTxnHandler().getCompactionByTxnId(rqst.getTxnid());
+        if (compactionInfo.isPresent()) {
+          MetaStoreListenerNotifier.notifyEvent(listeners, EventType.COMMIT_COMPACTION,
+              new CommitCompactionEvent(rqst.getTxnid(), compactionInfo.get(), this));
+        }
+      }
+    }
+
+    @Override
+    public void repl_tbl_writeid_state(ReplTblWriteIdStateRequest rqst) throws TException {
+      getTxnHandler().replTableWriteIdState(rqst);
+    }
+
+    @Override
+    public GetValidWriteIdsResponse get_valid_write_ids(GetValidWriteIdsRequest rqst) throws TException {
+      return getTxnHandler().getValidWriteIds(rqst);
+    }
+
+    @Override
+    public void set_hadoop_jobid(String jobId, long cqId) {
+      getTxnHandler().setHadoopJobId(jobId, cqId);
+    }
+
+    @Override
+    public OptionalCompactionInfoStruct find_next_compact(String workerId) throws MetaException{
+      return CompactionInfo.compactionInfoToOptionalStruct(
+          getTxnHandler().findNextToCompact(workerId));
+    }
+
+    @Override
+    public void mark_cleaned(CompactionInfoStruct cr) throws MetaException {
+      getTxnHandler().markCleaned(CompactionInfo.compactionStructToInfo(cr));
+    }
+
+    @Override
+    public void mark_compacted(CompactionInfoStruct cr) throws MetaException {
+      getTxnHandler().markCompacted(CompactionInfo.compactionStructToInfo(cr));
+    }
+
+    @Override
+    public void mark_failed(CompactionInfoStruct cr) throws MetaException {
+      getTxnHandler().markFailed(CompactionInfo.compactionStructToInfo(cr));
+    }
+
+    @Override
+    public List<String> find_columns_with_stats(CompactionInfoStruct cr) throws MetaException {
+      return getTxnHandler().findColumnsWithStats(CompactionInfo.compactionStructToInfo(cr));
+    }
+
+    @Override
+    public void update_compactor_state(CompactionInfoStruct cr, long highWaterMark) throws MetaException {
+      getTxnHandler().updateCompactorState(
+          CompactionInfo.compactionStructToInfo(cr), highWaterMark);
+    }
+
+    @Override
+    public AllocateTableWriteIdsResponse allocate_table_write_ids(
+            AllocateTableWriteIdsRequest rqst) throws TException {
+      AllocateTableWriteIdsResponse response = getTxnHandler().allocateTableWriteIds(rqst);
+      if (listeners != null && !listeners.isEmpty()) {
+        MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ALLOC_WRITE_ID,
+                new AllocWriteIdEvent(response.getTxnToWriteIds(), rqst.getDbName(),
+                        rqst.getTableName(), this));
+      }
+      return response;
+    }
+
+    @Override
+    public MaxAllocatedTableWriteIdResponse get_max_allocated_table_write_id(MaxAllocatedTableWriteIdRequest rqst)
+        throws MetaException {
+      return getTxnHandler().getMaxAllocatedTableWrited(rqst);
+    }
+
+    @Override
+    public void seed_write_id(SeedTableWriteIdsRequest rqst) throws MetaException {
+      getTxnHandler().seedWriteId(rqst);
+    }
+
+    @Override
+    public void seed_txn_id(SeedTxnIdRequest rqst) throws MetaException {
+      getTxnHandler().seedTxnId(rqst);
+    }
+
+    private void addTxnWriteNotificationLog(Table tableObj, Partition ptnObj, WriteNotificationLogRequest rqst)
+            throws MetaException {
+      String partition = ""; //Empty string is an invalid partition name. Can be used for non partitioned table.
+      if (ptnObj != null) {
+        partition = Warehouse.makePartName(tableObj.getPartitionKeys(), rqst.getPartitionVals());
+      }
+      AcidWriteEvent event = new AcidWriteEvent(partition, tableObj, ptnObj, rqst);
+      getTxnHandler().addWriteNotificationLog(event);
+      if (listeners != null && !listeners.isEmpty()) {
+        MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ACID_WRITE, event);
+      }
+    }
+
+    private Table getTblObject(String db, String table) throws MetaException, NoSuchObjectException {
+      GetTableRequest req = new GetTableRequest(db, table);
+      req.setCapabilities(new ClientCapabilities(Lists.newArrayList(ClientCapability.TEST_CAPABILITY, ClientCapability.INSERT_ONLY_TABLES)));
+      return get_table_req(req).getTable();
+    }
+
+    private Partition getPartitionObj(String db, String table, List<String> partitionVals, Table tableObj)
+            throws MetaException, NoSuchObjectException {
+      if (tableObj.isSetPartitionKeys() && !tableObj.getPartitionKeys().isEmpty()) {
+        return get_partition(db, table, partitionVals);
+      }
+      return null;
+    }
+
+    @Override
+    public WriteNotificationLogResponse add_write_notification_log(WriteNotificationLogRequest rqst)
+            throws TException {
+      Table tableObj = getTblObject(rqst.getDb(), rqst.getTable());
+      Partition ptnObj = getPartitionObj(rqst.getDb(), rqst.getTable(), rqst.getPartitionVals(), tableObj);
+      addTxnWriteNotificationLog(tableObj, ptnObj, rqst);
+      return new WriteNotificationLogResponse();
+    }
+
+    @Override
+    public LockResponse lock(LockRequest rqst) throws TException {
+      return getTxnHandler().lock(rqst);
+    }
+
+    @Override
+    public LockResponse check_lock(CheckLockRequest rqst) throws TException {
+      return getTxnHandler().checkLock(rqst);
+    }
+
+    @Override
+    public void unlock(UnlockRequest rqst) throws TException {
+      getTxnHandler().unlock(rqst);
+    }
+
+    @Override
+    public ShowLocksResponse show_locks(ShowLocksRequest rqst) throws TException {
+      return getTxnHandler().showLocks(rqst);
+    }
+
+    @Override
+    public void heartbeat(HeartbeatRequest ids) throws TException {
+      getTxnHandler().heartbeat(ids);
+    }
+
+    @Override
+    public HeartbeatTxnRangeResponse heartbeat_txn_range(HeartbeatTxnRangeRequest rqst)
+      throws TException {
+      return getTxnHandler().heartbeatTxnRange(rqst);
+    }
+    @Deprecated
+    @Override
+    public void compact(CompactionRequest rqst) throws TException {
+      compact2(rqst);
+    }
+    @Override
+    public CompactionResponse compact2(CompactionRequest rqst) throws TException {
+      return getTxnHandler().compact(rqst);
+    }
+
+    @Override
+    public ShowCompactResponse show_compact(ShowCompactRequest rqst) throws TException {
+      ShowCompactResponse response = getTxnHandler().showCompact(rqst);
+      response.setCompacts(FilterUtils.filterCompactionsIfEnabled(isServerFilterEnabled,
+              filterHook, getDefaultCatalog(conf), response.getCompacts()));
+      return response;
+    }
+
+    @Override
+    public void flushCache() throws TException {
+      getMS().flushCache();
+    }
+
+    @Override
+    public void add_dynamic_partitions(AddDynamicPartitions rqst) throws TException {
+      getTxnHandler().addDynamicPartitions(rqst);
+    }
+
+    @Override
+    public GetPrincipalsInRoleResponse get_principals_in_role(GetPrincipalsInRoleRequest request)
+        throws TException {
+
+      incrementCounter("get_principals_in_role");
+      firePreEvent(new PreAuthorizationCallEvent(this));
+      Exception ex = null;
+      GetPrincipalsInRoleResponse response = null;
+      try {
+        response = new GetPrincipalsInRoleResponse(getMS().listRoleMembers(request.getRoleName()));
+      } catch (MetaException e) {
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        rethrowException(e);
+      } finally {
+        endFunction("get_principals_in_role", ex == null, ex);
+      }
+      return response;
+    }
+
+    @Override
+    public GetRoleGrantsForPrincipalResponse get_role_grants_for_principal(
+        GetRoleGrantsForPrincipalRequest request) throws TException {
+
+      incrementCounter("get_role_grants_for_principal");
+      firePreEvent(new PreAuthorizationCallEvent(this));
+      Exception ex = null;
+      List<RolePrincipalGrant> roleMaps = null;
+      try {
+        roleMaps = getMS().listRolesWithGrants(request.getPrincipal_name(), request.getPrincipal_type());
+      } catch (MetaException e) {
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        rethrowException(e);
+      } finally {
+        endFunction("get_role_grants_for_principal", ex == null, ex);
+      }
+
+      //List<RolePrincipalGrant> roleGrantsList = getRolePrincipalGrants(roleMaps);
+      return new GetRoleGrantsForPrincipalResponse(roleMaps);
+    }
+
+    @Override
+    public AggrStats get_aggr_stats_for(PartitionsStatsRequest request) throws TException {
+      String catName = request.isSetCatName() ? request.getCatName().toLowerCase() :
+          getDefaultCatalog(conf);
+      String dbName = request.getDbName().toLowerCase();
+      String tblName = request.getTblName().toLowerCase();
+      startFunction("get_aggr_stats_for", ": table=" +
+          TableName.getQualified(catName, dbName, tblName));
+
+      List<String> lowerCaseColNames = new ArrayList<>(request.getColNames().size());
+      for (String colName : request.getColNames()) {
+        lowerCaseColNames.add(colName.toLowerCase());
+      }
+      List<String> lowerCasePartNames = new ArrayList<>(request.getPartNames().size());
+      for (String partName : request.getPartNames()) {
+        lowerCasePartNames.add(lowerCaseConvertPartName(partName));
+      }
+      AggrStats aggrStats = null;
+
+      try {
+        aggrStats = getMS().get_aggr_stats_for(catName, dbName, tblName,
+            lowerCasePartNames, lowerCaseColNames, request.getEngine(), request.getValidWriteIdList());
+        return aggrStats;
+      } finally {
+          endFunction("get_aggr_stats_for", aggrStats == null, null, request.getTblName());
+      }
+
+    }
+
+    @Override
+    public boolean set_aggr_stats_for(SetPartitionsStatsRequest request) throws TException {
+      boolean ret = true;
+      List<ColumnStatistics> csNews = request.getColStats();
+      if (csNews == null || csNews.isEmpty()) {
+        return ret;
+      }
+      // figure out if it is table level or partition level
+      ColumnStatistics firstColStats = csNews.get(0);
+      ColumnStatisticsDesc statsDesc = firstColStats.getStatsDesc();
+      String catName = statsDesc.isSetCatName() ? statsDesc.getCatName() : getDefaultCatalog(conf);
+      String dbName = statsDesc.getDbName();
+      String tableName = statsDesc.getTableName();
+      List<String> colNames = new ArrayList<>();
+      for (ColumnStatisticsObj obj : firstColStats.getStatsObj()) {
+        colNames.add(obj.getColName());
+      }
+      if (statsDesc.isIsTblLevel()) {
+        // there should be only one ColumnStatistics
+        if (request.getColStatsSize() != 1) {
+          throw new MetaException(
+              "Expecting only 1 ColumnStatistics for table's column stats, but find "
+                  + request.getColStatsSize());
+        }
+        if (request.isSetNeedMerge() && request.isNeedMerge()) {
+          return updateTableColumnStatsWithMerge(catName, dbName, tableName, colNames, request);
+        } else {
+          // This is the overwrite case, we do not care about the accuracy.
+          return updateTableColumnStatsInternal(firstColStats,
+              request.getValidWriteIdList(), request.getWriteId());
+        }
+      } else {
+        // partition level column stats merging
+        // note that we may have two or more duplicate partition names.
+        // see autoColumnStats_2.q under TestMiniLlapLocalCliDriver
+        Map<String, ColumnStatistics> newStatsMap = new HashMap<>();
+        for (ColumnStatistics csNew : csNews) {
+          String partName = csNew.getStatsDesc().getPartName();
+          if (newStatsMap.containsKey(partName)) {
+            MetaStoreServerUtils.mergeColStats(csNew, newStatsMap.get(partName));
+          }
+          newStatsMap.put(partName, csNew);
+        }
+
+        if (request.isSetNeedMerge() && request.isNeedMerge()) {
+          ret = updatePartColumnStatsWithMerge(catName, dbName, tableName,
+              colNames, newStatsMap, request);
+        } else { // No merge.
+          Table t = getTable(catName, dbName, tableName);
+          for (Entry<String, ColumnStatistics> entry : newStatsMap.entrySet()) {
+            // We don't short-circuit on errors here anymore. That can leave acid stats invalid.
+            ret = updatePartitonColStatsInternal(t, entry.getValue(),
+                request.getValidWriteIdList(), request.getWriteId()) && ret;
+          }
+        }
+      }
+      return ret;
+    }
+
+    private boolean updatePartColumnStatsWithMerge(String catName, String dbName, String tableName,
+      List<String> colNames, Map<String, ColumnStatistics> newStatsMap, SetPartitionsStatsRequest request)
+          throws MetaException, NoSuchObjectException, InvalidObjectException, InvalidInputException {
+      RawStore ms = getMS();
+      ms.openTransaction();
+      boolean isCommitted = false, result = false;
+      try {
+        // a single call to get all column stats for all partitions
+        List<String> partitionNames = new ArrayList<>();
+        partitionNames.addAll(newStatsMap.keySet());
+        List<ColumnStatistics> csOlds = ms.getPartitionColumnStatistics(catName, dbName, tableName,
+            partitionNames, colNames, request.getEngine(), request.getValidWriteIdList());
+        if (newStatsMap.values().size() != csOlds.size()) {
+          // some of the partitions miss stats.
+          LOG.debug("Some of the partitions miss stats.");
+        }
+        Map<String, ColumnStatistics> oldStatsMap = new HashMap<>();
+        for (ColumnStatistics csOld : csOlds) {
+          oldStatsMap.put(csOld.getStatsDesc().getPartName(), csOld);
+        }
+
+        // another single call to get all the partition objects
+        List<Partition> partitions = ms.getPartitionsByNames(catName, dbName, tableName, partitionNames);
+        Map<String, Partition> mapToPart = new HashMap<>();
+        for (int index = 0; index < partitionNames.size(); index++) {
+          mapToPart.put(partitionNames.get(index), partitions.get(index));
+        }
+
+        Table t = getTable(catName, dbName, tableName);
+        for (Entry<String, ColumnStatistics> entry : newStatsMap.entrySet()) {
+          ColumnStatistics csNew = entry.getValue();
+          ColumnStatistics csOld = oldStatsMap.get(entry.getKey());
+          boolean isInvalidTxnStats = csOld != null
+              && csOld.isSetIsStatsCompliant() && !csOld.isIsStatsCompliant();
+          Partition part = mapToPart.get(entry.getKey());
+          if (isInvalidTxnStats) {
+            // No columns can be merged; a shortcut for getMergableCols.
+            csNew.setStatsObj(Lists.newArrayList());
+          } else {
+            // we first use getParameters() to prune the stats
+            MetaStoreServerUtils.getMergableCols(csNew, part.getParameters());
+            // we merge those that can be merged
+            if (csOld != null && csOld.getStatsObjSize() != 0 && !csNew.getStatsObj().isEmpty()) {
+              MetaStoreServerUtils.mergeColStats(csNew, csOld);
+            }
+          }
+
+          if (!csNew.getStatsObj().isEmpty()) {
+            // We don't short-circuit on errors here anymore. That can leave acid stats invalid.
+            result = updatePartitonColStatsInternal(t, csNew,
+                request.getValidWriteIdList(), request.getWriteId()) && result;
+          } else if (isInvalidTxnStats) {
+            // For now because the stats state is such as it is, we will invalidate everything.
+            // Overall the sematics here are not clear - we could invalide only some columns, but does
+            // that make any physical sense? Could query affect some columns but not others?
+            part.setWriteId(request.getWriteId());
+            StatsSetupConst.clearColumnStatsState(part.getParameters());
+            StatsSetupConst.setBasicStatsState(part.getParameters(), StatsSetupConst.FALSE);
+            ms.alterPartition(catName, dbName, tableName, part.getValues(), part,
+                request.getValidWriteIdList());
+            result = false;
+          } else {
+            // TODO: why doesn't the original call for non acid tables invalidate the stats?
+            LOG.debug("All the column stats " + csNew.getStatsDesc().getPartName()
+                + " are not accurate to merge.");
+          }
+        }
+        ms.commitTransaction();
+        isCommitted = true;
+      } finally {
+        if (!isCommitted) {
+          ms.rollbackTransaction();
+        }
+      }
+      return result;
+    }
+
+
+    private boolean updateTableColumnStatsWithMerge(String catName, String dbName, String tableName,
+        List<String> colNames, SetPartitionsStatsRequest request) throws MetaException,
+        NoSuchObjectException, InvalidObjectException, InvalidInputException {
+      ColumnStatistics firstColStats = request.getColStats().get(0);
+      RawStore ms = getMS();
+      ms.openTransaction();
+      boolean isCommitted = false, result = false;
+      try {
+        ColumnStatistics csOld = ms.getTableColumnStatistics(catName, dbName, tableName, colNames,
+            request.getEngine(), request.getValidWriteIdList());
+        // we first use the valid stats list to prune the stats
+        boolean isInvalidTxnStats = csOld != null
+            && csOld.isSetIsStatsCompliant() && !csOld.isIsStatsCompliant();
+        if (isInvalidTxnStats) {
+          // No columns can be merged; a shortcut for getMergableCols.
+          firstColStats.setStatsObj(Lists.newArrayList());
+        } else {
+          Table t = getTable(catName, dbName, tableName);
+          MetaStoreServerUtils.getMergableCols(firstColStats, t.getParameters());
+
+          // we merge those that can be merged
+          if (csOld != null && csOld.getStatsObjSize() != 0 && !firstColStats.getStatsObj().isEmpty()) {
+            MetaStoreServerUtils.mergeColStats(firstColStats, csOld);
+          }
+        }
+
+        if (!firstColStats.getStatsObj().isEmpty()) {
+          result = updateTableColumnStatsInternal(firstColStats,
+              request.getValidWriteIdList(), request.getWriteId());
+        } else if (isInvalidTxnStats) {
+          // For now because the stats state is such as it is, we will invalidate everything.
+          // Overall the sematics here are not clear - we could invalide only some columns, but does
+          // that make any physical sense? Could query affect some columns but not others?
+          Table t = getTable(catName, dbName, tableName);
+          t.setWriteId(request.getWriteId());
+          StatsSetupConst.clearColumnStatsState(t.getParameters());
+          StatsSetupConst.setBasicStatsState(t.getParameters(), StatsSetupConst.FALSE);
+          ms.alterTable(catName, dbName, tableName, t, request.getValidWriteIdList());
+        } else {
+          // TODO: why doesn't the original call for non acid tables invalidate the stats?
+          LOG.debug("All the column stats are not accurate to merge.");
+          result = true;
+        }
+
+        ms.commitTransaction();
+        isCommitted = true;
+      } finally {
+        if (!isCommitted) {
+          ms.rollbackTransaction();
+        }
+      }
+      return result;
+    }
+
+    private Table getTable(String catName, String dbName, String tableName)
+        throws MetaException, InvalidObjectException {
+      return getTable(catName, dbName, tableName, null);
+    }
+
+    private Table getTable(String catName, String dbName, String tableName,
+                           String writeIdList)
+        throws MetaException, InvalidObjectException {
+      Table t = getMS().getTable(catName, dbName, tableName, writeIdList);
+      if (t == null) {
+        throw new InvalidObjectException(TableName.getQualified(catName, dbName, tableName)
+            + " table not found");
+      }
+      return t;
+    }
+
+    @Override
+    public NotificationEventResponse get_next_notification(NotificationEventRequest rqst)
+        throws TException {
+      try {
+        authorizeProxyPrivilege();
+      } catch (Exception ex) {
+        LOG.error("Not authorized to make the get_next_notification call. You can try to disable " +
+            ConfVars.EVENT_DB_NOTIFICATION_API_AUTH.toString(), ex);
+        throw new TException(ex);
+      }
+
+      RawStore ms = getMS();
+      return ms.getNextNotification(rqst);
+    }
+
+    @Override
+    public CurrentNotificationEventId get_current_notificationEventId() throws TException {
+      try {
+        authorizeProxyPrivilege();
+      } catch (Exception ex) {
+        LOG.error("Not authorized to make the get_current_notificationEventId call. You can try to disable " +
+            ConfVars.EVENT_DB_NOTIFICATION_API_AUTH.toString(), ex);
+        throw new TException(ex);
+      }
+
+      RawStore ms = getMS();
+      return ms.getCurrentNotificationEventId();
+    }
+
+    @Override
+    public NotificationEventsCountResponse get_notification_events_count(NotificationEventsCountRequest rqst)
+            throws TException {
+      try {
+        authorizeProxyPrivilege();
+      } catch (Exception ex) {
+        LOG.error("Not authorized to make the get_notification_events_count call. You can try to disable " +
+            ConfVars.EVENT_DB_NOTIFICATION_API_AUTH.toString(), ex);
+        throw new TException(ex);
+      }
+
+      RawStore ms = getMS();
+      return ms.getNotificationEventsCount(rqst);
+    }
+
+    private void authorizeProxyPrivilege() throws Exception {
+      // Skip the auth in embedded mode or if the auth is disabled
+      if (!isMetaStoreRemote() ||
+          !MetastoreConf.getBoolVar(conf, ConfVars.EVENT_DB_NOTIFICATION_API_AUTH)) {
+        return;
+      }
+      String user = null;
+      try {
+        user = SecurityUtils.getUGI().getShortUserName();
+      } catch (Exception ex) {
+        LOG.error("Cannot obtain username", ex);
+        throw ex;
+      }
+      if (!MetaStoreServerUtils.checkUserHasHostProxyPrivileges(user, conf, getIPAddress())) {
+        throw new MetaException("User " + user + " is not allowed to perform this API call");
+      }
+    }
+
+    @Override
+    public FireEventResponse fire_listener_event(FireEventRequest rqst) throws TException {
+      switch (rqst.getData().getSetField()) {
+        case INSERT_DATA:
+        case INSERT_DATAS:
+        String catName =
+            rqst.isSetCatName() ? rqst.getCatName() : getDefaultCatalog(conf);
+        String dbName = rqst.getDbName();
+        String tblName = rqst.getTableName();
+        boolean isSuccessful = rqst.isSuccessful();
+        List<InsertEvent> events = new ArrayList<>();
+        if (rqst.getData().isSetInsertData()) {
+          events.add(new InsertEvent(catName, dbName, tblName,
+              rqst.getPartitionVals(),
+              rqst.getData().getInsertData(), isSuccessful, this));
+        } else {
+          // this is a bulk fire insert event operation
+          // we use the partition values field from the InsertEventRequestData object
+          // instead of the FireEventRequest object
+          for (InsertEventRequestData insertData : rqst.getData().getInsertDatas()) {
+            if (!insertData.isSetPartitionVal()) {
+              throw new MetaException(
+                  "Partition values must be set when firing multiple insert events");
+            }
+            events.add(new InsertEvent(catName, dbName, tblName,
+                insertData.getPartitionVal(),
+                insertData, isSuccessful, this));
+          }
+        }
+        FireEventResponse response = new FireEventResponse();
+        for (InsertEvent event : events) {
+          /*
+           * The transactional listener response will be set already on the event, so there is not need
+           * to pass the response to the non-transactional listener.
+           */
+          MetaStoreListenerNotifier
+              .notifyEvent(transactionalListeners, EventType.INSERT, event);
+          MetaStoreListenerNotifier.notifyEvent(listeners, EventType.INSERT, event);
+          if (event.getParameters() != null && event.getParameters()
+              .containsKey(
+                  MetaStoreEventListenerConstants.DB_NOTIFICATION_EVENT_ID_KEY_NAME)) {
+            response.addToEventIds(Long.valueOf(event.getParameters()
+                .get(MetaStoreEventListenerConstants.DB_NOTIFICATION_EVENT_ID_KEY_NAME)));
+          } else {
+            String msg = "Insert event id not generated for ";
+            if (event.getPartitionObj() != null) {
+              msg += "partition " + Arrays
+                  .toString(event.getPartitionObj().getValues().toArray()) + " of ";
+            }
+            msg +=
+                " of table " + event.getTableObj().getDbName() + "." + event.getTableObj()
+                    .getTableName();
+            LOG.warn(msg);
+          }
+        }
+        return response;
+        default:
+        throw new TException("Event type " + rqst.getData().getSetField().toString()
+            + " not currently supported.");
+      }
+
+    }
+
+    @Override
+    public GetFileMetadataByExprResult get_file_metadata_by_expr(GetFileMetadataByExprRequest req)
+        throws TException {
+      GetFileMetadataByExprResult result = new GetFileMetadataByExprResult();
+      RawStore ms = getMS();
+      if (!ms.isFileMetadataSupported()) {
+        result.setIsSupported(false);
+        result.setMetadata(Collections.emptyMap()); // Set the required field.
+        return result;
+      }
+      result.setIsSupported(true);
+
+      List<Long> fileIds = req.getFileIds();
+      boolean needMetadata = !req.isSetDoGetFooters() || req.isDoGetFooters();
+      FileMetadataExprType type = req.isSetType() ? req.getType() : FileMetadataExprType.ORC_SARG;
+
+      ByteBuffer[] metadatas = needMetadata ? new ByteBuffer[fileIds.size()] : null;
+      ByteBuffer[] ppdResults = new ByteBuffer[fileIds.size()];
+      boolean[] eliminated = new boolean[fileIds.size()];
+
+      getMS().getFileMetadataByExpr(fileIds, type, req.getExpr(), metadatas, ppdResults, eliminated);
+      for (int i = 0; i < fileIds.size(); ++i) {
+        if (!eliminated[i] && ppdResults[i] == null)
+         {
+          continue; // No metadata => no ppd.
+        }
+        MetadataPpdResult mpr = new MetadataPpdResult();
+        ByteBuffer ppdResult = eliminated[i] ? null : handleReadOnlyBufferForThrift(ppdResults[i]);
+        mpr.setIncludeBitset(ppdResult);
+        if (needMetadata) {
+          ByteBuffer metadata = eliminated[i] ? null : handleReadOnlyBufferForThrift(metadatas[i]);
+          mpr.setMetadata(metadata);
+        }
+        result.putToMetadata(fileIds.get(i), mpr);
+      }
+      if (!result.isSetMetadata()) {
+        result.setMetadata(Collections.emptyMap()); // Set the required field.
+      }
+      return result;
+    }
+
+    @Override
+    public GetFileMetadataResult get_file_metadata(GetFileMetadataRequest req) throws TException {
+      GetFileMetadataResult result = new GetFileMetadataResult();
+      RawStore ms = getMS();
+      if (!ms.isFileMetadataSupported()) {
+        result.setIsSupported(false);
+        result.setMetadata(Collections.emptyMap()); // Set the required field.
+        return result;
+      }
+      result.setIsSupported(true);
+      List<Long> fileIds = req.getFileIds();
+      ByteBuffer[] metadatas = ms.getFileMetadata(fileIds);
+      assert metadatas.length == fileIds.size();
+      for (int i = 0; i < metadatas.length; ++i) {
+        ByteBuffer bb = metadatas[i];
+        if (bb == null) {
+          continue;
+        }
+        bb = handleReadOnlyBufferForThrift(bb);
+        result.putToMetadata(fileIds.get(i), bb);
+      }
+      if (!result.isSetMetadata()) {
+        result.setMetadata(Collections.emptyMap()); // Set the required field.
+      }
+      return result;
+    }
+
+    private ByteBuffer handleReadOnlyBufferForThrift(ByteBuffer bb) {
+      if (!bb.isReadOnly()) {
+        return bb;
+      }
+      // Thrift cannot write read-only buffers... oh well.
+      // TODO: actually thrift never writes to the buffer, so we could use reflection to
+      //       unset the unnecessary read-only flag if allocation/copy perf becomes a problem.
+      ByteBuffer copy = ByteBuffer.allocate(bb.capacity());
+      copy.put(bb);
+      copy.flip();
+      return copy;
+    }
+
+    @Override
+    public PutFileMetadataResult put_file_metadata(PutFileMetadataRequest req) throws TException {
+      RawStore ms = getMS();
+      if (ms.isFileMetadataSupported()) {
+        ms.putFileMetadata(req.getFileIds(), req.getMetadata(), req.getType());
+      }
+      return new PutFileMetadataResult();
+    }
+
+    @Override
+    public ClearFileMetadataResult clear_file_metadata(ClearFileMetadataRequest req)
+        throws TException {
+      getMS().putFileMetadata(req.getFileIds(), null, null);
+      return new ClearFileMetadataResult();
+    }
+
+    @Override
+    public CacheFileMetadataResult cache_file_metadata(
+        CacheFileMetadataRequest req) throws TException {
+      RawStore ms = getMS();
+      if (!ms.isFileMetadataSupported()) {
+        return new CacheFileMetadataResult(false);
+      }
+      String dbName = req.getDbName(), tblName = req.getTblName(),
+          partName = req.isSetPartName() ? req.getPartName() : null;
+      boolean isAllPart = req.isSetIsAllParts() && req.isIsAllParts();
+      ms.openTransaction();
+      boolean success = false;
+      try {
+        Table tbl = ms.getTable(DEFAULT_CATALOG_NAME, dbName, tblName);
+        if (tbl == null) {
+          throw new NoSuchObjectException(dbName + "." + tblName + " not found");
+        }
+        boolean isPartitioned = tbl.isSetPartitionKeys() && tbl.getPartitionKeysSize() > 0;
+        String tableInputFormat = tbl.isSetSd() ? tbl.getSd().getInputFormat() : null;
+        if (!isPartitioned) {
+          if (partName != null || isAllPart) {
+            throw new MetaException("Table is not partitioned");
+          }
+          if (!tbl.isSetSd() || !tbl.getSd().isSetLocation()) {
+            throw new MetaException(
+                "Table does not have storage location; this operation is not supported on views");
+          }
+          FileMetadataExprType type = expressionProxy.getMetadataType(tableInputFormat);
+          if (type == null) {
+            throw new MetaException("The operation is not supported for " + tableInputFormat);
+          }
+          fileMetadataManager.queueCacheMetadata(tbl.getSd().getLocation(), type);
+          success = true;
+        } else {
+          List<String> partNames;
+          if (partName != null) {
+            partNames = Lists.newArrayList(partName);
+          } else if (isAllPart) {
+            partNames = ms.listPartitionNames(DEFAULT_CATALOG_NAME, dbName, tblName, (short)-1);
+          } else {
+            throw new MetaException("Table is partitioned");
+          }
+          int batchSize = MetastoreConf.getIntVar(
+              conf, ConfVars.BATCH_RETRIEVE_OBJECTS_MAX);
+          int index = 0;
+          int successCount = 0, failCount = 0;
+          HashSet<String> failFormats = null;
+          while (index < partNames.size()) {
+            int currentBatchSize = Math.min(batchSize, partNames.size() - index);
+            List<String> nameBatch = partNames.subList(index, index + currentBatchSize);
+            index += currentBatchSize;
+            List<Partition> parts = ms.getPartitionsByNames(DEFAULT_CATALOG_NAME, dbName, tblName, nameBatch);
+            for (Partition part : parts) {
+              if (!part.isSetSd() || !part.getSd().isSetLocation()) {
+                throw new MetaException("Partition does not have storage location;" +
+                    " this operation is not supported on views");
+              }
+              String inputFormat = part.getSd().isSetInputFormat()
+                  ? part.getSd().getInputFormat() : tableInputFormat;
+              FileMetadataExprType type = expressionProxy.getMetadataType(inputFormat);
+              if (type == null) {
+                ++failCount;
+                if (failFormats == null) {
+                  failFormats = new HashSet<>();
+                }
+                failFormats.add(inputFormat);
+              } else {
+                ++successCount;
+                fileMetadataManager.queueCacheMetadata(part.getSd().getLocation(), type);
+              }
+            }
+          }
+          success = true; // Regardless of the following exception
+          if (failCount > 0) {
+            String errorMsg = "The operation failed for " + failCount + " partitions and "
+                + "succeeded for " + successCount + " partitions; unsupported formats: ";
+            boolean isFirst = true;
+            for (String s : failFormats) {
+              if (!isFirst) {
+                errorMsg += ", ";
+              }
+              isFirst = false;
+              errorMsg += s;
+            }
+            throw new MetaException(errorMsg);
+          }
+        }
+      } finally {
+        if (success) {
+          if (!ms.commitTransaction()) {
+            throw new MetaException("Failed to commit");
+          }
+        } else {
+          ms.rollbackTransaction();
+        }
+      }
+      return new CacheFileMetadataResult(true);
+    }
+
+    @VisibleForTesting
+    void updateMetrics() throws MetaException {
+      if (databaseCount != null) {
+        tableCount.set(getMS().getTableCount());
+        partCount.set(getMS().getPartitionCount());
+        databaseCount.set(getMS().getDatabaseCount());
+      }
+    }
+
+    @Override
+    public PrimaryKeysResponse get_primary_keys(PrimaryKeysRequest request) throws TException {
+      String catName = request.isSetCatName() ? request.getCatName() : getDefaultCatalog(conf);
+      String db_name = request.getDb_name();
+      String tbl_name = request.getTbl_name();
+      startTableFunction("get_primary_keys", catName, db_name, tbl_name);
+      List<SQLPrimaryKey> ret = null;
+      Exception ex = null;
+      try {
+        ret = getMS().getPrimaryKeys(catName, db_name, tbl_name);
+      } catch (Exception e) {
+       ex = e;
+       throwMetaException(e);
+     } finally {
+       endFunction("get_primary_keys", ret != null, ex, tbl_name);
+     }
+     return new PrimaryKeysResponse(ret);
+    }
+
+    @Override
+    public ForeignKeysResponse get_foreign_keys(ForeignKeysRequest request) throws TException {
+      String catName = request.isSetCatName() ? request.getCatName() : getDefaultCatalog(conf);
+      String parent_db_name = request.getParent_db_name();
+      String parent_tbl_name = request.getParent_tbl_name();
+      String foreign_db_name = request.getForeign_db_name();
+      String foreign_tbl_name = request.getForeign_tbl_name();
+      startFunction("get_foreign_keys", " : parentdb=" + parent_db_name +
+        " parenttbl=" + parent_tbl_name + " foreigndb=" + foreign_db_name +
+        " foreigntbl=" + foreign_tbl_name);
+      List<SQLForeignKey> ret = null;
+      Exception ex = null;
+      try {
+        ret = getMS().getForeignKeys(catName, parent_db_name, parent_tbl_name,
+              foreign_db_name, foreign_tbl_name);
+      } catch (Exception e) {
+        ex = e;
+        throwMetaException(e);
+      } finally {
+        endFunction("get_foreign_keys", ret != null, ex, foreign_tbl_name);
+      }
+      return new ForeignKeysResponse(ret);
+    }
+
+    private void throwMetaException(Exception e) throws MetaException,
+        NoSuchObjectException {
+      if (e instanceof MetaException) {
+        throw (MetaException) e;
+      } else if (e instanceof NoSuchObjectException) {
+        throw (NoSuchObjectException) e;
+      } else {
+        throw newMetaException(e);
+      }
+    }
+
+    @Override
+    public UniqueConstraintsResponse get_unique_constraints(UniqueConstraintsRequest request)
+        throws TException {
+      String catName = request.isSetCatName() ? request.getCatName() : getDefaultCatalog(conf);
+      String db_name = request.getDb_name();
+      String tbl_name = request.getTbl_name();
+      startTableFunction("get_unique_constraints", catName, db_name, tbl_name);
+      List<SQLUniqueConstraint> ret = null;
+      Exception ex = null;
+      try {
+        ret = getMS().getUniqueConstraints(catName, db_name, tbl_name);
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_unique_constraints", ret != null, ex, tbl_name);
+      }
+      return new UniqueConstraintsResponse(ret);
+    }
+
+    @Override
+    public NotNullConstraintsResponse get_not_null_constraints(NotNullConstraintsRequest request)
+        throws TException {
+      String catName = request.isSetCatName() ? request.getCatName() : getDefaultCatalog(conf);
+      String db_name = request.getDb_name();
+      String tbl_name = request.getTbl_name();
+      startTableFunction("get_not_null_constraints", catName, db_name, tbl_name);
+      List<SQLNotNullConstraint> ret = null;
+      Exception ex = null;
+      try {
+        ret = getMS().getNotNullConstraints(catName, db_name, tbl_name);
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_not_null_constraints", ret != null, ex, tbl_name);
+      }
+      return new NotNullConstraintsResponse(ret);
+    }
+
+    @Override
+    public DefaultConstraintsResponse get_default_constraints(DefaultConstraintsRequest request)
+        throws TException {
+      String catName = request.isSetCatName() ? request.getCatName() : getDefaultCatalog(conf);
+      String db_name = request.getDb_name();
+      String tbl_name = request.getTbl_name();
+      startTableFunction("get_default_constraints", catName, db_name, tbl_name);
+      List<SQLDefaultConstraint> ret = null;
+      Exception ex = null;
+      try {
+        ret = getMS().getDefaultConstraints(catName, db_name, tbl_name);
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_default_constraints", ret != null, ex, tbl_name);
+      }
+      return new DefaultConstraintsResponse(ret);
+    }
+
+    @Override
+    public CheckConstraintsResponse get_check_constraints(CheckConstraintsRequest request)
+        throws TException {
+      String catName = request.getCatName();
+      String db_name = request.getDb_name();
+      String tbl_name = request.getTbl_name();
+      startTableFunction("get_check_constraints", catName, db_name, tbl_name);
+      List<SQLCheckConstraint> ret = null;
+      Exception ex = null;
+      try {
+        ret = getMS().getCheckConstraints(catName, db_name, tbl_name);
+      } catch (MetaException e) {
+        ex = e;
+        throw e;
+      } catch (Exception e) {
+        ex = e;
+        throw newMetaException(e);
+      } finally {
+        endFunction("get_check_constraints", ret != null, ex, tbl_name);
+      }
+      return new CheckConstraintsResponse(ret);
+    }
+
+    /**
+     * Api to fetch all table constraints at once
+     * @param request it consist of catalog name, database name and table name to identify the table in metastore
+     * @return all constraints attached to given table
+     * @throws TException
+     */
+    @Override
+    public AllTableConstraintsResponse get_all_table_constraints(AllTableConstraintsRequest request)
+        throws TException, MetaException, NoSuchObjectException {
+      String catName = request.isSetCatName() ? request.getCatName() : getDefaultCatalog(conf);
+      String dbName = request.getDbName();
+      String tblName = request.getTblName();
+      startTableFunction("get_all_table_constraints", catName, dbName, tblName);
+      SQLAllTableConstraints ret = null;
+      Exception ex = null;
+      try {
+        ret = getMS().getAllTableConstraints(catName, dbName, tblName);
+      } catch (Exception e) {
+        ex = e;
+        throwMetaException(e);
+      } finally {
+        endFunction("get_all_table_constraints", ret != null, ex, tblName);
+      }
+      return new AllTableConstraintsResponse(ret);
+    }
+
+    @Override
+    public String get_metastore_db_uuid() throws TException {
+      try {
+        return getMS().getMetastoreDbUuid();
+      } catch (MetaException e) {
+        LOG.error("Exception thrown while querying metastore db uuid", e);
+        throw e;
+      }
+    }
+
+    @Override
+    public WMCreateResourcePlanResponse create_resource_plan(WMCreateResourcePlanRequest request)
+        throws AlreadyExistsException, InvalidObjectException, MetaException, TException {
+      int defaultPoolSize = MetastoreConf.getIntVar(
+          conf, MetastoreConf.ConfVars.WM_DEFAULT_POOL_SIZE);
+      WMResourcePlan plan = request.getResourcePlan();
+      if (defaultPoolSize > 0 && plan.isSetQueryParallelism()) {
+        // If the default pool is not disabled, override the size with the specified parallelism.
+        defaultPoolSize = plan.getQueryParallelism();
+      }
+      try {
+        getMS().createResourcePlan(plan, request.getCopyFrom(), defaultPoolSize);
+        return new WMCreateResourcePlanResponse();
+      } catch (MetaException e) {
+        LOG.error("Exception while trying to persist resource plan", e);
+        throw e;
+      }
+    }
+
+    @Override
+    public WMGetResourcePlanResponse get_resource_plan(WMGetResourcePlanRequest request)
+        throws NoSuchObjectException, MetaException, TException {
+      try {
+        WMFullResourcePlan rp = getMS().getResourcePlan(request.getResourcePlanName(), request.getNs());
+        WMGetResourcePlanResponse resp = new WMGetResourcePlanResponse();
+        resp.setResourcePlan(rp);
+        return resp;
+      } catch (MetaException e) {
+        LOG.error("Exception while trying to retrieve resource plan", e);
+        throw e;
+      }
+    }
+
+    @Override
+    public WMGetAllResourcePlanResponse get_all_resource_plans(WMGetAllResourcePlanRequest request)
+        throws MetaException, TException {
+      try {
+        WMGetAllResourcePlanResponse resp = new WMGetAllResourcePlanResponse();
+        resp.setResourcePlans(getMS().getAllResourcePlans(request.getNs()));
+        return resp;
+      } catch (MetaException e) {
+        LOG.error("Exception while trying to retrieve resource plans", e);
+        throw e;
+      }
+    }
+
+    @Override
+    public WMAlterResourcePlanResponse alter_resource_plan(WMAlterResourcePlanRequest request)
+        throws NoSuchObjectException, InvalidOperationException, MetaException, TException {
+      try {
+        if (((request.isIsEnableAndActivate() ? 1 : 0) + (request.isIsReplace() ? 1 : 0)
+           + (request.isIsForceDeactivate() ? 1 : 0)) > 1) {
+          throw new MetaException("Invalid request; multiple flags are set");
+        }
+        WMAlterResourcePlanResponse response = new WMAlterResourcePlanResponse();
+        // This method will only return full resource plan when activating one,
+        // to give the caller the result atomically with the activation.
+        WMFullResourcePlan fullPlanAfterAlter = getMS().alterResourcePlan(
+            request.getResourcePlanName(), request.getNs(), request.getResourcePlan(),
+            request.isIsEnableAndActivate(), request.isIsForceDeactivate(), request.isIsReplace());
+        if (fullPlanAfterAlter != null) {
+          response.setFullResourcePlan(fullPlanAfterAlter);
+        }
+        return response;
+      } catch (MetaException e) {
+        LOG.error("Exception while trying to alter resource plan", e);
+        throw e;
+      }
+    }
+
+    @Override
+    public WMGetActiveResourcePlanResponse get_active_resource_plan(
+        WMGetActiveResourcePlanRequest request) throws MetaException, TException {
+      try {
+        WMGetActiveResourcePlanResponse response = new WMGetActiveResourcePlanResponse();
+        response.setResourcePlan(getMS().getActiveResourcePlan(request.getNs()));
+        return response;
+      } catch (MetaException e) {
+        LOG.error("Exception while trying to get active resource plan", e);
+        throw e;
+      }
+    }
+
+    @Override
+    public WMValidateResourcePlanResponse validate_resource_plan(WMValidateResourcePlanRequest request)
+        throws NoSuchObjectException, MetaException, TException {
+      try {
+        return getMS().validateResourcePlan(request.getResourcePlanName(), request.getNs());
+      } catch (MetaException e) {
+        LOG.error("Exception while trying to validate resource plan", e);
+        throw e;
+      }
+    }
+
+    @Override
+    public WMDropResourcePlanResponse drop_resource_plan(WMDropResourcePlanRequest request)
+        throws NoSuchObjectException, InvalidOperationException, MetaException, TException {
+      try {
+        getMS().dropResourcePlan(request.getResourcePlanName(), request.getNs());
+        return new WMDropResourcePlanResponse();
+      } catch (MetaException e) {
+        LOG.error("Exception while trying to drop resource plan", e);
+        throw e;
+      }
+    }
+
+    @Override
+    public WMCreateTriggerResponse create_wm_trigger(WMCreateTriggerRequest request)
+        throws AlreadyExistsException, InvalidObjectException, MetaException, TException {
+      try {
+        getMS().createWMTrigger(request.getTrigger());
+        return new WMCreateTriggerResponse();
+      } catch (MetaException e) {
+        LOG.error("Exception while trying to create trigger", e);
+        throw e;
+      }
+    }
+
+    @Override
+    public WMAlterTriggerResponse alter_wm_trigger(WMAlterTriggerRequest request)
+        throws NoSuchObjectException, InvalidObjectException, MetaException, TException {
+      try {
+        getMS().alterWMTrigger(request.getTrigger());
+        return new WMAlterTriggerResponse();
+      } catch (MetaException e) {
+        LOG.error("Exception while trying to alter trigger", e);
+        throw e;
+      }
+    }
+
+    @Override
+    public WMDropTriggerResponse drop_wm_trigger(WMDropTriggerRequest request)
+        throws NoSuchObjectException, InvalidOperationException, MetaException, TException {
+      try {
+        getMS().dropWMTrigger(request.getResourcePlanName(), request.getTriggerName(), request.getNs());
+        return new WMDropTriggerResponse();
+      } catch (MetaException e) {
+        LOG.error("Exception while trying to drop trigger.", e);
+        throw e;
+      }
+    }
+
+    @Override
+    public WMGetTriggersForResourePlanResponse get_triggers_for_resourceplan(
+        WMGetTriggersForResourePlanRequest request)
+        throws NoSuchObjectException, MetaException, TException {
+      try {
+        List<WMTrigger> triggers =
+            getMS().getTriggersForResourcePlan(request.getResourcePlanName(), request.getNs());
+        WMGetTriggersForResourePlanResponse response = new WMGetTriggersForResourePlanResponse();
+        response.setTriggers(triggers);
+        return response;
+      } catch (MetaException e) {
+        LOG.error("Exception while trying to retrieve triggers plans", e);
+        throw e;
+      }
+    }
+
+    @Override
+    public WMAlterPoolResponse alter_wm_pool(WMAlterPoolRequest request)
+        throws AlreadyExistsException, NoSuchObjectException, InvalidObjectException, MetaException,
+        TException {
+      try {
+        getMS().alterPool(request.getPool(), request.getPoolPath());
+        return new WMAlterPoolResponse();
+      } catch (MetaException e) {
+        LOG.error("Exception while trying to alter WMPool", e);
+        throw e;
+      }
+    }
+
+    @Override
+    public WMCreatePoolResponse create_wm_pool(WMCreatePoolRequest request)
+        throws AlreadyExistsException, NoSuchObjectException, InvalidObjectException, MetaException,
+        TException {
+      try {
+        getMS().createPool(request.getPool());
+        return new WMCreatePoolResponse();
+      } catch (MetaException e) {
+        LOG.error("Exception while trying to create WMPool", e);
+        throw e;
+      }
+    }
+
+    @Override
+    public WMDropPoolResponse drop_wm_pool(WMDropPoolRequest request)
+        throws NoSuchObjectException, InvalidOperationException, MetaException, TException {
+      try {
+        getMS().dropWMPool(request.getResourcePlanName(), request.getPoolPath(), request.getNs());
+        return new WMDropPoolResponse();
+      } catch (MetaException e) {
+        LOG.error("Exception while trying to drop WMPool", e);
+        throw e;
+      }
+    }
+
+    @Override
+    public WMCreateOrUpdateMappingResponse create_or_update_wm_mapping(
+        WMCreateOrUpdateMappingRequest request) throws AlreadyExistsException,
+        NoSuchObjectException, InvalidObjectException, MetaException, TException {
+      try {
+        getMS().createOrUpdateWMMapping(request.getMapping(), request.isUpdate());
+        return new WMCreateOrUpdateMappingResponse();
+      } catch (MetaException e) {
+        LOG.error("Exception while trying to create or update WMMapping", e);
+        throw e;
+      }
+    }
+
+    @Override
+    public WMDropMappingResponse drop_wm_mapping(WMDropMappingRequest request)
+        throws NoSuchObjectException, InvalidOperationException, MetaException, TException {
+      try {
+        getMS().dropWMMapping(request.getMapping());
+        return new WMDropMappingResponse();
+      } catch (MetaException e) {
+        LOG.error("Exception while trying to drop WMMapping", e);
+        throw e;
+      }
+    }
+
+    @Override
+    public WMCreateOrDropTriggerToPoolMappingResponse create_or_drop_wm_trigger_to_pool_mapping(
+        WMCreateOrDropTriggerToPoolMappingRequest request) throws AlreadyExistsException,
+        NoSuchObjectException, InvalidObjectException, MetaException, TException {
+      try {
+        if (request.isDrop()) {
+          getMS().dropWMTriggerToPoolMapping(request.getResourcePlanName(),
+              request.getTriggerName(), request.getPoolPath(), request.getNs());
+        } else {
+          getMS().createWMTriggerToPoolMapping(request.getResourcePlanName(),
+              request.getTriggerName(), request.getPoolPath(), request.getNs());
+        }
+        return new WMCreateOrDropTriggerToPoolMappingResponse();
+      } catch (MetaException e) {
+        LOG.error("Exception while trying to create or drop pool mappings", e);
+        throw e;
+      }
+    }
+
+    @Override
+    public void create_ischema(ISchema schema) throws TException {
+      startFunction("create_ischema", ": " + schema.getName());
+      boolean success = false;
+      Exception ex = null;
+      RawStore ms = getMS();
+      try {
+        firePreEvent(new PreCreateISchemaEvent(this, schema));
+        Map<String, String> transactionalListenersResponses = Collections.emptyMap();
+        ms.openTransaction();
+        try {
+          ms.createISchema(schema);
+
+          if (!transactionalListeners.isEmpty()) {
+            transactionalListenersResponses =
+                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                    EventType.CREATE_ISCHEMA, new CreateISchemaEvent(true, this, schema));
+          }
+          success = ms.commitTransaction();
+        } finally {
+          if (!success) {
+            ms.rollbackTransaction();
+          }
+          if (!listeners.isEmpty()) {
+            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.CREATE_ISCHEMA,
+                new CreateISchemaEvent(success, this, schema), null,
+                transactionalListenersResponses, ms);
+          }
+        }
+      } catch (MetaException|AlreadyExistsException e) {
+        LOG.error("Caught exception creating schema", e);
+        ex = e;
+        throw e;
+      } finally {
+        endFunction("create_ischema", success, ex);
+      }
+    }
+
+    @Override
+    public void alter_ischema(AlterISchemaRequest rqst) throws TException {
+      startFunction("alter_ischema", ": " + rqst);
+      boolean success = false;
+      Exception ex = null;
+      RawStore ms = getMS();
+      try {
+        ISchema oldSchema = ms.getISchema(rqst.getName());
+        if (oldSchema == null) {
+          throw new NoSuchObjectException("Could not find schema " + rqst.getName());
+        }
+        firePreEvent(new PreAlterISchemaEvent(this, oldSchema, rqst.getNewSchema()));
+        Map<String, String> transactionalListenersResponses = Collections.emptyMap();
+        ms.openTransaction();
+        try {
+          ms.alterISchema(rqst.getName(), rqst.getNewSchema());
+          if (!transactionalListeners.isEmpty()) {
+            transactionalListenersResponses =
+                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                    EventType.ALTER_ISCHEMA, new AlterISchemaEvent(true, this, oldSchema, rqst.getNewSchema()));
+          }
+          success = ms.commitTransaction();
+        } finally {
+          if (!success) {
+            ms.rollbackTransaction();
+          }
+          if (!listeners.isEmpty()) {
+            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ALTER_ISCHEMA,
+                new AlterISchemaEvent(success, this, oldSchema, rqst.getNewSchema()), null,
+                transactionalListenersResponses, ms);
+          }
+        }
+      } catch (MetaException|NoSuchObjectException e) {
+        LOG.error("Caught exception altering schema", e);
+        ex = e;
+        throw e;
+      } finally {
+        endFunction("alter_ischema", success, ex);
+      }
+    }
+
+    @Override
+    public ISchema get_ischema(ISchemaName schemaName) throws TException {
+      startFunction("get_ischema", ": " + schemaName);
+      Exception ex = null;
+      ISchema schema = null;
+      try {
+        schema = getMS().getISchema(schemaName);
+        if (schema == null) {
+          throw new NoSuchObjectException("No schema named " + schemaName + " exists");
+        }
+        firePreEvent(new PreReadISchemaEvent(this, schema));
+        return schema;
+      } catch (MetaException e) {
+        LOG.error("Caught exception getting schema", e);
+        ex = e;
+        throw e;
+      } finally {
+        endFunction("get_ischema", schema != null, ex);
+      }
+    }
+
+    @Override
+    public void drop_ischema(ISchemaName schemaName) throws TException {
+      startFunction("drop_ischema", ": " + schemaName);
+      Exception ex = null;
+      boolean success = false;
+      RawStore ms = getMS();
+      try {
+        // look for any valid versions.  This will also throw NoSuchObjectException if the schema
+        // itself doesn't exist, which is what we want.
+        SchemaVersion latest = ms.getLatestSchemaVersion(schemaName);
+        if (latest != null) {
+          ex = new InvalidOperationException("Schema " + schemaName + " cannot be dropped, it has" +
+              " at least one valid version");
+          throw (InvalidObjectException)ex;
+        }
+        ISchema schema = ms.getISchema(schemaName);
+        firePreEvent(new PreDropISchemaEvent(this, schema));
+        Map<String, String> transactionalListenersResponses = Collections.emptyMap();
+        ms.openTransaction();
+        try {
+          ms.dropISchema(schemaName);
+          if (!transactionalListeners.isEmpty()) {
+            transactionalListenersResponses =
+                MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                    EventType.DROP_ISCHEMA, new DropISchemaEvent(true, this, schema));
+          }
+          success = ms.commitTransaction();
+        } finally {
+          if (!success) {
+            ms.rollbackTransaction();
+          }
+          if (!listeners.isEmpty()) {
+            MetaStoreListenerNotifier.notifyEvent(listeners, EventType.DROP_ISCHEMA,
+                new DropISchemaEvent(success, this, schema), null,
+                transactionalListenersResponses, ms);
+          }
+        }
+      } catch (MetaException|NoSuchObjectException e) {
+        LOG.error("Caught exception dropping schema", e);
... 380 lines suppressed ...

[hive] 26/38: HIVE-24396: get_table_core() to return null instead of exception

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 5c98e3073e52431bcece39cdfe7e655abf1917b0
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Tue Dec 1 15:50:12 2020 -0500

    HIVE-24396: get_table_core() to return null instead of exception
---
 .../org/apache/hadoop/hive/metastore/HiveMetaStore.java   | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
index 26552d1..638b426 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
@@ -3739,12 +3739,19 @@ public class HiveMetaStore extends ThriftHiveMetastore {
       Table t = null;
       try {
         db = get_database_core(catName, dbname);
-        if (db != null) {
-          if (db.getType().equals(DatabaseType.REMOTE)) {
-            return DataConnectorProviderFactory.getDataConnectorProvider(db).getTable(name);
+      } catch (Exception e) { /* appears exception is not thrown currently if db doesnt exist */ }
+
+      if (db != null) {
+        if (db.getType().equals(DatabaseType.REMOTE)) {
+          t = DataConnectorProviderFactory.getDataConnectorProvider(db).getTable(name);
+          if (t == null) {
+            throw new NoSuchObjectException(TableName.getQualified(catName, dbname, name) +
+              " table not found");
           }
+          t.setDbName(dbname);
+          return t;
         }
-      } catch (Exception e) { /* appears exception is not thrown currently if db doesnt exist */ }
+      }
 
       try {
         t = getMS().getTable(catName, dbname, name, writeIdList);

[hive] 07/38: NullPointerException in CreateDatabaseOperation due to last change

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit c6ed378164f352ed620b5e9647ca6ad2e28a0d7d
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Tue Nov 17 13:16:46 2020 -0500

    NullPointerException in CreateDatabaseOperation due to last change
---
 .../hadoop/hive/ql/ddl/database/create/CreateDatabaseOperation.java    | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseOperation.java
index def742d..d02b039 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseOperation.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseOperation.java
@@ -54,14 +54,15 @@ public class CreateDatabaseOperation extends DDLOperation<CreateDatabaseDesc> {
         if (desc.getManagedLocationUri() != null) {
           database.setManagedLocationUri(desc.getManagedLocationUri());
         }
+        makeLocationQualified(database);
         if (database.getLocationUri().equalsIgnoreCase(database.getManagedLocationUri())) {
           throw new HiveException("Managed and external locations for database cannot be the same");
         }
       } else {
+        makeLocationQualified(database);
         database.setConnector_name(desc.getConnectorName());
         database.setRemote_dbname(desc.getRemoteDbName());
       }
-      makeLocationQualified(database);
       context.getDb().createDatabase(database, desc.getIfNotExists());
     } catch (AlreadyExistsException ex) {
       //it would be better if AlreadyExistsException had an errorCode field....

[hive] 11/38: HIVE-24396: Added schema changes for Oracle Made DBS.TYPE NOT NULL in all scripts Added Type support to DatabaseBuilder Added Unit test for DataConnector Added Unit test REMOTE Database Fixed test failures in TestSchemaToolForMetaStore

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 7d91a9a297cf9409383a712dcb20bf55c0886b3d
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Fri Nov 20 11:34:53 2020 -0500

    HIVE-24396: Added schema changes for Oracle
                Made DBS.TYPE NOT NULL in all scripts
                Added Type support to DatabaseBuilder
                Added Unit test for DataConnector
                Added Unit test REMOTE Database
                Fixed test failures in TestSchemaToolForMetaStore
---
 .../src/main/thrift/hive_metastore.thrift          |  12 +-
 .../metastore/client/builder/DatabaseBuilder.java  |  25 +++-
 .../src/main/sql/derby/hive-schema-4.0.0.derby.sql |   2 +-
 .../sql/derby/upgrade-3.2.0-to-4.0.0.derby.sql     |   3 +-
 .../src/main/sql/mysql/hive-schema-4.0.0.mysql.sql |   2 +-
 .../sql/mysql/upgrade-3.2.0-to-4.0.0.mysql.sql     |   4 +-
 .../main/sql/oracle/hive-schema-4.0.0.oracle.sql   |  25 +++-
 .../sql/oracle/upgrade-3.2.0-to-4.0.0.oracle.sql   |  25 ++++
 .../sql/postgres/hive-schema-4.0.0.postgres.sql    |   2 +-
 .../postgres/upgrade-3.2.0-to-4.0.0.postgres.sql   |   4 +-
 .../hadoop/hive/metastore/TestHiveMetaStore.java   | 136 +++++++++++++++++++++
 .../schematool/TestSchemaToolForMetastore.java     |  18 +--
 12 files changed, 233 insertions(+), 25 deletions(-)

diff --git a/standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift b/standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift
index a91a140..9e43101 100644
--- a/standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift
+++ b/standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift
@@ -919,12 +919,12 @@ struct GetPartitionsByNamesResult {
 }
 
 struct DataConnector {
-  1: string name
-  2: string type
-  3: string url
-  4: optional string description
-  5: optional map<string,string> parameters
-  6: optional string ownerName
+  1: string name,
+  2: string type,
+  3: string url,
+  4: optional string description,
+  5: optional map<string,string> parameters,
+  6: optional string ownerName,
   7: optional PrincipalType ownerType,
   8: optional i32 createTime
 }
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/client/builder/DatabaseBuilder.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/client/builder/DatabaseBuilder.java
index 806bf0f..8cd4b85 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/client/builder/DatabaseBuilder.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/client/builder/DatabaseBuilder.java
@@ -44,6 +44,7 @@ public class DatabaseBuilder {
   private PrincipalType ownerType;
   private int createTime;
   private DatabaseType type;
+  private String connectorName, remoteDBName;
 
   public DatabaseBuilder() {
   }
@@ -109,6 +110,16 @@ public class DatabaseBuilder {
     return this;
   }
 
+  public DatabaseBuilder setConnectorName(String connectorName) {
+    this.connectorName = connectorName;
+    return this;
+  }
+
+  public DatabaseBuilder setRemoteDBName(String remoteDBName) {
+    this.remoteDBName = remoteDBName;
+    return this;
+  }
+
   public Database build(Configuration conf) throws MetaException {
     if (name == null) throw new MetaException("You must name the database");
     if (catalogName == null) catalogName = MetaStoreUtils.getDefaultCatalog(conf);
@@ -122,7 +133,19 @@ public class DatabaseBuilder {
       db.setOwnerName(ownerName);
       if (ownerType == null) ownerType = PrincipalType.USER;
       db.setOwnerType(ownerType);
-      if (type == null) type = DatabaseType.NATIVE;
+      if (type == null) {
+        type = DatabaseType.NATIVE;
+        if (connectorName != null || remoteDBName != null) {
+          throw new MetaException("connector name or remoteDBName cannot be set for database of type NATIVE");
+        }
+      } else if (type == DatabaseType.REMOTE) {
+        if (connectorName == null)
+          throw new MetaException("connector name cannot be null for database of type REMOTE");
+        db.setConnector_name(connectorName);
+        if (remoteDBName != null) {
+          db.setRemote_dbname(remoteDBName);
+        }
+      }
       db.setType(type);
       return db;
     } catch (IOException e) {
diff --git a/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-4.0.0.derby.sql b/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-4.0.0.derby.sql
index f51b712..9e9e7ea 100644
--- a/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-4.0.0.derby.sql
+++ b/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-4.0.0.derby.sql
@@ -25,7 +25,7 @@ CREATE TABLE "APP"."DBS" (
   "CTLG_NAME" VARCHAR(256) NOT NULL DEFAULT 'hive',
   "CREATE_TIME" INTEGER,
   "DB_MANAGED_LOCATION_URI" VARCHAR(4000),
-  "TYPE" VARCHAR(32) DEFAULT 'NATIVE',
+  "TYPE" VARCHAR(32) DEFAULT 'NATIVE' NOT NULL,
   "DATACONNECTOR_NAME" VARCHAR(128),
   "REMOTE_DBNAME" VARCHAR(128)
 );
diff --git a/standalone-metastore/metastore-server/src/main/sql/derby/upgrade-3.2.0-to-4.0.0.derby.sql b/standalone-metastore/metastore-server/src/main/sql/derby/upgrade-3.2.0-to-4.0.0.derby.sql
index ed37748..a31e663 100644
--- a/standalone-metastore/metastore-server/src/main/sql/derby/upgrade-3.2.0-to-4.0.0.derby.sql
+++ b/standalone-metastore/metastore-server/src/main/sql/derby/upgrade-3.2.0-to-4.0.0.derby.sql
@@ -151,8 +151,9 @@ ALTER TABLE COMPLETED_COMPACTIONS ADD CC_WORKER_VERSION varchar(128);
 CREATE TABLE "APP"."DATACONNECTORS" ("DC_NAME" VARCHAR(128) NOT NULL, "TYPE" VARCHAR(128) NOT NULL, "COMMENT" VARCHAR(256), "OWNER_NAME" VARCHAR(256), "OWNER_TYPE" VARCHAR(10), "CREATE_TIME" INTEGER);
 CREATE TABLE "APP"."DATACONNECTORS" ("DC_NAME" VARCHAR(128) NOT NULL, "TYPE" VARCHAR(128) NOT NULL, "COMMENT" VARCHAR(256), "OWNER_NAME" VARCHAR(256), "OWNER_TYPE" VARCHAR(10), "CREATE_TIME" INTEGER NOT NULL);
 CREATE TABLE "APP"."DATACONNECTOR_PARAMS" ("DC_NAME" VARCHAR(128) NOT NULL, "PARAM_KEY" VARCHAR(180) NOT NULL, "PARAM_VALUE" VARCHAR(4000), "COMMENT" VARCHAR(256));
-ALTER TABLE "APP"."DBS" ADD COLUMN "TYPE" VARCHAR(32) DEFAULT 'NATIVE';
+ALTER TABLE "APP"."DBS" ADD COLUMN "TYPE" VARCHAR(32) DEFAULT 'NATIVE' NOT NULL;
 ALTER TABLE "APP"."DBS" ADD COLUMN "DATACONNECTOR_NAME" VARCHAR(128);
+ALTER TABLE "APP"."DBS" ADD COLUMN "REMOTE_DBNAME" VARCHAR(128);
 UPDATE "APP"."DBS" SET TYPE='NATIVE' WHERE TYPE IS NULL;
 ALTER TABLE "APP"."DATACONNECTORS" ADD CONSTRAINT "DATACONNECTORS_KEY_PK" PRIMARY KEY ("DC_NAME");
 ALTER TABLE "APP"."DATACONNECTOR_PARAMS" ADD CONSTRAINT "DATACONNECTOR_PARAMS_KEY_PK" PRIMARY KEY ("DC_NAME", "PARAM_KEY");
diff --git a/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-4.0.0.mysql.sql b/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-4.0.0.mysql.sql
index 48e6f7d..97ed533 100644
--- a/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-4.0.0.mysql.sql
+++ b/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-4.0.0.mysql.sql
@@ -105,7 +105,7 @@ CREATE TABLE IF NOT EXISTS `DBS` (
   `CTLG_NAME` varchar(256) NOT NULL DEFAULT 'hive',
   `CREATE_TIME` INT(11),
   `DB_MANAGED_LOCATION_URI` varchar(4000) CHARACTER SET latin1 COLLATE latin1_bin,
-  `TYPE` VARCHAR(32) DEFAULT 'NATIVE',
+  `TYPE` VARCHAR(32) DEFAULT 'NATIVE' NOT NULL,
   `DATACONNECTOR_NAME` VARCHAR(128),
   `REMOTE_DBNAME` VARCHAR(128),
   PRIMARY KEY (`DB_ID`),
diff --git a/standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-3.2.0-to-4.0.0.mysql.sql b/standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-3.2.0-to-4.0.0.mysql.sql
index e86c8b0..03bef05 100644
--- a/standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-3.2.0-to-4.0.0.mysql.sql
+++ b/standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-3.2.0-to-4.0.0.mysql.sql
@@ -175,10 +175,10 @@ CREATE TABLE `DATACONNECTOR_PARAMS` (
   CONSTRAINT `DATACONNECTOR_NAME_FK1` FOREIGN KEY (`NAME`) REFERENCES `DATACONNECTORS` (`NAME`) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
-ALTER TABLE `DBS` ADD COLUMN `TYPE` VARCHAR(32) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT 'NATIVE';
-UPDATE `DBS` SET `TYPE` = 'NATIVE' WHERE `TYPE` IS NULL;
+ALTER TABLE `DBS` ADD COLUMN `TYPE` VARCHAR(32) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT 'NATIVE' NOT NULL;
 ALTER TABLE `DBS` ADD COLUMN `DATACONNECTOR_NAME` VARCHAR(128) CHARACTER SET latin1 COLLATE latin1_bin;
 ALTER TABLE `DBS` ADD COLUMN `REMOTE_DBNAME` VARCHAR(128) CHARACTER SET latin1 COLLATE latin1_bin;
+UPDATE `DBS` SET `TYPE` = 'NATIVE' WHERE `TYPE` IS NULL;
 
 -- These lines need to be last.  Insert any changes above.
 UPDATE VERSION SET SCHEMA_VERSION='4.0.0', VERSION_COMMENT='Hive release version 4.0.0' where VER_ID=1;
diff --git a/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-4.0.0.oracle.sql b/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-4.0.0.oracle.sql
index 1292aee..fbe6266 100644
--- a/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-4.0.0.oracle.sql
+++ b/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-4.0.0.oracle.sql
@@ -102,7 +102,10 @@ CREATE TABLE DBS
     OWNER_TYPE VARCHAR2(10) NULL,
     CTLG_NAME VARCHAR2(256) DEFAULT 'hive' NOT NULL,
     CREATE_TIME NUMBER (10),
-    DB_MANAGED_LOCATION_URI VARCHAR2(4000) NULL
+    DB_MANAGED_LOCATION_URI VARCHAR2(4000) NULL,
+    TYPE VARCHAR2(32) DEFAULT 'NATIVE' NOT NULL,
+    DATACONNECTOR_NAME VARCHAR2(128) NULL,
+    REMOTE_DBNAME VARCHAR2(128) NULL
 );
 
 ALTER TABLE DBS ADD CONSTRAINT DBS_PK PRIMARY KEY (DB_ID);
@@ -1279,6 +1282,26 @@ CREATE TABLE "PACKAGES" (
 CREATE UNIQUE INDEX UNIQUEPKG ON PACKAGES ("NAME", "DB_ID");
 ALTER TABLE "PACKAGES" ADD CONSTRAINT "PACKAGES_FK1" FOREIGN KEY ("DB_ID") REFERENCES "DBS" ("DB_ID");
 
+-- HIVE-24396
+-- Create DataConnectors and DataConnector_Params tables
+CREATE TABLE DATACONNECTORS (
+  NAME VARCHAR2(128) NOT NULL,
+  TYPE VARCHAR2(32) NOT NULL,
+  URL VARCHAR2(4000) NOT NULL,
+  "COMMENT" VARCHAR2(256),
+  OWNER_NAME VARCHAR2(256),
+  OWNER_TYPE VARCHAR2(10),
+  CREATE_TIME NUMBER(10) NOT NULL,
+  PRIMARY KEY (NAME)
+);
+
+CREATE TABLE DATACONNECTOR_PARAMS (
+  NAME VARCHAR2(128) NOT NULL,
+  PARAM_KEY VARCHAR2(180) NOT NULL,
+  PARAM_VALUE VARCHAR2(4000),
+  PRIMARY KEY (NAME, PARAM_KEY),
+  CONSTRAINT DATACONNECTOR_NAME_FK1 FOREIGN KEY (NAME) REFERENCES DATACONNECTORS (NAME) ON DELETE CASCADE
+);
 
 -- -----------------------------------------------------------------
 -- Record schema version. Should be the last step in the init script
diff --git a/standalone-metastore/metastore-server/src/main/sql/oracle/upgrade-3.2.0-to-4.0.0.oracle.sql b/standalone-metastore/metastore-server/src/main/sql/oracle/upgrade-3.2.0-to-4.0.0.oracle.sql
index eb1faa0..e0354f1 100644
--- a/standalone-metastore/metastore-server/src/main/sql/oracle/upgrade-3.2.0-to-4.0.0.oracle.sql
+++ b/standalone-metastore/metastore-server/src/main/sql/oracle/upgrade-3.2.0-to-4.0.0.oracle.sql
@@ -146,6 +146,31 @@ CREATE INDEX CTLG_NAME_DBS ON DBS(CTLG_NAME);
 
 -- HIVE-24770
 UPDATE SERDES SET SLIB='org.apache.hadoop.hive.serde2.MultiDelimitSerDe' where SLIB='org.apache.hadoop.hive.contrib.serde2.MultiDelimitSerDe';
+=======
+-- HIVE-24396
+-- Create DataConnectors and DataConnector_Params tables
+CREATE TABLE DATACONNECTORS (
+  NAME VARCHAR2(128) NOT NULL,
+  TYPE VARCHAR2(32) NOT NULL,
+  URL VARCHAR2(4000) NOT NULL,
+  "COMMENT" VARCHAR2(256),
+  OWNER_NAME VARCHAR2(256),
+  OWNER_TYPE VARCHAR2(10),
+  CREATE_TIME NUMBER(10) NOT NULL,
+  PRIMARY KEY (NAME)
+);
+
+CREATE TABLE DATACONNECTOR_PARAMS (
+  NAME VARCHAR2(128) NOT NULL,
+  PARAM_KEY VARCHAR2(180) NOT NULL,
+  PARAM_VALUE VARCHAR2(4000),
+  PRIMARY KEY (NAME, PARAM_KEY),
+  CONSTRAINT DATACONNECTOR_NAME_FK1 FOREIGN KEY (NAME) REFERENCES DATACONNECTORS (NAME) ON DELETE CASCADE
+);
+ALTER TABLE DBS ADD TYPE VARCHAR2(32) DEFAULT 'NATIVE' NOT NULL;
+ALTER TABLE DBS ADD DATACONNECTOR_NAME VARCHAR2(128) NULL;
+ALTER TABLE DBS ADD REMOTE_DBNAME VARCHAR2(128) NULL;
+UPDATE DBS SET TYPE='NATIVE' WHERE TYPE IS NULL;
 
 -- HIVE-24880
 ALTER TABLE COMPACTION_QUEUE ADD CQ_INITIATOR_ID varchar(128);
diff --git a/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-4.0.0.postgres.sql b/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-4.0.0.postgres.sql
index 998b66e..b86628b 100644
--- a/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-4.0.0.postgres.sql
+++ b/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-4.0.0.postgres.sql
@@ -84,7 +84,7 @@ CREATE TABLE "DBS" (
     "CTLG_NAME" varchar(256) DEFAULT 'hive' NOT NULL,
     "CREATE_TIME" bigint,
     "DB_MANAGED_LOCATION_URI" character varying(4000),
-    "TYPE" character varying(32) DEFAULT 'NATIVE',
+    "TYPE" character varying(32) DEFAULT 'NATIVE' NOT NULL,
     "DATACONNECTOR_NAME" character varying(128),
     "REMOTE_DBNAME" character varying(128)
 );
diff --git a/standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-3.2.0-to-4.0.0.postgres.sql b/standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-3.2.0-to-4.0.0.postgres.sql
index afbdacf..6f6d5a7 100644
--- a/standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-3.2.0-to-4.0.0.postgres.sql
+++ b/standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-3.2.0-to-4.0.0.postgres.sql
@@ -298,10 +298,10 @@ CREATE TABLE "DATACONNECTOR_PARAMS" (
   PRIMARY KEY ("NAME", "PARAM_KEY"),
   CONSTRAINT "DATACONNECTOR_NAME_FK1" FOREIGN KEY ("NAME") REFERENCES "DATACONNECTORS"("NAME") ON DELETE CASCADE
 );
-ALTER TABLE "DBS" ADD "TYPE" character varying(32);
-UPDATE "DBS" SET "TYPE"= 'NATIVE' WHERE "TYPE" IS NULL;
+ALTER TABLE "DBS" ADD "TYPE" character varying(32) DEFAULT 'NATIVE' NOT NULL;
 ALTER TABLE "DBS" ADD "DATACONNECTOR_NAME" character varying(128);
 ALTER TABLE "DBS" ADD "REMOTE_DBNAME" character varying(128);
+UPDATE "DBS" SET "TYPE"= 'NATIVE' WHERE "TYPE" IS NULL;
 
 -- These lines need to be last. Insert any changes above.
 UPDATE "VERSION" SET "SCHEMA_VERSION"='4.0.0', "VERSION_COMMENT"='Hive release version 4.0.0' where "VER_ID"=1;
diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
index 75b0fcf..0c740ab 100644
--- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
+++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
@@ -44,6 +44,8 @@ import java.lang.reflect.*;
 import static org.mockito.Mockito.mock;
 
 import com.google.common.collect.Sets;
+import org.apache.hadoop.hive.metastore.api.DataConnector;
+import org.apache.hadoop.hive.metastore.api.DatabaseType;
 import org.apache.hadoop.hive.metastore.api.GetPartitionsFilterSpec;
 import org.apache.hadoop.hive.metastore.api.GetProjectionsSpec;
 import org.apache.hadoop.hive.metastore.api.GetPartitionsRequest;
@@ -55,6 +57,7 @@ import org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder;
 import org.apache.hadoop.hive.metastore.client.builder.TableBuilder;
 import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
 import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars;
+import org.apache.hadoop.hive.metastore.dataconnector.jdbc.AbstractJDBCConnectorProvider;
 import org.apache.hadoop.hive.metastore.utils.FileUtils;
 import org.apache.hadoop.hive.metastore.utils.MetaStoreServerUtils;
 import org.apache.hadoop.hive.metastore.utils.MetastoreVersionInfo;
@@ -105,6 +108,7 @@ import com.google.common.collect.Lists;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
@@ -3488,4 +3492,136 @@ public abstract class TestHiveMetaStore {
 
     silentDropDatabase(dbName);
   }
+
+  @Test
+  public void testDataConnector() throws Throwable {
+    final String connector_name1 = "test_connector1";
+    final String connector_name2 = "test_connector2";
+    final String mysql_type = "mysql";
+    final String mysql_url = "jdbc:mysql://nightly1.apache.org:3306/hive1";
+    final String postgres_type = "postgres";
+    final String postgres_url = "jdbc:postgresql://localhost:5432";
+
+    try {
+      DataConnector connector = new DataConnector(connector_name1, mysql_type, mysql_url);
+      Map<String, String> params = new HashMap<>();
+      params.put(AbstractJDBCConnectorProvider.JDBC_USERNAME, "hive");
+      params.put(AbstractJDBCConnectorProvider.JDBC_PASSWORD, "hive");
+      connector.setParameters(params);
+      client.createDataConnector(connector);
+
+      DataConnector dConn = client.getDataConnector(connector_name1);
+      assertNotNull(dConn);
+      assertEquals("name of returned data connector is different from that of inserted connector", connector_name1,
+          dConn.getName());
+      assertEquals("type of data connector returned is different from the type inserted", mysql_type, dConn.getType());
+      assertEquals("url of the data connector returned is different from the url inserted", mysql_url, dConn.getUrl());
+      assertEquals(SecurityUtils.getUser(), dConn.getOwnerName());
+      assertEquals(PrincipalType.USER, dConn.getOwnerType());
+      assertNotEquals("Size of data connector parameters not as expected", 0, dConn.getParametersSize());
+
+      try {
+        client.createDataConnector(connector);
+        fail("Creating duplicate connector should fail");
+      } catch (Exception e) { /* as expected */ }
+
+      connector = new DataConnector(connector_name2, postgres_type, postgres_url);
+      params = new HashMap<>();
+      params.put(AbstractJDBCConnectorProvider.JDBC_USERNAME, "hive");
+      params.put(AbstractJDBCConnectorProvider.JDBC_PASSWORD, "hive");
+      connector.setParameters(params);
+      client.createDataConnector(connector);
+
+      dConn = client.getDataConnector(connector_name2);
+      assertEquals("name of returned data connector is different from that of inserted connector", connector_name2,
+          dConn.getName());
+      assertEquals("type of data connector returned is different from the type inserted", postgres_type, dConn.getType());
+      assertEquals("url of the data connector returned is different from the url inserted", postgres_url, dConn.getUrl());
+
+      List<String> connectors = client.getAllDataConnectors();
+      assertEquals("Number of dataconnectors returned is not as expected", 2, connectors.size());
+
+      DataConnector connector1 = new DataConnector(connector);
+      connector1.setUrl(mysql_url);
+      client.alterDataConnector(connector.getName(), connector1);
+
+      dConn = client.getDataConnector(connector.getName());
+      assertEquals("url of the data connector returned is different from the url inserted", mysql_url, dConn.getUrl());
+
+      // alter data connector parameters
+      params.put(AbstractJDBCConnectorProvider.JDBC_NUM_PARTITIONS, "5");
+      connector1.setParameters(params);
+      client.alterDataConnector(connector.getName(), connector1);
+
+      dConn = client.getDataConnector(connector.getName());
+      assertEquals("Size of data connector parameters not as expected", 3, dConn.getParametersSize());
+
+      // alter data connector parameters
+      connector1.setOwnerName("hiveadmin");
+      connector1.setOwnerType(PrincipalType.ROLE);
+      client.alterDataConnector(connector.getName(), connector1);
+
+      dConn = client.getDataConnector(connector.getName());
+      assertEquals("Data connector owner name not as expected", "hiveadmin", dConn.getOwnerName());
+      assertEquals("Data connector owner type not as expected", PrincipalType.ROLE, dConn.getOwnerType());
+
+      client.dropDataConnector(connector_name1, false, false);
+      connectors = client.getAllDataConnectors();
+      assertEquals("Number of dataconnectors returned is not as expected", 1, connectors.size());
+
+      client.dropDataConnector(connector_name2, false, false);
+      connectors = client.getAllDataConnectors();
+      assertEquals("Number of dataconnectors returned is not as expected", 0, connectors.size());
+    } catch (Throwable e) {
+      System.err.println(StringUtils.stringifyException(e));
+      System.err.println("testDataConnector() failed.");
+      throw e;
+    }
+  }
+
+  @Test
+  public void testRemoteDatabase() throws Throwable {
+    final String connector_name1 = "test_connector1";
+    final String mysql_type = "mysql";
+    final String mysql_url = "jdbc:mysql://nightly1.apache.org:3306/hive1";
+    final String db_name = "mysql_remote";
+    final String db2 = "mysql_dup";
+
+    try {
+      DataConnector connector = new DataConnector(connector_name1, mysql_type, mysql_url);
+      Map<String, String> params = new HashMap<>();
+      params.put(AbstractJDBCConnectorProvider.JDBC_USERNAME, "hive");
+      params.put(AbstractJDBCConnectorProvider.JDBC_PASSWORD, "hive");
+      connector.setParameters(params);
+      client.createDataConnector(connector);
+
+      DataConnector dConn = client.getDataConnector(connector_name1);
+      new DatabaseBuilder().setName(db_name).setType(DatabaseType.REMOTE).setConnectorName(connector_name1)
+          .setRemoteDBName(db_name).create(client, conf);
+
+      Database db = client.getDatabase(db_name);
+      assertNotNull(db);
+      assertEquals(db.getType(), DatabaseType.REMOTE);
+      assertEquals(db.getConnector_name(), connector_name1);
+      assertEquals(db.getRemote_dbname(), db_name);
+
+      // new db in hive pointing to same remote db.
+      new DatabaseBuilder().setName(db2).setType(DatabaseType.REMOTE).setConnectorName(connector_name1)
+          .setRemoteDBName(db_name).create(client, conf);
+
+      db = client.getDatabase(db2);
+      assertNotNull(db);
+      assertEquals(db.getType(), DatabaseType.REMOTE);
+      assertEquals(db.getConnector_name(), connector_name1);
+      assertEquals(db.getRemote_dbname(), db_name);
+
+      client.dropDataConnector(connector_name1, false, false);
+      client.dropDatabase(db_name);
+      client.dropDatabase(db2);
+    } catch (Throwable e) {
+      System.err.println(StringUtils.stringifyException(e));
+      System.err.println("testRemoteDatabase() failed.");
+      throw e;
+    }
+  }
 }
diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/tools/schematool/TestSchemaToolForMetastore.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/tools/schematool/TestSchemaToolForMetastore.java
index 709c90c..f6a029a 100644
--- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/tools/schematool/TestSchemaToolForMetastore.java
+++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/tools/schematool/TestSchemaToolForMetastore.java
@@ -111,7 +111,7 @@ public class TestSchemaToolForMetastore {
     String[] scripts = new String[] {
         "insert into CTLGS values(99, 'test_cat_1', 'description', 'hdfs://myhost.com:8020/user/hive/warehouse/mydb', " + time + ");",
         "insert into SEQUENCE_TABLE values('org.apache.hadoop.hive.metastore.model.MDatabase', 100);",
-        "insert into DBS values(99, 'test db1', 'hdfs:///tmp/ext', 'db1', 'test', 'test', 'test_cat_1', " + time + ", 'hdfs:///tmp/mgd');"
+        "insert into DBS values(99, 'test db1', 'hdfs:///tmp/ext', 'db1', 'test', 'test', 'test_cat_1', " + time + ", 'hdfs:///tmp/mgd', 'NATIVE', '', '');"
     };
     File scriptFile = generateTestScript(scripts);
     schemaTool.execSql(scriptFile.getPath());
@@ -123,7 +123,7 @@ public class TestSchemaToolForMetastore {
         "delete from SEQUENCE_TABLE;",
         "delete from DBS;",
         "insert into SEQUENCE_TABLE values('org.apache.hadoop.hive.metastore.model.MDatabase', 100);",
-        "insert into DBS values(102, 'test db1', 'hdfs:///tmp/ext', 'db1', 'test', 'test', 'test_cat_1', " + time + ", 'hdfs:///tmp/mgd');"
+        "insert into DBS values(102, 'test db1', 'hdfs:///tmp/ext', 'db1', 'test', 'test', 'test_cat_1', " + time + ", 'hdfs:///tmp/mgd', 'NATIVE', '', '');"
     };
     scriptFile = generateTestScript(scripts);
     schemaTool.execSql(scriptFile.getPath());
@@ -388,8 +388,8 @@ public class TestSchemaToolForMetastore {
     // Test valid case
     String[] scripts = new String[] {
         "insert into CTLGS values(3, 'test_cat_2', 'description', 'hdfs://myhost.com:8020/user/hive/warehouse/mydb', " + time + ");",
-        "insert into DBS values(2, 'my db', 'hdfs://myhost.com:8020/user/hive/warehouse/mydb', 'mydb', 'public', 'role', 'test_cat_2', " + time + ", '');",
-        "insert into DBS values(7, 'db with bad port', 'hdfs://myhost.com:8020/', 'haDB', 'public', 'role', 'test_cat_2', " + time + ", '');",
+        "insert into DBS values(2, 'my db', 'hdfs://myhost.com:8020/user/hive/warehouse/mydb', 'mydb', 'public', 'role', 'test_cat_2', " + time + ", '', 'NATIVE', '', '');",
+        "insert into DBS values(7, 'db with bad port', 'hdfs://myhost.com:8020/', 'haDB', 'public', 'role', 'test_cat_2', " + time + ", '', 'NATIVE', '', '');",
         "insert into SDS(SD_ID,CD_ID,INPUT_FORMAT,IS_COMPRESSED,IS_STOREDASSUBDIRECTORIES,LOCATION,NUM_BUCKETS,OUTPUT_FORMAT,SERDE_ID) values (1,null,'org.apache.hadoop.mapred.TextInputFormat','N','N','hdfs://myhost.com:8020/user/hive/warehouse/mydb',-1,'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat',null);",
         "insert into SDS(SD_ID,CD_ID,INPUT_FORMAT,IS_COMPRESSED,IS_STOREDASSUBDIRECTORIES,LOCATION,NUM_BUCKETS,OUTPUT_FORMAT,SERDE_ID) values (2,null,'org.apache.hadoop.mapred.TextInputFormat','N','N','hdfs://myhost.com:8020/user/admin/2015_11_18',-1,'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat',null);",
         "insert into SDS(SD_ID,CD_ID,INPUT_FORMAT,IS_COMPRESSED,IS_STOREDASSUBDIRECTORIES,LOCATION,NUM_BUCKETS,OUTPUT_FORMAT,SERDE_ID) values (3,null,'org.apache.hadoop.mapred.TextInputFormat','N','N',null,-1,'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat',null);",
@@ -416,10 +416,10 @@ public class TestSchemaToolForMetastore {
         "delete from TBLS;",
         "delete from SDS;",
         "delete from DBS;",
-        "insert into DBS values(2, 'my db', '/user/hive/warehouse/mydb', 'mydb', 'public', 'role', 'test_cat_2', " + time + ", '');",
-        "insert into DBS values(4, 'my db2', 'hdfs://myhost.com:8020', '', 'public', 'role', 'test_cat_2', " + time + ", '');",
-        "insert into DBS values(6, 'db with bad port', 'hdfs://myhost.com:8020:', 'zDB', 'public', 'role', 'test_cat_2', " + time + ", '');",
-        "insert into DBS values(7, 'db with bad port', 'hdfs://mynameservice.com/', 'haDB', 'public', 'role', 'test_cat_2', " + time + ", '');",
+        "insert into DBS values(2, 'my db', '/user/hive/warehouse/mydb', 'mydb', 'public', 'role', 'test_cat_2', " + time + ", '', 'NATIVE', '', '');",
+        "insert into DBS values(4, 'my db2', 'hdfs://myhost.com:8020', '', 'public', 'role', 'test_cat_2', " + time + ", '', 'NATIVE', '', '');",
+        "insert into DBS values(6, 'db with bad port', 'hdfs://myhost.com:8020:', 'zDB', 'public', 'role', 'test_cat_2', " + time + ", '', 'NATIVE', '', '');",
+        "insert into DBS values(7, 'db with bad port', 'hdfs://mynameservice.com/', 'haDB', 'public', 'role', 'test_cat_2', " + time + ", '', 'NATIVE', '', '');",
         "insert into SDS(SD_ID,CD_ID,INPUT_FORMAT,IS_COMPRESSED,IS_STOREDASSUBDIRECTORIES,LOCATION,NUM_BUCKETS,OUTPUT_FORMAT,SERDE_ID) values (1,null,'org.apache.hadoop.mapred.TextInputFormat','N','N','hdfs://yourhost.com:8020/user/hive/warehouse/mydb',-1,'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat',null);",
         "insert into SDS(SD_ID,CD_ID,INPUT_FORMAT,IS_COMPRESSED,IS_STOREDASSUBDIRECTORIES,LOCATION,NUM_BUCKETS,OUTPUT_FORMAT,SERDE_ID) values (2,null,'org.apache.hadoop.mapred.TextInputFormat','N','N','file:///user/admin/2015_11_18',-1,'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat',null);",
         "insert into TBLS(TBL_ID,CREATE_TIME,DB_ID,LAST_ACCESS_TIME,OWNER,RETENTION,SD_ID,TBL_NAME,TBL_TYPE,VIEW_EXPANDED_TEXT,VIEW_ORIGINAL_TEXT,IS_REWRITE_ENABLED) values (2 ,1435255431,2,0 ,'hive',0,1,'mytal','MANAGED_TABLE',NULL,NULL,'n');",
@@ -519,7 +519,7 @@ public class TestSchemaToolForMetastore {
     String time = String.valueOf(System.currentTimeMillis()/1000);
      String[] scripts = new String[] {
           "insert into CTLGS values (2, 'mycat', 'my description', 'hdfs://myhost.com:8020/user/hive/warehouse', " + time + ");",
-          "insert into DBS values(2, 'my db', 'hdfs://myhost.com:8020/user/hive/warehouse/mydb', 'mydb', 'public', 'role', 'mycat', " + time + ", '');",
+          "insert into DBS values(2, 'my db', 'hdfs://myhost.com:8020/user/hive/warehouse/mydb', 'mydb', 'public', 'role', 'mycat', " + time + ", '', 'NATIVE', '', '');",
           "insert into SDS(SD_ID,CD_ID,INPUT_FORMAT,IS_COMPRESSED,IS_STOREDASSUBDIRECTORIES,LOCATION,NUM_BUCKETS,OUTPUT_FORMAT,SERDE_ID) values (1,null,'org.apache.hadoop.mapred.TextInputFormat','N','N','hdfs://myhost.com:8020/user/hive/warehouse/mydb',-1,'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat',null);",
           "insert into SDS(SD_ID,CD_ID,INPUT_FORMAT,IS_COMPRESSED,IS_STOREDASSUBDIRECTORIES,LOCATION,NUM_BUCKETS,OUTPUT_FORMAT,SERDE_ID) values (2,null,'org.apache.hadoop.mapred.TextInputFormat','N','N','hdfs://myhost.com:8020/user/admin/2015_11_18',-1,'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat',null);",
           "insert into TBLS(TBL_ID,CREATE_TIME,DB_ID,LAST_ACCESS_TIME,OWNER,RETENTION,SD_ID,TBL_NAME,TBL_TYPE,VIEW_EXPANDED_TEXT,VIEW_ORIGINAL_TEXT,IS_REWRITE_ENABLED) values (2 ,1435255431,2,0 ,'hive',0,1,'mytal','MANAGED_TABLE',NULL,NULL,'n');",

[hive] 09/38: Adding schema changes for mysql and postgres as well

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit b30173d4c27d9c6b44913c3c8f1f766b36990189
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Wed Nov 18 13:37:31 2020 -0500

    Adding schema changes for mysql and postgres as well
---
 .../src/main/sql/derby/hive-schema-4.0.0.derby.sql |  3 ++-
 .../sql/derby/upgrade-3.2.0-to-4.0.0.derby.sql     |  2 ++
 .../src/main/sql/mysql/hive-schema-4.0.0.mysql.sql | 24 ++++++++++++++++++++
 .../sql/mysql/upgrade-3.2.0-to-4.0.0.mysql.sql     | 26 ++++++++++++++++++++++
 .../sql/postgres/hive-schema-4.0.0.postgres.sql    | 25 ++++++++++++++++++++-
 .../postgres/upgrade-3.2.0-to-4.0.0.postgres.sql   | 25 +++++++++++++++++++++
 6 files changed, 103 insertions(+), 2 deletions(-)

diff --git a/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-4.0.0.derby.sql b/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-4.0.0.derby.sql
index 7829f0f..f51b712 100644
--- a/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-4.0.0.derby.sql
+++ b/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-4.0.0.derby.sql
@@ -818,7 +818,8 @@ CREATE TABLE "APP"."STORED_PROCS" (
 
 CREATE UNIQUE INDEX "UNIQUESTOREDPROC" ON "STORED_PROCS" ("NAME", "DB_ID");
 ALTER TABLE "STORED_PROCS" ADD CONSTRAINT "STOREDPROC_FK1" FOREIGN KEY ("DB_ID") REFERENCES "DBS" ("DB_ID");
-CREATE TABLE "APP"."DATACONNECTORS" ("NAME" VARCHAR(128) NOT NULL, "TYPE" VARCHAR(32) NOT NULL, "URL" VARCHAR(4000) NOT NULL, "COMMENT" VARCHAR(256), "OWNER_NAME" VARCHAR(256), "OWNER_TYPE" VARCHAR(10), "CREATE_TIME" INTEGER);
+
+CREATE TABLE "APP"."DATACONNECTORS" ("NAME" VARCHAR(128) NOT NULL, "TYPE" VARCHAR(32) NOT NULL, "URL" VARCHAR(4000) NOT NULL, "COMMENT" VARCHAR(256), "OWNER_NAME" VARCHAR(256), "OWNER_TYPE" VARCHAR(10), "CREATE_TIME" INTEGER NOT NULL);
 CREATE TABLE "APP"."DATACONNECTOR_PARAMS" ("NAME" VARCHAR(128) NOT NULL, "PARAM_KEY" VARCHAR(180) NOT NULL, "PARAM_VALUE" VARCHAR(4000));
 ALTER TABLE "APP"."DATACONNECTORS" ADD CONSTRAINT "DATACONNECTORS_KEY_PK" PRIMARY KEY ("NAME");
 ALTER TABLE "APP"."DATACONNECTOR_PARAMS" ADD CONSTRAINT "DATACONNECTOR_PARAMS_KEY_PK" PRIMARY KEY ("NAME", "PARAM_KEY");
diff --git a/standalone-metastore/metastore-server/src/main/sql/derby/upgrade-3.2.0-to-4.0.0.derby.sql b/standalone-metastore/metastore-server/src/main/sql/derby/upgrade-3.2.0-to-4.0.0.derby.sql
index 0bc9003..ed37748 100644
--- a/standalone-metastore/metastore-server/src/main/sql/derby/upgrade-3.2.0-to-4.0.0.derby.sql
+++ b/standalone-metastore/metastore-server/src/main/sql/derby/upgrade-3.2.0-to-4.0.0.derby.sql
@@ -149,9 +149,11 @@ ALTER TABLE COMPLETED_COMPACTIONS ADD CC_WORKER_VERSION varchar(128);
 
 -- HIVE-24396
 CREATE TABLE "APP"."DATACONNECTORS" ("DC_NAME" VARCHAR(128) NOT NULL, "TYPE" VARCHAR(128) NOT NULL, "COMMENT" VARCHAR(256), "OWNER_NAME" VARCHAR(256), "OWNER_TYPE" VARCHAR(10), "CREATE_TIME" INTEGER);
+CREATE TABLE "APP"."DATACONNECTORS" ("DC_NAME" VARCHAR(128) NOT NULL, "TYPE" VARCHAR(128) NOT NULL, "COMMENT" VARCHAR(256), "OWNER_NAME" VARCHAR(256), "OWNER_TYPE" VARCHAR(10), "CREATE_TIME" INTEGER NOT NULL);
 CREATE TABLE "APP"."DATACONNECTOR_PARAMS" ("DC_NAME" VARCHAR(128) NOT NULL, "PARAM_KEY" VARCHAR(180) NOT NULL, "PARAM_VALUE" VARCHAR(4000), "COMMENT" VARCHAR(256));
 ALTER TABLE "APP"."DBS" ADD COLUMN "TYPE" VARCHAR(32) DEFAULT 'NATIVE';
 ALTER TABLE "APP"."DBS" ADD COLUMN "DATACONNECTOR_NAME" VARCHAR(128);
+UPDATE "APP"."DBS" SET TYPE='NATIVE' WHERE TYPE IS NULL;
 ALTER TABLE "APP"."DATACONNECTORS" ADD CONSTRAINT "DATACONNECTORS_KEY_PK" PRIMARY KEY ("DC_NAME");
 ALTER TABLE "APP"."DATACONNECTOR_PARAMS" ADD CONSTRAINT "DATACONNECTOR_PARAMS_KEY_PK" PRIMARY KEY ("DC_NAME", "PARAM_KEY");
 ALTER TABLE "APP"."DATACONNECTOR_PARAMS" ADD CONSTRAINT "DC_NAME_FK1" FOREIGN KEY ("DC_NAME") REFERENCES "APP"."DATACONNECTORS" ("DC_NAME") ON DELETE NO ACTION ON UPDATE NO ACTION;
diff --git a/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-4.0.0.mysql.sql b/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-4.0.0.mysql.sql
index 8744319..48e6f7d 100644
--- a/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-4.0.0.mysql.sql
+++ b/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-4.0.0.mysql.sql
@@ -105,6 +105,9 @@ CREATE TABLE IF NOT EXISTS `DBS` (
   `CTLG_NAME` varchar(256) NOT NULL DEFAULT 'hive',
   `CREATE_TIME` INT(11),
   `DB_MANAGED_LOCATION_URI` varchar(4000) CHARACTER SET latin1 COLLATE latin1_bin,
+  `TYPE` VARCHAR(32) DEFAULT 'NATIVE',
+  `DATACONNECTOR_NAME` VARCHAR(128),
+  `REMOTE_DBNAME` VARCHAR(128),
   PRIMARY KEY (`DB_ID`),
   UNIQUE KEY `UNIQUE_DATABASE` (`NAME`, `CTLG_NAME`),
   CONSTRAINT `CTLG_FK1` FOREIGN KEY (`CTLG_NAME`) REFERENCES `CTLGS` (`NAME`)
@@ -1304,6 +1307,27 @@ CREATE TABLE PACKAGES (
 CREATE UNIQUE INDEX UNIQUEPKG ON PACKAGES (NAME, DB_ID);
 ALTER TABLE `PACKAGES` ADD CONSTRAINT `PACKAGES_FK1` FOREIGN KEY (`DB_ID`) REFERENCES DBS (`DB_ID`);
 
+-- HIVE-24396
+-- Create DataConnectors and DataConnector_Params tables
+CREATE TABLE `DATACONNECTORS` (
+  `NAME` VARCHAR(128) NOT NULL,
+  `TYPE` VARCHAR(32) NOT NULL,
+  `URL` VARCHAR(4000) NOT NULL,
+  `COMMENT` VARCHAR(256),
+  `OWNER_NAME` VARCHAR(256),
+  `OWNER_TYPE` VARCHAR(10),
+  `CREATE_TIME` INT(11) NOT NULL,
+  PRIMARY KEY (`NAME`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+CREATE TABLE `DATACONNECTOR_PARAMS` (
+  `NAME` VARCHAR(128) NOT NULL,
+  `PARAM_KEY` VARCHAR(180) NOT NULL,
+  `PARAM_VALUE` VARCHAR(4000),
+  PRIMARY KEY (`NAME`, `PARAM_KEY`),
+  CONSTRAINT `DATACONNECTOR_NAME_FK1` FOREIGN KEY (`NAME`) REFERENCES `DATACONNECTORS` (`NAME`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
 -- -----------------------------------------------------------------
 -- Record schema version. Should be the last step in the init script
 -- -----------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-3.2.0-to-4.0.0.mysql.sql b/standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-3.2.0-to-4.0.0.mysql.sql
index 889247d..e86c8b0 100644
--- a/standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-3.2.0-to-4.0.0.mysql.sql
+++ b/standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-3.2.0-to-4.0.0.mysql.sql
@@ -154,6 +154,32 @@ ALTER TABLE COMPLETED_COMPACTIONS ADD CC_INITIATOR_ID varchar(128);
 ALTER TABLE COMPLETED_COMPACTIONS ADD CC_INITIATOR_VERSION varchar(128);
 ALTER TABLE COMPLETED_COMPACTIONS ADD CC_WORKER_VERSION varchar(128);
 
+-- HIVE-24396
+-- Create DataConnectors and DataConnector_Params tables
+CREATE TABLE `DATACONNECTORS` (
+  `NAME` VARCHAR(128) NOT NULL,
+  `TYPE` VARCHAR(32) NOT NULL,
+  `URL` VARCHAR(4000) NOT NULL,
+  `COMMENT` VARCHAR(256),
+  `OWNER_NAME` VARCHAR(256),
+  `OWNER_TYPE` VARCHAR(10),
+  `CREATE_TIME` INT(11) NOT NULL,
+  PRIMARY KEY (`NAME`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+CREATE TABLE `DATACONNECTOR_PARAMS` (
+  `NAME` VARCHAR(128) NOT NULL,
+  `PARAM_KEY` VARCHAR(180) NOT NULL,
+  `PARAM_VALUE` VARCHAR(4000),
+  PRIMARY KEY (`NAME`, `PARAM_KEY`),
+  CONSTRAINT `DATACONNECTOR_NAME_FK1` FOREIGN KEY (`NAME`) REFERENCES `DATACONNECTORS` (`NAME`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+ALTER TABLE `DBS` ADD COLUMN `TYPE` VARCHAR(32) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT 'NATIVE';
+UPDATE `DBS` SET `TYPE` = 'NATIVE' WHERE `TYPE` IS NULL;
+ALTER TABLE `DBS` ADD COLUMN `DATACONNECTOR_NAME` VARCHAR(128) CHARACTER SET latin1 COLLATE latin1_bin;
+ALTER TABLE `DBS` ADD COLUMN `REMOTE_DBNAME` VARCHAR(128) CHARACTER SET latin1 COLLATE latin1_bin;
+
 -- These lines need to be last.  Insert any changes above.
 UPDATE VERSION SET SCHEMA_VERSION='4.0.0', VERSION_COMMENT='Hive release version 4.0.0' where VER_ID=1;
 SELECT 'Finished upgrading MetaStore schema from 3.2.0 to 4.0.0' AS MESSAGE;
diff --git a/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-4.0.0.postgres.sql b/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-4.0.0.postgres.sql
index 7f21179..998b66e 100644
--- a/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-4.0.0.postgres.sql
+++ b/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-4.0.0.postgres.sql
@@ -83,7 +83,10 @@ CREATE TABLE "DBS" (
     "OWNER_TYPE" character varying(10) DEFAULT NULL::character varying,
     "CTLG_NAME" varchar(256) DEFAULT 'hive' NOT NULL,
     "CREATE_TIME" bigint,
-    "DB_MANAGED_LOCATION_URI" character varying(4000)
+    "DB_MANAGED_LOCATION_URI" character varying(4000),
+    "TYPE" character varying(32) DEFAULT 'NATIVE',
+    "DATACONNECTOR_NAME" character varying(128),
+    "REMOTE_DBNAME" character varying(128)
 );
 
 
@@ -1966,6 +1969,26 @@ CREATE TABLE "PACKAGES" (
 CREATE UNIQUE INDEX "UNIQUEPKG" ON "PACKAGES" ("NAME", "DB_ID");
 ALTER TABLE ONLY "PACKAGES" ADD CONSTRAINT "PACKAGES_FK1" FOREIGN KEY ("DB_ID") REFERENCES "DBS" ("DB_ID")  DEFERRABLE;
 
+-- HIVE-24396
+-- Create DataConnectors and DataConnector_Params tables
+CREATE TABLE "DATACONNECTORS" (
+  "NAME" character varying(128) NOT NULL,
+  "TYPE" character varying(32) NOT NULL,
+  "URL" character varying(4000) NOT NULL,
+  "COMMENT" character varying(256),
+  "OWNER_NAME" character varying(256),
+  "OWNER_TYPE" character varying(10),
+  "CREATE_TIME" INTEGER NOT NULL,
+  PRIMARY KEY ("NAME")
+);
+
+CREATE TABLE "DATACONNECTOR_PARAMS" (
+  "NAME" character varying(128) NOT NULL,
+  "PARAM_KEY" character varying(180) NOT NULL,
+  "PARAM_VALUE" character varying(4000),
+  PRIMARY KEY ("NAME", "PARAM_KEY"),
+  CONSTRAINT "DATACONNECTOR_NAME_FK1" FOREIGN KEY ("NAME") REFERENCES "DATACONNECTORS"("NAME") ON DELETE CASCADE
+);
 
 -- -----------------------------------------------------------------
 -- Record schema version. Should be the last step in the init script
diff --git a/standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-3.2.0-to-4.0.0.postgres.sql b/standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-3.2.0-to-4.0.0.postgres.sql
index 216a3ec..afbdacf 100644
--- a/standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-3.2.0-to-4.0.0.postgres.sql
+++ b/standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-3.2.0-to-4.0.0.postgres.sql
@@ -278,6 +278,31 @@ ALTER TABLE "COMPLETED_COMPACTIONS" ADD "CC_INITIATOR_ID" varchar(128);
 ALTER TABLE "COMPLETED_COMPACTIONS" ADD "CC_INITIATOR_VERSION" varchar(128);
 ALTER TABLE "COMPLETED_COMPACTIONS" ADD "CC_WORKER_VERSION" varchar(128);
 
+-- HIVE-24396
+-- Create DataConnectors and DataConnector_Params tables
+CREATE TABLE "DATACONNECTORS" (
+  "NAME" character varying(128) NOT NULL,
+  "TYPE" character varying(32) NOT NULL,
+  "URL" character varying(4000) NOT NULL,
+  "COMMENT" character varying(256),
+  "OWNER_NAME" character varying(256),
+  "OWNER_TYPE" character varying(10),
+  "CREATE_TIME" INTEGER NOT NULL,
+  PRIMARY KEY ("NAME")
+);
+
+CREATE TABLE "DATACONNECTOR_PARAMS" (
+  "NAME" character varying(128) NOT NULL,
+  "PARAM_KEY" character varying(180) NOT NULL,
+  "PARAM_VALUE" character varying(4000),
+  PRIMARY KEY ("NAME", "PARAM_KEY"),
+  CONSTRAINT "DATACONNECTOR_NAME_FK1" FOREIGN KEY ("NAME") REFERENCES "DATACONNECTORS"("NAME") ON DELETE CASCADE
+);
+ALTER TABLE "DBS" ADD "TYPE" character varying(32);
+UPDATE "DBS" SET "TYPE"= 'NATIVE' WHERE "TYPE" IS NULL;
+ALTER TABLE "DBS" ADD "DATACONNECTOR_NAME" character varying(128);
+ALTER TABLE "DBS" ADD "REMOTE_DBNAME" character varying(128);
+
 -- These lines need to be last. Insert any changes above.
 UPDATE "VERSION" SET "SCHEMA_VERSION"='4.0.0', "VERSION_COMMENT"='Hive release version 4.0.0' where "VER_ID"=1;
 SELECT 'Finished upgrading MetaStore schema from 3.2.0 to 4.0.0';

[hive] 02/38: Adding DDL support for connectors (create/drop/show/desc/alter)

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 87c74ec2d5f86e911d7b832f4d58b5e5e8f4c161
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Tue Nov 10 12:27:03 2020 -0500

    Adding DDL support for connectors (create/drop/show/desc/alter)
---
 .../hadoop/hive/ql/parse/AlterClauseParser.g       |  4 +-
 .../apache/hadoop/hive/ql/parse/CreateDDLParser.g  |  9 ++-
 .../hadoop/hive/ql/parse/IdentifiersParser.g       |  2 +-
 .../ql/ddl/database/create/CreateDatabaseDesc.java |  9 ---
 .../alter/AbstractAlterDataConnectorAnalyzer.java  | 42 +++++++++++
 .../alter/AbstractAlterDataConnectorDesc.java      | 54 +++++++++++++
 .../alter/AbstractAlterDataConnectorOperation.java | 59 +++++++++++++++
 .../owner/AlterDataConnectorSetOwnerAnalyzer.java  | 54 +++++++++++++
 .../owner/AlterDataConnectorSetOwnerDesc.java      | 45 +++++++++++
 .../owner/AlterDataConnectorSetOwnerOperation.java | 41 ++++++++++
 .../AlterDataConnectorSetPropertiesAnalyzer.java   | 58 ++++++++++++++
 .../AlterDataConnectorSetPropertiesDesc.java       | 47 ++++++++++++
 .../AlterDataConnectorSetPropertiesOperation.java  | 49 ++++++++++++
 .../url/AlterDataConnectorSetUrlAnalyzer.java      | 47 ++++++++++++
 .../alter/url/AlterDataConnectorSetUrlDesc.java    | 43 +++++++++++
 .../url/AlterDataConnectorSetUrlOperation.java     | 65 ++++++++++++++++
 .../create/CreateDataConnectorAnalyzer.java        | 88 ++++++++++++++++++++++
 .../create/CreateDataConnectorDesc.java            | 80 ++++++++++++++++++++
 .../create/CreateDataConnectorOperation.java       | 71 +++++++++++++++++
 .../desc/DescDataConnectorAnalyzer.java            | 61 +++++++++++++++
 .../dataconnector/desc/DescDataConnectorDesc.java  | 71 +++++++++++++++++
 .../desc/DescDataConnectorOperation.java           | 62 +++++++++++++++
 .../drop/DropDataConnectorAnalyzer.java            | 59 +++++++++++++++
 .../dataconnector/drop/DropDataConnectorDesc.java  | 62 +++++++++++++++
 .../drop/DropDataConnectorOperation.java           | 65 ++++++++++++++++
 .../show/ShowDataConnectorsAnalyzer.java           | 57 ++++++++++++++
 .../dataconnector/show/ShowDataConnectorsDesc.java | 54 +++++++++++++
 .../show/ShowDataConnectorsOperation.java          | 66 ++++++++++++++++
 28 files changed, 1411 insertions(+), 13 deletions(-)

diff --git a/parser/src/java/org/apache/hadoop/hive/ql/parse/AlterClauseParser.g b/parser/src/java/org/apache/hadoop/hive/ql/parse/AlterClauseParser.g
index c5074be..4625618 100644
--- a/parser/src/java/org/apache/hadoop/hive/ql/parse/AlterClauseParser.g
+++ b/parser/src/java/org/apache/hadoop/hive/ql/parse/AlterClauseParser.g
@@ -463,8 +463,8 @@ alterDataConnectorStatementSuffix
 alterDataConnectorSuffixProperties
 @init { gParent.pushMsg("alter connector set properties statement", state); }
 @after { gParent.popMsg(state); }
-    : name=identifier KW_SET KW_DBPROPERTIES dbProperties
-    -> ^(TOK_ALTERDATACONNECTOR_PROPERTIES $name dbProperties)
+    : name=identifier KW_SET KW_DCPROPERTIES dcProperties
+    -> ^(TOK_ALTERDATACONNECTOR_PROPERTIES $name dcProperties)
     ;
 
 alterDataConnectorSuffixSetOwner
diff --git a/parser/src/java/org/apache/hadoop/hive/ql/parse/CreateDDLParser.g b/parser/src/java/org/apache/hadoop/hive/ql/parse/CreateDDLParser.g
index 434ae57..69da7c7 100644
--- a/parser/src/java/org/apache/hadoop/hive/ql/parse/CreateDDLParser.g
+++ b/parser/src/java/org/apache/hadoop/hive/ql/parse/CreateDDLParser.g
@@ -112,7 +112,7 @@ createTableStatement
 createDataConnectorStatement
 @init { gParent.pushMsg("create connector statement", state); }
 @after { gParent.popMsg(state); }
-    : KW_CREATE KW_DATACONNECTOR ifNotExists? name=identifier dataConnectorType dataConnectorUrl dataConnectorComment? ( KW_WITH KW_PROPERTIES dcprops=dbProperties)?
+    : KW_CREATE KW_DATACONNECTOR ifNotExists? name=identifier dataConnectorType dataConnectorUrl dataConnectorComment? ( KW_WITH KW_DCPROPERTIES dcprops=dcProperties)?
     -> ^(TOK_CREATEDATACONNECTOR $name ifNotExists? dataConnectorType dataConnectorUrl dataConnectorComment? $dcprops?)
     ;
 
@@ -137,6 +137,13 @@ dataConnectorType
     -> ^(TOK_DATACONNECTORTYPE $dcType)
     ;
 
+dcProperties
+@init { gParent.pushMsg("dcproperties", state); }
+@after { gParent.popMsg(state); }
+    :
+      LPAREN dbPropertiesList RPAREN -> ^(TOK_DATACONNECTORPROPERTIES dbPropertiesList)
+    ;
+
 dropDataConnectorStatement
 @init { gParent.pushMsg("drop connector statement", state); }
 @after { gParent.popMsg(state); }
diff --git a/parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g b/parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
index 9402471..d836b80 100644
--- a/parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
+++ b/parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
@@ -913,7 +913,7 @@ nonReserved
     KW_ABORT | KW_ADD | KW_ADMIN | KW_AFTER | KW_ANALYZE | KW_ARCHIVE | KW_ASC | KW_BEFORE | KW_BUCKET | KW_BUCKETS
     | KW_CASCADE | KW_CBO | KW_CHANGE | KW_CHECK | KW_CLUSTER | KW_CLUSTERED | KW_CLUSTERSTATUS | KW_COLLECTION | KW_COLUMNS
     | KW_COMMENT | KW_COMPACT | KW_COMPACTIONS | KW_COMPUTE | KW_CONCATENATE | KW_CONTINUE | KW_COST | KW_DATA | KW_DAY
-    | KW_DATABASES | KW_DATETIME | KW_DBPROPERTIES | KW_DEFERRED | KW_DEFINED | KW_DELIMITED | KW_DEPENDENCY
+    | KW_DATABASES | KW_DATETIME | KW_DBPROPERTIES | KW_DCPROPERTIES | KW_DEFERRED | KW_DEFINED | KW_DELIMITED | KW_DEPENDENCY
     | KW_DESC | KW_DIRECTORIES | KW_DIRECTORY | KW_DISABLE | KW_DISTRIBUTE | KW_DISTRIBUTED | KW_DOW | KW_ELEM_TYPE
     | KW_ENABLE | KW_ENFORCED | KW_ESCAPED | KW_EXCLUSIVE | KW_EXPLAIN | KW_EXPORT | KW_FIELDS | KW_FILE | KW_FILEFORMAT
     | KW_FIRST | KW_FORMAT | KW_FORMATTED | KW_FUNCTIONS | KW_HOLD_DDLTIME | KW_HOUR | KW_IDXPROPERTIES | KW_RESPECT | KW_IGNORE
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseDesc.java
index ef9d8c8..45df31c 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseDesc.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseDesc.java
@@ -49,15 +49,6 @@ public class CreateDatabaseDesc implements DDLDesc, Serializable {
   public CreateDatabaseDesc(String databaseName, String comment, String locationUri, String managedLocationUri,
       boolean ifNotExists, Map<String, String> dbProperties) {
     this(databaseName, comment, locationUri, managedLocationUri, ifNotExists, dbProperties, "NATIVE", null, null);
-/*
-    this.databaseName = databaseName;
-    this.comment = comment;
-    this.locationUri = locationUri;
-    this.managedLocationUri = managedLocationUri;
-    this.ifNotExists = ifNotExists;
-    this.dbProperties = dbProperties;
-
- */
   }
 
   public CreateDatabaseDesc(String databaseName, String comment, String locationUri, String managedLocationUri,
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorAnalyzer.java
new file mode 100644
index 0000000..28e5def
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorAnalyzer.java
@@ -0,0 +1,42 @@
+/*
+ * 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.hadoop.hive.ql.ddl.dataconnector.alter;
+
+import org.apache.hadoop.hive.metastore.api.DataConnector;
+import org.apache.hadoop.hive.ql.QueryState;
+import org.apache.hadoop.hive.ql.ddl.DDLWork;
+import org.apache.hadoop.hive.ql.exec.TaskFactory;
+import org.apache.hadoop.hive.ql.hooks.WriteEntity;
+import org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+
+/**
+ * Analyzer for data connector alteration commands.
+ */
+public abstract class AbstractAlterDataConnectorAnalyzer extends BaseSemanticAnalyzer {
+  public AbstractAlterDataConnectorAnalyzer(QueryState queryState) throws SemanticException {
+    super(queryState);
+  }
+
+  protected void addAlterDataConnectorDesc(AbstractAlterDataConnectorDesc alterDesc) throws SemanticException {
+    DataConnector connector = getDataConnector(alterDesc.getConnectorName());
+    outputs.add(new WriteEntity(connector, WriteEntity.WriteType.DDL_NO_LOCK));
+    rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), alterDesc)));
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorDesc.java
new file mode 100644
index 0000000..281378f
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorDesc.java
@@ -0,0 +1,54 @@
+/*
+ * 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.hadoop.hive.ql.ddl.dataconnector.alter;
+
+import java.io.Serializable;
+
+import org.apache.hadoop.hive.ql.ddl.DDLDesc;
+import org.apache.hadoop.hive.ql.parse.ReplicationSpec;
+import org.apache.hadoop.hive.ql.plan.Explain;
+import org.apache.hadoop.hive.ql.plan.Explain.Level;
+
+/**
+ * DDL task description for ALTER CONNECTOR commands.
+ */
+public abstract class AbstractAlterDataConnectorDesc implements DDLDesc, Serializable {
+  private static final long serialVersionUID = 1L;
+
+  private final String connectorName;
+  private final ReplicationSpec replicationSpec;
+
+  public AbstractAlterDataConnectorDesc(String connectorName, ReplicationSpec replicationSpec) {
+    this.connectorName = connectorName;
+    this.replicationSpec = replicationSpec;
+  }
+
+  @Explain(displayName="name", explainLevels = {Level.USER, Level.DEFAULT, Level.EXTENDED })
+  public String getConnectorName() {
+    return connectorName;
+  }
+
+  /**
+   * @return what kind of replication scope this alter is running under.
+   * This can result in a "ALTER IF NEWER THAN" kind of semantic
+   */
+  public ReplicationSpec getReplicationSpec() {
+    return this.replicationSpec;
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorOperation.java
new file mode 100644
index 0000000..a29dd4a
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorOperation.java
@@ -0,0 +1,59 @@
+/*
+ * 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.hadoop.hive.ql.ddl.dataconnector.alter;
+
+import java.util.Map;
+
+import org.apache.hadoop.hive.metastore.api.DataConnector;
+import org.apache.hadoop.hive.ql.ErrorMsg;
+import org.apache.hadoop.hive.ql.ddl.DDLOperation;
+import org.apache.hadoop.hive.ql.ddl.DDLOperationContext;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+
+/**
+ * Operation process of altering a data connector.
+ */
+public abstract class AbstractAlterDataConnectorOperation<T extends AbstractAlterDataConnectorDesc> extends DDLOperation<T> {
+  public AbstractAlterDataConnectorOperation(DDLOperationContext context, T desc) {
+    super(context, desc);
+  }
+
+  @Override
+  public int execute() throws HiveException {
+    String dcName = desc.getConnectorName();
+    DataConnector connector = context.getDb().getDataConnector(dcName);
+    if (connector == null) {
+      throw new HiveException(ErrorMsg.DATACONNECTOR_ALREADY_EXISTS, dcName);
+    }
+
+    Map<String, String> params = connector.getParameters();
+    if ((null != desc.getReplicationSpec()) &&
+        !desc.getReplicationSpec().allowEventReplacementInto(params)) {
+      LOG.debug("DDLTask: Alter Connector {} is skipped as connector is newer than update", dcName);
+      return 0; // no replacement, the existing connector state is newer than our update.
+    }
+
+    doAlteration(connector, params);
+
+    context.getDb().alterDataConnector(connector.getName(), connector);
+    return 0;
+  }
+
+  protected abstract void doAlteration(DataConnector connector, Map<String, String> params) throws HiveException;
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerAnalyzer.java
new file mode 100644
index 0000000..1fb34e1
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerAnalyzer.java
@@ -0,0 +1,54 @@
+/*
+ * 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.hadoop.hive.ql.ddl.dataconnector.alter.owner;
+
+import org.apache.hadoop.hive.ql.QueryState;
+import org.apache.hadoop.hive.ql.ddl.DDLSemanticAnalyzerFactory.DDLType;
+import org.apache.hadoop.hive.ql.ddl.dataconnector.alter.AbstractAlterDataConnectorAnalyzer;
+import org.apache.hadoop.hive.ql.ddl.privilege.PrincipalDesc;
+import org.apache.hadoop.hive.ql.parse.ASTNode;
+import org.apache.hadoop.hive.ql.parse.HiveParser;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+import org.apache.hadoop.hive.ql.parse.authorization.AuthorizationParseUtils;
+
+/**
+ * Analyzer for data connector set owner commands.
+ */
+@DDLType(types = HiveParser.TOK_ALTERDATACONNECTOR_OWNER)
+public class AlterDataConnectorSetOwnerAnalyzer extends AbstractAlterDataConnectorAnalyzer {
+  public AlterDataConnectorSetOwnerAnalyzer(QueryState queryState) throws SemanticException {
+    super(queryState);
+  }
+
+  @Override
+  public void analyzeInternal(ASTNode root) throws SemanticException {
+    String connectorName = getUnescapedName((ASTNode) root.getChild(0));
+    PrincipalDesc principalDesc = AuthorizationParseUtils.getPrincipalDesc((ASTNode) root.getChild(1));
+
+    if (principalDesc.getName() == null) {
+      throw new SemanticException("Owner name can't be null in alter connector set owner command");
+    }
+    if (principalDesc.getType() == null) {
+      throw new SemanticException("Owner type can't be null in alter connector set owner command");
+    }
+
+    AlterDataConnectorSetOwnerDesc desc = new AlterDataConnectorSetOwnerDesc(connectorName, principalDesc, null);
+    addAlterDataConnectorDesc(desc);
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerDesc.java
new file mode 100644
index 0000000..8d2c0c3
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerDesc.java
@@ -0,0 +1,45 @@
+/*
+ * 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.hadoop.hive.ql.ddl.dataconnector.alter.owner;
+
+import org.apache.hadoop.hive.ql.ddl.dataconnector.alter.AbstractAlterDataConnectorDesc;
+import org.apache.hadoop.hive.ql.ddl.privilege.PrincipalDesc;
+import org.apache.hadoop.hive.ql.parse.ReplicationSpec;
+import org.apache.hadoop.hive.ql.plan.Explain;
+import org.apache.hadoop.hive.ql.plan.Explain.Level;
+
+/**
+ * DDL task description for ALTER CONNECTOR ... SET OWNER ... commands.
+ */
+@Explain(displayName = "Set DataConnector Owner", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
+public class AlterDataConnectorSetOwnerDesc extends AbstractAlterDataConnectorDesc {
+  private static final long serialVersionUID = 1L;
+
+  private final PrincipalDesc ownerPrincipal;
+
+  public AlterDataConnectorSetOwnerDesc(String connectorName, PrincipalDesc ownerPrincipal, ReplicationSpec replicationSpec) {
+    super(connectorName, replicationSpec);
+    this.ownerPrincipal = ownerPrincipal;
+  }
+
+  @Explain(displayName="owner")
+  public PrincipalDesc getOwnerPrincipal() {
+    return ownerPrincipal;
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerOperation.java
new file mode 100644
index 0000000..7f06a4d
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/owner/AlterDataConnectorSetOwnerOperation.java
@@ -0,0 +1,41 @@
+/*
+ * 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.hadoop.hive.ql.ddl.dataconnector.alter.owner;
+
+import java.util.Map;
+
+import org.apache.hadoop.hive.metastore.api.DataConnector;
+import org.apache.hadoop.hive.ql.ddl.DDLOperationContext;
+import org.apache.hadoop.hive.ql.ddl.dataconnector.alter.AbstractAlterDataConnectorOperation;
+
+/**
+ * Operation process of altering a connector's owner.
+ */
+public class AlterDataConnectorSetOwnerOperation extends
+    AbstractAlterDataConnectorOperation<AlterDataConnectorSetOwnerDesc> {
+  public AlterDataConnectorSetOwnerOperation(DDLOperationContext context, AlterDataConnectorSetOwnerDesc desc) {
+    super(context, desc);
+  }
+
+  @Override
+  protected void doAlteration(DataConnector connector, Map<String, String> params) {
+    connector.setOwnerName(desc.getOwnerPrincipal().getName());
+    connector.setOwnerType(desc.getOwnerPrincipal().getType());
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesAnalyzer.java
new file mode 100644
index 0000000..1ddb73f
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesAnalyzer.java
@@ -0,0 +1,58 @@
+/*
+ * 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.hadoop.hive.ql.ddl.dataconnector.alter.properties;
+
+import java.util.Map;
+
+import org.apache.hadoop.hive.ql.QueryState;
+import org.apache.hadoop.hive.ql.ddl.DDLSemanticAnalyzerFactory.DDLType;
+import org.apache.hadoop.hive.ql.ddl.dataconnector.alter.AbstractAlterDataConnectorAnalyzer;
+import org.apache.hadoop.hive.ql.parse.ASTNode;
+import org.apache.hadoop.hive.ql.parse.HiveParser;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+
+/**
+ * Analyzer for connector set properties commands.
+ */
+@DDLType(types = HiveParser.TOK_ALTERDATACONNECTOR_PROPERTIES)
+public class AlterDataConnectorSetPropertiesAnalyzer extends AbstractAlterDataConnectorAnalyzer {
+  public AlterDataConnectorSetPropertiesAnalyzer(QueryState queryState) throws SemanticException {
+    super(queryState);
+  }
+
+  @Override
+  public void analyzeInternal(ASTNode root) throws SemanticException {
+    String connectorName = unescapeIdentifier(root.getChild(0).getText());
+
+    Map<String, String> dbProps = null;
+    for (int i = 1; i < root.getChildCount(); i++) {
+      ASTNode childNode = (ASTNode) root.getChild(i);
+      switch (childNode.getToken().getType()) {
+      case HiveParser.TOK_DATACONNECTORPROPERTIES:
+        dbProps = getProps((ASTNode) childNode.getChild(0));
+        break;
+      default:
+        throw new SemanticException("Unrecognized token in ALTER CONNECTOR statement");
+      }
+    }
+
+    AlterDataConnectorSetPropertiesDesc desc = new AlterDataConnectorSetPropertiesDesc(connectorName, dbProps, null);
+    addAlterDataConnectorDesc(desc);
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesDesc.java
new file mode 100644
index 0000000..07958c2
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesDesc.java
@@ -0,0 +1,47 @@
+/*
+ * 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.hadoop.hive.ql.ddl.dataconnector.alter.properties;
+
+import java.util.Map;
+
+import org.apache.hadoop.hive.ql.ddl.dataconnector.alter.AbstractAlterDataConnectorDesc;
+import org.apache.hadoop.hive.ql.parse.ReplicationSpec;
+import org.apache.hadoop.hive.ql.plan.Explain;
+import org.apache.hadoop.hive.ql.plan.Explain.Level;
+
+/**
+ * DDL task description for ALTER CONNECTOR ... SET PROPERTIES ... commands.
+ */
+@Explain(displayName = "Set Connector Properties", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
+public class AlterDataConnectorSetPropertiesDesc extends AbstractAlterDataConnectorDesc {
+  private static final long serialVersionUID = 1L;
+
+  private final Map<String, String> dcProperties;
+
+  public AlterDataConnectorSetPropertiesDesc(String connectorName, Map<String, String> dcProperties,
+      ReplicationSpec replicationSpec) {
+    super(connectorName, replicationSpec);
+    this.dcProperties = dcProperties;
+  }
+
+  @Explain(displayName="properties")
+  public Map<String, String> getConnectorProperties() {
+    return dcProperties;
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesOperation.java
new file mode 100644
index 0000000..c9fa032
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/properties/AlterDataConnectorSetPropertiesOperation.java
@@ -0,0 +1,49 @@
+/*
+ * 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.hadoop.hive.ql.ddl.dataconnector.alter.properties;
+
+import java.util.Map;
+
+import org.apache.hadoop.hive.metastore.api.DataConnector;
+import org.apache.hadoop.hive.ql.ddl.DDLOperationContext;
+import org.apache.hadoop.hive.ql.ddl.dataconnector.alter.AbstractAlterDataConnectorOperation;
+
+/**
+ * Operation process of altering a dataconnector's properties.
+ */
+public class AlterDataConnectorSetPropertiesOperation
+    extends AbstractAlterDataConnectorOperation<AlterDataConnectorSetPropertiesDesc> {
+  public AlterDataConnectorSetPropertiesOperation(DDLOperationContext context, AlterDataConnectorSetPropertiesDesc desc) {
+    super(context, desc);
+  }
+
+  @Override
+  protected void doAlteration(DataConnector connector, Map<String, String> params) {
+    Map<String, String> newParams = desc.getConnectorProperties();
+
+    // if both old and new params are not null, merge them
+    if (params != null && newParams != null) {
+      params.putAll(newParams);
+      connector.setParameters(params);
+    } else {
+      // if one of them is null, replace the old params with the new one
+      connector.setParameters(newParams);
+    }
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlAnalyzer.java
new file mode 100644
index 0000000..217f702
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlAnalyzer.java
@@ -0,0 +1,47 @@
+/*
+ * 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.hadoop.hive.ql.ddl.dataconnector.alter.url;
+
+import org.apache.hadoop.hive.ql.QueryState;
+import org.apache.hadoop.hive.ql.ddl.DDLSemanticAnalyzerFactory.DDLType;
+import org.apache.hadoop.hive.ql.ddl.dataconnector.alter.AbstractAlterDataConnectorAnalyzer;
+import org.apache.hadoop.hive.ql.parse.ASTNode;
+import org.apache.hadoop.hive.ql.parse.HiveParser;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+
+/**
+ * Analyzer for connector set url commands.
+ */
+@DDLType(types = HiveParser.TOK_ALTERDATACONNECTOR_URL)
+public class AlterDataConnectorSetUrlAnalyzer extends AbstractAlterDataConnectorAnalyzer {
+  public AlterDataConnectorSetUrlAnalyzer(QueryState queryState) throws SemanticException {
+    super(queryState);
+  }
+
+  @Override
+  public void analyzeInternal(ASTNode root) throws SemanticException {
+    String connectorName = getUnescapedName((ASTNode) root.getChild(0));
+    String newURL = unescapeSQLString(root.getChild(1).getText());
+
+    outputs.add(toWriteEntity(newURL));
+
+    AlterDataConnectorSetUrlDesc desc = new AlterDataConnectorSetUrlDesc(connectorName, newURL);
+    addAlterDataConnectorDesc(desc);
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlDesc.java
new file mode 100644
index 0000000..a142ea0
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlDesc.java
@@ -0,0 +1,43 @@
+/*
+ * 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.hadoop.hive.ql.ddl.dataconnector.alter.url;
+
+import org.apache.hadoop.hive.ql.ddl.dataconnector.alter.AbstractAlterDataConnectorDesc;
+import org.apache.hadoop.hive.ql.plan.Explain;
+import org.apache.hadoop.hive.ql.plan.Explain.Level;
+
+/**
+ * DDL task description for ALTER CONNECTOR ... SET URL ... commands.
+ */
+@Explain(displayName = "Set Connector URL", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
+public class AlterDataConnectorSetUrlDesc extends AbstractAlterDataConnectorDesc {
+  private static final long serialVersionUID = 1L;
+
+  private final String url;
+
+  public AlterDataConnectorSetUrlDesc(String connectorName, String location) {
+    super(connectorName, null);
+    this.url = location;
+  }
+
+  @Explain(displayName="url")
+  public String getURL() {
+    return url;
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlOperation.java
new file mode 100644
index 0000000..d9caee0
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlOperation.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.ddl.dataconnector.alter.url;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.hive.metastore.api.DataConnector;
+import org.apache.hadoop.hive.ql.ErrorMsg;
+import org.apache.hadoop.hive.ql.ddl.DDLOperationContext;
+import org.apache.hadoop.hive.ql.ddl.dataconnector.alter.AbstractAlterDataConnectorOperation;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+
+/**
+ * Operation process of altering a connector's URL.
+ */
+public class AlterDataConnectorSetUrlOperation extends
+    AbstractAlterDataConnectorOperation<AlterDataConnectorSetUrlDesc> {
+  public AlterDataConnectorSetUrlOperation(DDLOperationContext context, AlterDataConnectorSetUrlDesc desc) {
+    super(context, desc);
+  }
+
+  @Override
+  protected void doAlteration(DataConnector connector, Map<String, String> params) throws HiveException {
+    try {
+      String newUrl = desc.getURL();
+
+      if (newUrl.equalsIgnoreCase(connector.getUrl())) {
+        throw new HiveException("Old and New URL's for data connector cannot be the same");
+      }
+
+      URI newURI = new URI(newUrl);
+      if (!newURI.isAbsolute() || StringUtils.isBlank(newURI.getScheme())) {
+        throw new HiveException(ErrorMsg.INVALID_PATH, newUrl); // TODO make a new error message for URL
+      }
+
+      if (newUrl.equals(connector.getUrl())) {
+        LOG.info("Alter Connector skipped. No change in url.");
+      } else {
+        connector.setUrl(newUrl);
+      }
+      return;
+    } catch (URISyntaxException e) {
+      throw new HiveException(e);
+    }
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/create/CreateDataConnectorAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/create/CreateDataConnectorAnalyzer.java
new file mode 100644
index 0000000..5867108
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/create/CreateDataConnectorAnalyzer.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.ddl.dataconnector.create;
+
+import java.util.Map;
+
+import org.apache.hadoop.hive.metastore.api.DataConnector;
+import org.apache.hadoop.hive.ql.QueryState;
+import org.apache.hadoop.hive.ql.exec.TaskFactory;
+import org.apache.hadoop.hive.ql.ddl.DDLSemanticAnalyzerFactory.DDLType;
+import org.apache.hadoop.hive.ql.ddl.DDLWork;
+import org.apache.hadoop.hive.ql.hooks.WriteEntity;
+import org.apache.hadoop.hive.ql.parse.ASTNode;
+import org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer;
+import org.apache.hadoop.hive.ql.parse.HiveParser;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+
+/**
+ * Analyzer for dataconnector creation commands.
+ */
+@DDLType(types = HiveParser.TOK_CREATEDATACONNECTOR)
+public class CreateDataConnectorAnalyzer extends BaseSemanticAnalyzer {
+  public CreateDataConnectorAnalyzer(QueryState queryState) throws SemanticException {
+    super(queryState);
+  }
+
+  @Override
+  public void analyzeInternal(ASTNode root) throws SemanticException {
+    boolean ifNotExists = false;
+    String comment = null;
+    String url = null;
+    String type = null;
+    Map<String, String> props = null;
+
+    String connectorName = unescapeIdentifier(root.getChild(0).getText());
+    for (int i = 1; i < root.getChildCount(); i++) {
+      ASTNode childNode = (ASTNode) root.getChild(i);
+      switch (childNode.getToken().getType()) {
+      case HiveParser.TOK_IFNOTEXISTS:
+        ifNotExists = true;
+        break;
+      case HiveParser.TOK_DATACONNECTORCOMMENT:
+        comment = unescapeSQLString(childNode.getChild(0).getText());
+        break;
+      case HiveParser.TOK_DATACONNECTORPROPERTIES:
+        props = getProps((ASTNode) childNode.getChild(0));
+        break;
+      case HiveParser.TOK_DATACONNECTORURL:
+        url = unescapeSQLString(childNode.getChild(0).getText());
+        outputs.add(toWriteEntity(url));
+        break;
+      case HiveParser.TOK_DATACONNECTORTYPE:
+        type = unescapeSQLString(childNode.getChild(0).getText());
+        break;
+      default:
+        throw new SemanticException("Unrecognized token in CREATE CONNECTOR statement");
+      }
+    }
+
+    CreateDataConnectorDesc desc = null;
+    DataConnector connector = new DataConnector(connectorName, type, url);
+    if (comment != null)
+      connector.setDescription(comment);
+    if (props != null)
+      connector.setParameters(props);
+
+    desc = new CreateDataConnectorDesc(connectorName, type, url, ifNotExists, comment, props);
+    rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc)));
+
+    outputs.add(new WriteEntity(connector, WriteEntity.WriteType.DDL_NO_LOCK));
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/create/CreateDataConnectorDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/create/CreateDataConnectorDesc.java
new file mode 100644
index 0000000..5d07c2c
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/create/CreateDataConnectorDesc.java
@@ -0,0 +1,80 @@
+/*
+ * 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.hadoop.hive.ql.ddl.dataconnector.create;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import org.apache.hadoop.hive.ql.ddl.DDLDesc;
+import org.apache.hadoop.hive.ql.plan.Explain;
+import org.apache.hadoop.hive.ql.plan.Explain.Level;
+
+/**
+ * DDL task description for CREATE DATACONNECTOR commands.
+ */
+@Explain(displayName = "Create DataConnector", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
+public class CreateDataConnectorDesc implements DDLDesc, Serializable {
+  private static final long serialVersionUID = 1L;
+
+  private final String connectorName;
+  private final String type;
+  private final String url;
+  private final String description;
+  private final boolean ifNotExists;
+  private final Map<String, String> dcProperties;
+
+  public CreateDataConnectorDesc(String connectorName, String type, String url, boolean ifNotExists, String description,
+      Map<String, String> dcProperties) {
+    this.connectorName = connectorName;
+    this.type = type;
+    this.url = url;
+    this.ifNotExists = ifNotExists;
+    this.dcProperties = dcProperties;
+    this.description = description;
+  }
+
+  @Explain(displayName="if not exists", displayOnlyOnTrue = true)
+  public boolean getIfNotExists() {
+    return ifNotExists;
+  }
+
+  public Map<String, String> getConnectorProperties() {
+    return dcProperties;
+  }
+
+  @Explain(displayName="name", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
+  public String getName() {
+    return connectorName;
+  }
+
+  @Explain(displayName="description")
+  public String getComment() {
+    return description;
+  }
+
+  @Explain(displayName="url")
+  public String getURL() {
+    return url;
+  }
+
+  @Explain(displayName="connector type")
+  public String getType() {
+    return type;
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/create/CreateDataConnectorOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/create/CreateDataConnectorOperation.java
new file mode 100644
index 0000000..bca0033
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/create/CreateDataConnectorOperation.java
@@ -0,0 +1,71 @@
+/*
+ * 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.hadoop.hive.ql.ddl.dataconnector.create;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.hive.metastore.api.AlreadyExistsException;
+import org.apache.hadoop.hive.metastore.api.DataConnector;
+import org.apache.hadoop.hive.metastore.api.PrincipalType;
+import org.apache.hadoop.hive.ql.ErrorMsg;
+import org.apache.hadoop.hive.ql.ddl.DDLOperation;
+import org.apache.hadoop.hive.ql.ddl.DDLOperationContext;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.session.SessionState;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * Operation process of creating a dataconnector.
+ */
+public class CreateDataConnectorOperation extends DDLOperation<CreateDataConnectorDesc> {
+
+  public CreateDataConnectorOperation(DDLOperationContext context, CreateDataConnectorDesc desc) {
+    super(context, desc);
+  }
+
+  @Override
+  public int execute() throws HiveException {
+    try {
+      URI connectorUri = new URI(desc.getURL());
+      if (!connectorUri.isAbsolute() || StringUtils.isBlank(connectorUri.getScheme())) {
+        throw new HiveException(ErrorMsg.INVALID_PATH, desc.getURL()); // TODO make a new error message for URL
+      }
+
+      DataConnector connector = new DataConnector(desc.getName(), desc.getType(), desc.getURL());
+      if (desc.getComment() != null)
+        connector.setDescription(desc.getComment());
+      connector.setOwnerName(SessionState.getUserFromAuthenticator());
+      connector.setOwnerType(PrincipalType.USER);
+      if (desc.getConnectorProperties() != null)
+        connector.setParameters(desc.getConnectorProperties());
+      try {
+        context.getDb().createDataConnector(connector, desc.getIfNotExists());
+      } catch (AlreadyExistsException ex) {
+        //it would be better if AlreadyExistsException had an errorCode field....
+        throw new HiveException(ex, ErrorMsg.DATACONNECTOR_ALREADY_EXISTS, desc.getName());
+      }
+
+      return 0;
+    } catch (URISyntaxException e) {
+      throw new HiveException(e);
+    }
+
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/desc/DescDataConnectorAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/desc/DescDataConnectorAnalyzer.java
new file mode 100644
index 0000000..b7f94d2
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/desc/DescDataConnectorAnalyzer.java
@@ -0,0 +1,61 @@
+/*
+ * 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.hadoop.hive.ql.ddl.dataconnector.desc;
+
+import org.apache.hadoop.hive.ql.QueryState;
+import org.apache.hadoop.hive.ql.exec.Task;
+import org.apache.hadoop.hive.ql.exec.TaskFactory;
+import org.apache.hadoop.hive.ql.ddl.DDLSemanticAnalyzerFactory.DDLType;
+import org.apache.hadoop.hive.ql.ddl.DDLWork;
+import org.apache.hadoop.hive.ql.hooks.ReadEntity;
+import org.apache.hadoop.hive.ql.parse.ASTNode;
+import org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer;
+import org.apache.hadoop.hive.ql.parse.HiveParser;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+
+/**
+ * Analyzer for data connector description commands.
+ */
+@DDLType(types = HiveParser.TOK_DESCDATACONNECTOR)
+public class DescDataConnectorAnalyzer extends BaseSemanticAnalyzer {
+  public DescDataConnectorAnalyzer(QueryState queryState) throws SemanticException {
+    super(queryState);
+  }
+
+  @Override
+  public void analyzeInternal(ASTNode root) throws SemanticException {
+    if (root.getChildCount() == 0 || root.getChildCount() > 2) {
+      throw new SemanticException("Unexpected Tokens at DESCRIBE CONNECTOR");
+    }
+
+    ctx.setResFile(ctx.getLocalTmpPath());
+
+    String connectorName = stripQuotes(root.getChild(0).getText());
+    boolean isExtended = root.getChildCount() == 2;
+
+    inputs.add(new ReadEntity(getDataConnector(connectorName)));
+
+    DescDataConnectorDesc desc = new DescDataConnectorDesc(ctx.getResFile(), connectorName, isExtended);
+    Task<DDLWork> task = TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc));
+    rootTasks.add(task);
+
+    task.setFetchSource(true);
+    setFetchTask(createFetchTask(desc.getSchema()));
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/desc/DescDataConnectorDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/desc/DescDataConnectorDesc.java
new file mode 100644
index 0000000..4a3ee6a
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/desc/DescDataConnectorDesc.java
@@ -0,0 +1,71 @@
+/*
+ * 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.hadoop.hive.ql.ddl.dataconnector.desc;
+
+import java.io.Serializable;
+
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.ql.ddl.DDLDesc;
+import org.apache.hadoop.hive.ql.plan.Explain;
+import org.apache.hadoop.hive.ql.plan.Explain.Level;
+
+/**
+ * DDL task description for DESC CONNECTOR commands.
+ */
+@Explain(displayName = "Describe Connector", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
+public class DescDataConnectorDesc implements DDLDesc, Serializable {
+  private static final long serialVersionUID = 1L;
+
+  public static final String DESC_DATACONNECTOR_SCHEMA =
+      "name,type,url,owner_name,owner_type,comment#string:string:string:string:string:string";
+
+  public static final String DESC_DATACONNECTOR_SCHEMA_EXTENDED =
+      "name,type,url,owner_name,owner_type,comment,parameters#" +
+      "string:string:string:string:string:string,string";
+
+  private final String resFile;
+  private final String dcName;
+  private final boolean isExtended;
+
+  public DescDataConnectorDesc(Path resFile, String dcName, boolean isExtended) {
+    this.resFile = resFile.toString();
+    this.dcName = dcName;
+    this.isExtended = isExtended;
+  }
+
+  @Explain(displayName = "extended", displayOnlyOnTrue=true,
+      explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
+  public boolean isExtended() {
+    return isExtended;
+  }
+
+  @Explain(displayName = "connector", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
+  public String getConnectorName() {
+    return dcName;
+  }
+
+  @Explain(displayName = "result file", explainLevels = { Level.EXTENDED })
+  public String getResFile() {
+    return resFile;
+  }
+
+  public String getSchema() {
+    return isExtended ? DESC_DATACONNECTOR_SCHEMA_EXTENDED : DESC_DATACONNECTOR_SCHEMA;
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/desc/DescDataConnectorOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/desc/DescDataConnectorOperation.java
new file mode 100644
index 0000000..de76842
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/desc/DescDataConnectorOperation.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.ddl.dataconnector.desc;
+
+import java.io.DataOutputStream;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.metastore.api.DataConnector;
+import org.apache.hadoop.hive.ql.ErrorMsg;
+import org.apache.hadoop.hive.ql.ddl.DDLOperation;
+import org.apache.hadoop.hive.ql.ddl.DDLOperationContext;
+import org.apache.hadoop.hive.ql.ddl.DDLUtils;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+
+/**
+ * Operation process of describing a data connector.
+ */
+public class DescDataConnectorOperation extends DDLOperation<DescDataConnectorDesc> {
+  public DescDataConnectorOperation(DDLOperationContext context, DescDataConnectorDesc desc) {
+    super(context, desc);
+  }
+
+  @Override
+  public int execute() throws HiveException {
+    try (DataOutputStream outStream = DDLUtils.getOutputStream(new Path(desc.getResFile()), context)) {
+      DataConnector connector = context.getDb().getDataConnector(desc.getConnectorName());
+      if (connector == null) {
+        throw new HiveException(ErrorMsg.DATACONNECTOR_NOT_EXISTS, desc.getConnectorName());
+      }
+
+      SortedMap<String, String> params = null;
+      if (desc.isExtended()) {
+        params = new TreeMap<>(connector.getParameters());
+      }
+
+      context.getFormatter().showDataConnectorDescription(outStream, connector.getName(), connector.getType(),
+          connector.getUrl(), connector.getOwnerName(), connector.getOwnerType(), connector.getDescription(), params);
+    } catch (Exception e) {
+      throw new HiveException(e, ErrorMsg.GENERIC_ERROR);
+    }
+
+    return 0;
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorAnalyzer.java
new file mode 100644
index 0000000..37817db
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorAnalyzer.java
@@ -0,0 +1,59 @@
+/*
+ * 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.hadoop.hive.ql.ddl.dataconnector.drop;
+
+import org.apache.hadoop.hive.metastore.api.DataConnector;
+import org.apache.hadoop.hive.ql.QueryState;
+import org.apache.hadoop.hive.ql.exec.TaskFactory;
+import org.apache.hadoop.hive.ql.ddl.DDLSemanticAnalyzerFactory.DDLType;
+import org.apache.hadoop.hive.ql.ddl.DDLWork;
+import org.apache.hadoop.hive.ql.hooks.ReadEntity;
+import org.apache.hadoop.hive.ql.hooks.WriteEntity;
+import org.apache.hadoop.hive.ql.parse.ASTNode;
+import org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer;
+import org.apache.hadoop.hive.ql.parse.HiveParser;
+import org.apache.hadoop.hive.ql.parse.ReplicationSpec;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+
+/**
+ * Analyzer for data connector dropping commands.
+ */
+@DDLType(types = HiveParser.TOK_DROPDATACONNECTOR)
+public class DropDataConnectorAnalyzer extends BaseSemanticAnalyzer {
+  public DropDataConnectorAnalyzer(QueryState queryState) throws SemanticException {
+    super(queryState);
+  }
+
+  @Override
+  public void analyzeInternal(ASTNode root) throws SemanticException {
+    String connectorName = unescapeIdentifier(root.getChild(0).getText());
+    boolean ifExists = root.getFirstChildWithType(HiveParser.TOK_IFEXISTS) != null;
+
+    DataConnector connector = getDataConnector(connectorName, !ifExists);
+    if (connector == null) {
+      return;
+    }
+
+    inputs.add(new ReadEntity(connector));
+    outputs.add(new WriteEntity(connector, WriteEntity.WriteType.DDL_EXCLUSIVE));
+
+    DropDataConnectorDesc desc = new DropDataConnectorDesc(connectorName, ifExists, new ReplicationSpec());
+    rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc)));
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorDesc.java
new file mode 100644
index 0000000..8e3bc6b
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorDesc.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.ddl.dataconnector.drop;
+
+import java.io.Serializable;
+
+import org.apache.hadoop.hive.ql.ddl.DDLDesc;
+import org.apache.hadoop.hive.ql.parse.ReplicationSpec;
+import org.apache.hadoop.hive.ql.plan.Explain;
+import org.apache.hadoop.hive.ql.plan.Explain.Level;
+
+/**
+ * DDL task description for DROP CONNECTOR commands.
+ */
+@Explain(displayName = "Drop Connector", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
+public class DropDataConnectorDesc implements DDLDesc, Serializable {
+  private static final long serialVersionUID = 1L;
+
+  private final String connectorName;
+  private final boolean ifExists;
+  private final ReplicationSpec replicationSpec;
+
+  public DropDataConnectorDesc(String connectorName, boolean ifExists, ReplicationSpec replicationSpec) {
+    this(connectorName, ifExists, false, replicationSpec);
+  }
+
+  public DropDataConnectorDesc(String connectorName, boolean ifExists, boolean cascade, ReplicationSpec replicationSpec) {
+    this.connectorName = connectorName;
+    this.ifExists = ifExists;
+    this.replicationSpec = replicationSpec;
+  }
+
+  @Explain(displayName = "connector", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
+  public String getConnectorName() {
+    return connectorName;
+  }
+
+  @Explain(displayName = "if exists")
+  public boolean getIfExists() {
+    return ifExists;
+  }
+
+  public ReplicationSpec getReplicationSpec() {
+    return replicationSpec;
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorOperation.java
new file mode 100644
index 0000000..64692f7
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/drop/DropDataConnectorOperation.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.ddl.dataconnector.drop;
+
+import org.apache.hadoop.hive.llap.LlapHiveUtils;
+import org.apache.hadoop.hive.llap.ProactiveEviction;
+import org.apache.hadoop.hive.metastore.api.DataConnector;
+import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
+import org.apache.hadoop.hive.ql.ErrorMsg;
+import org.apache.hadoop.hive.ql.ddl.DDLOperation;
+import org.apache.hadoop.hive.ql.ddl.DDLOperationContext;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.parse.ReplicationSpec;
+
+/**
+ * Operation process of dropping a data connector.
+ */
+public class DropDataConnectorOperation extends DDLOperation<DropDataConnectorDesc> {
+  public DropDataConnectorOperation(DDLOperationContext context, DropDataConnectorDesc desc) {
+    super(context, desc);
+  }
+
+  @Override
+  public int execute() throws HiveException {
+    try {
+      String dcName = desc.getConnectorName();
+      ReplicationSpec replicationSpec = desc.getReplicationSpec();
+      if (replicationSpec.isInReplicationScope()) {
+        DataConnector connector = context.getDb().getDataConnector(dcName);
+        if (connector == null || !replicationSpec.allowEventReplacementInto(connector.getParameters())) {
+          return 0;
+        }
+      }
+
+      context.getDb().dropDataConnector(dcName, desc.getIfExists());
+
+      // TODO is this required for Connectors
+      if (LlapHiveUtils.isLlapMode(context.getConf())) {
+        ProactiveEviction.Request.Builder llapEvictRequestBuilder = ProactiveEviction.Request.Builder.create();
+        llapEvictRequestBuilder.addDb(dcName);
+        ProactiveEviction.evict(context.getConf(), llapEvictRequestBuilder.build());
+      }
+    } catch (NoSuchObjectException ex) {
+      throw new HiveException(ex, ErrorMsg.DATACONNECTOR_NOT_EXISTS, desc.getConnectorName());
+    }
+
+    return 0;
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsAnalyzer.java
new file mode 100644
index 0000000..20ec39e
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsAnalyzer.java
@@ -0,0 +1,57 @@
+/*
+ * 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.hadoop.hive.ql.ddl.dataconnector.show;
+
+import org.apache.hadoop.hive.ql.QueryState;
+import org.apache.hadoop.hive.ql.exec.Task;
+import org.apache.hadoop.hive.ql.exec.TaskFactory;
+import org.apache.hadoop.hive.ql.ddl.DDLSemanticAnalyzerFactory.DDLType;
+import org.apache.hadoop.hive.ql.ddl.DDLWork;
+import org.apache.hadoop.hive.ql.parse.ASTNode;
+import org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer;
+import org.apache.hadoop.hive.ql.parse.HiveParser;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+
+/**
+ * Analyzer for show connectors commands.
+ */
+@DDLType(types = HiveParser.TOK_SHOWDATACONNECTORS)
+public class ShowDataConnectorsAnalyzer extends BaseSemanticAnalyzer {
+  public ShowDataConnectorsAnalyzer(QueryState queryState) throws SemanticException {
+    super(queryState);
+  }
+
+  @Override
+  public void analyzeInternal(ASTNode root) throws SemanticException {
+    if (root.getChildCount() > 1) {
+      throw new SemanticException("Unexpected Tokens at SHOW CONNECTORS");
+    }
+
+    ctx.setResFile(ctx.getLocalTmpPath());
+
+    String connectorPattern = root.getChildCount() == 1 ? unescapeSQLString(root.getChild(0).getText()) : null;
+    ShowDataConnectorsDesc desc = new ShowDataConnectorsDesc(ctx.getResFile(), connectorPattern);
+
+    Task<DDLWork> task = TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc));
+    rootTasks.add(task);
+
+    task.setFetchSource(true);
+    setFetchTask(createFetchTask(ShowDataConnectorsDesc.SHOW_DATACONNECTORS_SCHEMA));
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsDesc.java
new file mode 100644
index 0000000..c72799f
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsDesc.java
@@ -0,0 +1,54 @@
+/*
+ * 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.hadoop.hive.ql.ddl.dataconnector.show;
+
+import java.io.Serializable;
+
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.ql.ddl.DDLDesc;
+import org.apache.hadoop.hive.ql.plan.Explain;
+import org.apache.hadoop.hive.ql.plan.Explain.Level;
+
+/**
+ * DDL task description for SHOW CONNECTORS commands.
+ */
+@Explain(displayName = "Show Connectors", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
+public class ShowDataConnectorsDesc implements DDLDesc, Serializable {
+  private static final long serialVersionUID = 1L;
+
+  public static final String SHOW_DATACONNECTORS_SCHEMA = "connector_name#string";
+
+  private final String resFile;
+  private final String pattern;
+
+  public ShowDataConnectorsDesc(Path resFile, String pattern) {
+    this.resFile = resFile.toString();
+    this.pattern = pattern;
+  }
+
+  @Explain(displayName = "pattern")
+  public String getPattern() {
+    return pattern;
+  }
+
+  @Explain(displayName = "result file", explainLevels = { Level.EXTENDED })
+  public String getResFile() {
+    return resFile;
+  }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsOperation.java
new file mode 100644
index 0000000..8ecc9eb
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsOperation.java
@@ -0,0 +1,66 @@
+/*
+ * 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.hadoop.hive.ql.ddl.dataconnector.show;
+
+import java.io.DataOutputStream;
+import java.util.List;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.ql.ErrorMsg;
+import org.apache.hadoop.hive.ql.ddl.DDLOperation;
+import org.apache.hadoop.hive.ql.ddl.DDLOperationContext;
+import org.apache.hadoop.hive.ql.ddl.DDLUtils;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.udf.UDFLike;
+import org.apache.hadoop.io.IOUtils;
+
+/**
+ * Operation process of showing data connectors.
+ */
+public class ShowDataConnectorsOperation extends DDLOperation<ShowDataConnectorsDesc> {
+  public ShowDataConnectorsOperation(DDLOperationContext context, ShowDataConnectorsDesc desc) {
+    super(context, desc);
+  }
+
+  @Override
+  public int execute() throws HiveException {
+    List<String> connectors = context.getDb().getAllDataConnectors();
+    if (desc.getPattern() != null) {
+      LOG.debug("pattern: {}", desc.getPattern());
+      Pattern pattern = Pattern.compile(UDFLike.likePatternToRegExp(desc.getPattern()), Pattern.CASE_INSENSITIVE);
+      connectors = connectors.stream().filter(name -> pattern.matcher(name).matches()).collect(Collectors.toList());
+    }
+
+    LOG.info("Found {} connector(s) matching the SHOW CONNECTORS statement.", connectors.size());
+
+    // write the results in the file
+    DataOutputStream outStream = DDLUtils.getOutputStream(new Path(desc.getResFile()), context);
+    try {
+      context.getFormatter().showDataConnectors(outStream, connectors);
+    } catch (Exception e) {
+      throw new HiveException(e, ErrorMsg.GENERIC_ERROR, "show connectors");
+    } finally {
+      IOUtils.closeStream(outStream);
+    }
+
+    return 0;
+  }
+}

[hive] 19/38: fix for 2 additional test failures

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit d66d5fc3480815fb39fad33f484a6a03119e2bf3
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Tue Nov 24 00:16:49 2020 -0500

    fix for 2 additional test failures
---
 .../plugin/sqlstd/Operation2Privilege.java         |   8 +
 .../results/clientpositive/dataconnector.q.out     | 205 ---------------------
 2 files changed, 8 insertions(+), 205 deletions(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/Operation2Privilege.java b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/Operation2Privilege.java
index 3a10a06..2b9c7ab 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/Operation2Privilege.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/Operation2Privilege.java
@@ -442,6 +442,14 @@ public class Operation2Privilege {
     op2Priv.put(HiveOperationType.CREATE_MAPPING, PrivRequirement.newIOPrivRequirement(null, null));
     op2Priv.put(HiveOperationType.ALTER_MAPPING, PrivRequirement.newIOPrivRequirement(null, null));
     op2Priv.put(HiveOperationType.DROP_MAPPING, PrivRequirement.newIOPrivRequirement(null, null));
+
+    op2Priv.put(HiveOperationType.CREATEDATACONNECTOR, PrivRequirement.newIOPrivRequirement(null, ADMIN_PRIV_AR));
+    op2Priv.put(HiveOperationType.DROPDATACONNECTOR, PrivRequirement.newIOPrivRequirement(null, ADMIN_PRIV_AR));
+    op2Priv.put(HiveOperationType.ALTERDATACONNECTOR, PrivRequirement.newIOPrivRequirement(null, ADMIN_PRIV_AR));
+    op2Priv.put(HiveOperationType.ALTERDATACONNECTOR_OWNER, PrivRequirement.newIOPrivRequirement(null, ADMIN_PRIV_AR));
+    op2Priv.put(HiveOperationType.ALTERDATACONNECTOR_URL, PrivRequirement.newIOPrivRequirement(null, ADMIN_PRIV_AR));
+    op2Priv.put(HiveOperationType.DESCDATACONNECTOR, PrivRequirement.newIOPrivRequirement(null, null));
+    op2Priv.put(HiveOperationType.SHOWDATACONNECTORS, PrivRequirement.newIOPrivRequirement(null, null));
   }
 
   /**
diff --git a/ql/src/test/results/clientpositive/dataconnector.q.out b/ql/src/test/results/clientpositive/dataconnector.q.out
deleted file mode 100644
index 8b678c2..0000000
--- a/ql/src/test/results/clientpositive/dataconnector.q.out
+++ /dev/null
@@ -1,205 +0,0 @@
-PREHOOK: query: SHOW CONNECTORS
-PREHOOK: type: SHOWDATACONNECTORS
-POSTHOOK: query: SHOW CONNECTORS
-POSTHOOK: type: SHOWDATACONNECTORS
-PREHOOK: query: CREATE CONNECTOR mysql_test
-TYPE 'mysql'
-URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
-COMMENT 'test connector'
-WITH DCPROPERTIES (
-"hive.sql.dbcp.username"="hive1",
-"hive.sql.dbcp.password"="hive1")
-PREHOOK: type: CREATEDATACONNECTOR
-PREHOOK: Output: connector:mysql_test
-POSTHOOK: query: CREATE CONNECTOR mysql_test
-TYPE 'mysql'
-URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
-COMMENT 'test connector'
-WITH DCPROPERTIES (
-"hive.sql.dbcp.username"="hive1",
-"hive.sql.dbcp.password"="hive1")
-POSTHOOK: type: CREATEDATACONNECTOR
-POSTHOOK: Output: connector:mysql_test
-PREHOOK: query: SHOW CONNECTORS
-PREHOOK: type: SHOWDATACONNECTORS
-POSTHOOK: query: SHOW CONNECTORS
-POSTHOOK: type: SHOWDATACONNECTORS
-mysql_test
-PREHOOK: query: CREATE CONNECTOR IF NOT EXISTS mysql_test
-TYPE 'mysql'
-URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
-COMMENT 'test connector'
-WITH DCPROPERTIES (
-"hive.sql.dbcp.username"="hive1",
-"hive.sql.dbcp.password"="hive1")
-PREHOOK: type: CREATEDATACONNECTOR
-PREHOOK: Output: connector:mysql_test
-POSTHOOK: query: CREATE CONNECTOR IF NOT EXISTS mysql_test
-TYPE 'mysql'
-URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
-COMMENT 'test connector'
-WITH DCPROPERTIES (
-"hive.sql.dbcp.username"="hive1",
-"hive.sql.dbcp.password"="hive1")
-POSTHOOK: type: CREATEDATACONNECTOR
-POSTHOOK: Output: connector:mysql_test
-PREHOOK: query: SHOW CONNECTORS
-PREHOOK: type: SHOWDATACONNECTORS
-POSTHOOK: query: SHOW CONNECTORS
-POSTHOOK: type: SHOWDATACONNECTORS
-mysql_test
-PREHOOK: query: CREATE CONNECTOR IF NOT EXISTS derby_test
-TYPE 'derby'
-#### A masked pattern was here ####
-COMMENT 'test derby connector'
-WITH DCPROPERTIES (
-"hive.sql.dbcp.username"="APP",
-"hive.sql.dbcp.password"="mine")
-PREHOOK: type: CREATEDATACONNECTOR
-PREHOOK: Output: connector:derby_test
-POSTHOOK: query: CREATE CONNECTOR IF NOT EXISTS derby_test
-TYPE 'derby'
-#### A masked pattern was here ####
-COMMENT 'test derby connector'
-WITH DCPROPERTIES (
-"hive.sql.dbcp.username"="APP",
-"hive.sql.dbcp.password"="mine")
-POSTHOOK: type: CREATEDATACONNECTOR
-POSTHOOK: Output: connector:derby_test
-PREHOOK: query: DROP CONNECTOR mysql_test
-PREHOOK: type: DROPDATACONNECTOR
-PREHOOK: Input: connector:mysql_test
-PREHOOK: Output: connector:mysql_test
-POSTHOOK: query: DROP CONNECTOR mysql_test
-POSTHOOK: type: DROPDATACONNECTOR
-POSTHOOK: Input: connector:mysql_test
-POSTHOOK: Output: connector:mysql_test
-PREHOOK: query: SHOW CONNECTORS
-PREHOOK: type: SHOWDATACONNECTORS
-POSTHOOK: query: SHOW CONNECTORS
-POSTHOOK: type: SHOWDATACONNECTORS
-derby_test
-PREHOOK: query: DROP CONNECTOR IF EXISTS mysql_test
-PREHOOK: type: DROPDATACONNECTOR
-POSTHOOK: query: DROP CONNECTOR IF EXISTS mysql_test
-POSTHOOK: type: DROPDATACONNECTOR
-PREHOOK: query: SHOW CONNECTORS
-PREHOOK: type: SHOWDATACONNECTORS
-POSTHOOK: query: SHOW CONNECTORS
-POSTHOOK: type: SHOWDATACONNECTORS
-derby_test
-PREHOOK: query: CREATE CONNECTOR mysql_test
-TYPE 'mysql'
-URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
-COMMENT 'test connector'
-WITH DCPROPERTIES (
-"hive.sql.dbcp.username"="hive1",
-"hive.sql.dbcp.password"="hive1")
-PREHOOK: type: CREATEDATACONNECTOR
-PREHOOK: Output: connector:mysql_test
-POSTHOOK: query: CREATE CONNECTOR mysql_test
-TYPE 'mysql'
-URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
-COMMENT 'test connector'
-WITH DCPROPERTIES (
-"hive.sql.dbcp.username"="hive1",
-"hive.sql.dbcp.password"="hive1")
-POSTHOOK: type: CREATEDATACONNECTOR
-POSTHOOK: Output: connector:mysql_test
-PREHOOK: query: SHOW CONNECTORS
-PREHOOK: type: SHOWDATACONNECTORS
-POSTHOOK: query: SHOW CONNECTORS
-POSTHOOK: type: SHOWDATACONNECTORS
-derby_test
-mysql_test
-PREHOOK: query: CREATE REMOTE DATABASE db_derby USING derby_test with DBPROPERTIES("connector.remoteDbName"="APP")
-PREHOOK: type: CREATEDATABASE
-PREHOOK: Output: database:db_derby
-#### A masked pattern was here ####
-POSTHOOK: query: CREATE REMOTE DATABASE db_derby USING derby_test with DBPROPERTIES("connector.remoteDbName"="APP")
-POSTHOOK: type: CREATEDATABASE
-POSTHOOK: Output: database:db_derby
-#### A masked pattern was here ####
-PREHOOK: query: SHOW DATABASES
-PREHOOK: type: SHOWDATABASES
-POSTHOOK: query: SHOW DATABASES
-POSTHOOK: type: SHOWDATABASES
-db_derby
-default
-PREHOOK: query: USE db_derby
-PREHOOK: type: SWITCHDATABASE
-PREHOOK: Input: database:db_derby
-POSTHOOK: query: USE db_derby
-POSTHOOK: type: SWITCHDATABASE
-POSTHOOK: Input: database:db_derby
-PREHOOK: query: SHOW TABLES
-PREHOOK: type: SHOWTABLES
-PREHOOK: Input: database:db_derby
-POSTHOOK: query: SHOW TABLES
-POSTHOOK: type: SHOWTABLES
-POSTHOOK: Input: database:db_derby
-PREHOOK: query: alter connector mysql_test set URL 'jdbc:mysql://nightly1.apache.org:3306/hive2'
-PREHOOK: type: ALTERDATACONNECTOR_
-PREHOOK: Output: connector:mysql_test
-POSTHOOK: query: alter connector mysql_test set URL 'jdbc:mysql://nightly1.apache.org:3306/hive2'
-POSTHOOK: type: ALTERDATACONNECTOR_
-POSTHOOK: Output: connector:mysql_test
-PREHOOK: query: DESCRIBE CONNECTOR extended mysql_test
-PREHOOK: type: DESCDATACONNECTOR
-PREHOOK: Input: connector:mysql_test
-POSTHOOK: query: DESCRIBE CONNECTOR extended mysql_test
-POSTHOOK: type: DESCDATACONNECTOR
-POSTHOOK: Input: connector:mysql_test
-mysql_test	mysql	jdbc:mysql://nightly1.apache.org:3306/hive2	hive_test_user	USER	test connector	{hive.sql.dbcp.password=hive1, hive.sql.dbcp.username=hive1}
-PREHOOK: query: alter connector mysql_test set DCPROPERTIES("hive.sql.dbcp.username"="hive2","hive.sql.dbcp.password"="hive2")
-PREHOOK: type: ALTERDATACONNECTOR
-PREHOOK: Output: connector:mysql_test
-POSTHOOK: query: alter connector mysql_test set DCPROPERTIES("hive.sql.dbcp.username"="hive2","hive.sql.dbcp.password"="hive2")
-POSTHOOK: type: ALTERDATACONNECTOR
-POSTHOOK: Output: connector:mysql_test
-PREHOOK: query: DESCRIBE CONNECTOR extended mysql_test
-PREHOOK: type: DESCDATACONNECTOR
-PREHOOK: Input: connector:mysql_test
-POSTHOOK: query: DESCRIBE CONNECTOR extended mysql_test
-POSTHOOK: type: DESCDATACONNECTOR
-POSTHOOK: Input: connector:mysql_test
-mysql_test	mysql	jdbc:mysql://nightly1.apache.org:3306/hive2	hive_test_user	USER	test connector	{hive.sql.dbcp.password=hive2, hive.sql.dbcp.username=hive2}
-PREHOOK: query: alter connector mysql_test set OWNER USER newuser
-PREHOOK: type: ALTERDATABASE_OWNER
-PREHOOK: Output: connector:mysql_test
-POSTHOOK: query: alter connector mysql_test set OWNER USER newuser
-POSTHOOK: type: ALTERDATABASE_OWNER
-POSTHOOK: Output: connector:mysql_test
-PREHOOK: query: DESCRIBE CONNECTOR extended mysql_test
-PREHOOK: type: DESCDATACONNECTOR
-PREHOOK: Input: connector:mysql_test
-POSTHOOK: query: DESCRIBE CONNECTOR extended mysql_test
-POSTHOOK: type: DESCDATACONNECTOR
-POSTHOOK: Input: connector:mysql_test
-mysql_test	mysql	jdbc:mysql://nightly1.apache.org:3306/hive2	newuser	USER	test connector	{hive.sql.dbcp.password=hive2, hive.sql.dbcp.username=hive2}
-PREHOOK: query: DROP DATABASE db_derby
-PREHOOK: type: DROPDATABASE
-PREHOOK: Input: database:db_derby
-PREHOOK: Output: database:db_derby
-POSTHOOK: query: DROP DATABASE db_derby
-POSTHOOK: type: DROPDATABASE
-POSTHOOK: Input: database:db_derby
-POSTHOOK: Output: database:db_derby
-PREHOOK: query: SHOW DATABASES
-PREHOOK: type: SHOWDATABASES
-POSTHOOK: query: SHOW DATABASES
-POSTHOOK: type: SHOWDATABASES
-default
-PREHOOK: query: DROP CONNECTOR mysql_test
-PREHOOK: type: DROPDATACONNECTOR
-PREHOOK: Input: connector:mysql_test
-PREHOOK: Output: connector:mysql_test
-POSTHOOK: query: DROP CONNECTOR mysql_test
-POSTHOOK: type: DROPDATACONNECTOR
-POSTHOOK: Input: connector:mysql_test
-POSTHOOK: Output: connector:mysql_test
-PREHOOK: query: SHOW CONNECTORS
-PREHOOK: type: SHOWDATACONNECTORS
-POSTHOOK: query: SHOW CONNECTORS
-POSTHOOK: type: SHOWDATACONNECTORS
-derby_test

[hive] 33/38: HIVE-24396: Cleanup and one test failure (Naveen Gangam)

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 14283d3260898a1f901e603ccc8985231fc3fd16
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Fri Mar 19 17:33:23 2021 -0400

    HIVE-24396: Cleanup and one test failure (Naveen Gangam)
---
 .../hadoop/hive/ql/ddl/database/create/CreateDatabaseDesc.java     | 7 -------
 .../java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java  | 2 +-
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseDesc.java
index 1590133..f458cdc 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseDesc.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseDesc.java
@@ -103,13 +103,6 @@ public class CreateDatabaseDesc implements DDLDesc, Serializable {
   @Explain(displayName="database type")
   public DatabaseType getDatabaseType() {
     return dbType;
-    /*
-    if (dbType == DatabaseType.NATIVE)
-      return "NATIVE";
-    else
-      return "REMOTE";
-
-     */
   }
 
   @Explain(displayName="connector name")
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java
index 05ae218..f8b337d 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java
@@ -434,7 +434,7 @@ class MetaStoreDirectSql {
       }
       db.setManagedLocationUri(MetastoreDirectSqlUtils.extractSqlString(dbline[8]));
       String dbType = MetastoreDirectSqlUtils.extractSqlString(dbline[9]);
-      if (dbType != null && dbType.equalsIgnoreCase("REMOTE")) {
+      if (dbType != null && dbType.equalsIgnoreCase(DatabaseType.REMOTE.name())) {
         db.setType(DatabaseType.REMOTE);
         db.setConnector_name(MetastoreDirectSqlUtils.extractSqlString(dbline[10]));
         db.setRemote_dbname(MetastoreDirectSqlUtils.extractSqlString(dbline[11]));

[hive] 04/38: Added provider for postgres, refactored bunch of classes

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 91f1ccd9d0be977fd3222a53b3e6758f83d88132
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Mon Nov 16 13:24:52 2020 -0500

    Added provider for postgres, refactored bunch of classes
---
 .../hadoop/hive/metastore/conf/MetastoreConf.java  |  10 ++
 .../AbstractDataConnectorProvider.java             |  45 +++++
 .../DataConnectorProviderFactory.java              |  13 +-
 .../dataconnector/IDataConnectorProvider.java      |   2 -
 .../JDBCConnectorProviderFactory.java              |  42 +++++
 ...der.java => AbstractJDBCConnectorProvider.java} | 192 ++++++++++++++-------
 .../dataconnector/jdbc/MySQLConfigGenerator.java   |   4 -
 ...orProvider.java => MySQLConnectorProvider.java} | 137 +++------------
 .../jdbc/PostgreSQLConnectorProvider.java          | 116 +++++++++++++
 9 files changed, 373 insertions(+), 188 deletions(-)

diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
index 2e03223..3489ccc 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
@@ -2257,4 +2257,14 @@ public class MetastoreConf {
     buf.append("Finished MetastoreConf object.\n");
     return buf.toString();
   }
+
+  public static char[] getValueFromKeystore(String keystorePath, String key) throws IOException {
+    char[] valueCharArray = null;
+    if (keystorePath != null && key != null) {
+      Configuration conf = new Configuration();
+      conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, keystorePath);
+      valueCharArray = conf.getPassword(key);
+    }
+    return valueCharArray;
+  }
 }
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/AbstractDataConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/AbstractDataConnectorProvider.java
index 2a73236..74ddbdd 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/AbstractDataConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/AbstractDataConnectorProvider.java
@@ -1,11 +1,19 @@
 package org.apache.hadoop.hive.metastore.dataconnector;
 
+import org.apache.hadoop.hive.metastore.TableType;
 import org.apache.hadoop.hive.metastore.api.DataConnector;
+import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.Order;
+import org.apache.hadoop.hive.metastore.api.SerDeInfo;
+import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
 import org.apache.hadoop.hive.metastore.api.Table;
 
 import java.net.ConnectException;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 public abstract class AbstractDataConnectorProvider implements IDataConnectorProvider {
   protected String scoped_db = null;
@@ -68,4 +76,41 @@ public abstract class AbstractDataConnectorProvider implements IDataConnectorPro
   @Override public Table getTable(String tableName) throws MetaException {
     return null;
   }
+
+  protected Table buildTableFromColsList(String tableName, List<FieldSchema> cols) {
+    //Setting the storage descriptor.
+    StorageDescriptor sd = new StorageDescriptor();
+    sd.setCols(cols);
+    SerDeInfo serdeInfo = new SerDeInfo();
+    serdeInfo.setName(tableName);
+    serdeInfo.setSerializationLib("org.apache.hive.storage.jdbc.JdbcSerDe");
+    Map<String, String> serdeParams = new HashMap<String, String>();
+    serdeParams.put("serialization.format", "1");
+    serdeInfo.setParameters(serdeParams);
+
+    sd.setSerdeInfo(serdeInfo);
+    sd.setInputFormat("org.apache.hive.storage.jdbc.JdbcInputFormat"); // TODO
+    sd.setOutputFormat("org.apache.hive.storage.jdbc.JdbcOutputFormat"); // TODO
+    sd.setLocation("/tmp/some_dummy_path"); // TODO
+    sd.setBucketCols(new ArrayList<String>());
+    sd.setSortCols(new ArrayList<Order>());
+
+    //Setting the required table information
+    Table table = new Table();
+    table.setTableName(tableName);
+    table.setTableType(TableType.EXTERNAL_TABLE.toString());
+    table.setDbName(scoped_db);
+    table.setSd(sd);
+    // set table properties that subclasses can fill-in
+    table.setParameters(new HashMap<String, String>());
+    // set partition keys to empty
+    table.setPartitionKeys(new
+        ArrayList<FieldSchema>());
+
+    return table;
+  }
+
+  abstract protected String getInputClass();
+
+  abstract protected String getOutputClass();
 }
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/DataConnectorProviderFactory.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/DataConnectorProviderFactory.java
index ce43633..7f321a8 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/DataConnectorProviderFactory.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/DataConnectorProviderFactory.java
@@ -6,18 +6,14 @@ import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.metastore.api.DatabaseType;
 import org.apache.hadoop.hive.metastore.api.MetaException;
 import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
-import static org.apache.hadoop.hive.metastore.dataconnector.IDataConnectorProvider.DERBY_TYPE;
-import static org.apache.hadoop.hive.metastore.dataconnector.IDataConnectorProvider.MSSQL_TYPE;
-import static org.apache.hadoop.hive.metastore.dataconnector.IDataConnectorProvider.MYSQL_TYPE;
-import static org.apache.hadoop.hive.metastore.dataconnector.IDataConnectorProvider.ORACLE_TYPE;
-import static org.apache.hadoop.hive.metastore.dataconnector.IDataConnectorProvider.POSTGRES_TYPE;
-import org.apache.hadoop.hive.metastore.dataconnector.jdbc.JDBCConnectorProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.util.HashMap;
 import java.util.Map;
 
+import static org.apache.hadoop.hive.metastore.dataconnector.IDataConnectorProvider.*;
+
 public class DataConnectorProviderFactory {
   Logger LOG = LoggerFactory.getLogger(DataConnectorProviderFactory.class);
 
@@ -45,7 +41,7 @@ public class DataConnectorProviderFactory {
     }
 
     String scopedDb = (db.getRemote_dbname() != null) ? db.getRemote_dbname() : db.getName();
-    if (cache.containsKey(db.getConnector_name().toLowerCase() != null)) {
+    if (cache.containsKey(db.getConnector_name().toLowerCase())) {
       provider = cache.get(db.getConnector_name().toLowerCase());
       if (provider != null) {
         provider.setScope(scopedDb);
@@ -67,7 +63,8 @@ public class DataConnectorProviderFactory {
     case ORACLE_TYPE:
     case POSTGRES_TYPE:
       try {
-        provider = new JDBCConnectorProvider(scopedDb, connector);
+        provider = JDBCConnectorProviderFactory.get(scopedDb, connector);
+        cache.put(db.getConnector_name(), provider);
       } catch (Exception e) {
         throw new MetaException("Could not instantiate a provider for database " + db.getName());
       }
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/IDataConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/IDataConnectorProvider.java
index 73b3db9..24a1d7e 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/IDataConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/IDataConnectorProvider.java
@@ -2,14 +2,12 @@ package org.apache.hadoop.hive.metastore.dataconnector;
 
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
-import org.apache.hadoop.hive.metastore.HiveMetaException;
 import org.apache.hadoop.hive.metastore.api.DataConnector;
 import org.apache.hadoop.hive.metastore.api.MetaException;
 import org.apache.hadoop.hive.metastore.api.Table;
 
 import java.net.ConnectException;
 import java.util.List;
-import java.util.Map;
 
 /**
  * This interface provides a way for us to plugin different datasources into hive.
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/JDBCConnectorProviderFactory.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/JDBCConnectorProviderFactory.java
new file mode 100644
index 0000000..537fd2c
--- /dev/null
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/JDBCConnectorProviderFactory.java
@@ -0,0 +1,42 @@
+package org.apache.hadoop.hive.metastore.dataconnector;
+
+import org.apache.hadoop.hive.metastore.api.DataConnector;
+import org.apache.hadoop.hive.metastore.dataconnector.jdbc.MySQLConnectorProvider;
+import org.apache.hadoop.hive.metastore.dataconnector.jdbc.PostgreSQLConnectorProvider;
+
+import static org.apache.hadoop.hive.metastore.dataconnector.IDataConnectorProvider.MYSQL_TYPE;
+import static org.apache.hadoop.hive.metastore.dataconnector.IDataConnectorProvider.POSTGRES_TYPE;
+
+
+public class JDBCConnectorProviderFactory {
+
+  public static IDataConnectorProvider get(String dbName, DataConnector connector) {
+    IDataConnectorProvider provider = null;
+    switch(connector.getType().toLowerCase()) {
+    case MYSQL_TYPE:
+      provider = new MySQLConnectorProvider(dbName, connector);
+      /*
+      try {
+        Class.forName(driverClassName);
+        handle = DriverManager.getConnection(jdbcUrl, username, password);
+        isOpen = true;
+      } catch (ClassNotFoundException cnfe) {
+        LOG.warn("Driver class not found in classpath:" + driverClassName);
+        throw new RuntimeException("Driver class not found:" + driverClassName);
+      } catch (SQLException sqle) {
+        LOG.warn("Could not connect to remote data source at " + jdbcUrl);
+        throw new ConnectException("Could not connect to remote datasource at " + jdbcUrl + ",cause:" + sqle.getMessage());
+      }
+       */
+      break;
+    case POSTGRES_TYPE:
+      provider = new PostgreSQLConnectorProvider(dbName, connector);
+      break;
+
+    default:
+      throw new RuntimeException("Unsupported JDBC type");
+    }
+
+    return provider;
+  }
+}
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/JDBCConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
similarity index 54%
copy from standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/JDBCConnectorProvider.java
copy to standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
index 7e9d408..d436123 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/JDBCConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
@@ -1,37 +1,53 @@
 package org.apache.hadoop.hive.metastore.dataconnector.jdbc;
 
-import java.net.ConnectException;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Date;
-
-import org.apache.hadoop.hive.conf.Constants;
-import org.apache.hadoop.hive.metastore.ColumnType;
-import org.apache.hadoop.hive.metastore.TableType;
-import org.apache.hadoop.hive.metastore.Warehouse;
 import org.apache.hadoop.hive.metastore.api.DataConnector;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.api.Order;
-import org.apache.hadoop.hive.metastore.api.SerDeInfo;
-import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
 import org.apache.hadoop.hive.metastore.api.Table;
 import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
 import org.apache.hadoop.hive.metastore.dataconnector.AbstractDataConnectorProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.HashMap;
+import java.io.IOException;
+import java.net.ConnectException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-public class JDBCConnectorProvider extends AbstractDataConnectorProvider {
-  private static Logger LOG = LoggerFactory.getLogger(JDBCConnectorProvider.class);
+public abstract class AbstractJDBCConnectorProvider extends AbstractDataConnectorProvider {
+  private static Logger LOG = LoggerFactory.getLogger(AbstractJDBCConnectorProvider.class);
+
+  // duplicate constants from Constants.java to avoid a dependency on hive-common
+  public static final String JDBC_HIVE_STORAGE_HANDLER_ID =
+      "org.apache.hive.storage.jdbc.JdbcStorageHandler";
+  public static final String JDBC_CONFIG_PREFIX = "hive.sql";
+  public static final String JDBC_CATALOG = JDBC_CONFIG_PREFIX + ".catalog";
+  public static final String JDBC_SCHEMA = JDBC_CONFIG_PREFIX + ".schema";
+  public static final String JDBC_TABLE = JDBC_CONFIG_PREFIX + ".table";
+  public static final String JDBC_DATABASE_TYPE = JDBC_CONFIG_PREFIX + ".database.type";
+  public static final String JDBC_URL = JDBC_CONFIG_PREFIX + ".jdbc.url";
+  public static final String JDBC_DRIVER = JDBC_CONFIG_PREFIX + ".jdbc.driver";
+  public static final String JDBC_USERNAME = JDBC_CONFIG_PREFIX + ".dbcp.username";
+  public static final String JDBC_PASSWORD = JDBC_CONFIG_PREFIX + ".dbcp.password";
+  public static final String JDBC_KEYSTORE = JDBC_CONFIG_PREFIX + ".dbcp.password.keystore";
+  public static final String JDBC_KEY = JDBC_CONFIG_PREFIX + ".dbcp.password.key";
+  public static final String JDBC_QUERY = JDBC_CONFIG_PREFIX + ".query";
+  public static final String JDBC_QUERY_FIELD_NAMES = JDBC_CONFIG_PREFIX + ".query.fieldNames";
+  public static final String JDBC_QUERY_FIELD_TYPES = JDBC_CONFIG_PREFIX + ".query.fieldTypes";
+  public static final String JDBC_SPLIT_QUERY = JDBC_CONFIG_PREFIX + ".query.split";
+  public static final String JDBC_PARTITION_COLUMN = JDBC_CONFIG_PREFIX + ".partitionColumn";
+  public static final String JDBC_NUM_PARTITIONS = JDBC_CONFIG_PREFIX + ".numPartitions";
+  public static final String JDBC_LOW_BOUND = JDBC_CONFIG_PREFIX + ".lowerBound";
+  public static final String JDBC_UPPER_BOUND = JDBC_CONFIG_PREFIX + ".upperBound";
+
+  private static final String JDBC_INPUTFORMAT_CLASS = "org.apache.hive.storage.jdbc.JdbcInputFormat".intern();
+  private static final String JDBC_OUTPUTFORMAT_CLASS = "org.apache.hive.storage.jdbc.JdbcOutputFormat".intern();
 
   String type = null; // MYSQL, POSTGRES, ORACLE, DERBY, MSSQL, DB2 etc.
   String driverClassName = null;
@@ -39,38 +55,40 @@ public class JDBCConnectorProvider extends AbstractDataConnectorProvider {
   String username = null;
   String password = null; // TODO convert to byte array
 
-  public JDBCConnectorProvider(String dbName, DataConnector dataConn) {
+  public AbstractJDBCConnectorProvider(String dbName, DataConnector dataConn) {
     super(dbName, dataConn);
     this.type = connector.getType().toUpperCase(); // TODO
     this.jdbcUrl = connector.getUrl();
-    this.username = connector.getParameters().get("dataconnector.username");
-    this.password = connector.getParameters().get("dataconnector.password");
+    this.username = connector.getParameters().get(JDBC_USERNAME);
+    this.password = connector.getParameters().get(JDBC_PASSWORD);
+    if (this.password == null) {
+      String keystore = connector.getParameters().get(JDBC_KEYSTORE);
+      String key = connector.getParameters().get(JDBC_KEY);
+      try {
+        char[] keyValue = MetastoreConf.getValueFromKeystore(keystore, key);
+        if (keyValue != null)
+          this.password = new String(keyValue);
+      } catch (IOException i) {
+        LOG.warn("Could not read key value from keystore");
+      }
+    }
   }
 
   @Override public void open() throws ConnectException {
-    switch(type.toLowerCase()) {
-    case MYSQL_TYPE:
-      driverClassName = "com.mysql.jdbc.Driver";
-      try {
-        Class.forName(driverClassName);
-        handle = DriverManager.getConnection(jdbcUrl, username, password);
-        isOpen = true;
-      } catch (ClassNotFoundException cnfe) {
-        LOG.warn("Driver class not found in classpath:" + driverClassName);
-        throw new RuntimeException("Driver class not found:" + driverClassName);
-      } catch (SQLException sqle) {
-        LOG.warn("Could not connect to remote data source at " + jdbcUrl);
-        throw new ConnectException("Could not connect to remote datasource at " + jdbcUrl + ",cause:" + sqle.getMessage());
-      }
-      break;
-    case POSTGRES_TYPE:
-      
-    default:
-      throw new RuntimeException("Unsupported JDBC type");
+    try {
+      Class.forName(driverClassName);
+      handle = DriverManager.getConnection(jdbcUrl, username, password);
+      isOpen = true;
+    } catch (ClassNotFoundException cnfe) {
+      LOG.warn("Driver class not found in classpath:" + driverClassName);
+      throw new RuntimeException("Driver class not found:" + driverClassName);
+    } catch (SQLException sqle) {
+      LOG.warn("Could not connect to remote data source at " + jdbcUrl);
+      throw new ConnectException("Could not connect to remote datasource at " + jdbcUrl + ",cause:" + sqle.getMessage());
     }
   }
 
-  private Connection getConnection() {
+  protected Connection getConnection() {
     try {
       if (!isOpen)
         open();
@@ -100,9 +118,7 @@ public class JDBCConnectorProvider extends AbstractDataConnectorProvider {
    * @throws MetaException To indicate any failures with executing this API
    * @param regex
    */
-  @Override public List<Table> getTables(String regex) throws MetaException {
-    return null;
-  }
+  @Override public abstract List<Table> getTables(String regex) throws MetaException;
 
   /**
    * Returns a list of all table names from the remote database.
@@ -133,6 +149,10 @@ public class JDBCConnectorProvider extends AbstractDataConnectorProvider {
     return null;
   }
 
+  protected abstract ResultSet fetchTableMetadata(String tableName) throws MetaException;
+
+  protected abstract ResultSet fetchTableNames() throws MetaException;
+
   /**
    * Fetch a single table with the given name, returns a Hive Table object from the remote database
    * @return Table A Table object for the matching table, null otherwise.
@@ -140,21 +160,30 @@ public class JDBCConnectorProvider extends AbstractDataConnectorProvider {
    * @param tableName
    */
   @Override public Table getTable(String tableName) throws MetaException {
+    ResultSet rs = null;
+    Table table = null;
     try {
+      // rs = fetchTableMetadata(tableName);
+      rs = fetchTableViaDBMetaData(tableName);
+      /*
       Statement stmt = getConnection().createStatement();
-      ResultSet rs = stmt.executeQuery(
+      rs = stmt.executeQuery(
           "SELECT table_name, column_name, is_nullable, data_type, character_maximum_length FROM INFORMATION_SCHEMA.Columns where table_schema='"
               + scoped_db + "' and table_name='" + tableName + "'");
+       */
       List<FieldSchema> cols = new ArrayList<>();
       // TODO throw exception is RS is empty
       while (rs.next()) {
         FieldSchema fs = new FieldSchema();
         fs.setName(rs.getString("COLUMN_NAME"));
-        fs.setType(getDataType(rs.getString("DATA_TYPE"), rs.getInt("CHARACTER_MAXIMUM_LENGTH")));
+        // fs.setType(getDataType(rs.getString("DATA_TYPE"), rs.getInt("CHARACTER_MAXIMUM_LENGTH")));
+        fs.setType(getDataType(rs.getString("TYPE_NAME"), rs.getInt("COLUMN_SIZE")));
         fs.setComment("inferred column type");
         cols.add(fs);
       }
 
+      table = buildTableFromColsList(tableName, cols);
+      /*
       //Setting the storage descriptor.
       StorageDescriptor sd = new StorageDescriptor();
       sd.setCols(cols);
@@ -176,41 +205,65 @@ public class JDBCConnectorProvider extends AbstractDataConnectorProvider {
       sd.setLocation("/tmp/some_dummy_path"); // TODO
       sd.setBucketCols(new ArrayList<String>());
       sd.setSortCols(new ArrayList<Order>());
+       */
 
       //Setting the table properties.
-      Map<String, String> tblProps = new HashMap<>();
-      tblProps.put(Constants.JDBC_DATABASE_TYPE, this.type);
-      tblProps.put(Constants.JDBC_DRIVER, this.driverClassName);
-      tblProps.put(Constants.JDBC_URL, this.jdbcUrl); // "jdbc://localhost:3306/hive"
-      tblProps.put(Constants.JDBC_USERNAME, this.username);
-      tblProps.put(Constants.JDBC_PASSWORD, this.password);
-      tblProps.put(Constants.JDBC_TABLE, tableName);
-      tblProps.put(hive_metastoreConstants.META_TABLE_STORAGE, Constants.JDBC_HIVE_STORAGE_HANDLER_ID);
-      tblProps.put("EXTERNAL", "TRUE");
-      // TODO: Need to include schema, catalog info in the paramters list.
+      table.getParameters().put(JDBC_DATABASE_TYPE, this.type);
+      table.getParameters().put(JDBC_DRIVER, this.driverClassName);
+      table.getParameters().put(JDBC_TABLE, tableName);
+      table.getParameters().put(JDBC_URL, this.jdbcUrl);
+      table.getParameters().put(hive_metastoreConstants.META_TABLE_STORAGE, JDBC_HIVE_STORAGE_HANDLER_ID);
+      table.getParameters().put("EXTERNAL", "TRUE");
+      Map<String, String> connectorParams = connector.getParameters();
+      for (String param: connectorParams.keySet()) {
+        if (param.startsWith(JDBC_CONFIG_PREFIX)) {
+          table.getParameters().put(param, connectorParams.get(param));
+        }
+      }
+      // TODO: Need to include schema, catalog info in the parameters list.
 
       //Setting the required table information
-      Table table = new Table();
-      table.setTableName(tableName);
-      table.setTableType(TableType.EXTERNAL_TABLE.toString());
-      table.setDbName(scoped_db);
-      table.setSd(sd);
-      table.setParameters(tblProps);
+      // Table table = new Table();
+      // table.setTableName(tableName);
+      // table.setTableType(TableType.EXTERNAL_TABLE.toString());
+      // table.setDbName(scoped_db);
+      // table.setSd(sd);
       // set partition keys to empty
-      table.setPartitionKeys(new ArrayList<FieldSchema>());
+      // table.setPartitionKeys(new
+          // ArrayList<FieldSchema>());
 
+      // table.setParameters(tblProps);
       return table;
     } catch (Exception e) {
       LOG.warn("Exception retrieving remote table " + scoped_db + "." + tableName + " via data connector "
           + connector.getName());
       throw new MetaException("Error retrieving remote table:" + e);
+    } finally {
+      try {
+        if (rs != null) {
+          rs.close();
+        }
+      } catch (Exception ex) { /* ignore */ }
     }
   }
 
+  private ResultSet fetchTableViaDBMetaData(String tableName) {
+    ResultSet rs = null;
+    try {
+      rs = getConnection().getMetaData().getColumns(scoped_db, null, tableName, null);
+    } catch (SQLException sqle) {
+      LOG.warn("Could not retrieve column names from JDBC table, cause:" + sqle.getMessage());
+    }
+    return rs;
+  }
+
   private String wrapSize(int size) {
     return "(" + size + ")";
   }
 
+  protected abstract String getDataType(String dbType, int size);
+
+  /*
   private String getDataType(String mySqlType, int size) {
     //TODO: Geomentric, network, bit, array data types of postgresql needs to be supported.
     switch(mySqlType)
@@ -273,4 +326,13 @@ public class JDBCConnectorProvider extends AbstractDataConnectorProvider {
       return ColumnType.VOID_TYPE_NAME;
     }
   }
+ */
+
+  @Override protected String getInputClass() {
+    return JDBC_INPUTFORMAT_CLASS;
+  }
+
+  @Override protected String getOutputClass() {
+    return JDBC_INPUTFORMAT_CLASS;
+  }
 }
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConfigGenerator.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConfigGenerator.java
deleted file mode 100644
index 307f7ad..0000000
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConfigGenerator.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package org.apache.hadoop.hive.metastore.dataconnector.jdbc;
-
-public class MySQLConfigGenerator {
-}
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/JDBCConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConnectorProvider.java
similarity index 63%
rename from standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/JDBCConnectorProvider.java
rename to standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConnectorProvider.java
index 7e9d408..cdeb6fa 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/JDBCConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConnectorProvider.java
@@ -1,135 +1,51 @@
 package org.apache.hadoop.hive.metastore.dataconnector.jdbc;
 
-import java.net.ConnectException;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Date;
-
-import org.apache.hadoop.hive.conf.Constants;
 import org.apache.hadoop.hive.metastore.ColumnType;
-import org.apache.hadoop.hive.metastore.TableType;
-import org.apache.hadoop.hive.metastore.Warehouse;
 import org.apache.hadoop.hive.metastore.api.DataConnector;
-import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.api.Order;
-import org.apache.hadoop.hive.metastore.api.SerDeInfo;
-import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
 import org.apache.hadoop.hive.metastore.api.Table;
-import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants;
-import org.apache.hadoop.hive.metastore.dataconnector.AbstractDataConnectorProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.HashMap;
+import java.io.IOException;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.List;
-import java.util.Map;
 
-public class JDBCConnectorProvider extends AbstractDataConnectorProvider {
-  private static Logger LOG = LoggerFactory.getLogger(JDBCConnectorProvider.class);
+public class MySQLConnectorProvider extends AbstractJDBCConnectorProvider {
+  private static Logger LOG = LoggerFactory.getLogger(MySQLConnectorProvider.class);
 
-  String type = null; // MYSQL, POSTGRES, ORACLE, DERBY, MSSQL, DB2 etc.
-  String driverClassName = null;
-  String jdbcUrl = null;
-  String username = null;
-  String password = null; // TODO convert to byte array
+  private static final String DRIVER_CLASS = "com.mysql.jdbc.Driver".intern();
 
-  public JDBCConnectorProvider(String dbName, DataConnector dataConn) {
+  public MySQLConnectorProvider(String dbName, DataConnector dataConn) {
     super(dbName, dataConn);
-    this.type = connector.getType().toUpperCase(); // TODO
-    this.jdbcUrl = connector.getUrl();
-    this.username = connector.getParameters().get("dataconnector.username");
-    this.password = connector.getParameters().get("dataconnector.password");
-  }
-
-  @Override public void open() throws ConnectException {
-    switch(type.toLowerCase()) {
-    case MYSQL_TYPE:
-      driverClassName = "com.mysql.jdbc.Driver";
-      try {
-        Class.forName(driverClassName);
-        handle = DriverManager.getConnection(jdbcUrl, username, password);
-        isOpen = true;
-      } catch (ClassNotFoundException cnfe) {
-        LOG.warn("Driver class not found in classpath:" + driverClassName);
-        throw new RuntimeException("Driver class not found:" + driverClassName);
-      } catch (SQLException sqle) {
-        LOG.warn("Could not connect to remote data source at " + jdbcUrl);
-        throw new ConnectException("Could not connect to remote datasource at " + jdbcUrl + ",cause:" + sqle.getMessage());
-      }
-      break;
-    case POSTGRES_TYPE:
-      
-    default:
-      throw new RuntimeException("Unsupported JDBC type");
-    }
-  }
-
-  private Connection getConnection() {
-    try {
-      if (!isOpen)
-        open();
-    } catch (ConnectException ce) {
-      throw new RuntimeException(ce.getMessage());
-    }
-
-    if (handle instanceof Connection)
-      return (Connection)handle;
-
-    throw new RuntimeException("unexpected type for connection handle");
-  }
-
-  @Override public void close() {
-    if (isOpen) {
-      try {
-        ((Connection)handle).close();
-      } catch (SQLException sqle) {
-        LOG.warn("Could not close jdbc connection to " + jdbcUrl, sqle);
-      }
-    }
-  }
-
-  /**
-   * Returns Hive Table objects from the remote database for tables that match a name pattern.
-   * @return List A collection of objects that match the name pattern, null otherwise.
-   * @throws MetaException To indicate any failures with executing this API
-   * @param regex
-   */
-  @Override public List<Table> getTables(String regex) throws MetaException {
-    return null;
+    driverClassName = DRIVER_CLASS;
   }
 
   /**
    * Returns a list of all table names from the remote database.
    * @return List A collection of all the table names, null if there are no tables.
-   * @throws MetaException To indicate any failures with executing this API
+   * @throws IOException To indicate any failures with executing this API
    */
-  @Override public List<String> getTableNames() throws MetaException {
+  @Override protected ResultSet fetchTableNames() throws MetaException {
     ResultSet rs = null;
     try {
       rs = getConnection().getMetaData().getTables(scoped_db, null, null, new String[] { "TABLE" });
-      if (rs != null) {
-        List<String> tables = new ArrayList<String>();
-        while(rs.next()) {
-          tables.add(rs.getString(3));
-        }
-        return tables;
-      }
     } catch (SQLException sqle) {
       LOG.warn("Could not retrieve table names from remote datasource, cause:" + sqle.getMessage());
-    } finally {
-      try {
-        if (rs != null) {
-          rs.close();
-          rs = null;
-        }
-      } catch(Exception e) { /* ignore */}
+      throw new MetaException("Could not retrieve table names from remote datasource, cause:" + sqle.getMessage());
     }
+    return rs;
+  }
+
+  /**
+   * Returns Hive Table objects from the remote database for tables that match a name pattern.
+   * @return List A collection of objects that match the name pattern, null otherwise.
+   * @throws MetaException To indicate any failures with executing this API
+   * @param regex
+   */
+  @Override public  List<Table> getTables(String regex) throws MetaException {
     return null;
   }
 
@@ -139,12 +55,13 @@ public class JDBCConnectorProvider extends AbstractDataConnectorProvider {
    * @throws MetaException To indicate any failures with executing this API
    * @param tableName
    */
-  @Override public Table getTable(String tableName) throws MetaException {
+  @Override public ResultSet fetchTableMetadata(String tableName) throws MetaException {
     try {
       Statement stmt = getConnection().createStatement();
       ResultSet rs = stmt.executeQuery(
           "SELECT table_name, column_name, is_nullable, data_type, character_maximum_length FROM INFORMATION_SCHEMA.Columns where table_schema='"
               + scoped_db + "' and table_name='" + tableName + "'");
+      /*
       List<FieldSchema> cols = new ArrayList<>();
       // TODO throw exception is RS is empty
       while (rs.next()) {
@@ -200,6 +117,8 @@ public class JDBCConnectorProvider extends AbstractDataConnectorProvider {
       table.setPartitionKeys(new ArrayList<FieldSchema>());
 
       return table;
+       */
+      return rs;
     } catch (Exception e) {
       LOG.warn("Exception retrieving remote table " + scoped_db + "." + tableName + " via data connector "
           + connector.getName());
@@ -211,9 +130,9 @@ public class JDBCConnectorProvider extends AbstractDataConnectorProvider {
     return "(" + size + ")";
   }
 
-  private String getDataType(String mySqlType, int size) {
+  protected String getDataType(String dbDataType, int size) {
     //TODO: Geomentric, network, bit, array data types of postgresql needs to be supported.
-    switch(mySqlType)
+    switch(dbDataType.toLowerCase())
     {
     case "char":
       return ColumnType.CHAR_TYPE_NAME + wrapSize(size);
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/PostgreSQLConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/PostgreSQLConnectorProvider.java
new file mode 100644
index 0000000..41e08e9
--- /dev/null
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/PostgreSQLConnectorProvider.java
@@ -0,0 +1,116 @@
+package org.apache.hadoop.hive.metastore.dataconnector.jdbc;
+
+import org.apache.hadoop.hive.metastore.ColumnType;
+import org.apache.hadoop.hive.metastore.api.DataConnector;
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+
+public class PostgreSQLConnectorProvider extends AbstractJDBCConnectorProvider {
+  private static Logger LOG = LoggerFactory.getLogger(MySQLConnectorProvider.class);
+  private static final String DRIVER_CLASS = "org.postgresql.Driver".intern();
+
+  public PostgreSQLConnectorProvider(String dbName, DataConnector dataConn) {
+    super(dbName, dataConn);
+    driverClassName = DRIVER_CLASS;
+  }
+
+  /**
+   * Returns Hive Table objects from the remote database for tables that match a name pattern.
+   * @return List A collection of objects that match the name pattern, null otherwise.
+   * @throws MetaException To indicate any failures with executing this API
+   * @param regex
+   */
+  @Override public List<Table> getTables(String regex) throws MetaException {
+    return null;
+  }
+
+  @Override protected ResultSet fetchTableMetadata(String tableName) throws MetaException {
+    ResultSet rs = null;
+    try {
+      rs = getConnection().getMetaData().getTables(scoped_db, null, null, new String[] { "TABLE" });
+    } catch (SQLException sqle) {
+      LOG.warn("Could not retrieve table names from remote datasource, cause:" + sqle.getMessage());
+      throw new MetaException("Could not retrieve table names from remote datasource, cause:" + sqle.getMessage());
+    }
+    return rs;
+  }
+
+  @Override protected ResultSet fetchTableNames() throws MetaException {
+    return null;
+  }
+
+  private String wrapSize(int size) {
+    return "(" + size + ")";
+  }
+
+  protected String getDataType(String dbDataType, int size) {
+    //TODO: Geomentric, network, bit, array data types of postgresql needs to be supported.
+    switch(dbDataType.toLowerCase())
+    {
+    case "char":
+    case "bpchar":
+      return ColumnType.CHAR_TYPE_NAME + wrapSize(size);
+    case "varchar":
+    case "tinytext":
+      return ColumnType.VARCHAR_TYPE_NAME + wrapSize(size);
+    case "text":
+    case "mediumtext":
+    case "enum":
+    case "set":
+    case "tsvector":
+    case "tsquery":
+    case "uuid":
+    case "json":
+      return ColumnType.STRING_TYPE_NAME;
+    case "blob":
+    case "mediumblob":
+    case "longblob":
+    case "bytea":
+      return ColumnType.BINARY_TYPE_NAME;
+    case "tinyint":
+      return ColumnType.TINYINT_TYPE_NAME;
+    case "smallint":
+    case "smallserial":
+      return ColumnType.SMALLINT_TYPE_NAME;
+    case "mediumint":
+    case "int":
+    case "serial":
+      return ColumnType.INT_TYPE_NAME;
+    case "bigint":
+    case "bigserial":
+    case "int8":
+    case "money":
+      return ColumnType.BIGINT_TYPE_NAME;
+    case "float":
+    case "real":
+      return ColumnType.FLOAT_TYPE_NAME;
+    case "double":
+    case "double precision":
+      return ColumnType.DOUBLE_TYPE_NAME;
+    case "decimal":
+    case "numeric":
+      return ColumnType.DECIMAL_TYPE_NAME;
+    case "date":
+      return ColumnType.DATE_TYPE_NAME;
+    case "datetime":
+      return ColumnType.DATETIME_TYPE_NAME;
+    case "timestamp":
+    case "time":
+    case "interval":
+      return ColumnType.TIMESTAMP_TYPE_NAME;
+    case "timestampz":
+    case "timez":
+      return ColumnType.TIMESTAMPTZ_TYPE_NAME;
+    case "boolean":
+      return ColumnType.BOOLEAN_TYPE_NAME;
+    default:
+      return ColumnType.VOID_TYPE_NAME;
+    }
+  }
+}

[hive] 10/38: HIVE-24396: getTable/getTables API not expected to throw NoSuchObjectException

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 1523cd47d0c81d5e2bb9f0b88d96efd847a67751
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Thu Nov 19 00:00:02 2020 -0500

    HIVE-24396: getTable/getTables API not expected to throw NoSuchObjectException
---
 .../apache/hadoop/hive/metastore/HiveMetaStoreClient.java   | 10 +++++-----
 .../org/apache/hadoop/hive/metastore/HiveMetaStore.java     | 13 ++++++-------
 .../hive/metastore/client/builder/DatabaseBuilder.java      | 10 ++++++++++
 .../apache/hadoop/hive/metastore/cache/TestCachedStore.java |  1 +
 4 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
index 8700bed..9dbaacc 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
@@ -1097,7 +1097,7 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
   /**
    * Create a new Database
    *
-   * @param connector
+   * @param db
    * @throws AlreadyExistsException
    * @throws InvalidObjectException
    * @throws MetaException
@@ -1105,12 +1105,12 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
    * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#create_database(Database)
    */
   @Override
-  public void createDatabase(Database connector)
+  public void createDatabase(Database db)
       throws AlreadyExistsException, InvalidObjectException, MetaException, TException {
-    if (!connector.isSetCatalogName()) {
-      connector.setCatalogName(getDefaultCatalog(conf));
+    if (!db.isSetCatalogName()) {
+      db.setCatalogName(getDefaultCatalog(conf));
     }
-    client.create_database(connector);
+    client.create_database(db);
   }
 
   /**
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
index ec0fa00..696b89d 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
@@ -3733,9 +3733,7 @@ public class HiveMetaStore extends ThriftHiveMetastore {
             return DataConnectorProviderFactory.getDataConnectorProvider(db).getTable(name);
           }
         }
-      } catch (NoSuchObjectException notExists) {
-        throw new MetaException("Database could not be found:" + dbname);
-      }
+      } catch (Exception e) { /* appears exception is not thrown currently if db doesnt exist */ }
 
       try {
         t = getMS().getTable(catName, dbname, name, writeIdList);
@@ -6003,9 +6001,7 @@ public class HiveMetaStore extends ThriftHiveMetastore {
             return DataConnectorProviderFactory.getDataConnectorProvider(db).getTableNames();
           }
         }
-      } catch (NoSuchObjectException notExists) {
-        throw new MetaException("Database could not be found:" + dbname);
-      }
+      } catch (Exception e) { /* appears we return empty set instead of throwing an exception */ }
 
       try {
         ret = getMS().getTables(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], pattern);
@@ -6065,10 +6061,13 @@ public class HiveMetaStore extends ThriftHiveMetastore {
       try {
         db = get_database_core(catName, dbname);
         if (db != null) {
-          if(db.getType().equals(DatabaseType.REMOTE)) {
+          if (db.getType().equals(DatabaseType.REMOTE)) {
             return DataConnectorProviderFactory.getDataConnectorProvider(db).getTableNames();
           }
         }
+      } catch (Exception e) { /* ignore */ }
+
+      try {
         ret = getMS().getTables(catName, dbname, pattern, TableType.valueOf(tableType), -1);
       } catch (MetaException e) {
         ex = e;
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/client/builder/DatabaseBuilder.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/client/builder/DatabaseBuilder.java
index 21e3a9f..806bf0f 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/client/builder/DatabaseBuilder.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/client/builder/DatabaseBuilder.java
@@ -22,6 +22,7 @@ import org.apache.hadoop.hive.metastore.IMetaStoreClient;
 import org.apache.hadoop.hive.metastore.Warehouse;
 import org.apache.hadoop.hive.metastore.api.Catalog;
 import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.api.DatabaseType;
 import org.apache.hadoop.hive.metastore.api.MetaException;
 import org.apache.hadoop.hive.metastore.api.PrincipalType;
 import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils;
@@ -42,6 +43,7 @@ public class DatabaseBuilder {
   private String ownerName;
   private PrincipalType ownerType;
   private int createTime;
+  private DatabaseType type;
 
   public DatabaseBuilder() {
   }
@@ -101,6 +103,12 @@ public class DatabaseBuilder {
     return this;
   }
 
+  public DatabaseBuilder setType(DatabaseType type) {
+    if (type != null)
+      this.type = type;
+    return this;
+  }
+
   public Database build(Configuration conf) throws MetaException {
     if (name == null) throw new MetaException("You must name the database");
     if (catalogName == null) catalogName = MetaStoreUtils.getDefaultCatalog(conf);
@@ -114,6 +122,8 @@ public class DatabaseBuilder {
       db.setOwnerName(ownerName);
       if (ownerType == null) ownerType = PrincipalType.USER;
       db.setOwnerType(ownerType);
+      if (type == null) type = DatabaseType.NATIVE;
+      db.setType(type);
       return db;
     } catch (IOException e) {
       throw MetaStoreUtils.newMetaException(e);
diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/cache/TestCachedStore.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/cache/TestCachedStore.java
index d285f3d..c71c459 100644
--- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/cache/TestCachedStore.java
+++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/cache/TestCachedStore.java
@@ -2053,6 +2053,7 @@ import static org.apache.hadoop.hive.metastore.Warehouse.DEFAULT_CATALOG_NAME;
     db.setOwnerType(PrincipalType.USER);
     db.setCatalogName(DEFAULT_CATALOG_NAME);
     db.setCreateTime((int) (System.currentTimeMillis() / 1000));
+    db.setType(DatabaseType.NATIVE);
     return db;
   }
 

[hive] 22/38: HIVE-24396: Build failure due to duplicate db definitions

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 5a2236eb7822a11d37b80f9a1d1c3debcc91c9a3
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Mon Nov 30 09:40:58 2020 -0500

    HIVE-24396: Build failure due to duplicate db definitions
---
 .../src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp | 7320 +++++++-------------
 .../gen/thrift/gen-cpp/hive_metastore_types.cpp    | 4253 ++++--------
 .../hive/metastore/api/AlterPartitionsRequest.java |   70 +-
 .../hive/metastore/api/AlterTableRequest.java      |   64 +-
 .../hive/metastore/api/CreateDatabaseRequest.java  |   44 +-
 .../hive/metastore/api/CreateTableRequest.java     |  484 +-
 .../hive/metastore/api/ExtendedTableInfo.java      |  128 +-
 .../hive/metastore/api/FindSchemasByColsResp.java  |   70 +-
 .../hive/metastore/api/GetDatabaseRequest.java     |   64 +-
 .../hive/metastore/api/GetProjectionsSpec.java     |   64 +-
 .../hadoop/hive/metastore/api/GetTableRequest.java |   64 +-
 .../hive/metastore/api/GetTablesExtRequest.java    |   64 +-
 .../hive/metastore/api/GetTablesRequest.java       |  128 +-
 .../hadoop/hive/metastore/api/GetTablesResult.java |   70 +-
 .../hive/metastore/api/RenamePartitionRequest.java |   64 +-
 .../hadoop/hive/metastore/api/SchemaVersion.java   |   70 +-
 .../hive/metastore/api/ThriftHiveMetastore.java    |  130 +-
 .../hive/metastore/api/WMFullResourcePlan.java     |  280 +-
 .../api/WMGetAllResourcePlanResponse.java          |   70 +-
 .../api/WMGetTriggersForResourePlanResponse.java   |   70 +-
 .../api/WMValidateResourcePlanResponse.java        |  128 +-
 .../gen-php/metastore/AlterPartitionsRequest.php   |   36 +-
 .../thrift/gen-php/metastore/AlterTableRequest.php |   33 +-
 .../gen-php/metastore/CreateDatabaseRequest.php    |   26 +-
 .../gen-php/metastore/CreateTableRequest.php       |  249 +-
 .../thrift/gen-php/metastore/ExtendedTableInfo.php |   66 +-
 .../gen-php/metastore/FindSchemasByColsResp.php    |   36 +-
 .../gen-php/metastore/GetDatabaseRequest.php       |   33 +-
 .../gen-php/metastore/GetProjectionsSpec.php       |   33 +-
 .../thrift/gen-php/metastore/GetTableRequest.php   |   33 +-
 .../gen-php/metastore/GetTablesExtRequest.php      |   33 +-
 .../thrift/gen-php/metastore/GetTablesRequest.php  |   66 +-
 .../thrift/gen-php/metastore/GetTablesResult.php   |   36 +-
 .../gen-php/metastore/RenamePartitionRequest.php   |   33 +-
 .../gen/thrift/gen-php/metastore/SchemaVersion.php |   36 +-
 ...ThriftHiveMetastore_get_all_packages_result.php |   18 +-
 .../gen-php/metastore/WMFullResourcePlan.php       |  144 +-
 .../metastore/WMGetAllResourcePlanResponse.php     |   36 +-
 .../WMGetTriggersForResourePlanResponse.php        |   36 +-
 .../metastore/WMValidateResourcePlanResponse.php   |   66 +-
 .../gen-py/hive_metastore/ThriftHiveMetastore.py   |   12 +-
 .../src/gen/thrift/gen-py/hive_metastore/ttypes.py |  856 +--
 .../apache/hadoop/hive/metastore/HMSHandler.java   |  446 +-
 .../org/apache/hadoop/hive/metastore/RawStore.java |    1 +
 44 files changed, 5160 insertions(+), 10903 deletions(-)

diff --git a/standalone-metastore/metastore-common/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp b/standalone-metastore/metastore-common/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp
index 4cd965e..2b67a2a 100644
--- a/standalone-metastore/metastore-common/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp
+++ b/standalone-metastore/metastore-common/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp
@@ -2561,25 +2561,14 @@ uint32_t ThriftHiveMetastore_get_databases_result::read(::apache::thrift::protoc
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size1651;
-            ::apache::thrift::protocol::TType _etype1654;
-            xfer += iprot->readListBegin(_etype1654, _size1651);
-            this->success.resize(_size1651);
-            uint32_t _i1655;
-            for (_i1655 = 0; _i1655 < _size1651; ++_i1655)
+            uint32_t _size1678;
+            ::apache::thrift::protocol::TType _etype1681;
+            xfer += iprot->readListBegin(_etype1681, _size1678);
+            this->success.resize(_size1678);
+            uint32_t _i1682;
+            for (_i1682 = 0; _i1682 < _size1678; ++_i1682)
             {
-              xfer += iprot->readString(this->success[_i1655]);
-=======
-            uint32_t _size1668;
-            ::apache::thrift::protocol::TType _etype1671;
-            xfer += iprot->readListBegin(_etype1671, _size1668);
-            this->success.resize(_size1668);
-            uint32_t _i1672;
-            for (_i1672 = 0; _i1672 < _size1668; ++_i1672)
-            {
-              xfer += iprot->readString(this->success[_i1672]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->success[_i1682]);
             }
             xfer += iprot->readListEnd();
           }
@@ -2618,17 +2607,10 @@ uint32_t ThriftHiveMetastore_get_databases_result::write(::apache::thrift::proto
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter1656;
-      for (_iter1656 = this->success.begin(); _iter1656 != this->success.end(); ++_iter1656)
-      {
-        xfer += oprot->writeString((*_iter1656));
-=======
-      std::vector<std::string> ::const_iterator _iter1673;
-      for (_iter1673 = this->success.begin(); _iter1673 != this->success.end(); ++_iter1673)
+      std::vector<std::string> ::const_iterator _iter1683;
+      for (_iter1683 = this->success.begin(); _iter1683 != this->success.end(); ++_iter1683)
       {
-        xfer += oprot->writeString((*_iter1673));
->>>>>>> External metastore: clean after rebase
+        xfer += oprot->writeString((*_iter1683));
       }
       xfer += oprot->writeListEnd();
     }
@@ -2673,25 +2655,14 @@ uint32_t ThriftHiveMetastore_get_databases_presult::read(::apache::thrift::proto
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size1657;
-            ::apache::thrift::protocol::TType _etype1660;
-            xfer += iprot->readListBegin(_etype1660, _size1657);
-            (*(this->success)).resize(_size1657);
-            uint32_t _i1661;
-            for (_i1661 = 0; _i1661 < _size1657; ++_i1661)
-            {
-              xfer += iprot->readString((*(this->success))[_i1661]);
-=======
-            uint32_t _size1674;
-            ::apache::thrift::protocol::TType _etype1677;
-            xfer += iprot->readListBegin(_etype1677, _size1674);
-            (*(this->success)).resize(_size1674);
-            uint32_t _i1678;
-            for (_i1678 = 0; _i1678 < _size1674; ++_i1678)
+            uint32_t _size1684;
+            ::apache::thrift::protocol::TType _etype1687;
+            xfer += iprot->readListBegin(_etype1687, _size1684);
+            (*(this->success)).resize(_size1684);
+            uint32_t _i1688;
+            for (_i1688 = 0; _i1688 < _size1684; ++_i1688)
             {
-              xfer += iprot->readString((*(this->success))[_i1678]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString((*(this->success))[_i1688]);
             }
             xfer += iprot->readListEnd();
           }
@@ -2808,25 +2779,14 @@ uint32_t ThriftHiveMetastore_get_all_databases_result::read(::apache::thrift::pr
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size1662;
-            ::apache::thrift::protocol::TType _etype1665;
-            xfer += iprot->readListBegin(_etype1665, _size1662);
-            this->success.resize(_size1662);
-            uint32_t _i1666;
-            for (_i1666 = 0; _i1666 < _size1662; ++_i1666)
+            uint32_t _size1689;
+            ::apache::thrift::protocol::TType _etype1692;
+            xfer += iprot->readListBegin(_etype1692, _size1689);
+            this->success.resize(_size1689);
+            uint32_t _i1693;
+            for (_i1693 = 0; _i1693 < _size1689; ++_i1693)
             {
-              xfer += iprot->readString(this->success[_i1666]);
-=======
-            uint32_t _size1679;
-            ::apache::thrift::protocol::TType _etype1682;
-            xfer += iprot->readListBegin(_etype1682, _size1679);
-            this->success.resize(_size1679);
-            uint32_t _i1683;
-            for (_i1683 = 0; _i1683 < _size1679; ++_i1683)
-            {
-              xfer += iprot->readString(this->success[_i1683]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->success[_i1693]);
             }
             xfer += iprot->readListEnd();
           }
@@ -2865,17 +2825,10 @@ uint32_t ThriftHiveMetastore_get_all_databases_result::write(::apache::thrift::p
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter1667;
-      for (_iter1667 = this->success.begin(); _iter1667 != this->success.end(); ++_iter1667)
-      {
-        xfer += oprot->writeString((*_iter1667));
-=======
-      std::vector<std::string> ::const_iterator _iter1684;
-      for (_iter1684 = this->success.begin(); _iter1684 != this->success.end(); ++_iter1684)
+      std::vector<std::string> ::const_iterator _iter1694;
+      for (_iter1694 = this->success.begin(); _iter1694 != this->success.end(); ++_iter1694)
       {
-        xfer += oprot->writeString((*_iter1684));
->>>>>>> External metastore: clean after rebase
+        xfer += oprot->writeString((*_iter1694));
       }
       xfer += oprot->writeListEnd();
     }
@@ -2920,25 +2873,14 @@ uint32_t ThriftHiveMetastore_get_all_databases_presult::read(::apache::thrift::p
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size1668;
-            ::apache::thrift::protocol::TType _etype1671;
-            xfer += iprot->readListBegin(_etype1671, _size1668);
-            (*(this->success)).resize(_size1668);
-            uint32_t _i1672;
-            for (_i1672 = 0; _i1672 < _size1668; ++_i1672)
+            uint32_t _size1695;
+            ::apache::thrift::protocol::TType _etype1698;
+            xfer += iprot->readListBegin(_etype1698, _size1695);
+            (*(this->success)).resize(_size1695);
+            uint32_t _i1699;
+            for (_i1699 = 0; _i1699 < _size1695; ++_i1699)
             {
-              xfer += iprot->readString((*(this->success))[_i1672]);
-=======
-            uint32_t _size1685;
-            ::apache::thrift::protocol::TType _etype1688;
-            xfer += iprot->readListBegin(_etype1688, _size1685);
-            (*(this->success)).resize(_size1685);
-            uint32_t _i1689;
-            for (_i1689 = 0; _i1689 < _size1685; ++_i1689)
-            {
-              xfer += iprot->readString((*(this->success))[_i1689]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString((*(this->success))[_i1699]);
             }
             xfer += iprot->readListEnd();
           }
@@ -3991,28 +3933,14 @@ uint32_t ThriftHiveMetastore_get_dataconnectors_result::read(::apache::thrift::p
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size1673;
-            ::apache::thrift::protocol::TType _ktype1674;
-            ::apache::thrift::protocol::TType _vtype1675;
-            xfer += iprot->readMapBegin(_ktype1674, _vtype1675, _size1673);
-            uint32_t _i1677;
-            for (_i1677 = 0; _i1677 < _size1673; ++_i1677)
-            {
-              std::string _key1678;
-              xfer += iprot->readString(_key1678);
-              Type& _val1679 = this->success[_key1678];
-              xfer += _val1679.read(iprot);
-=======
-            uint32_t _size1690;
-            ::apache::thrift::protocol::TType _etype1693;
-            xfer += iprot->readListBegin(_etype1693, _size1690);
-            this->success.resize(_size1690);
-            uint32_t _i1694;
-            for (_i1694 = 0; _i1694 < _size1690; ++_i1694)
+            uint32_t _size1700;
+            ::apache::thrift::protocol::TType _etype1703;
+            xfer += iprot->readListBegin(_etype1703, _size1700);
+            this->success.resize(_size1700);
+            uint32_t _i1704;
+            for (_i1704 = 0; _i1704 < _size1700; ++_i1704)
             {
-              xfer += iprot->readString(this->success[_i1694]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->success[_i1704]);
             }
             xfer += iprot->readListEnd();
           }
@@ -4050,20 +3978,11 @@ uint32_t ThriftHiveMetastore_get_dataconnectors_result::write(::apache::thrift::
   if (this->__isset.success) {
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
-<<<<<<< HEAD
-      xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-      std::map<std::string, Type> ::const_iterator _iter1680;
-      for (_iter1680 = this->success.begin(); _iter1680 != this->success.end(); ++_iter1680)
-      {
-        xfer += oprot->writeString(_iter1680->first);
-        xfer += _iter1680->second.write(oprot);
-=======
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-      std::vector<std::string> ::const_iterator _iter1695;
-      for (_iter1695 = this->success.begin(); _iter1695 != this->success.end(); ++_iter1695)
+      std::vector<std::string> ::const_iterator _iter1705;
+      for (_iter1705 = this->success.begin(); _iter1705 != this->success.end(); ++_iter1705)
       {
-        xfer += oprot->writeString((*_iter1695));
->>>>>>> External metastore: clean after rebase
+        xfer += oprot->writeString((*_iter1705));
       }
       xfer += oprot->writeListEnd();
     }
@@ -4108,28 +4027,14 @@ uint32_t ThriftHiveMetastore_get_dataconnectors_presult::read(::apache::thrift::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size1681;
-            ::apache::thrift::protocol::TType _ktype1682;
-            ::apache::thrift::protocol::TType _vtype1683;
-            xfer += iprot->readMapBegin(_ktype1682, _vtype1683, _size1681);
-            uint32_t _i1685;
-            for (_i1685 = 0; _i1685 < _size1681; ++_i1685)
+            uint32_t _size1706;
+            ::apache::thrift::protocol::TType _etype1709;
+            xfer += iprot->readListBegin(_etype1709, _size1706);
+            (*(this->success)).resize(_size1706);
+            uint32_t _i1710;
+            for (_i1710 = 0; _i1710 < _size1706; ++_i1710)
             {
-              std::string _key1686;
-              xfer += iprot->readString(_key1686);
-              Type& _val1687 = (*(this->success))[_key1686];
-              xfer += _val1687.read(iprot);
-=======
-            uint32_t _size1696;
-            ::apache::thrift::protocol::TType _etype1699;
-            xfer += iprot->readListBegin(_etype1699, _size1696);
-            (*(this->success)).resize(_size1696);
-            uint32_t _i1700;
-            for (_i1700 = 0; _i1700 < _size1696; ++_i1700)
-            {
-              xfer += iprot->readString((*(this->success))[_i1700]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString((*(this->success))[_i1710]);
             }
             xfer += iprot->readListEnd();
           }
@@ -4279,29 +4184,6 @@ uint32_t ThriftHiveMetastore_alter_dataconnector_result::read(::apache::thrift::
     }
     switch (fid)
     {
-<<<<<<< HEAD
-      case 0:
-        if (ftype == ::apache::thrift::protocol::T_LIST) {
-          {
-            this->success.clear();
-            uint32_t _size1688;
-            ::apache::thrift::protocol::TType _etype1691;
-            xfer += iprot->readListBegin(_etype1691, _size1688);
-            this->success.resize(_size1688);
-            uint32_t _i1692;
-            for (_i1692 = 0; _i1692 < _size1688; ++_i1692)
-            {
-              xfer += this->success[_i1692].read(iprot);
-            }
-            xfer += iprot->readListEnd();
-          }
-          this->__isset.success = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-=======
->>>>>>> External metastore: clean after rebase
       case 1:
         if (ftype == ::apache::thrift::protocol::T_STRUCT) {
           xfer += this->o1.read(iprot);
@@ -4336,23 +4218,7 @@ uint32_t ThriftHiveMetastore_alter_dataconnector_result::write(::apache::thrift:
 
   xfer += oprot->writeStructBegin("ThriftHiveMetastore_alter_dataconnector_result");
 
-<<<<<<< HEAD
-  if (this->__isset.success) {
-    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
-    {
-      xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-      std::vector<FieldSchema> ::const_iterator _iter1693;
-      for (_iter1693 = this->success.begin(); _iter1693 != this->success.end(); ++_iter1693)
-      {
-        xfer += (*_iter1693).write(oprot);
-      }
-      xfer += oprot->writeListEnd();
-    }
-    xfer += oprot->writeFieldEnd();
-  } else if (this->__isset.o1) {
-=======
   if (this->__isset.o1) {
->>>>>>> External metastore: clean after rebase
     xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
     xfer += this->o1.write(oprot);
     xfer += oprot->writeFieldEnd();
@@ -4392,29 +4258,6 @@ uint32_t ThriftHiveMetastore_alter_dataconnector_presult::read(::apache::thrift:
     }
     switch (fid)
     {
-<<<<<<< HEAD
-      case 0:
-        if (ftype == ::apache::thrift::protocol::T_LIST) {
-          {
-            (*(this->success)).clear();
-            uint32_t _size1694;
-            ::apache::thrift::protocol::TType _etype1697;
-            xfer += iprot->readListBegin(_etype1697, _size1694);
-            (*(this->success)).resize(_size1694);
-            uint32_t _i1698;
-            for (_i1698 = 0; _i1698 < _size1694; ++_i1698)
-            {
-              xfer += (*(this->success))[_i1698].read(iprot);
-            }
-            xfer += iprot->readListEnd();
-          }
-          this->__isset.success = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-=======
->>>>>>> External metastore: clean after rebase
       case 1:
         if (ftype == ::apache::thrift::protocol::T_STRUCT) {
           xfer += this->o1.read(iprot);
@@ -4549,25 +4392,8 @@ uint32_t ThriftHiveMetastore_get_type_result::read(::apache::thrift::protocol::T
     switch (fid)
     {
       case 0:
-<<<<<<< HEAD
-        if (ftype == ::apache::thrift::protocol::T_LIST) {
-          {
-            this->success.clear();
-            uint32_t _size1699;
-            ::apache::thrift::protocol::TType _etype1702;
-            xfer += iprot->readListBegin(_etype1702, _size1699);
-            this->success.resize(_size1699);
-            uint32_t _i1703;
-            for (_i1703 = 0; _i1703 < _size1699; ++_i1703)
-            {
-              xfer += this->success[_i1703].read(iprot);
-            }
-            xfer += iprot->readListEnd();
-          }
-=======
         if (ftype == ::apache::thrift::protocol::T_STRUCT) {
           xfer += this->success.read(iprot);
->>>>>>> External metastore: clean after rebase
           this->__isset.success = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -4608,21 +4434,8 @@ uint32_t ThriftHiveMetastore_get_type_result::write(::apache::thrift::protocol::
   xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_type_result");
 
   if (this->__isset.success) {
-<<<<<<< HEAD
-    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
-    {
-      xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-      std::vector<FieldSchema> ::const_iterator _iter1704;
-      for (_iter1704 = this->success.begin(); _iter1704 != this->success.end(); ++_iter1704)
-      {
-        xfer += (*_iter1704).write(oprot);
-      }
-      xfer += oprot->writeListEnd();
-    }
-=======
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_STRUCT, 0);
     xfer += this->success.write(oprot);
->>>>>>> External metastore: clean after rebase
     xfer += oprot->writeFieldEnd();
   } else if (this->__isset.o1) {
     xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
@@ -4665,25 +4478,8 @@ uint32_t ThriftHiveMetastore_get_type_presult::read(::apache::thrift::protocol::
     switch (fid)
     {
       case 0:
-<<<<<<< HEAD
-        if (ftype == ::apache::thrift::protocol::T_LIST) {
-          {
-            (*(this->success)).clear();
-            uint32_t _size1705;
-            ::apache::thrift::protocol::TType _etype1708;
-            xfer += iprot->readListBegin(_etype1708, _size1705);
-            (*(this->success)).resize(_size1705);
-            uint32_t _i1709;
-            for (_i1709 = 0; _i1709 < _size1705; ++_i1709)
-            {
-              xfer += (*(this->success))[_i1709].read(iprot);
-            }
-            xfer += iprot->readListEnd();
-          }
-=======
         if (ftype == ::apache::thrift::protocol::T_STRUCT) {
           xfer += (*(this->success)).read(iprot);
->>>>>>> External metastore: clean after rebase
           this->__isset.success = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -5070,25 +4866,8 @@ uint32_t ThriftHiveMetastore_drop_type_result::read(::apache::thrift::protocol::
     switch (fid)
     {
       case 0:
-<<<<<<< HEAD
-        if (ftype == ::apache::thrift::protocol::T_LIST) {
-          {
-            this->success.clear();
-            uint32_t _size1710;
-            ::apache::thrift::protocol::TType _etype1713;
-            xfer += iprot->readListBegin(_etype1713, _size1710);
-            this->success.resize(_size1710);
-            uint32_t _i1714;
-            for (_i1714 = 0; _i1714 < _size1710; ++_i1714)
-            {
-              xfer += this->success[_i1714].read(iprot);
-            }
-            xfer += iprot->readListEnd();
-          }
-=======
         if (ftype == ::apache::thrift::protocol::T_BOOL) {
           xfer += iprot->readBool(this->success);
->>>>>>> External metastore: clean after rebase
           this->__isset.success = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -5129,21 +4908,8 @@ uint32_t ThriftHiveMetastore_drop_type_result::write(::apache::thrift::protocol:
   xfer += oprot->writeStructBegin("ThriftHiveMetastore_drop_type_result");
 
   if (this->__isset.success) {
-<<<<<<< HEAD
-    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
-    {
-      xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-      std::vector<FieldSchema> ::const_iterator _iter1715;
-      for (_iter1715 = this->success.begin(); _iter1715 != this->success.end(); ++_iter1715)
-      {
-        xfer += (*_iter1715).write(oprot);
-      }
-      xfer += oprot->writeListEnd();
-    }
-=======
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_BOOL, 0);
     xfer += oprot->writeBool(this->success);
->>>>>>> External metastore: clean after rebase
     xfer += oprot->writeFieldEnd();
   } else if (this->__isset.o1) {
     xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
@@ -5186,25 +4952,8 @@ uint32_t ThriftHiveMetastore_drop_type_presult::read(::apache::thrift::protocol:
     switch (fid)
     {
       case 0:
-<<<<<<< HEAD
-        if (ftype == ::apache::thrift::protocol::T_LIST) {
-          {
-            (*(this->success)).clear();
-            uint32_t _size1716;
-            ::apache::thrift::protocol::TType _etype1719;
-            xfer += iprot->readListBegin(_etype1719, _size1716);
-            (*(this->success)).resize(_size1716);
-            uint32_t _i1720;
-            for (_i1720 = 0; _i1720 < _size1716; ++_i1720)
-            {
-              xfer += (*(this->success))[_i1720].read(iprot);
-            }
-            xfer += iprot->readListEnd();
-          }
-=======
         if (ftype == ::apache::thrift::protocol::T_BOOL) {
           xfer += iprot->readBool((*(this->success)));
->>>>>>> External metastore: clean after rebase
           this->__isset.success = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -5347,28 +5096,17 @@ uint32_t ThriftHiveMetastore_get_type_all_result::read(::apache::thrift::protoco
         if (ftype == ::apache::thrift::protocol::T_MAP) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size1721;
-            ::apache::thrift::protocol::TType _etype1724;
-            xfer += iprot->readListBegin(_etype1724, _size1721);
-            this->success.resize(_size1721);
-            uint32_t _i1725;
-            for (_i1725 = 0; _i1725 < _size1721; ++_i1725)
-            {
-              xfer += this->success[_i1725].read(iprot);
-=======
-            uint32_t _size1701;
-            ::apache::thrift::protocol::TType _ktype1702;
-            ::apache::thrift::protocol::TType _vtype1703;
-            xfer += iprot->readMapBegin(_ktype1702, _vtype1703, _size1701);
-            uint32_t _i1705;
-            for (_i1705 = 0; _i1705 < _size1701; ++_i1705)
+            uint32_t _size1711;
+            ::apache::thrift::protocol::TType _ktype1712;
+            ::apache::thrift::protocol::TType _vtype1713;
+            xfer += iprot->readMapBegin(_ktype1712, _vtype1713, _size1711);
+            uint32_t _i1715;
+            for (_i1715 = 0; _i1715 < _size1711; ++_i1715)
             {
-              std::string _key1706;
-              xfer += iprot->readString(_key1706);
-              Type& _val1707 = this->success[_key1706];
-              xfer += _val1707.read(iprot);
->>>>>>> External metastore: clean after rebase
+              std::string _key1716;
+              xfer += iprot->readString(_key1716);
+              Type& _val1717 = this->success[_key1716];
+              xfer += _val1717.read(iprot);
             }
             xfer += iprot->readMapEnd();
           }
@@ -5406,20 +5144,12 @@ uint32_t ThriftHiveMetastore_get_type_all_result::write(::apache::thrift::protoc
   if (this->__isset.success) {
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_MAP, 0);
     {
-<<<<<<< HEAD
-      xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-      std::vector<FieldSchema> ::const_iterator _iter1726;
-      for (_iter1726 = this->success.begin(); _iter1726 != this->success.end(); ++_iter1726)
-      {
-        xfer += (*_iter1726).write(oprot);
-=======
       xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-      std::map<std::string, Type> ::const_iterator _iter1708;
-      for (_iter1708 = this->success.begin(); _iter1708 != this->success.end(); ++_iter1708)
+      std::map<std::string, Type> ::const_iterator _iter1718;
+      for (_iter1718 = this->success.begin(); _iter1718 != this->success.end(); ++_iter1718)
       {
-        xfer += oprot->writeString(_iter1708->first);
-        xfer += _iter1708->second.write(oprot);
->>>>>>> External metastore: clean after rebase
+        xfer += oprot->writeString(_iter1718->first);
+        xfer += _iter1718->second.write(oprot);
       }
       xfer += oprot->writeMapEnd();
     }
@@ -5464,28 +5194,17 @@ uint32_t ThriftHiveMetastore_get_type_all_presult::read(::apache::thrift::protoc
         if (ftype == ::apache::thrift::protocol::T_MAP) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size1727;
-            ::apache::thrift::protocol::TType _etype1730;
-            xfer += iprot->readListBegin(_etype1730, _size1727);
-            (*(this->success)).resize(_size1727);
-            uint32_t _i1731;
-            for (_i1731 = 0; _i1731 < _size1727; ++_i1731)
+            uint32_t _size1719;
+            ::apache::thrift::protocol::TType _ktype1720;
+            ::apache::thrift::protocol::TType _vtype1721;
+            xfer += iprot->readMapBegin(_ktype1720, _vtype1721, _size1719);
+            uint32_t _i1723;
+            for (_i1723 = 0; _i1723 < _size1719; ++_i1723)
             {
-              xfer += (*(this->success))[_i1731].read(iprot);
-=======
-            uint32_t _size1709;
-            ::apache::thrift::protocol::TType _ktype1710;
-            ::apache::thrift::protocol::TType _vtype1711;
-            xfer += iprot->readMapBegin(_ktype1710, _vtype1711, _size1709);
-            uint32_t _i1713;
-            for (_i1713 = 0; _i1713 < _size1709; ++_i1713)
-            {
-              std::string _key1714;
-              xfer += iprot->readString(_key1714);
-              Type& _val1715 = (*(this->success))[_key1714];
-              xfer += _val1715.read(iprot);
->>>>>>> External metastore: clean after rebase
+              std::string _key1724;
+              xfer += iprot->readString(_key1724);
+              Type& _val1725 = (*(this->success))[_key1724];
+              xfer += _val1725.read(iprot);
             }
             xfer += iprot->readMapEnd();
           }
@@ -5639,14 +5358,14 @@ uint32_t ThriftHiveMetastore_get_fields_result::read(::apache::thrift::protocol:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-            uint32_t _size1716;
-            ::apache::thrift::protocol::TType _etype1719;
-            xfer += iprot->readListBegin(_etype1719, _size1716);
-            this->success.resize(_size1716);
-            uint32_t _i1720;
-            for (_i1720 = 0; _i1720 < _size1716; ++_i1720)
+            uint32_t _size1726;
+            ::apache::thrift::protocol::TType _etype1729;
+            xfer += iprot->readListBegin(_etype1729, _size1726);
+            this->success.resize(_size1726);
+            uint32_t _i1730;
+            for (_i1730 = 0; _i1730 < _size1726; ++_i1730)
             {
-              xfer += this->success[_i1720].read(iprot);
+              xfer += this->success[_i1730].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -5701,10 +5420,10 @@ uint32_t ThriftHiveMetastore_get_fields_result::write(::apache::thrift::protocol
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-      std::vector<FieldSchema> ::const_iterator _iter1721;
-      for (_iter1721 = this->success.begin(); _iter1721 != this->success.end(); ++_iter1721)
+      std::vector<FieldSchema> ::const_iterator _iter1731;
+      for (_iter1731 = this->success.begin(); _iter1731 != this->success.end(); ++_iter1731)
       {
-        xfer += (*_iter1721).write(oprot);
+        xfer += (*_iter1731).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -5757,14 +5476,14 @@ uint32_t ThriftHiveMetastore_get_fields_presult::read(::apache::thrift::protocol
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-            uint32_t _size1722;
-            ::apache::thrift::protocol::TType _etype1725;
-            xfer += iprot->readListBegin(_etype1725, _size1722);
-            (*(this->success)).resize(_size1722);
-            uint32_t _i1726;
-            for (_i1726 = 0; _i1726 < _size1722; ++_i1726)
+            uint32_t _size1732;
+            ::apache::thrift::protocol::TType _etype1735;
+            xfer += iprot->readListBegin(_etype1735, _size1732);
+            (*(this->success)).resize(_size1732);
+            uint32_t _i1736;
+            for (_i1736 = 0; _i1736 < _size1732; ++_i1736)
             {
-              xfer += (*(this->success))[_i1726].read(iprot);
+              xfer += (*(this->success))[_i1736].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -5950,14 +5669,14 @@ uint32_t ThriftHiveMetastore_get_fields_with_environment_context_result::read(::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-            uint32_t _size1727;
-            ::apache::thrift::protocol::TType _etype1730;
-            xfer += iprot->readListBegin(_etype1730, _size1727);
-            this->success.resize(_size1727);
-            uint32_t _i1731;
-            for (_i1731 = 0; _i1731 < _size1727; ++_i1731)
+            uint32_t _size1737;
+            ::apache::thrift::protocol::TType _etype1740;
+            xfer += iprot->readListBegin(_etype1740, _size1737);
+            this->success.resize(_size1737);
+            uint32_t _i1741;
+            for (_i1741 = 0; _i1741 < _size1737; ++_i1741)
             {
-              xfer += this->success[_i1731].read(iprot);
+              xfer += this->success[_i1741].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -6012,10 +5731,10 @@ uint32_t ThriftHiveMetastore_get_fields_with_environment_context_result::write(:
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-      std::vector<FieldSchema> ::const_iterator _iter1732;
-      for (_iter1732 = this->success.begin(); _iter1732 != this->success.end(); ++_iter1732)
+      std::vector<FieldSchema> ::const_iterator _iter1742;
+      for (_iter1742 = this->success.begin(); _iter1742 != this->success.end(); ++_iter1742)
       {
-        xfer += (*_iter1732).write(oprot);
+        xfer += (*_iter1742).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -6068,14 +5787,14 @@ uint32_t ThriftHiveMetastore_get_fields_with_environment_context_presult::read(:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-            uint32_t _size1733;
-            ::apache::thrift::protocol::TType _etype1736;
-            xfer += iprot->readListBegin(_etype1736, _size1733);
-            (*(this->success)).resize(_size1733);
-            uint32_t _i1737;
-            for (_i1737 = 0; _i1737 < _size1733; ++_i1737)
+            uint32_t _size1743;
+            ::apache::thrift::protocol::TType _etype1746;
+            xfer += iprot->readListBegin(_etype1746, _size1743);
+            (*(this->success)).resize(_size1743);
+            uint32_t _i1747;
+            for (_i1747 = 0; _i1747 < _size1743; ++_i1747)
             {
-              xfer += (*(this->success))[_i1737].read(iprot);
+              xfer += (*(this->success))[_i1747].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -6492,14 +6211,14 @@ uint32_t ThriftHiveMetastore_get_schema_result::read(::apache::thrift::protocol:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-            uint32_t _size1738;
-            ::apache::thrift::protocol::TType _etype1741;
-            xfer += iprot->readListBegin(_etype1741, _size1738);
-            this->success.resize(_size1738);
-            uint32_t _i1742;
-            for (_i1742 = 0; _i1742 < _size1738; ++_i1742)
+            uint32_t _size1748;
+            ::apache::thrift::protocol::TType _etype1751;
+            xfer += iprot->readListBegin(_etype1751, _size1748);
+            this->success.resize(_size1748);
+            uint32_t _i1752;
+            for (_i1752 = 0; _i1752 < _size1748; ++_i1752)
             {
-              xfer += this->success[_i1742].read(iprot);
+              xfer += this->success[_i1752].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -6554,10 +6273,10 @@ uint32_t ThriftHiveMetastore_get_schema_result::write(::apache::thrift::protocol
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-      std::vector<FieldSchema> ::const_iterator _iter1743;
-      for (_iter1743 = this->success.begin(); _iter1743 != this->success.end(); ++_iter1743)
+      std::vector<FieldSchema> ::const_iterator _iter1753;
+      for (_iter1753 = this->success.begin(); _iter1753 != this->success.end(); ++_iter1753)
       {
-        xfer += (*_iter1743).write(oprot);
+        xfer += (*_iter1753).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -6610,14 +6329,14 @@ uint32_t ThriftHiveMetastore_get_schema_presult::read(::apache::thrift::protocol
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-            uint32_t _size1744;
-            ::apache::thrift::protocol::TType _etype1747;
-            xfer += iprot->readListBegin(_etype1747, _size1744);
-            (*(this->success)).resize(_size1744);
-            uint32_t _i1748;
-            for (_i1748 = 0; _i1748 < _size1744; ++_i1748)
+            uint32_t _size1754;
+            ::apache::thrift::protocol::TType _etype1757;
+            xfer += iprot->readListBegin(_etype1757, _size1754);
+            (*(this->success)).resize(_size1754);
+            uint32_t _i1758;
+            for (_i1758 = 0; _i1758 < _size1754; ++_i1758)
             {
-              xfer += (*(this->success))[_i1748].read(iprot);
+              xfer += (*(this->success))[_i1758].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -6803,14 +6522,14 @@ uint32_t ThriftHiveMetastore_get_schema_with_environment_context_result::read(::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-            uint32_t _size1749;
-            ::apache::thrift::protocol::TType _etype1752;
-            xfer += iprot->readListBegin(_etype1752, _size1749);
-            this->success.resize(_size1749);
-            uint32_t _i1753;
-            for (_i1753 = 0; _i1753 < _size1749; ++_i1753)
+            uint32_t _size1759;
+            ::apache::thrift::protocol::TType _etype1762;
+            xfer += iprot->readListBegin(_etype1762, _size1759);
+            this->success.resize(_size1759);
+            uint32_t _i1763;
+            for (_i1763 = 0; _i1763 < _size1759; ++_i1763)
             {
-              xfer += this->success[_i1753].read(iprot);
+              xfer += this->success[_i1763].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -6865,10 +6584,10 @@ uint32_t ThriftHiveMetastore_get_schema_with_environment_context_result::write(:
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-      std::vector<FieldSchema> ::const_iterator _iter1754;
-      for (_iter1754 = this->success.begin(); _iter1754 != this->success.end(); ++_iter1754)
+      std::vector<FieldSchema> ::const_iterator _iter1764;
+      for (_iter1764 = this->success.begin(); _iter1764 != this->success.end(); ++_iter1764)
       {
-        xfer += (*_iter1754).write(oprot);
+        xfer += (*_iter1764).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -6921,14 +6640,14 @@ uint32_t ThriftHiveMetastore_get_schema_with_environment_context_presult::read(:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-            uint32_t _size1755;
-            ::apache::thrift::protocol::TType _etype1758;
-            xfer += iprot->readListBegin(_etype1758, _size1755);
-            (*(this->success)).resize(_size1755);
-            uint32_t _i1759;
-            for (_i1759 = 0; _i1759 < _size1755; ++_i1759)
+            uint32_t _size1765;
+            ::apache::thrift::protocol::TType _etype1768;
+            xfer += iprot->readListBegin(_etype1768, _size1765);
+            (*(this->success)).resize(_size1765);
+            uint32_t _i1769;
+            for (_i1769 = 0; _i1769 < _size1765; ++_i1769)
             {
-              xfer += (*(this->success))[_i1759].read(iprot);
+              xfer += (*(this->success))[_i1769].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -7768,25 +7487,14 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::read(::apache::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->primaryKeys.clear();
-<<<<<<< HEAD
-            uint32_t _size1732;
-            ::apache::thrift::protocol::TType _etype1735;
-            xfer += iprot->readListBegin(_etype1735, _size1732);
-            this->primaryKeys.resize(_size1732);
-            uint32_t _i1736;
-            for (_i1736 = 0; _i1736 < _size1732; ++_i1736)
-            {
-              xfer += this->primaryKeys[_i1736].read(iprot);
-=======
-            uint32_t _size1760;
-            ::apache::thrift::protocol::TType _etype1763;
-            xfer += iprot->readListBegin(_etype1763, _size1760);
-            this->primaryKeys.resize(_size1760);
-            uint32_t _i1764;
-            for (_i1764 = 0; _i1764 < _size1760; ++_i1764)
+            uint32_t _size1770;
+            ::apache::thrift::protocol::TType _etype1773;
+            xfer += iprot->readListBegin(_etype1773, _size1770);
+            this->primaryKeys.resize(_size1770);
+            uint32_t _i1774;
+            for (_i1774 = 0; _i1774 < _size1770; ++_i1774)
             {
-              xfer += this->primaryKeys[_i1764].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->primaryKeys[_i1774].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -7799,25 +7507,14 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::read(::apache::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->foreignKeys.clear();
-<<<<<<< HEAD
-            uint32_t _size1737;
-            ::apache::thrift::protocol::TType _etype1740;
-            xfer += iprot->readListBegin(_etype1740, _size1737);
-            this->foreignKeys.resize(_size1737);
-            uint32_t _i1741;
-            for (_i1741 = 0; _i1741 < _size1737; ++_i1741)
-            {
-              xfer += this->foreignKeys[_i1741].read(iprot);
-=======
-            uint32_t _size1765;
-            ::apache::thrift::protocol::TType _etype1768;
-            xfer += iprot->readListBegin(_etype1768, _size1765);
-            this->foreignKeys.resize(_size1765);
-            uint32_t _i1769;
-            for (_i1769 = 0; _i1769 < _size1765; ++_i1769)
+            uint32_t _size1775;
+            ::apache::thrift::protocol::TType _etype1778;
+            xfer += iprot->readListBegin(_etype1778, _size1775);
+            this->foreignKeys.resize(_size1775);
+            uint32_t _i1779;
+            for (_i1779 = 0; _i1779 < _size1775; ++_i1779)
             {
-              xfer += this->foreignKeys[_i1769].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->foreignKeys[_i1779].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -7830,25 +7527,14 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::read(::apache::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->uniqueConstraints.clear();
-<<<<<<< HEAD
-            uint32_t _size1742;
-            ::apache::thrift::protocol::TType _etype1745;
-            xfer += iprot->readListBegin(_etype1745, _size1742);
-            this->uniqueConstraints.resize(_size1742);
-            uint32_t _i1746;
-            for (_i1746 = 0; _i1746 < _size1742; ++_i1746)
-            {
-              xfer += this->uniqueConstraints[_i1746].read(iprot);
-=======
-            uint32_t _size1770;
-            ::apache::thrift::protocol::TType _etype1773;
-            xfer += iprot->readListBegin(_etype1773, _size1770);
-            this->uniqueConstraints.resize(_size1770);
-            uint32_t _i1774;
-            for (_i1774 = 0; _i1774 < _size1770; ++_i1774)
+            uint32_t _size1780;
+            ::apache::thrift::protocol::TType _etype1783;
+            xfer += iprot->readListBegin(_etype1783, _size1780);
+            this->uniqueConstraints.resize(_size1780);
+            uint32_t _i1784;
+            for (_i1784 = 0; _i1784 < _size1780; ++_i1784)
             {
-              xfer += this->uniqueConstraints[_i1774].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->uniqueConstraints[_i1784].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -7861,25 +7547,14 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::read(::apache::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->notNullConstraints.clear();
-<<<<<<< HEAD
-            uint32_t _size1747;
-            ::apache::thrift::protocol::TType _etype1750;
-            xfer += iprot->readListBegin(_etype1750, _size1747);
-            this->notNullConstraints.resize(_size1747);
-            uint32_t _i1751;
-            for (_i1751 = 0; _i1751 < _size1747; ++_i1751)
-            {
-              xfer += this->notNullConstraints[_i1751].read(iprot);
-=======
-            uint32_t _size1775;
-            ::apache::thrift::protocol::TType _etype1778;
-            xfer += iprot->readListBegin(_etype1778, _size1775);
-            this->notNullConstraints.resize(_size1775);
-            uint32_t _i1779;
-            for (_i1779 = 0; _i1779 < _size1775; ++_i1779)
+            uint32_t _size1785;
+            ::apache::thrift::protocol::TType _etype1788;
+            xfer += iprot->readListBegin(_etype1788, _size1785);
+            this->notNullConstraints.resize(_size1785);
+            uint32_t _i1789;
+            for (_i1789 = 0; _i1789 < _size1785; ++_i1789)
             {
-              xfer += this->notNullConstraints[_i1779].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->notNullConstraints[_i1789].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -7892,25 +7567,14 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::read(::apache::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->defaultConstraints.clear();
-<<<<<<< HEAD
-            uint32_t _size1752;
-            ::apache::thrift::protocol::TType _etype1755;
-            xfer += iprot->readListBegin(_etype1755, _size1752);
-            this->defaultConstraints.resize(_size1752);
-            uint32_t _i1756;
-            for (_i1756 = 0; _i1756 < _size1752; ++_i1756)
-            {
-              xfer += this->defaultConstraints[_i1756].read(iprot);
-=======
-            uint32_t _size1780;
-            ::apache::thrift::protocol::TType _etype1783;
-            xfer += iprot->readListBegin(_etype1783, _size1780);
-            this->defaultConstraints.resize(_size1780);
-            uint32_t _i1784;
-            for (_i1784 = 0; _i1784 < _size1780; ++_i1784)
+            uint32_t _size1790;
+            ::apache::thrift::protocol::TType _etype1793;
+            xfer += iprot->readListBegin(_etype1793, _size1790);
+            this->defaultConstraints.resize(_size1790);
+            uint32_t _i1794;
+            for (_i1794 = 0; _i1794 < _size1790; ++_i1794)
             {
-              xfer += this->defaultConstraints[_i1784].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->defaultConstraints[_i1794].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -7923,25 +7587,14 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::read(::apache::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->checkConstraints.clear();
-<<<<<<< HEAD
-            uint32_t _size1757;
-            ::apache::thrift::protocol::TType _etype1760;
-            xfer += iprot->readListBegin(_etype1760, _size1757);
-            this->checkConstraints.resize(_size1757);
-            uint32_t _i1761;
-            for (_i1761 = 0; _i1761 < _size1757; ++_i1761)
-            {
-              xfer += this->checkConstraints[_i1761].read(iprot);
-=======
-            uint32_t _size1785;
-            ::apache::thrift::protocol::TType _etype1788;
-            xfer += iprot->readListBegin(_etype1788, _size1785);
-            this->checkConstraints.resize(_size1785);
-            uint32_t _i1789;
-            for (_i1789 = 0; _i1789 < _size1785; ++_i1789)
+            uint32_t _size1795;
+            ::apache::thrift::protocol::TType _etype1798;
+            xfer += iprot->readListBegin(_etype1798, _size1795);
+            this->checkConstraints.resize(_size1795);
+            uint32_t _i1799;
+            for (_i1799 = 0; _i1799 < _size1795; ++_i1799)
             {
-              xfer += this->checkConstraints[_i1789].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->checkConstraints[_i1799].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -7974,17 +7627,10 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::write(::apache:
   xfer += oprot->writeFieldBegin("primaryKeys", ::apache::thrift::protocol::T_LIST, 2);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->primaryKeys.size()));
-<<<<<<< HEAD
-    std::vector<SQLPrimaryKey> ::const_iterator _iter1762;
-    for (_iter1762 = this->primaryKeys.begin(); _iter1762 != this->primaryKeys.end(); ++_iter1762)
-    {
-      xfer += (*_iter1762).write(oprot);
-=======
-    std::vector<SQLPrimaryKey> ::const_iterator _iter1790;
-    for (_iter1790 = this->primaryKeys.begin(); _iter1790 != this->primaryKeys.end(); ++_iter1790)
+    std::vector<SQLPrimaryKey> ::const_iterator _iter1800;
+    for (_iter1800 = this->primaryKeys.begin(); _iter1800 != this->primaryKeys.end(); ++_iter1800)
     {
-      xfer += (*_iter1790).write(oprot);
->>>>>>> External metastore: clean after rebase
+      xfer += (*_iter1800).write(oprot);
     }
     xfer += oprot->writeListEnd();
   }
@@ -7993,17 +7639,10 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::write(::apache:
   xfer += oprot->writeFieldBegin("foreignKeys", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->foreignKeys.size()));
-<<<<<<< HEAD
-    std::vector<SQLForeignKey> ::const_iterator _iter1763;
-    for (_iter1763 = this->foreignKeys.begin(); _iter1763 != this->foreignKeys.end(); ++_iter1763)
-    {
-      xfer += (*_iter1763).write(oprot);
-=======
-    std::vector<SQLForeignKey> ::const_iterator _iter1791;
-    for (_iter1791 = this->foreignKeys.begin(); _iter1791 != this->foreignKeys.end(); ++_iter1791)
+    std::vector<SQLForeignKey> ::const_iterator _iter1801;
+    for (_iter1801 = this->foreignKeys.begin(); _iter1801 != this->foreignKeys.end(); ++_iter1801)
     {
-      xfer += (*_iter1791).write(oprot);
->>>>>>> External metastore: clean after rebase
+      xfer += (*_iter1801).write(oprot);
     }
     xfer += oprot->writeListEnd();
   }
@@ -8012,17 +7651,10 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::write(::apache:
   xfer += oprot->writeFieldBegin("uniqueConstraints", ::apache::thrift::protocol::T_LIST, 4);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->uniqueConstraints.size()));
-<<<<<<< HEAD
-    std::vector<SQLUniqueConstraint> ::const_iterator _iter1764;
-    for (_iter1764 = this->uniqueConstraints.begin(); _iter1764 != this->uniqueConstraints.end(); ++_iter1764)
-    {
-      xfer += (*_iter1764).write(oprot);
-=======
-    std::vector<SQLUniqueConstraint> ::const_iterator _iter1792;
-    for (_iter1792 = this->uniqueConstraints.begin(); _iter1792 != this->uniqueConstraints.end(); ++_iter1792)
+    std::vector<SQLUniqueConstraint> ::const_iterator _iter1802;
+    for (_iter1802 = this->uniqueConstraints.begin(); _iter1802 != this->uniqueConstraints.end(); ++_iter1802)
     {
-      xfer += (*_iter1792).write(oprot);
->>>>>>> External metastore: clean after rebase
+      xfer += (*_iter1802).write(oprot);
     }
     xfer += oprot->writeListEnd();
   }
@@ -8031,17 +7663,10 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::write(::apache:
   xfer += oprot->writeFieldBegin("notNullConstraints", ::apache::thrift::protocol::T_LIST, 5);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->notNullConstraints.size()));
-<<<<<<< HEAD
-    std::vector<SQLNotNullConstraint> ::const_iterator _iter1765;
-    for (_iter1765 = this->notNullConstraints.begin(); _iter1765 != this->notNullConstraints.end(); ++_iter1765)
+    std::vector<SQLNotNullConstraint> ::const_iterator _iter1803;
+    for (_iter1803 = this->notNullConstraints.begin(); _iter1803 != this->notNullConstraints.end(); ++_iter1803)
     {
-      xfer += (*_iter1765).write(oprot);
-=======
-    std::vector<SQLNotNullConstraint> ::const_iterator _iter1793;
-    for (_iter1793 = this->notNullConstraints.begin(); _iter1793 != this->notNullConstraints.end(); ++_iter1793)
-    {
-      xfer += (*_iter1793).write(oprot);
->>>>>>> External metastore: clean after rebase
+      xfer += (*_iter1803).write(oprot);
     }
     xfer += oprot->writeListEnd();
   }
@@ -8050,17 +7675,10 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::write(::apache:
   xfer += oprot->writeFieldBegin("defaultConstraints", ::apache::thrift::protocol::T_LIST, 6);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->defaultConstraints.size()));
-<<<<<<< HEAD
-    std::vector<SQLDefaultConstraint> ::const_iterator _iter1766;
-    for (_iter1766 = this->defaultConstraints.begin(); _iter1766 != this->defaultConstraints.end(); ++_iter1766)
-    {
-      xfer += (*_iter1766).write(oprot);
-=======
-    std::vector<SQLDefaultConstraint> ::const_iterator _iter1794;
-    for (_iter1794 = this->defaultConstraints.begin(); _iter1794 != this->defaultConstraints.end(); ++_iter1794)
+    std::vector<SQLDefaultConstraint> ::const_iterator _iter1804;
+    for (_iter1804 = this->defaultConstraints.begin(); _iter1804 != this->defaultConstraints.end(); ++_iter1804)
     {
-      xfer += (*_iter1794).write(oprot);
->>>>>>> External metastore: clean after rebase
+      xfer += (*_iter1804).write(oprot);
     }
     xfer += oprot->writeListEnd();
   }
@@ -8069,17 +7687,10 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_args::write(::apache:
   xfer += oprot->writeFieldBegin("checkConstraints", ::apache::thrift::protocol::T_LIST, 7);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->checkConstraints.size()));
-<<<<<<< HEAD
-    std::vector<SQLCheckConstraint> ::const_iterator _iter1767;
-    for (_iter1767 = this->checkConstraints.begin(); _iter1767 != this->checkConstraints.end(); ++_iter1767)
+    std::vector<SQLCheckConstraint> ::const_iterator _iter1805;
+    for (_iter1805 = this->checkConstraints.begin(); _iter1805 != this->checkConstraints.end(); ++_iter1805)
     {
-      xfer += (*_iter1767).write(oprot);
-=======
-    std::vector<SQLCheckConstraint> ::const_iterator _iter1795;
-    for (_iter1795 = this->checkConstraints.begin(); _iter1795 != this->checkConstraints.end(); ++_iter1795)
-    {
-      xfer += (*_iter1795).write(oprot);
->>>>>>> External metastore: clean after rebase
+      xfer += (*_iter1805).write(oprot);
     }
     xfer += oprot->writeListEnd();
   }
@@ -8107,17 +7718,10 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_pargs::write(::apache
   xfer += oprot->writeFieldBegin("primaryKeys", ::apache::thrift::protocol::T_LIST, 2);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->primaryKeys)).size()));
-<<<<<<< HEAD
-    std::vector<SQLPrimaryKey> ::const_iterator _iter1768;
-    for (_iter1768 = (*(this->primaryKeys)).begin(); _iter1768 != (*(this->primaryKeys)).end(); ++_iter1768)
-    {
-      xfer += (*_iter1768).write(oprot);
-=======
-    std::vector<SQLPrimaryKey> ::const_iterator _iter1796;
-    for (_iter1796 = (*(this->primaryKeys)).begin(); _iter1796 != (*(this->primaryKeys)).end(); ++_iter1796)
+    std::vector<SQLPrimaryKey> ::const_iterator _iter1806;
+    for (_iter1806 = (*(this->primaryKeys)).begin(); _iter1806 != (*(this->primaryKeys)).end(); ++_iter1806)
     {
-      xfer += (*_iter1796).write(oprot);
->>>>>>> External metastore: clean after rebase
+      xfer += (*_iter1806).write(oprot);
     }
     xfer += oprot->writeListEnd();
   }
@@ -8126,17 +7730,10 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_pargs::write(::apache
   xfer += oprot->writeFieldBegin("foreignKeys", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->foreignKeys)).size()));
-<<<<<<< HEAD
-    std::vector<SQLForeignKey> ::const_iterator _iter1769;
-    for (_iter1769 = (*(this->foreignKeys)).begin(); _iter1769 != (*(this->foreignKeys)).end(); ++_iter1769)
+    std::vector<SQLForeignKey> ::const_iterator _iter1807;
+    for (_iter1807 = (*(this->foreignKeys)).begin(); _iter1807 != (*(this->foreignKeys)).end(); ++_iter1807)
     {
-      xfer += (*_iter1769).write(oprot);
-=======
-    std::vector<SQLForeignKey> ::const_iterator _iter1797;
-    for (_iter1797 = (*(this->foreignKeys)).begin(); _iter1797 != (*(this->foreignKeys)).end(); ++_iter1797)
-    {
-      xfer += (*_iter1797).write(oprot);
->>>>>>> External metastore: clean after rebase
+      xfer += (*_iter1807).write(oprot);
     }
     xfer += oprot->writeListEnd();
   }
@@ -8145,17 +7742,10 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_pargs::write(::apache
   xfer += oprot->writeFieldBegin("uniqueConstraints", ::apache::thrift::protocol::T_LIST, 4);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->uniqueConstraints)).size()));
-<<<<<<< HEAD
-    std::vector<SQLUniqueConstraint> ::const_iterator _iter1770;
-    for (_iter1770 = (*(this->uniqueConstraints)).begin(); _iter1770 != (*(this->uniqueConstraints)).end(); ++_iter1770)
-    {
-      xfer += (*_iter1770).write(oprot);
-=======
-    std::vector<SQLUniqueConstraint> ::const_iterator _iter1798;
-    for (_iter1798 = (*(this->uniqueConstraints)).begin(); _iter1798 != (*(this->uniqueConstraints)).end(); ++_iter1798)
+    std::vector<SQLUniqueConstraint> ::const_iterator _iter1808;
+    for (_iter1808 = (*(this->uniqueConstraints)).begin(); _iter1808 != (*(this->uniqueConstraints)).end(); ++_iter1808)
     {
-      xfer += (*_iter1798).write(oprot);
->>>>>>> External metastore: clean after rebase
+      xfer += (*_iter1808).write(oprot);
     }
     xfer += oprot->writeListEnd();
   }
@@ -8164,17 +7754,10 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_pargs::write(::apache
   xfer += oprot->writeFieldBegin("notNullConstraints", ::apache::thrift::protocol::T_LIST, 5);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->notNullConstraints)).size()));
-<<<<<<< HEAD
-    std::vector<SQLNotNullConstraint> ::const_iterator _iter1771;
-    for (_iter1771 = (*(this->notNullConstraints)).begin(); _iter1771 != (*(this->notNullConstraints)).end(); ++_iter1771)
+    std::vector<SQLNotNullConstraint> ::const_iterator _iter1809;
+    for (_iter1809 = (*(this->notNullConstraints)).begin(); _iter1809 != (*(this->notNullConstraints)).end(); ++_iter1809)
     {
-      xfer += (*_iter1771).write(oprot);
-=======
-    std::vector<SQLNotNullConstraint> ::const_iterator _iter1799;
-    for (_iter1799 = (*(this->notNullConstraints)).begin(); _iter1799 != (*(this->notNullConstraints)).end(); ++_iter1799)
-    {
-      xfer += (*_iter1799).write(oprot);
->>>>>>> External metastore: clean after rebase
+      xfer += (*_iter1809).write(oprot);
     }
     xfer += oprot->writeListEnd();
   }
@@ -8183,17 +7766,10 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_pargs::write(::apache
   xfer += oprot->writeFieldBegin("defaultConstraints", ::apache::thrift::protocol::T_LIST, 6);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->defaultConstraints)).size()));
-<<<<<<< HEAD
-    std::vector<SQLDefaultConstraint> ::const_iterator _iter1772;
-    for (_iter1772 = (*(this->defaultConstraints)).begin(); _iter1772 != (*(this->defaultConstraints)).end(); ++_iter1772)
-    {
-      xfer += (*_iter1772).write(oprot);
-=======
-    std::vector<SQLDefaultConstraint> ::const_iterator _iter1800;
-    for (_iter1800 = (*(this->defaultConstraints)).begin(); _iter1800 != (*(this->defaultConstraints)).end(); ++_iter1800)
+    std::vector<SQLDefaultConstraint> ::const_iterator _iter1810;
+    for (_iter1810 = (*(this->defaultConstraints)).begin(); _iter1810 != (*(this->defaultConstraints)).end(); ++_iter1810)
     {
-      xfer += (*_iter1800).write(oprot);
->>>>>>> External metastore: clean after rebase
+      xfer += (*_iter1810).write(oprot);
     }
     xfer += oprot->writeListEnd();
   }
@@ -8202,17 +7778,10 @@ uint32_t ThriftHiveMetastore_create_table_with_constraints_pargs::write(::apache
   xfer += oprot->writeFieldBegin("checkConstraints", ::apache::thrift::protocol::T_LIST, 7);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->checkConstraints)).size()));
-<<<<<<< HEAD
-    std::vector<SQLCheckConstraint> ::const_iterator _iter1773;
-    for (_iter1773 = (*(this->checkConstraints)).begin(); _iter1773 != (*(this->checkConstraints)).end(); ++_iter1773)
-    {
-      xfer += (*_iter1773).write(oprot);
-=======
-    std::vector<SQLCheckConstraint> ::const_iterator _iter1801;
-    for (_iter1801 = (*(this->checkConstraints)).begin(); _iter1801 != (*(this->checkConstraints)).end(); ++_iter1801)
+    std::vector<SQLCheckConstraint> ::const_iterator _iter1811;
+    for (_iter1811 = (*(this->checkConstraints)).begin(); _iter1811 != (*(this->checkConstraints)).end(); ++_iter1811)
     {
-      xfer += (*_iter1801).write(oprot);
->>>>>>> External metastore: clean after rebase
+      xfer += (*_iter1811).write(oprot);
     }
     xfer += oprot->writeListEnd();
   }
@@ -10627,25 +10196,14 @@ uint32_t ThriftHiveMetastore_truncate_table_args::read(::apache::thrift::protoco
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->partNames.clear();
-<<<<<<< HEAD
-            uint32_t _size1774;
-            ::apache::thrift::protocol::TType _etype1777;
-            xfer += iprot->readListBegin(_etype1777, _size1774);
-            this->partNames.resize(_size1774);
-            uint32_t _i1778;
-            for (_i1778 = 0; _i1778 < _size1774; ++_i1778)
-            {
-              xfer += iprot->readString(this->partNames[_i1778]);
-=======
-            uint32_t _size1802;
-            ::apache::thrift::protocol::TType _etype1805;
-            xfer += iprot->readListBegin(_etype1805, _size1802);
-            this->partNames.resize(_size1802);
-            uint32_t _i1806;
-            for (_i1806 = 0; _i1806 < _size1802; ++_i1806)
+            uint32_t _size1812;
+            ::apache::thrift::protocol::TType _etype1815;
+            xfer += iprot->readListBegin(_etype1815, _size1812);
+            this->partNames.resize(_size1812);
+            uint32_t _i1816;
+            for (_i1816 = 0; _i1816 < _size1812; ++_i1816)
             {
-              xfer += iprot->readString(this->partNames[_i1806]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->partNames[_i1816]);
             }
             xfer += iprot->readListEnd();
           }
@@ -10682,17 +10240,10 @@ uint32_t ThriftHiveMetastore_truncate_table_args::write(::apache::thrift::protoc
   xfer += oprot->writeFieldBegin("partNames", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->partNames.size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter1779;
-    for (_iter1779 = this->partNames.begin(); _iter1779 != this->partNames.end(); ++_iter1779)
+    std::vector<std::string> ::const_iterator _iter1817;
+    for (_iter1817 = this->partNames.begin(); _iter1817 != this->partNames.end(); ++_iter1817)
     {
-      xfer += oprot->writeString((*_iter1779));
-=======
-    std::vector<std::string> ::const_iterator _iter1807;
-    for (_iter1807 = this->partNames.begin(); _iter1807 != this->partNames.end(); ++_iter1807)
-    {
-      xfer += oprot->writeString((*_iter1807));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter1817));
     }
     xfer += oprot->writeListEnd();
   }
@@ -10724,17 +10275,10 @@ uint32_t ThriftHiveMetastore_truncate_table_pargs::write(::apache::thrift::proto
   xfer += oprot->writeFieldBegin("partNames", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->partNames)).size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter1780;
-    for (_iter1780 = (*(this->partNames)).begin(); _iter1780 != (*(this->partNames)).end(); ++_iter1780)
-    {
-      xfer += oprot->writeString((*_iter1780));
-=======
-    std::vector<std::string> ::const_iterator _iter1808;
-    for (_iter1808 = (*(this->partNames)).begin(); _iter1808 != (*(this->partNames)).end(); ++_iter1808)
+    std::vector<std::string> ::const_iterator _iter1818;
+    for (_iter1818 = (*(this->partNames)).begin(); _iter1818 != (*(this->partNames)).end(); ++_iter1818)
     {
-      xfer += oprot->writeString((*_iter1808));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter1818));
     }
     xfer += oprot->writeListEnd();
   }
@@ -11185,25 +10729,14 @@ uint32_t ThriftHiveMetastore_get_tables_result::read(::apache::thrift::protocol:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size1781;
-            ::apache::thrift::protocol::TType _etype1784;
-            xfer += iprot->readListBegin(_etype1784, _size1781);
-            this->success.resize(_size1781);
-            uint32_t _i1785;
-            for (_i1785 = 0; _i1785 < _size1781; ++_i1785)
+            uint32_t _size1819;
+            ::apache::thrift::protocol::TType _etype1822;
+            xfer += iprot->readListBegin(_etype1822, _size1819);
+            this->success.resize(_size1819);
+            uint32_t _i1823;
+            for (_i1823 = 0; _i1823 < _size1819; ++_i1823)
             {
-              xfer += iprot->readString(this->success[_i1785]);
-=======
-            uint32_t _size1809;
-            ::apache::thrift::protocol::TType _etype1812;
-            xfer += iprot->readListBegin(_etype1812, _size1809);
-            this->success.resize(_size1809);
-            uint32_t _i1813;
-            for (_i1813 = 0; _i1813 < _size1809; ++_i1813)
-            {
-              xfer += iprot->readString(this->success[_i1813]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->success[_i1823]);
             }
             xfer += iprot->readListEnd();
           }
@@ -11242,17 +10775,10 @@ uint32_t ThriftHiveMetastore_get_tables_result::write(::apache::thrift::protocol
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter1786;
-      for (_iter1786 = this->success.begin(); _iter1786 != this->success.end(); ++_iter1786)
-      {
-        xfer += oprot->writeString((*_iter1786));
-=======
-      std::vector<std::string> ::const_iterator _iter1814;
-      for (_iter1814 = this->success.begin(); _iter1814 != this->success.end(); ++_iter1814)
+      std::vector<std::string> ::const_iterator _iter1824;
+      for (_iter1824 = this->success.begin(); _iter1824 != this->success.end(); ++_iter1824)
       {
-        xfer += oprot->writeString((*_iter1814));
->>>>>>> External metastore: clean after rebase
+        xfer += oprot->writeString((*_iter1824));
       }
       xfer += oprot->writeListEnd();
     }
@@ -11297,25 +10823,14 @@ uint32_t ThriftHiveMetastore_get_tables_presult::read(::apache::thrift::protocol
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size1787;
-            ::apache::thrift::protocol::TType _etype1790;
-            xfer += iprot->readListBegin(_etype1790, _size1787);
-            (*(this->success)).resize(_size1787);
-            uint32_t _i1791;
-            for (_i1791 = 0; _i1791 < _size1787; ++_i1791)
-            {
-              xfer += iprot->readString((*(this->success))[_i1791]);
-=======
-            uint32_t _size1815;
-            ::apache::thrift::protocol::TType _etype1818;
-            xfer += iprot->readListBegin(_etype1818, _size1815);
-            (*(this->success)).resize(_size1815);
-            uint32_t _i1819;
-            for (_i1819 = 0; _i1819 < _size1815; ++_i1819)
+            uint32_t _size1825;
+            ::apache::thrift::protocol::TType _etype1828;
+            xfer += iprot->readListBegin(_etype1828, _size1825);
+            (*(this->success)).resize(_size1825);
+            uint32_t _i1829;
+            for (_i1829 = 0; _i1829 < _size1825; ++_i1829)
             {
-              xfer += iprot->readString((*(this->success))[_i1819]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString((*(this->success))[_i1829]);
             }
             xfer += iprot->readListEnd();
           }
@@ -11485,25 +11000,14 @@ uint32_t ThriftHiveMetastore_get_tables_by_type_result::read(::apache::thrift::p
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size1792;
-            ::apache::thrift::protocol::TType _etype1795;
-            xfer += iprot->readListBegin(_etype1795, _size1792);
-            this->success.resize(_size1792);
-            uint32_t _i1796;
-            for (_i1796 = 0; _i1796 < _size1792; ++_i1796)
+            uint32_t _size1830;
+            ::apache::thrift::protocol::TType _etype1833;
+            xfer += iprot->readListBegin(_etype1833, _size1830);
+            this->success.resize(_size1830);
+            uint32_t _i1834;
+            for (_i1834 = 0; _i1834 < _size1830; ++_i1834)
             {
-              xfer += iprot->readString(this->success[_i1796]);
-=======
-            uint32_t _size1820;
-            ::apache::thrift::protocol::TType _etype1823;
-            xfer += iprot->readListBegin(_etype1823, _size1820);
-            this->success.resize(_size1820);
-            uint32_t _i1824;
-            for (_i1824 = 0; _i1824 < _size1820; ++_i1824)
-            {
-              xfer += iprot->readString(this->success[_i1824]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->success[_i1834]);
             }
             xfer += iprot->readListEnd();
           }
@@ -11542,17 +11046,10 @@ uint32_t ThriftHiveMetastore_get_tables_by_type_result::write(::apache::thrift::
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter1797;
-      for (_iter1797 = this->success.begin(); _iter1797 != this->success.end(); ++_iter1797)
-      {
-        xfer += oprot->writeString((*_iter1797));
-=======
-      std::vector<std::string> ::const_iterator _iter1825;
-      for (_iter1825 = this->success.begin(); _iter1825 != this->success.end(); ++_iter1825)
+      std::vector<std::string> ::const_iterator _iter1835;
+      for (_iter1835 = this->success.begin(); _iter1835 != this->success.end(); ++_iter1835)
       {
-        xfer += oprot->writeString((*_iter1825));
->>>>>>> External metastore: clean after rebase
+        xfer += oprot->writeString((*_iter1835));
       }
       xfer += oprot->writeListEnd();
     }
@@ -11597,25 +11094,14 @@ uint32_t ThriftHiveMetastore_get_tables_by_type_presult::read(::apache::thrift::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size1798;
-            ::apache::thrift::protocol::TType _etype1801;
-            xfer += iprot->readListBegin(_etype1801, _size1798);
-            (*(this->success)).resize(_size1798);
-            uint32_t _i1802;
-            for (_i1802 = 0; _i1802 < _size1798; ++_i1802)
+            uint32_t _size1836;
+            ::apache::thrift::protocol::TType _etype1839;
+            xfer += iprot->readListBegin(_etype1839, _size1836);
+            (*(this->success)).resize(_size1836);
+            uint32_t _i1840;
+            for (_i1840 = 0; _i1840 < _size1836; ++_i1840)
             {
-              xfer += iprot->readString((*(this->success))[_i1802]);
-=======
-            uint32_t _size1826;
-            ::apache::thrift::protocol::TType _etype1829;
-            xfer += iprot->readListBegin(_etype1829, _size1826);
-            (*(this->success)).resize(_size1826);
-            uint32_t _i1830;
-            for (_i1830 = 0; _i1830 < _size1826; ++_i1830)
-            {
-              xfer += iprot->readString((*(this->success))[_i1830]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString((*(this->success))[_i1840]);
             }
             xfer += iprot->readListEnd();
           }
@@ -11732,25 +11218,14 @@ uint32_t ThriftHiveMetastore_get_all_materialized_view_objects_for_rewriting_res
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size1803;
-            ::apache::thrift::protocol::TType _etype1806;
-            xfer += iprot->readListBegin(_etype1806, _size1803);
-            this->success.resize(_size1803);
-            uint32_t _i1807;
-            for (_i1807 = 0; _i1807 < _size1803; ++_i1807)
-            {
-              xfer += this->success[_i1807].read(iprot);
-=======
-            uint32_t _size1831;
-            ::apache::thrift::protocol::TType _etype1834;
-            xfer += iprot->readListBegin(_etype1834, _size1831);
-            this->success.resize(_size1831);
-            uint32_t _i1835;
-            for (_i1835 = 0; _i1835 < _size1831; ++_i1835)
+            uint32_t _size1841;
+            ::apache::thrift::protocol::TType _etype1844;
+            xfer += iprot->readListBegin(_etype1844, _size1841);
+            this->success.resize(_size1841);
+            uint32_t _i1845;
+            for (_i1845 = 0; _i1845 < _size1841; ++_i1845)
             {
-              xfer += this->success[_i1835].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->success[_i1845].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -11789,17 +11264,10 @@ uint32_t ThriftHiveMetastore_get_all_materialized_view_objects_for_rewriting_res
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<Table> ::const_iterator _iter1808;
-      for (_iter1808 = this->success.begin(); _iter1808 != this->success.end(); ++_iter1808)
+      std::vector<Table> ::const_iterator _iter1846;
+      for (_iter1846 = this->success.begin(); _iter1846 != this->success.end(); ++_iter1846)
       {
-        xfer += (*_iter1808).write(oprot);
-=======
-      std::vector<Table> ::const_iterator _iter1836;
-      for (_iter1836 = this->success.begin(); _iter1836 != this->success.end(); ++_iter1836)
-      {
-        xfer += (*_iter1836).write(oprot);
->>>>>>> External metastore: clean after rebase
+        xfer += (*_iter1846).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -11844,25 +11312,14 @@ uint32_t ThriftHiveMetastore_get_all_materialized_view_objects_for_rewriting_pre
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size1809;
-            ::apache::thrift::protocol::TType _etype1812;
-            xfer += iprot->readListBegin(_etype1812, _size1809);
-            (*(this->success)).resize(_size1809);
-            uint32_t _i1813;
-            for (_i1813 = 0; _i1813 < _size1809; ++_i1813)
-            {
-              xfer += (*(this->success))[_i1813].read(iprot);
-=======
-            uint32_t _size1837;
-            ::apache::thrift::protocol::TType _etype1840;
-            xfer += iprot->readListBegin(_etype1840, _size1837);
-            (*(this->success)).resize(_size1837);
-            uint32_t _i1841;
-            for (_i1841 = 0; _i1841 < _size1837; ++_i1841)
+            uint32_t _size1847;
+            ::apache::thrift::protocol::TType _etype1850;
+            xfer += iprot->readListBegin(_etype1850, _size1847);
+            (*(this->success)).resize(_size1847);
+            uint32_t _i1851;
+            for (_i1851 = 0; _i1851 < _size1847; ++_i1851)
             {
-              xfer += (*(this->success))[_i1841].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += (*(this->success))[_i1851].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -12000,25 +11457,14 @@ uint32_t ThriftHiveMetastore_get_materialized_views_for_rewriting_result::read(:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size1814;
-            ::apache::thrift::protocol::TType _etype1817;
-            xfer += iprot->readListBegin(_etype1817, _size1814);
-            this->success.resize(_size1814);
-            uint32_t _i1818;
-            for (_i1818 = 0; _i1818 < _size1814; ++_i1818)
+            uint32_t _size1852;
+            ::apache::thrift::protocol::TType _etype1855;
+            xfer += iprot->readListBegin(_etype1855, _size1852);
+            this->success.resize(_size1852);
+            uint32_t _i1856;
+            for (_i1856 = 0; _i1856 < _size1852; ++_i1856)
             {
-              xfer += iprot->readString(this->success[_i1818]);
-=======
-            uint32_t _size1842;
-            ::apache::thrift::protocol::TType _etype1845;
-            xfer += iprot->readListBegin(_etype1845, _size1842);
-            this->success.resize(_size1842);
-            uint32_t _i1846;
-            for (_i1846 = 0; _i1846 < _size1842; ++_i1846)
-            {
-              xfer += iprot->readString(this->success[_i1846]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->success[_i1856]);
             }
             xfer += iprot->readListEnd();
           }
@@ -12057,17 +11503,10 @@ uint32_t ThriftHiveMetastore_get_materialized_views_for_rewriting_result::write(
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter1819;
-      for (_iter1819 = this->success.begin(); _iter1819 != this->success.end(); ++_iter1819)
-      {
-        xfer += oprot->writeString((*_iter1819));
-=======
-      std::vector<std::string> ::const_iterator _iter1847;
-      for (_iter1847 = this->success.begin(); _iter1847 != this->success.end(); ++_iter1847)
+      std::vector<std::string> ::const_iterator _iter1857;
+      for (_iter1857 = this->success.begin(); _iter1857 != this->success.end(); ++_iter1857)
       {
-        xfer += oprot->writeString((*_iter1847));
->>>>>>> External metastore: clean after rebase
+        xfer += oprot->writeString((*_iter1857));
       }
       xfer += oprot->writeListEnd();
     }
@@ -12112,25 +11551,14 @@ uint32_t ThriftHiveMetastore_get_materialized_views_for_rewriting_presult::read(
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size1820;
-            ::apache::thrift::protocol::TType _etype1823;
-            xfer += iprot->readListBegin(_etype1823, _size1820);
-            (*(this->success)).resize(_size1820);
-            uint32_t _i1824;
-            for (_i1824 = 0; _i1824 < _size1820; ++_i1824)
+            uint32_t _size1858;
+            ::apache::thrift::protocol::TType _etype1861;
+            xfer += iprot->readListBegin(_etype1861, _size1858);
+            (*(this->success)).resize(_size1858);
+            uint32_t _i1862;
+            for (_i1862 = 0; _i1862 < _size1858; ++_i1862)
             {
-              xfer += iprot->readString((*(this->success))[_i1824]);
-=======
-            uint32_t _size1848;
-            ::apache::thrift::protocol::TType _etype1851;
-            xfer += iprot->readListBegin(_etype1851, _size1848);
-            (*(this->success)).resize(_size1848);
-            uint32_t _i1852;
-            for (_i1852 = 0; _i1852 < _size1848; ++_i1852)
-            {
-              xfer += iprot->readString((*(this->success))[_i1852]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString((*(this->success))[_i1862]);
             }
             xfer += iprot->readListEnd();
           }
@@ -12205,25 +11633,14 @@ uint32_t ThriftHiveMetastore_get_table_meta_args::read(::apache::thrift::protoco
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->tbl_types.clear();
-<<<<<<< HEAD
-            uint32_t _size1825;
-            ::apache::thrift::protocol::TType _etype1828;
-            xfer += iprot->readListBegin(_etype1828, _size1825);
-            this->tbl_types.resize(_size1825);
-            uint32_t _i1829;
-            for (_i1829 = 0; _i1829 < _size1825; ++_i1829)
+            uint32_t _size1863;
+            ::apache::thrift::protocol::TType _etype1866;
+            xfer += iprot->readListBegin(_etype1866, _size1863);
+            this->tbl_types.resize(_size1863);
+            uint32_t _i1867;
+            for (_i1867 = 0; _i1867 < _size1863; ++_i1867)
             {
-              xfer += iprot->readString(this->tbl_types[_i1829]);
-=======
-            uint32_t _size1853;
-            ::apache::thrift::protocol::TType _etype1856;
-            xfer += iprot->readListBegin(_etype1856, _size1853);
-            this->tbl_types.resize(_size1853);
-            uint32_t _i1857;
-            for (_i1857 = 0; _i1857 < _size1853; ++_i1857)
-            {
-              xfer += iprot->readString(this->tbl_types[_i1857]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->tbl_types[_i1867]);
             }
             xfer += iprot->readListEnd();
           }
@@ -12260,17 +11677,10 @@ uint32_t ThriftHiveMetastore_get_table_meta_args::write(::apache::thrift::protoc
   xfer += oprot->writeFieldBegin("tbl_types", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->tbl_types.size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter1830;
-    for (_iter1830 = this->tbl_types.begin(); _iter1830 != this->tbl_types.end(); ++_iter1830)
-    {
-      xfer += oprot->writeString((*_iter1830));
-=======
-    std::vector<std::string> ::const_iterator _iter1858;
-    for (_iter1858 = this->tbl_types.begin(); _iter1858 != this->tbl_types.end(); ++_iter1858)
+    std::vector<std::string> ::const_iterator _iter1868;
+    for (_iter1868 = this->tbl_types.begin(); _iter1868 != this->tbl_types.end(); ++_iter1868)
     {
-      xfer += oprot->writeString((*_iter1858));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter1868));
     }
     xfer += oprot->writeListEnd();
   }
@@ -12302,17 +11712,10 @@ uint32_t ThriftHiveMetastore_get_table_meta_pargs::write(::apache::thrift::proto
   xfer += oprot->writeFieldBegin("tbl_types", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->tbl_types)).size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter1831;
-    for (_iter1831 = (*(this->tbl_types)).begin(); _iter1831 != (*(this->tbl_types)).end(); ++_iter1831)
+    std::vector<std::string> ::const_iterator _iter1869;
+    for (_iter1869 = (*(this->tbl_types)).begin(); _iter1869 != (*(this->tbl_types)).end(); ++_iter1869)
     {
-      xfer += oprot->writeString((*_iter1831));
-=======
-    std::vector<std::string> ::const_iterator _iter1859;
-    for (_iter1859 = (*(this->tbl_types)).begin(); _iter1859 != (*(this->tbl_types)).end(); ++_iter1859)
-    {
-      xfer += oprot->writeString((*_iter1859));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter1869));
     }
     xfer += oprot->writeListEnd();
   }
@@ -12353,25 +11756,14 @@ uint32_t ThriftHiveMetastore_get_table_meta_result::read(::apache::thrift::proto
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size1832;
-            ::apache::thrift::protocol::TType _etype1835;
-            xfer += iprot->readListBegin(_etype1835, _size1832);
-            this->success.resize(_size1832);
-            uint32_t _i1836;
-            for (_i1836 = 0; _i1836 < _size1832; ++_i1836)
-            {
-              xfer += this->success[_i1836].read(iprot);
-=======
-            uint32_t _size1860;
-            ::apache::thrift::protocol::TType _etype1863;
-            xfer += iprot->readListBegin(_etype1863, _size1860);
-            this->success.resize(_size1860);
-            uint32_t _i1864;
-            for (_i1864 = 0; _i1864 < _size1860; ++_i1864)
+            uint32_t _size1870;
+            ::apache::thrift::protocol::TType _etype1873;
+            xfer += iprot->readListBegin(_etype1873, _size1870);
+            this->success.resize(_size1870);
+            uint32_t _i1874;
+            for (_i1874 = 0; _i1874 < _size1870; ++_i1874)
             {
-              xfer += this->success[_i1864].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->success[_i1874].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -12410,17 +11802,10 @@ uint32_t ThriftHiveMetastore_get_table_meta_result::write(::apache::thrift::prot
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<TableMeta> ::const_iterator _iter1837;
-      for (_iter1837 = this->success.begin(); _iter1837 != this->success.end(); ++_iter1837)
+      std::vector<TableMeta> ::const_iterator _iter1875;
+      for (_iter1875 = this->success.begin(); _iter1875 != this->success.end(); ++_iter1875)
       {
-        xfer += (*_iter1837).write(oprot);
-=======
-      std::vector<TableMeta> ::const_iterator _iter1865;
-      for (_iter1865 = this->success.begin(); _iter1865 != this->success.end(); ++_iter1865)
-      {
-        xfer += (*_iter1865).write(oprot);
->>>>>>> External metastore: clean after rebase
+        xfer += (*_iter1875).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -12465,25 +11850,14 @@ uint32_t ThriftHiveMetastore_get_table_meta_presult::read(::apache::thrift::prot
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size1838;
-            ::apache::thrift::protocol::TType _etype1841;
-            xfer += iprot->readListBegin(_etype1841, _size1838);
-            (*(this->success)).resize(_size1838);
-            uint32_t _i1842;
-            for (_i1842 = 0; _i1842 < _size1838; ++_i1842)
-            {
-              xfer += (*(this->success))[_i1842].read(iprot);
-=======
-            uint32_t _size1866;
-            ::apache::thrift::protocol::TType _etype1869;
-            xfer += iprot->readListBegin(_etype1869, _size1866);
-            (*(this->success)).resize(_size1866);
-            uint32_t _i1870;
-            for (_i1870 = 0; _i1870 < _size1866; ++_i1870)
+            uint32_t _size1876;
+            ::apache::thrift::protocol::TType _etype1879;
+            xfer += iprot->readListBegin(_etype1879, _size1876);
+            (*(this->success)).resize(_size1876);
+            uint32_t _i1880;
+            for (_i1880 = 0; _i1880 < _size1876; ++_i1880)
             {
-              xfer += (*(this->success))[_i1870].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += (*(this->success))[_i1880].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -12621,25 +11995,14 @@ uint32_t ThriftHiveMetastore_get_all_tables_result::read(::apache::thrift::proto
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size1843;
-            ::apache::thrift::protocol::TType _etype1846;
-            xfer += iprot->readListBegin(_etype1846, _size1843);
-            this->success.resize(_size1843);
-            uint32_t _i1847;
-            for (_i1847 = 0; _i1847 < _size1843; ++_i1847)
+            uint32_t _size1881;
+            ::apache::thrift::protocol::TType _etype1884;
+            xfer += iprot->readListBegin(_etype1884, _size1881);
+            this->success.resize(_size1881);
+            uint32_t _i1885;
+            for (_i1885 = 0; _i1885 < _size1881; ++_i1885)
             {
-              xfer += iprot->readString(this->success[_i1847]);
-=======
-            uint32_t _size1871;
-            ::apache::thrift::protocol::TType _etype1874;
-            xfer += iprot->readListBegin(_etype1874, _size1871);
-            this->success.resize(_size1871);
-            uint32_t _i1875;
-            for (_i1875 = 0; _i1875 < _size1871; ++_i1875)
-            {
-              xfer += iprot->readString(this->success[_i1875]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->success[_i1885]);
             }
             xfer += iprot->readListEnd();
           }
@@ -12678,17 +12041,10 @@ uint32_t ThriftHiveMetastore_get_all_tables_result::write(::apache::thrift::prot
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter1848;
-      for (_iter1848 = this->success.begin(); _iter1848 != this->success.end(); ++_iter1848)
-      {
-        xfer += oprot->writeString((*_iter1848));
-=======
-      std::vector<std::string> ::const_iterator _iter1876;
-      for (_iter1876 = this->success.begin(); _iter1876 != this->success.end(); ++_iter1876)
+      std::vector<std::string> ::const_iterator _iter1886;
+      for (_iter1886 = this->success.begin(); _iter1886 != this->success.end(); ++_iter1886)
       {
-        xfer += oprot->writeString((*_iter1876));
->>>>>>> External metastore: clean after rebase
+        xfer += oprot->writeString((*_iter1886));
       }
       xfer += oprot->writeListEnd();
     }
@@ -12733,25 +12089,14 @@ uint32_t ThriftHiveMetastore_get_all_tables_presult::read(::apache::thrift::prot
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size1849;
-            ::apache::thrift::protocol::TType _etype1852;
-            xfer += iprot->readListBegin(_etype1852, _size1849);
-            (*(this->success)).resize(_size1849);
-            uint32_t _i1853;
-            for (_i1853 = 0; _i1853 < _size1849; ++_i1853)
+            uint32_t _size1887;
+            ::apache::thrift::protocol::TType _etype1890;
+            xfer += iprot->readListBegin(_etype1890, _size1887);
+            (*(this->success)).resize(_size1887);
+            uint32_t _i1891;
+            for (_i1891 = 0; _i1891 < _size1887; ++_i1891)
             {
-              xfer += iprot->readString((*(this->success))[_i1853]);
-=======
-            uint32_t _size1877;
-            ::apache::thrift::protocol::TType _etype1880;
-            xfer += iprot->readListBegin(_etype1880, _size1877);
-            (*(this->success)).resize(_size1877);
-            uint32_t _i1881;
-            for (_i1881 = 0; _i1881 < _size1877; ++_i1881)
-            {
-              xfer += iprot->readString((*(this->success))[_i1881]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString((*(this->success))[_i1891]);
             }
             xfer += iprot->readListEnd();
           }
@@ -13061,25 +12406,14 @@ uint32_t ThriftHiveMetastore_get_table_objects_by_name_args::read(::apache::thri
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->tbl_names.clear();
-<<<<<<< HEAD
-            uint32_t _size1854;
-            ::apache::thrift::protocol::TType _etype1857;
-            xfer += iprot->readListBegin(_etype1857, _size1854);
-            this->tbl_names.resize(_size1854);
-            uint32_t _i1858;
-            for (_i1858 = 0; _i1858 < _size1854; ++_i1858)
-            {
-              xfer += iprot->readString(this->tbl_names[_i1858]);
-=======
-            uint32_t _size1882;
-            ::apache::thrift::protocol::TType _etype1885;
-            xfer += iprot->readListBegin(_etype1885, _size1882);
-            this->tbl_names.resize(_size1882);
-            uint32_t _i1886;
-            for (_i1886 = 0; _i1886 < _size1882; ++_i1886)
+            uint32_t _size1892;
+            ::apache::thrift::protocol::TType _etype1895;
+            xfer += iprot->readListBegin(_etype1895, _size1892);
+            this->tbl_names.resize(_size1892);
+            uint32_t _i1896;
+            for (_i1896 = 0; _i1896 < _size1892; ++_i1896)
             {
-              xfer += iprot->readString(this->tbl_names[_i1886]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->tbl_names[_i1896]);
             }
             xfer += iprot->readListEnd();
           }
@@ -13112,17 +12446,10 @@ uint32_t ThriftHiveMetastore_get_table_objects_by_name_args::write(::apache::thr
   xfer += oprot->writeFieldBegin("tbl_names", ::apache::thrift::protocol::T_LIST, 2);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->tbl_names.size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter1859;
-    for (_iter1859 = this->tbl_names.begin(); _iter1859 != this->tbl_names.end(); ++_iter1859)
+    std::vector<std::string> ::const_iterator _iter1897;
+    for (_iter1897 = this->tbl_names.begin(); _iter1897 != this->tbl_names.end(); ++_iter1897)
     {
-      xfer += oprot->writeString((*_iter1859));
-=======
-    std::vector<std::string> ::const_iterator _iter1887;
-    for (_iter1887 = this->tbl_names.begin(); _iter1887 != this->tbl_names.end(); ++_iter1887)
-    {
-      xfer += oprot->writeString((*_iter1887));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter1897));
     }
     xfer += oprot->writeListEnd();
   }
@@ -13150,17 +12477,10 @@ uint32_t ThriftHiveMetastore_get_table_objects_by_name_pargs::write(::apache::th
   xfer += oprot->writeFieldBegin("tbl_names", ::apache::thrift::protocol::T_LIST, 2);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->tbl_names)).size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter1860;
-    for (_iter1860 = (*(this->tbl_names)).begin(); _iter1860 != (*(this->tbl_names)).end(); ++_iter1860)
-    {
-      xfer += oprot->writeString((*_iter1860));
-=======
-    std::vector<std::string> ::const_iterator _iter1888;
-    for (_iter1888 = (*(this->tbl_names)).begin(); _iter1888 != (*(this->tbl_names)).end(); ++_iter1888)
+    std::vector<std::string> ::const_iterator _iter1898;
+    for (_iter1898 = (*(this->tbl_names)).begin(); _iter1898 != (*(this->tbl_names)).end(); ++_iter1898)
     {
-      xfer += oprot->writeString((*_iter1888));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter1898));
     }
     xfer += oprot->writeListEnd();
   }
@@ -13201,25 +12521,14 @@ uint32_t ThriftHiveMetastore_get_table_objects_by_name_result::read(::apache::th
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size1861;
-            ::apache::thrift::protocol::TType _etype1864;
-            xfer += iprot->readListBegin(_etype1864, _size1861);
-            this->success.resize(_size1861);
-            uint32_t _i1865;
-            for (_i1865 = 0; _i1865 < _size1861; ++_i1865)
+            uint32_t _size1899;
+            ::apache::thrift::protocol::TType _etype1902;
+            xfer += iprot->readListBegin(_etype1902, _size1899);
+            this->success.resize(_size1899);
+            uint32_t _i1903;
+            for (_i1903 = 0; _i1903 < _size1899; ++_i1903)
             {
-              xfer += this->success[_i1865].read(iprot);
-=======
-            uint32_t _size1889;
-            ::apache::thrift::protocol::TType _etype1892;
-            xfer += iprot->readListBegin(_etype1892, _size1889);
-            this->success.resize(_size1889);
-            uint32_t _i1893;
-            for (_i1893 = 0; _i1893 < _size1889; ++_i1893)
-            {
-              xfer += this->success[_i1893].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->success[_i1903].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -13250,17 +12559,10 @@ uint32_t ThriftHiveMetastore_get_table_objects_by_name_result::write(::apache::t
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<Table> ::const_iterator _iter1866;
-      for (_iter1866 = this->success.begin(); _iter1866 != this->success.end(); ++_iter1866)
-      {
-        xfer += (*_iter1866).write(oprot);
-=======
-      std::vector<Table> ::const_iterator _iter1894;
-      for (_iter1894 = this->success.begin(); _iter1894 != this->success.end(); ++_iter1894)
+      std::vector<Table> ::const_iterator _iter1904;
+      for (_iter1904 = this->success.begin(); _iter1904 != this->success.end(); ++_iter1904)
       {
-        xfer += (*_iter1894).write(oprot);
->>>>>>> External metastore: clean after rebase
+        xfer += (*_iter1904).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -13301,25 +12603,14 @@ uint32_t ThriftHiveMetastore_get_table_objects_by_name_presult::read(::apache::t
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size1867;
-            ::apache::thrift::protocol::TType _etype1870;
-            xfer += iprot->readListBegin(_etype1870, _size1867);
-            (*(this->success)).resize(_size1867);
-            uint32_t _i1871;
-            for (_i1871 = 0; _i1871 < _size1867; ++_i1871)
+            uint32_t _size1905;
+            ::apache::thrift::protocol::TType _etype1908;
+            xfer += iprot->readListBegin(_etype1908, _size1905);
+            (*(this->success)).resize(_size1905);
+            uint32_t _i1909;
+            for (_i1909 = 0; _i1909 < _size1905; ++_i1909)
             {
-              xfer += (*(this->success))[_i1871].read(iprot);
-=======
-            uint32_t _size1895;
-            ::apache::thrift::protocol::TType _etype1898;
-            xfer += iprot->readListBegin(_etype1898, _size1895);
-            (*(this->success)).resize(_size1895);
-            uint32_t _i1899;
-            for (_i1899 = 0; _i1899 < _size1895; ++_i1899)
-            {
-              xfer += (*(this->success))[_i1899].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += (*(this->success))[_i1909].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -13449,25 +12740,14 @@ uint32_t ThriftHiveMetastore_get_tables_ext_result::read(::apache::thrift::proto
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size1872;
-            ::apache::thrift::protocol::TType _etype1875;
-            xfer += iprot->readListBegin(_etype1875, _size1872);
-            this->success.resize(_size1872);
-            uint32_t _i1876;
-            for (_i1876 = 0; _i1876 < _size1872; ++_i1876)
-            {
-              xfer += this->success[_i1876].read(iprot);
-=======
-            uint32_t _size1900;
-            ::apache::thrift::protocol::TType _etype1903;
-            xfer += iprot->readListBegin(_etype1903, _size1900);
-            this->success.resize(_size1900);
-            uint32_t _i1904;
-            for (_i1904 = 0; _i1904 < _size1900; ++_i1904)
+            uint32_t _size1910;
+            ::apache::thrift::protocol::TType _etype1913;
+            xfer += iprot->readListBegin(_etype1913, _size1910);
+            this->success.resize(_size1910);
+            uint32_t _i1914;
+            for (_i1914 = 0; _i1914 < _size1910; ++_i1914)
             {
-              xfer += this->success[_i1904].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->success[_i1914].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -13506,17 +12786,10 @@ uint32_t ThriftHiveMetastore_get_tables_ext_result::write(::apache::thrift::prot
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<ExtendedTableInfo> ::const_iterator _iter1877;
-      for (_iter1877 = this->success.begin(); _iter1877 != this->success.end(); ++_iter1877)
+      std::vector<ExtendedTableInfo> ::const_iterator _iter1915;
+      for (_iter1915 = this->success.begin(); _iter1915 != this->success.end(); ++_iter1915)
       {
-        xfer += (*_iter1877).write(oprot);
-=======
-      std::vector<ExtendedTableInfo> ::const_iterator _iter1905;
-      for (_iter1905 = this->success.begin(); _iter1905 != this->success.end(); ++_iter1905)
-      {
-        xfer += (*_iter1905).write(oprot);
->>>>>>> External metastore: clean after rebase
+        xfer += (*_iter1915).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -13561,25 +12834,14 @@ uint32_t ThriftHiveMetastore_get_tables_ext_presult::read(::apache::thrift::prot
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size1878;
-            ::apache::thrift::protocol::TType _etype1881;
-            xfer += iprot->readListBegin(_etype1881, _size1878);
-            (*(this->success)).resize(_size1878);
-            uint32_t _i1882;
-            for (_i1882 = 0; _i1882 < _size1878; ++_i1882)
-            {
-              xfer += (*(this->success))[_i1882].read(iprot);
-=======
-            uint32_t _size1906;
-            ::apache::thrift::protocol::TType _etype1909;
-            xfer += iprot->readListBegin(_etype1909, _size1906);
-            (*(this->success)).resize(_size1906);
-            uint32_t _i1910;
-            for (_i1910 = 0; _i1910 < _size1906; ++_i1910)
+            uint32_t _size1916;
+            ::apache::thrift::protocol::TType _etype1919;
+            xfer += iprot->readListBegin(_etype1919, _size1916);
+            (*(this->success)).resize(_size1916);
+            uint32_t _i1920;
+            for (_i1920 = 0; _i1920 < _size1916; ++_i1920)
             {
-              xfer += (*(this->success))[_i1910].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += (*(this->success))[_i1920].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -14761,25 +14023,14 @@ uint32_t ThriftHiveMetastore_get_table_names_by_filter_result::read(::apache::th
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size1883;
-            ::apache::thrift::protocol::TType _etype1886;
-            xfer += iprot->readListBegin(_etype1886, _size1883);
-            this->success.resize(_size1883);
-            uint32_t _i1887;
-            for (_i1887 = 0; _i1887 < _size1883; ++_i1887)
+            uint32_t _size1921;
+            ::apache::thrift::protocol::TType _etype1924;
+            xfer += iprot->readListBegin(_etype1924, _size1921);
+            this->success.resize(_size1921);
+            uint32_t _i1925;
+            for (_i1925 = 0; _i1925 < _size1921; ++_i1925)
             {
-              xfer += iprot->readString(this->success[_i1887]);
-=======
-            uint32_t _size1911;
-            ::apache::thrift::protocol::TType _etype1914;
-            xfer += iprot->readListBegin(_etype1914, _size1911);
-            this->success.resize(_size1911);
-            uint32_t _i1915;
-            for (_i1915 = 0; _i1915 < _size1911; ++_i1915)
-            {
-              xfer += iprot->readString(this->success[_i1915]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->success[_i1925]);
             }
             xfer += iprot->readListEnd();
           }
@@ -14834,17 +14085,10 @@ uint32_t ThriftHiveMetastore_get_table_names_by_filter_result::write(::apache::t
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter1888;
-      for (_iter1888 = this->success.begin(); _iter1888 != this->success.end(); ++_iter1888)
-      {
-        xfer += oprot->writeString((*_iter1888));
-=======
-      std::vector<std::string> ::const_iterator _iter1916;
-      for (_iter1916 = this->success.begin(); _iter1916 != this->success.end(); ++_iter1916)
+      std::vector<std::string> ::const_iterator _iter1926;
+      for (_iter1926 = this->success.begin(); _iter1926 != this->success.end(); ++_iter1926)
       {
-        xfer += oprot->writeString((*_iter1916));
->>>>>>> External metastore: clean after rebase
+        xfer += oprot->writeString((*_iter1926));
       }
       xfer += oprot->writeListEnd();
     }
@@ -14897,25 +14141,14 @@ uint32_t ThriftHiveMetastore_get_table_names_by_filter_presult::read(::apache::t
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size1889;
-            ::apache::thrift::protocol::TType _etype1892;
-            xfer += iprot->readListBegin(_etype1892, _size1889);
-            (*(this->success)).resize(_size1889);
-            uint32_t _i1893;
-            for (_i1893 = 0; _i1893 < _size1889; ++_i1893)
+            uint32_t _size1927;
+            ::apache::thrift::protocol::TType _etype1930;
+            xfer += iprot->readListBegin(_etype1930, _size1927);
+            (*(this->success)).resize(_size1927);
+            uint32_t _i1931;
+            for (_i1931 = 0; _i1931 < _size1927; ++_i1931)
             {
-              xfer += iprot->readString((*(this->success))[_i1893]);
-=======
-            uint32_t _size1917;
-            ::apache::thrift::protocol::TType _etype1920;
-            xfer += iprot->readListBegin(_etype1920, _size1917);
-            (*(this->success)).resize(_size1917);
-            uint32_t _i1921;
-            for (_i1921 = 0; _i1921 < _size1917; ++_i1921)
-            {
-              xfer += iprot->readString((*(this->success))[_i1921]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString((*(this->success))[_i1931]);
             }
             xfer += iprot->readListEnd();
           }
@@ -16476,25 +15709,14 @@ uint32_t ThriftHiveMetastore_add_partitions_args::read(::apache::thrift::protoco
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->new_parts.clear();
-<<<<<<< HEAD
-            uint32_t _size1894;
-            ::apache::thrift::protocol::TType _etype1897;
-            xfer += iprot->readListBegin(_etype1897, _size1894);
-            this->new_parts.resize(_size1894);
-            uint32_t _i1898;
-            for (_i1898 = 0; _i1898 < _size1894; ++_i1898)
-            {
-              xfer += this->new_parts[_i1898].read(iprot);
-=======
-            uint32_t _size1922;
-            ::apache::thrift::protocol::TType _etype1925;
-            xfer += iprot->readListBegin(_etype1925, _size1922);
-            this->new_parts.resize(_size1922);
-            uint32_t _i1926;
-            for (_i1926 = 0; _i1926 < _size1922; ++_i1926)
+            uint32_t _size1932;
+            ::apache::thrift::protocol::TType _etype1935;
+            xfer += iprot->readListBegin(_etype1935, _size1932);
+            this->new_parts.resize(_size1932);
+            uint32_t _i1936;
+            for (_i1936 = 0; _i1936 < _size1932; ++_i1936)
             {
-              xfer += this->new_parts[_i1926].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->new_parts[_i1936].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -16523,17 +15745,10 @@ uint32_t ThriftHiveMetastore_add_partitions_args::write(::apache::thrift::protoc
   xfer += oprot->writeFieldBegin("new_parts", ::apache::thrift::protocol::T_LIST, 1);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->new_parts.size()));
-<<<<<<< HEAD
-    std::vector<Partition> ::const_iterator _iter1899;
-    for (_iter1899 = this->new_parts.begin(); _iter1899 != this->new_parts.end(); ++_iter1899)
+    std::vector<Partition> ::const_iterator _iter1937;
+    for (_iter1937 = this->new_parts.begin(); _iter1937 != this->new_parts.end(); ++_iter1937)
     {
-      xfer += (*_iter1899).write(oprot);
-=======
-    std::vector<Partition> ::const_iterator _iter1927;
-    for (_iter1927 = this->new_parts.begin(); _iter1927 != this->new_parts.end(); ++_iter1927)
-    {
-      xfer += (*_iter1927).write(oprot);
->>>>>>> External metastore: clean after rebase
+      xfer += (*_iter1937).write(oprot);
     }
     xfer += oprot->writeListEnd();
   }
@@ -16557,17 +15772,10 @@ uint32_t ThriftHiveMetastore_add_partitions_pargs::write(::apache::thrift::proto
   xfer += oprot->writeFieldBegin("new_parts", ::apache::thrift::protocol::T_LIST, 1);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->new_parts)).size()));
-<<<<<<< HEAD
-    std::vector<Partition> ::const_iterator _iter1900;
-    for (_iter1900 = (*(this->new_parts)).begin(); _iter1900 != (*(this->new_parts)).end(); ++_iter1900)
-    {
-      xfer += (*_iter1900).write(oprot);
-=======
-    std::vector<Partition> ::const_iterator _iter1928;
-    for (_iter1928 = (*(this->new_parts)).begin(); _iter1928 != (*(this->new_parts)).end(); ++_iter1928)
+    std::vector<Partition> ::const_iterator _iter1938;
+    for (_iter1938 = (*(this->new_parts)).begin(); _iter1938 != (*(this->new_parts)).end(); ++_iter1938)
     {
-      xfer += (*_iter1928).write(oprot);
->>>>>>> External metastore: clean after rebase
+      xfer += (*_iter1938).write(oprot);
     }
     xfer += oprot->writeListEnd();
   }
@@ -16776,25 +15984,14 @@ uint32_t ThriftHiveMetastore_add_partitions_pspec_args::read(::apache::thrift::p
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->new_parts.clear();
-<<<<<<< HEAD
-            uint32_t _size1901;
-            ::apache::thrift::protocol::TType _etype1904;
-            xfer += iprot->readListBegin(_etype1904, _size1901);
-            this->new_parts.resize(_size1901);
-            uint32_t _i1905;
-            for (_i1905 = 0; _i1905 < _size1901; ++_i1905)
+            uint32_t _size1939;
+            ::apache::thrift::protocol::TType _etype1942;
+            xfer += iprot->readListBegin(_etype1942, _size1939);
+            this->new_parts.resize(_size1939);
+            uint32_t _i1943;
+            for (_i1943 = 0; _i1943 < _size1939; ++_i1943)
             {
-              xfer += this->new_parts[_i1905].read(iprot);
-=======
-            uint32_t _size1929;
-            ::apache::thrift::protocol::TType _etype1932;
-            xfer += iprot->readListBegin(_etype1932, _size1929);
-            this->new_parts.resize(_size1929);
-            uint32_t _i1933;
-            for (_i1933 = 0; _i1933 < _size1929; ++_i1933)
-            {
-              xfer += this->new_parts[_i1933].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->new_parts[_i1943].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -16823,17 +16020,10 @@ uint32_t ThriftHiveMetastore_add_partitions_pspec_args::write(::apache::thrift::
   xfer += oprot->writeFieldBegin("new_parts", ::apache::thrift::protocol::T_LIST, 1);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->new_parts.size()));
-<<<<<<< HEAD
-    std::vector<PartitionSpec> ::const_iterator _iter1906;
-    for (_iter1906 = this->new_parts.begin(); _iter1906 != this->new_parts.end(); ++_iter1906)
-    {
-      xfer += (*_iter1906).write(oprot);
-=======
-    std::vector<PartitionSpec> ::const_iterator _iter1934;
-    for (_iter1934 = this->new_parts.begin(); _iter1934 != this->new_parts.end(); ++_iter1934)
+    std::vector<PartitionSpec> ::const_iterator _iter1944;
+    for (_iter1944 = this->new_parts.begin(); _iter1944 != this->new_parts.end(); ++_iter1944)
     {
-      xfer += (*_iter1934).write(oprot);
->>>>>>> External metastore: clean after rebase
+      xfer += (*_iter1944).write(oprot);
     }
     xfer += oprot->writeListEnd();
   }
@@ -16857,17 +16047,10 @@ uint32_t ThriftHiveMetastore_add_partitions_pspec_pargs::write(::apache::thrift:
   xfer += oprot->writeFieldBegin("new_parts", ::apache::thrift::protocol::T_LIST, 1);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->new_parts)).size()));
-<<<<<<< HEAD
-    std::vector<PartitionSpec> ::const_iterator _iter1907;
-    for (_iter1907 = (*(this->new_parts)).begin(); _iter1907 != (*(this->new_parts)).end(); ++_iter1907)
+    std::vector<PartitionSpec> ::const_iterator _iter1945;
+    for (_iter1945 = (*(this->new_parts)).begin(); _iter1945 != (*(this->new_parts)).end(); ++_iter1945)
     {
-      xfer += (*_iter1907).write(oprot);
-=======
-    std::vector<PartitionSpec> ::const_iterator _iter1935;
-    for (_iter1935 = (*(this->new_parts)).begin(); _iter1935 != (*(this->new_parts)).end(); ++_iter1935)
-    {
-      xfer += (*_iter1935).write(oprot);
->>>>>>> External metastore: clean after rebase
+      xfer += (*_iter1945).write(oprot);
     }
     xfer += oprot->writeListEnd();
   }
@@ -17092,25 +16275,14 @@ uint32_t ThriftHiveMetastore_append_partition_args::read(::apache::thrift::proto
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
-<<<<<<< HEAD
-            uint32_t _size1908;
-            ::apache::thrift::protocol::TType _etype1911;
-            xfer += iprot->readListBegin(_etype1911, _size1908);
-            this->part_vals.resize(_size1908);
-            uint32_t _i1912;
-            for (_i1912 = 0; _i1912 < _size1908; ++_i1912)
-            {
-              xfer += iprot->readString(this->part_vals[_i1912]);
-=======
-            uint32_t _size1936;
-            ::apache::thrift::protocol::TType _etype1939;
-            xfer += iprot->readListBegin(_etype1939, _size1936);
-            this->part_vals.resize(_size1936);
-            uint32_t _i1940;
-            for (_i1940 = 0; _i1940 < _size1936; ++_i1940)
+            uint32_t _size1946;
+            ::apache::thrift::protocol::TType _etype1949;
+            xfer += iprot->readListBegin(_etype1949, _size1946);
+            this->part_vals.resize(_size1946);
+            uint32_t _i1950;
+            for (_i1950 = 0; _i1950 < _size1946; ++_i1950)
             {
-              xfer += iprot->readString(this->part_vals[_i1940]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->part_vals[_i1950]);
             }
             xfer += iprot->readListEnd();
           }
@@ -17147,17 +16319,10 @@ uint32_t ThriftHiveMetastore_append_partition_args::write(::apache::thrift::prot
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter1913;
-    for (_iter1913 = this->part_vals.begin(); _iter1913 != this->part_vals.end(); ++_iter1913)
+    std::vector<std::string> ::const_iterator _iter1951;
+    for (_iter1951 = this->part_vals.begin(); _iter1951 != this->part_vals.end(); ++_iter1951)
     {
-      xfer += oprot->writeString((*_iter1913));
-=======
-    std::vector<std::string> ::const_iterator _iter1941;
-    for (_iter1941 = this->part_vals.begin(); _iter1941 != this->part_vals.end(); ++_iter1941)
-    {
-      xfer += oprot->writeString((*_iter1941));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter1951));
     }
     xfer += oprot->writeListEnd();
   }
@@ -17189,17 +16354,10 @@ uint32_t ThriftHiveMetastore_append_partition_pargs::write(::apache::thrift::pro
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter1914;
-    for (_iter1914 = (*(this->part_vals)).begin(); _iter1914 != (*(this->part_vals)).end(); ++_iter1914)
-    {
-      xfer += oprot->writeString((*_iter1914));
-=======
-    std::vector<std::string> ::const_iterator _iter1942;
-    for (_iter1942 = (*(this->part_vals)).begin(); _iter1942 != (*(this->part_vals)).end(); ++_iter1942)
+    std::vector<std::string> ::const_iterator _iter1952;
+    for (_iter1952 = (*(this->part_vals)).begin(); _iter1952 != (*(this->part_vals)).end(); ++_iter1952)
     {
-      xfer += oprot->writeString((*_iter1942));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter1952));
     }
     xfer += oprot->writeListEnd();
   }
@@ -17671,25 +16829,14 @@ uint32_t ThriftHiveMetastore_append_partition_with_environment_context_args::rea
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
-<<<<<<< HEAD
-            uint32_t _size1915;
-            ::apache::thrift::protocol::TType _etype1918;
-            xfer += iprot->readListBegin(_etype1918, _size1915);
-            this->part_vals.resize(_size1915);
-            uint32_t _i1919;
-            for (_i1919 = 0; _i1919 < _size1915; ++_i1919)
+            uint32_t _size1953;
+            ::apache::thrift::protocol::TType _etype1956;
+            xfer += iprot->readListBegin(_etype1956, _size1953);
+            this->part_vals.resize(_size1953);
+            uint32_t _i1957;
+            for (_i1957 = 0; _i1957 < _size1953; ++_i1957)
             {
-              xfer += iprot->readString(this->part_vals[_i1919]);
-=======
-            uint32_t _size1943;
-            ::apache::thrift::protocol::TType _etype1946;
-            xfer += iprot->readListBegin(_etype1946, _size1943);
-            this->part_vals.resize(_size1943);
-            uint32_t _i1947;
-            for (_i1947 = 0; _i1947 < _size1943; ++_i1947)
-            {
-              xfer += iprot->readString(this->part_vals[_i1947]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->part_vals[_i1957]);
             }
             xfer += iprot->readListEnd();
           }
@@ -17734,17 +16881,10 @@ uint32_t ThriftHiveMetastore_append_partition_with_environment_context_args::wri
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter1920;
-    for (_iter1920 = this->part_vals.begin(); _iter1920 != this->part_vals.end(); ++_iter1920)
-    {
-      xfer += oprot->writeString((*_iter1920));
-=======
-    std::vector<std::string> ::const_iterator _iter1948;
-    for (_iter1948 = this->part_vals.begin(); _iter1948 != this->part_vals.end(); ++_iter1948)
+    std::vector<std::string> ::const_iterator _iter1958;
+    for (_iter1958 = this->part_vals.begin(); _iter1958 != this->part_vals.end(); ++_iter1958)
     {
-      xfer += oprot->writeString((*_iter1948));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter1958));
     }
     xfer += oprot->writeListEnd();
   }
@@ -17780,17 +16920,10 @@ uint32_t ThriftHiveMetastore_append_partition_with_environment_context_pargs::wr
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter1921;
-    for (_iter1921 = (*(this->part_vals)).begin(); _iter1921 != (*(this->part_vals)).end(); ++_iter1921)
+    std::vector<std::string> ::const_iterator _iter1959;
+    for (_iter1959 = (*(this->part_vals)).begin(); _iter1959 != (*(this->part_vals)).end(); ++_iter1959)
     {
-      xfer += oprot->writeString((*_iter1921));
-=======
-    std::vector<std::string> ::const_iterator _iter1949;
-    for (_iter1949 = (*(this->part_vals)).begin(); _iter1949 != (*(this->part_vals)).end(); ++_iter1949)
-    {
-      xfer += oprot->writeString((*_iter1949));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter1959));
     }
     xfer += oprot->writeListEnd();
   }
@@ -18593,25 +17726,14 @@ uint32_t ThriftHiveMetastore_drop_partition_args::read(::apache::thrift::protoco
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
-<<<<<<< HEAD
-            uint32_t _size1922;
-            ::apache::thrift::protocol::TType _etype1925;
-            xfer += iprot->readListBegin(_etype1925, _size1922);
-            this->part_vals.resize(_size1922);
-            uint32_t _i1926;
-            for (_i1926 = 0; _i1926 < _size1922; ++_i1926)
-            {
-              xfer += iprot->readString(this->part_vals[_i1926]);
-=======
-            uint32_t _size1950;
-            ::apache::thrift::protocol::TType _etype1953;
-            xfer += iprot->readListBegin(_etype1953, _size1950);
-            this->part_vals.resize(_size1950);
-            uint32_t _i1954;
-            for (_i1954 = 0; _i1954 < _size1950; ++_i1954)
+            uint32_t _size1960;
+            ::apache::thrift::protocol::TType _etype1963;
+            xfer += iprot->readListBegin(_etype1963, _size1960);
+            this->part_vals.resize(_size1960);
+            uint32_t _i1964;
+            for (_i1964 = 0; _i1964 < _size1960; ++_i1964)
             {
-              xfer += iprot->readString(this->part_vals[_i1954]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->part_vals[_i1964]);
             }
             xfer += iprot->readListEnd();
           }
@@ -18656,17 +17778,10 @@ uint32_t ThriftHiveMetastore_drop_partition_args::write(::apache::thrift::protoc
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter1927;
-    for (_iter1927 = this->part_vals.begin(); _iter1927 != this->part_vals.end(); ++_iter1927)
+    std::vector<std::string> ::const_iterator _iter1965;
+    for (_iter1965 = this->part_vals.begin(); _iter1965 != this->part_vals.end(); ++_iter1965)
     {
-      xfer += oprot->writeString((*_iter1927));
-=======
-    std::vector<std::string> ::const_iterator _iter1955;
-    for (_iter1955 = this->part_vals.begin(); _iter1955 != this->part_vals.end(); ++_iter1955)
-    {
-      xfer += oprot->writeString((*_iter1955));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter1965));
     }
     xfer += oprot->writeListEnd();
   }
@@ -18702,17 +17817,10 @@ uint32_t ThriftHiveMetastore_drop_partition_pargs::write(::apache::thrift::proto
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter1928;
-    for (_iter1928 = (*(this->part_vals)).begin(); _iter1928 != (*(this->part_vals)).end(); ++_iter1928)
-    {
-      xfer += oprot->writeString((*_iter1928));
-=======
-    std::vector<std::string> ::const_iterator _iter1956;
-    for (_iter1956 = (*(this->part_vals)).begin(); _iter1956 != (*(this->part_vals)).end(); ++_iter1956)
+    std::vector<std::string> ::const_iterator _iter1966;
+    for (_iter1966 = (*(this->part_vals)).begin(); _iter1966 != (*(this->part_vals)).end(); ++_iter1966)
     {
-      xfer += oprot->writeString((*_iter1956));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter1966));
     }
     xfer += oprot->writeListEnd();
   }
@@ -18921,25 +18029,14 @@ uint32_t ThriftHiveMetastore_drop_partition_with_environment_context_args::read(
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
-<<<<<<< HEAD
-            uint32_t _size1929;
-            ::apache::thrift::protocol::TType _etype1932;
-            xfer += iprot->readListBegin(_etype1932, _size1929);
-            this->part_vals.resize(_size1929);
-            uint32_t _i1933;
-            for (_i1933 = 0; _i1933 < _size1929; ++_i1933)
-            {
-              xfer += iprot->readString(this->part_vals[_i1933]);
-=======
-            uint32_t _size1957;
-            ::apache::thrift::protocol::TType _etype1960;
-            xfer += iprot->readListBegin(_etype1960, _size1957);
-            this->part_vals.resize(_size1957);
-            uint32_t _i1961;
-            for (_i1961 = 0; _i1961 < _size1957; ++_i1961)
+            uint32_t _size1967;
+            ::apache::thrift::protocol::TType _etype1970;
+            xfer += iprot->readListBegin(_etype1970, _size1967);
+            this->part_vals.resize(_size1967);
+            uint32_t _i1971;
+            for (_i1971 = 0; _i1971 < _size1967; ++_i1971)
             {
-              xfer += iprot->readString(this->part_vals[_i1961]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->part_vals[_i1971]);
             }
             xfer += iprot->readListEnd();
           }
@@ -18992,17 +18089,10 @@ uint32_t ThriftHiveMetastore_drop_partition_with_environment_context_args::write
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter1934;
-    for (_iter1934 = this->part_vals.begin(); _iter1934 != this->part_vals.end(); ++_iter1934)
+    std::vector<std::string> ::const_iterator _iter1972;
+    for (_iter1972 = this->part_vals.begin(); _iter1972 != this->part_vals.end(); ++_iter1972)
     {
-      xfer += oprot->writeString((*_iter1934));
-=======
-    std::vector<std::string> ::const_iterator _iter1962;
-    for (_iter1962 = this->part_vals.begin(); _iter1962 != this->part_vals.end(); ++_iter1962)
-    {
-      xfer += oprot->writeString((*_iter1962));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter1972));
     }
     xfer += oprot->writeListEnd();
   }
@@ -19042,17 +18132,10 @@ uint32_t ThriftHiveMetastore_drop_partition_with_environment_context_pargs::writ
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter1935;
-    for (_iter1935 = (*(this->part_vals)).begin(); _iter1935 != (*(this->part_vals)).end(); ++_iter1935)
-    {
-      xfer += oprot->writeString((*_iter1935));
-=======
-    std::vector<std::string> ::const_iterator _iter1963;
-    for (_iter1963 = (*(this->part_vals)).begin(); _iter1963 != (*(this->part_vals)).end(); ++_iter1963)
+    std::vector<std::string> ::const_iterator _iter1973;
+    for (_iter1973 = (*(this->part_vals)).begin(); _iter1973 != (*(this->part_vals)).end(); ++_iter1973)
     {
-      xfer += oprot->writeString((*_iter1963));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter1973));
     }
     xfer += oprot->writeListEnd();
   }
@@ -20058,25 +19141,14 @@ uint32_t ThriftHiveMetastore_get_partition_args::read(::apache::thrift::protocol
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
-<<<<<<< HEAD
-            uint32_t _size1936;
-            ::apache::thrift::protocol::TType _etype1939;
-            xfer += iprot->readListBegin(_etype1939, _size1936);
-            this->part_vals.resize(_size1936);
-            uint32_t _i1940;
-            for (_i1940 = 0; _i1940 < _size1936; ++_i1940)
+            uint32_t _size1974;
+            ::apache::thrift::protocol::TType _etype1977;
+            xfer += iprot->readListBegin(_etype1977, _size1974);
+            this->part_vals.resize(_size1974);
+            uint32_t _i1978;
+            for (_i1978 = 0; _i1978 < _size1974; ++_i1978)
             {
-              xfer += iprot->readString(this->part_vals[_i1940]);
-=======
-            uint32_t _size1964;
-            ::apache::thrift::protocol::TType _etype1967;
-            xfer += iprot->readListBegin(_etype1967, _size1964);
-            this->part_vals.resize(_size1964);
-            uint32_t _i1968;
-            for (_i1968 = 0; _i1968 < _size1964; ++_i1968)
-            {
-              xfer += iprot->readString(this->part_vals[_i1968]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->part_vals[_i1978]);
             }
             xfer += iprot->readListEnd();
           }
@@ -20113,17 +19185,10 @@ uint32_t ThriftHiveMetastore_get_partition_args::write(::apache::thrift::protoco
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter1941;
-    for (_iter1941 = this->part_vals.begin(); _iter1941 != this->part_vals.end(); ++_iter1941)
-    {
-      xfer += oprot->writeString((*_iter1941));
-=======
-    std::vector<std::string> ::const_iterator _iter1969;
-    for (_iter1969 = this->part_vals.begin(); _iter1969 != this->part_vals.end(); ++_iter1969)
+    std::vector<std::string> ::const_iterator _iter1979;
+    for (_iter1979 = this->part_vals.begin(); _iter1979 != this->part_vals.end(); ++_iter1979)
     {
-      xfer += oprot->writeString((*_iter1969));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter1979));
     }
     xfer += oprot->writeListEnd();
   }
@@ -20155,17 +19220,10 @@ uint32_t ThriftHiveMetastore_get_partition_pargs::write(::apache::thrift::protoc
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter1942;
-    for (_iter1942 = (*(this->part_vals)).begin(); _iter1942 != (*(this->part_vals)).end(); ++_iter1942)
+    std::vector<std::string> ::const_iterator _iter1980;
+    for (_iter1980 = (*(this->part_vals)).begin(); _iter1980 != (*(this->part_vals)).end(); ++_iter1980)
     {
-      xfer += oprot->writeString((*_iter1942));
-=======
-    std::vector<std::string> ::const_iterator _iter1970;
-    for (_iter1970 = (*(this->part_vals)).begin(); _iter1970 != (*(this->part_vals)).end(); ++_iter1970)
-    {
-      xfer += oprot->writeString((*_iter1970));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter1980));
     }
     xfer += oprot->writeListEnd();
   }
@@ -20581,31 +19639,17 @@ uint32_t ThriftHiveMetastore_exchange_partition_args::read(::apache::thrift::pro
         if (ftype == ::apache::thrift::protocol::T_MAP) {
           {
             this->partitionSpecs.clear();
-<<<<<<< HEAD
-            uint32_t _size1943;
-            ::apache::thrift::protocol::TType _ktype1944;
-            ::apache::thrift::protocol::TType _vtype1945;
-            xfer += iprot->readMapBegin(_ktype1944, _vtype1945, _size1943);
-            uint32_t _i1947;
-            for (_i1947 = 0; _i1947 < _size1943; ++_i1947)
-            {
-              std::string _key1948;
-              xfer += iprot->readString(_key1948);
-              std::string& _val1949 = this->partitionSpecs[_key1948];
-              xfer += iprot->readString(_val1949);
-=======
-            uint32_t _size1971;
-            ::apache::thrift::protocol::TType _ktype1972;
-            ::apache::thrift::protocol::TType _vtype1973;
-            xfer += iprot->readMapBegin(_ktype1972, _vtype1973, _size1971);
-            uint32_t _i1975;
-            for (_i1975 = 0; _i1975 < _size1971; ++_i1975)
+            uint32_t _size1981;
+            ::apache::thrift::protocol::TType _ktype1982;
+            ::apache::thrift::protocol::TType _vtype1983;
+            xfer += iprot->readMapBegin(_ktype1982, _vtype1983, _size1981);
+            uint32_t _i1985;
+            for (_i1985 = 0; _i1985 < _size1981; ++_i1985)
             {
-              std::string _key1976;
-              xfer += iprot->readString(_key1976);
-              std::string& _val1977 = this->partitionSpecs[_key1976];
-              xfer += iprot->readString(_val1977);
->>>>>>> External metastore: clean after rebase
+              std::string _key1986;
+              xfer += iprot->readString(_key1986);
+              std::string& _val1987 = this->partitionSpecs[_key1986];
+              xfer += iprot->readString(_val1987);
             }
             xfer += iprot->readMapEnd();
           }
@@ -20666,19 +19710,11 @@ uint32_t ThriftHiveMetastore_exchange_partition_args::write(::apache::thrift::pr
   xfer += oprot->writeFieldBegin("partitionSpecs", ::apache::thrift::protocol::T_MAP, 1);
   {
     xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->partitionSpecs.size()));
-<<<<<<< HEAD
-    std::map<std::string, std::string> ::const_iterator _iter1950;
-    for (_iter1950 = this->partitionSpecs.begin(); _iter1950 != this->partitionSpecs.end(); ++_iter1950)
-    {
-      xfer += oprot->writeString(_iter1950->first);
-      xfer += oprot->writeString(_iter1950->second);
-=======
-    std::map<std::string, std::string> ::const_iterator _iter1978;
-    for (_iter1978 = this->partitionSpecs.begin(); _iter1978 != this->partitionSpecs.end(); ++_iter1978)
+    std::map<std::string, std::string> ::const_iterator _iter1988;
+    for (_iter1988 = this->partitionSpecs.begin(); _iter1988 != this->partitionSpecs.end(); ++_iter1988)
     {
-      xfer += oprot->writeString(_iter1978->first);
-      xfer += oprot->writeString(_iter1978->second);
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString(_iter1988->first);
+      xfer += oprot->writeString(_iter1988->second);
     }
     xfer += oprot->writeMapEnd();
   }
@@ -20718,19 +19754,11 @@ uint32_t ThriftHiveMetastore_exchange_partition_pargs::write(::apache::thrift::p
   xfer += oprot->writeFieldBegin("partitionSpecs", ::apache::thrift::protocol::T_MAP, 1);
   {
     xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->partitionSpecs)).size()));
-<<<<<<< HEAD
-    std::map<std::string, std::string> ::const_iterator _iter1951;
-    for (_iter1951 = (*(this->partitionSpecs)).begin(); _iter1951 != (*(this->partitionSpecs)).end(); ++_iter1951)
-    {
-      xfer += oprot->writeString(_iter1951->first);
-      xfer += oprot->writeString(_iter1951->second);
-=======
-    std::map<std::string, std::string> ::const_iterator _iter1979;
-    for (_iter1979 = (*(this->partitionSpecs)).begin(); _iter1979 != (*(this->partitionSpecs)).end(); ++_iter1979)
+    std::map<std::string, std::string> ::const_iterator _iter1989;
+    for (_iter1989 = (*(this->partitionSpecs)).begin(); _iter1989 != (*(this->partitionSpecs)).end(); ++_iter1989)
     {
-      xfer += oprot->writeString(_iter1979->first);
-      xfer += oprot->writeString(_iter1979->second);
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString(_iter1989->first);
+      xfer += oprot->writeString(_iter1989->second);
     }
     xfer += oprot->writeMapEnd();
   }
@@ -20975,31 +20003,17 @@ uint32_t ThriftHiveMetastore_exchange_partitions_args::read(::apache::thrift::pr
         if (ftype == ::apache::thrift::protocol::T_MAP) {
           {
             this->partitionSpecs.clear();
-<<<<<<< HEAD
-            uint32_t _size1952;
-            ::apache::thrift::protocol::TType _ktype1953;
-            ::apache::thrift::protocol::TType _vtype1954;
-            xfer += iprot->readMapBegin(_ktype1953, _vtype1954, _size1952);
-            uint32_t _i1956;
-            for (_i1956 = 0; _i1956 < _size1952; ++_i1956)
+            uint32_t _size1990;
+            ::apache::thrift::protocol::TType _ktype1991;
+            ::apache::thrift::protocol::TType _vtype1992;
+            xfer += iprot->readMapBegin(_ktype1991, _vtype1992, _size1990);
+            uint32_t _i1994;
+            for (_i1994 = 0; _i1994 < _size1990; ++_i1994)
             {
-              std::string _key1957;
-              xfer += iprot->readString(_key1957);
-              std::string& _val1958 = this->partitionSpecs[_key1957];
-              xfer += iprot->readString(_val1958);
-=======
-            uint32_t _size1980;
-            ::apache::thrift::protocol::TType _ktype1981;
-            ::apache::thrift::protocol::TType _vtype1982;
-            xfer += iprot->readMapBegin(_ktype1981, _vtype1982, _size1980);
-            uint32_t _i1984;
-            for (_i1984 = 0; _i1984 < _size1980; ++_i1984)
-            {
-              std::string _key1985;
-              xfer += iprot->readString(_key1985);
-              std::string& _val1986 = this->partitionSpecs[_key1985];
-              xfer += iprot->readString(_val1986);
->>>>>>> External metastore: clean after rebase
+              std::string _key1995;
+              xfer += iprot->readString(_key1995);
+              std::string& _val1996 = this->partitionSpecs[_key1995];
+              xfer += iprot->readString(_val1996);
             }
             xfer += iprot->readMapEnd();
           }
@@ -21060,19 +20074,11 @@ uint32_t ThriftHiveMetastore_exchange_partitions_args::write(::apache::thrift::p
   xfer += oprot->writeFieldBegin("partitionSpecs", ::apache::thrift::protocol::T_MAP, 1);
   {
     xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->partitionSpecs.size()));
-<<<<<<< HEAD
-    std::map<std::string, std::string> ::const_iterator _iter1959;
-    for (_iter1959 = this->partitionSpecs.begin(); _iter1959 != this->partitionSpecs.end(); ++_iter1959)
-    {
-      xfer += oprot->writeString(_iter1959->first);
-      xfer += oprot->writeString(_iter1959->second);
-=======
-    std::map<std::string, std::string> ::const_iterator _iter1987;
-    for (_iter1987 = this->partitionSpecs.begin(); _iter1987 != this->partitionSpecs.end(); ++_iter1987)
+    std::map<std::string, std::string> ::const_iterator _iter1997;
+    for (_iter1997 = this->partitionSpecs.begin(); _iter1997 != this->partitionSpecs.end(); ++_iter1997)
     {
-      xfer += oprot->writeString(_iter1987->first);
-      xfer += oprot->writeString(_iter1987->second);
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString(_iter1997->first);
+      xfer += oprot->writeString(_iter1997->second);
     }
     xfer += oprot->writeMapEnd();
   }
@@ -21112,19 +20118,11 @@ uint32_t ThriftHiveMetastore_exchange_partitions_pargs::write(::apache::thrift::
   xfer += oprot->writeFieldBegin("partitionSpecs", ::apache::thrift::protocol::T_MAP, 1);
   {
     xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->partitionSpecs)).size()));
-<<<<<<< HEAD
-    std::map<std::string, std::string> ::const_iterator _iter1960;
-    for (_iter1960 = (*(this->partitionSpecs)).begin(); _iter1960 != (*(this->partitionSpecs)).end(); ++_iter1960)
-    {
-      xfer += oprot->writeString(_iter1960->first);
-      xfer += oprot->writeString(_iter1960->second);
-=======
-    std::map<std::string, std::string> ::const_iterator _iter1988;
-    for (_iter1988 = (*(this->partitionSpecs)).begin(); _iter1988 != (*(this->partitionSpecs)).end(); ++_iter1988)
+    std::map<std::string, std::string> ::const_iterator _iter1998;
+    for (_iter1998 = (*(this->partitionSpecs)).begin(); _iter1998 != (*(this->partitionSpecs)).end(); ++_iter1998)
     {
-      xfer += oprot->writeString(_iter1988->first);
-      xfer += oprot->writeString(_iter1988->second);
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString(_iter1998->first);
+      xfer += oprot->writeString(_iter1998->second);
     }
     xfer += oprot->writeMapEnd();
   }
@@ -21181,25 +20179,14 @@ uint32_t ThriftHiveMetastore_exchange_partitions_result::read(::apache::thrift::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size1961;
-            ::apache::thrift::protocol::TType _etype1964;
-            xfer += iprot->readListBegin(_etype1964, _size1961);
-            this->success.resize(_size1961);
-            uint32_t _i1965;
-            for (_i1965 = 0; _i1965 < _size1961; ++_i1965)
+            uint32_t _size1999;
+            ::apache::thrift::protocol::TType _etype2002;
+            xfer += iprot->readListBegin(_etype2002, _size1999);
+            this->success.resize(_size1999);
+            uint32_t _i2003;
+            for (_i2003 = 0; _i2003 < _size1999; ++_i2003)
             {
-              xfer += this->success[_i1965].read(iprot);
-=======
-            uint32_t _size1989;
-            ::apache::thrift::protocol::TType _etype1992;
-            xfer += iprot->readListBegin(_etype1992, _size1989);
-            this->success.resize(_size1989);
-            uint32_t _i1993;
-            for (_i1993 = 0; _i1993 < _size1989; ++_i1993)
-            {
-              xfer += this->success[_i1993].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->success[_i2003].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -21262,17 +20249,10 @@ uint32_t ThriftHiveMetastore_exchange_partitions_result::write(::apache::thrift:
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<Partition> ::const_iterator _iter1966;
-      for (_iter1966 = this->success.begin(); _iter1966 != this->success.end(); ++_iter1966)
-      {
-        xfer += (*_iter1966).write(oprot);
-=======
-      std::vector<Partition> ::const_iterator _iter1994;
-      for (_iter1994 = this->success.begin(); _iter1994 != this->success.end(); ++_iter1994)
+      std::vector<Partition> ::const_iterator _iter2004;
+      for (_iter2004 = this->success.begin(); _iter2004 != this->success.end(); ++_iter2004)
       {
-        xfer += (*_iter1994).write(oprot);
->>>>>>> External metastore: clean after rebase
+        xfer += (*_iter2004).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -21329,161 +20309,14 @@ uint32_t ThriftHiveMetastore_exchange_partitions_presult::read(::apache::thrift:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size1967;
-            ::apache::thrift::protocol::TType _etype1970;
-            xfer += iprot->readListBegin(_etype1970, _size1967);
-            (*(this->success)).resize(_size1967);
-            uint32_t _i1971;
-            for (_i1971 = 0; _i1971 < _size1967; ++_i1971)
-            {
-              xfer += (*(this->success))[_i1971].read(iprot);
-            }
-            xfer += iprot->readListEnd();
-          }
-          this->__isset.success = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 1:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o1.read(iprot);
-          this->__isset.o1 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 2:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o2.read(iprot);
-          this->__isset.o2 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 3:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o3.read(iprot);
-          this->__isset.o3 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 4:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o4.read(iprot);
-          this->__isset.o4 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      default:
-        xfer += iprot->skip(ftype);
-        break;
-    }
-    xfer += iprot->readFieldEnd();
-  }
-
-  xfer += iprot->readStructEnd();
-
-  return xfer;
-}
-
-
-ThriftHiveMetastore_get_partition_with_auth_args::~ThriftHiveMetastore_get_partition_with_auth_args() noexcept {
-}
-
-
-uint32_t ThriftHiveMetastore_get_partition_with_auth_args::read(::apache::thrift::protocol::TProtocol* iprot) {
-
-  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
-  uint32_t xfer = 0;
-  std::string fname;
-  ::apache::thrift::protocol::TType ftype;
-  int16_t fid;
-
-  xfer += iprot->readStructBegin(fname);
-
-  using ::apache::thrift::protocol::TProtocolException;
-
-
-  while (true)
-  {
-    xfer += iprot->readFieldBegin(fname, ftype, fid);
-    if (ftype == ::apache::thrift::protocol::T_STOP) {
-      break;
-    }
-    switch (fid)
-    {
-      case 1:
-        if (ftype == ::apache::thrift::protocol::T_STRING) {
-          xfer += iprot->readString(this->db_name);
-          this->__isset.db_name = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 2:
-        if (ftype == ::apache::thrift::protocol::T_STRING) {
-          xfer += iprot->readString(this->tbl_name);
-          this->__isset.tbl_name = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 3:
-        if (ftype == ::apache::thrift::protocol::T_LIST) {
-          {
-            this->part_vals.clear();
-            uint32_t _size1972;
-            ::apache::thrift::protocol::TType _etype1975;
-            xfer += iprot->readListBegin(_etype1975, _size1972);
-            this->part_vals.resize(_size1972);
-            uint32_t _i1976;
-            for (_i1976 = 0; _i1976 < _size1972; ++_i1976)
-            {
-              xfer += iprot->readString(this->part_vals[_i1976]);
-            }
-            xfer += iprot->readListEnd();
-          }
-          this->__isset.part_vals = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 4:
-        if (ftype == ::apache::thrift::protocol::T_STRING) {
-          xfer += iprot->readString(this->user_name);
-          this->__isset.user_name = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 5:
-        if (ftype == ::apache::thrift::protocol::T_LIST) {
-          {
-            this->group_names.clear();
-            uint32_t _size1977;
-            ::apache::thrift::protocol::TType _etype1980;
-            xfer += iprot->readListBegin(_etype1980, _size1977);
-            this->group_names.resize(_size1977);
-            uint32_t _i1981;
-            for (_i1981 = 0; _i1981 < _size1977; ++_i1981)
-            {
-              xfer += iprot->readString(this->group_names[_i1981]);
-            }
-            xfer += iprot->readListEnd();
-          }
-=======
-            uint32_t _size1995;
-            ::apache::thrift::protocol::TType _etype1998;
-            xfer += iprot->readListBegin(_etype1998, _size1995);
-            (*(this->success)).resize(_size1995);
-            uint32_t _i1999;
-            for (_i1999 = 0; _i1999 < _size1995; ++_i1999)
+            uint32_t _size2005;
+            ::apache::thrift::protocol::TType _etype2008;
+            xfer += iprot->readListBegin(_etype2008, _size2005);
+            (*(this->success)).resize(_size2005);
+            uint32_t _i2009;
+            for (_i2009 = 0; _i2009 < _size2005; ++_i2009)
             {
-              xfer += (*(this->success))[_i1999].read(iprot);
+              xfer += (*(this->success))[_i2009].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -21582,14 +20415,14 @@ uint32_t ThriftHiveMetastore_get_partition_with_auth_args::read(::apache::thrift
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
-            uint32_t _size2000;
-            ::apache::thrift::protocol::TType _etype2003;
-            xfer += iprot->readListBegin(_etype2003, _size2000);
-            this->part_vals.resize(_size2000);
-            uint32_t _i2004;
-            for (_i2004 = 0; _i2004 < _size2000; ++_i2004)
+            uint32_t _size2010;
+            ::apache::thrift::protocol::TType _etype2013;
+            xfer += iprot->readListBegin(_etype2013, _size2010);
+            this->part_vals.resize(_size2010);
+            uint32_t _i2014;
+            for (_i2014 = 0; _i2014 < _size2010; ++_i2014)
             {
-              xfer += iprot->readString(this->part_vals[_i2004]);
+              xfer += iprot->readString(this->part_vals[_i2014]);
             }
             xfer += iprot->readListEnd();
           }
@@ -21610,18 +20443,17 @@ uint32_t ThriftHiveMetastore_get_partition_with_auth_args::read(::apache::thrift
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->group_names.clear();
-            uint32_t _size2005;
-            ::apache::thrift::protocol::TType _etype2008;
-            xfer += iprot->readListBegin(_etype2008, _size2005);
-            this->group_names.resize(_size2005);
-            uint32_t _i2009;
-            for (_i2009 = 0; _i2009 < _size2005; ++_i2009)
+            uint32_t _size2015;
+            ::apache::thrift::protocol::TType _etype2018;
+            xfer += iprot->readListBegin(_etype2018, _size2015);
+            this->group_names.resize(_size2015);
+            uint32_t _i2019;
+            for (_i2019 = 0; _i2019 < _size2015; ++_i2019)
             {
-              xfer += iprot->readString(this->group_names[_i2009]);
+              xfer += iprot->readString(this->group_names[_i2019]);
             }
             xfer += iprot->readListEnd();
           }
->>>>>>> External metastore: clean after rebase
           this->__isset.group_names = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -21655,17 +20487,10 @@ uint32_t ThriftHiveMetastore_get_partition_with_auth_args::write(::apache::thrif
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter1982;
-    for (_iter1982 = this->part_vals.begin(); _iter1982 != this->part_vals.end(); ++_iter1982)
+    std::vector<std::string> ::const_iterator _iter2020;
+    for (_iter2020 = this->part_vals.begin(); _iter2020 != this->part_vals.end(); ++_iter2020)
     {
-      xfer += oprot->writeString((*_iter1982));
-=======
-    std::vector<std::string> ::const_iterator _iter2010;
-    for (_iter2010 = this->part_vals.begin(); _iter2010 != this->part_vals.end(); ++_iter2010)
-    {
-      xfer += oprot->writeString((*_iter2010));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2020));
     }
     xfer += oprot->writeListEnd();
   }
@@ -21678,17 +20503,10 @@ uint32_t ThriftHiveMetastore_get_partition_with_auth_args::write(::apache::thrif
   xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 5);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->group_names.size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter1983;
-    for (_iter1983 = this->group_names.begin(); _iter1983 != this->group_names.end(); ++_iter1983)
-    {
-      xfer += oprot->writeString((*_iter1983));
-=======
-    std::vector<std::string> ::const_iterator _iter2011;
-    for (_iter2011 = this->group_names.begin(); _iter2011 != this->group_names.end(); ++_iter2011)
+    std::vector<std::string> ::const_iterator _iter2021;
+    for (_iter2021 = this->group_names.begin(); _iter2021 != this->group_names.end(); ++_iter2021)
     {
-      xfer += oprot->writeString((*_iter2011));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2021));
     }
     xfer += oprot->writeListEnd();
   }
@@ -21720,17 +20538,10 @@ uint32_t ThriftHiveMetastore_get_partition_with_auth_pargs::write(::apache::thri
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter1984;
-    for (_iter1984 = (*(this->part_vals)).begin(); _iter1984 != (*(this->part_vals)).end(); ++_iter1984)
+    std::vector<std::string> ::const_iterator _iter2022;
+    for (_iter2022 = (*(this->part_vals)).begin(); _iter2022 != (*(this->part_vals)).end(); ++_iter2022)
     {
-      xfer += oprot->writeString((*_iter1984));
-=======
-    std::vector<std::string> ::const_iterator _iter2012;
-    for (_iter2012 = (*(this->part_vals)).begin(); _iter2012 != (*(this->part_vals)).end(); ++_iter2012)
-    {
-      xfer += oprot->writeString((*_iter2012));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2022));
     }
     xfer += oprot->writeListEnd();
   }
@@ -21743,17 +20554,10 @@ uint32_t ThriftHiveMetastore_get_partition_with_auth_pargs::write(::apache::thri
   xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 5);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->group_names)).size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter1985;
-    for (_iter1985 = (*(this->group_names)).begin(); _iter1985 != (*(this->group_names)).end(); ++_iter1985)
-    {
-      xfer += oprot->writeString((*_iter1985));
-=======
-    std::vector<std::string> ::const_iterator _iter2013;
-    for (_iter2013 = (*(this->group_names)).begin(); _iter2013 != (*(this->group_names)).end(); ++_iter2013)
+    std::vector<std::string> ::const_iterator _iter2023;
+    for (_iter2023 = (*(this->group_names)).begin(); _iter2023 != (*(this->group_names)).end(); ++_iter2023)
     {
-      xfer += oprot->writeString((*_iter2013));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2023));
     }
     xfer += oprot->writeListEnd();
   }
@@ -22312,25 +21116,14 @@ uint32_t ThriftHiveMetastore_get_partitions_result::read(::apache::thrift::proto
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size1986;
-            ::apache::thrift::protocol::TType _etype1989;
-            xfer += iprot->readListBegin(_etype1989, _size1986);
-            this->success.resize(_size1986);
-            uint32_t _i1990;
-            for (_i1990 = 0; _i1990 < _size1986; ++_i1990)
+            uint32_t _size2024;
+            ::apache::thrift::protocol::TType _etype2027;
+            xfer += iprot->readListBegin(_etype2027, _size2024);
+            this->success.resize(_size2024);
+            uint32_t _i2028;
+            for (_i2028 = 0; _i2028 < _size2024; ++_i2028)
             {
-              xfer += this->success[_i1990].read(iprot);
-=======
-            uint32_t _size2014;
-            ::apache::thrift::protocol::TType _etype2017;
-            xfer += iprot->readListBegin(_etype2017, _size2014);
-            this->success.resize(_size2014);
-            uint32_t _i2018;
-            for (_i2018 = 0; _i2018 < _size2014; ++_i2018)
-            {
-              xfer += this->success[_i2018].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->success[_i2028].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -22377,17 +21170,10 @@ uint32_t ThriftHiveMetastore_get_partitions_result::write(::apache::thrift::prot
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<Partition> ::const_iterator _iter1991;
-      for (_iter1991 = this->success.begin(); _iter1991 != this->success.end(); ++_iter1991)
-      {
-        xfer += (*_iter1991).write(oprot);
-=======
-      std::vector<Partition> ::const_iterator _iter2019;
-      for (_iter2019 = this->success.begin(); _iter2019 != this->success.end(); ++_iter2019)
+      std::vector<Partition> ::const_iterator _iter2029;
+      for (_iter2029 = this->success.begin(); _iter2029 != this->success.end(); ++_iter2029)
       {
-        xfer += (*_iter2019).write(oprot);
->>>>>>> External metastore: clean after rebase
+        xfer += (*_iter2029).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -22436,25 +21222,14 @@ uint32_t ThriftHiveMetastore_get_partitions_presult::read(::apache::thrift::prot
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size1992;
-            ::apache::thrift::protocol::TType _etype1995;
-            xfer += iprot->readListBegin(_etype1995, _size1992);
-            (*(this->success)).resize(_size1992);
-            uint32_t _i1996;
-            for (_i1996 = 0; _i1996 < _size1992; ++_i1996)
+            uint32_t _size2030;
+            ::apache::thrift::protocol::TType _etype2033;
+            xfer += iprot->readListBegin(_etype2033, _size2030);
+            (*(this->success)).resize(_size2030);
+            uint32_t _i2034;
+            for (_i2034 = 0; _i2034 < _size2030; ++_i2034)
             {
-              xfer += (*(this->success))[_i1996].read(iprot);
-=======
-            uint32_t _size2020;
-            ::apache::thrift::protocol::TType _etype2023;
-            xfer += iprot->readListBegin(_etype2023, _size2020);
-            (*(this->success)).resize(_size2020);
-            uint32_t _i2024;
-            for (_i2024 = 0; _i2024 < _size2020; ++_i2024)
-            {
-              xfer += (*(this->success))[_i2024].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += (*(this->success))[_i2034].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -22780,25 +21555,14 @@ uint32_t ThriftHiveMetastore_get_partitions_with_auth_args::read(::apache::thrif
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->group_names.clear();
-<<<<<<< HEAD
-            uint32_t _size1997;
-            ::apache::thrift::protocol::TType _etype2000;
-            xfer += iprot->readListBegin(_etype2000, _size1997);
-            this->group_names.resize(_size1997);
-            uint32_t _i2001;
-            for (_i2001 = 0; _i2001 < _size1997; ++_i2001)
-            {
-              xfer += iprot->readString(this->group_names[_i2001]);
-=======
-            uint32_t _size2025;
-            ::apache::thrift::protocol::TType _etype2028;
-            xfer += iprot->readListBegin(_etype2028, _size2025);
-            this->group_names.resize(_size2025);
-            uint32_t _i2029;
-            for (_i2029 = 0; _i2029 < _size2025; ++_i2029)
+            uint32_t _size2035;
+            ::apache::thrift::protocol::TType _etype2038;
+            xfer += iprot->readListBegin(_etype2038, _size2035);
+            this->group_names.resize(_size2035);
+            uint32_t _i2039;
+            for (_i2039 = 0; _i2039 < _size2035; ++_i2039)
             {
-              xfer += iprot->readString(this->group_names[_i2029]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->group_names[_i2039]);
             }
             xfer += iprot->readListEnd();
           }
@@ -22843,17 +21607,10 @@ uint32_t ThriftHiveMetastore_get_partitions_with_auth_args::write(::apache::thri
   xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 5);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->group_names.size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter2002;
-    for (_iter2002 = this->group_names.begin(); _iter2002 != this->group_names.end(); ++_iter2002)
+    std::vector<std::string> ::const_iterator _iter2040;
+    for (_iter2040 = this->group_names.begin(); _iter2040 != this->group_names.end(); ++_iter2040)
     {
-      xfer += oprot->writeString((*_iter2002));
-=======
-    std::vector<std::string> ::const_iterator _iter2030;
-    for (_iter2030 = this->group_names.begin(); _iter2030 != this->group_names.end(); ++_iter2030)
-    {
-      xfer += oprot->writeString((*_iter2030));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2040));
     }
     xfer += oprot->writeListEnd();
   }
@@ -22893,17 +21650,10 @@ uint32_t ThriftHiveMetastore_get_partitions_with_auth_pargs::write(::apache::thr
   xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 5);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->group_names)).size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter2003;
-    for (_iter2003 = (*(this->group_names)).begin(); _iter2003 != (*(this->group_names)).end(); ++_iter2003)
-    {
-      xfer += oprot->writeString((*_iter2003));
-=======
-    std::vector<std::string> ::const_iterator _iter2031;
-    for (_iter2031 = (*(this->group_names)).begin(); _iter2031 != (*(this->group_names)).end(); ++_iter2031)
+    std::vector<std::string> ::const_iterator _iter2041;
+    for (_iter2041 = (*(this->group_names)).begin(); _iter2041 != (*(this->group_names)).end(); ++_iter2041)
     {
-      xfer += oprot->writeString((*_iter2031));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2041));
     }
     xfer += oprot->writeListEnd();
   }
@@ -22944,25 +21694,14 @@ uint32_t ThriftHiveMetastore_get_partitions_with_auth_result::read(::apache::thr
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2004;
-            ::apache::thrift::protocol::TType _etype2007;
-            xfer += iprot->readListBegin(_etype2007, _size2004);
-            this->success.resize(_size2004);
-            uint32_t _i2008;
-            for (_i2008 = 0; _i2008 < _size2004; ++_i2008)
+            uint32_t _size2042;
+            ::apache::thrift::protocol::TType _etype2045;
+            xfer += iprot->readListBegin(_etype2045, _size2042);
+            this->success.resize(_size2042);
+            uint32_t _i2046;
+            for (_i2046 = 0; _i2046 < _size2042; ++_i2046)
             {
-              xfer += this->success[_i2008].read(iprot);
-=======
-            uint32_t _size2032;
-            ::apache::thrift::protocol::TType _etype2035;
-            xfer += iprot->readListBegin(_etype2035, _size2032);
-            this->success.resize(_size2032);
-            uint32_t _i2036;
-            for (_i2036 = 0; _i2036 < _size2032; ++_i2036)
-            {
-              xfer += this->success[_i2036].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->success[_i2046].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -23009,17 +21748,10 @@ uint32_t ThriftHiveMetastore_get_partitions_with_auth_result::write(::apache::th
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<Partition> ::const_iterator _iter2009;
-      for (_iter2009 = this->success.begin(); _iter2009 != this->success.end(); ++_iter2009)
-      {
-        xfer += (*_iter2009).write(oprot);
-=======
-      std::vector<Partition> ::const_iterator _iter2037;
-      for (_iter2037 = this->success.begin(); _iter2037 != this->success.end(); ++_iter2037)
+      std::vector<Partition> ::const_iterator _iter2047;
+      for (_iter2047 = this->success.begin(); _iter2047 != this->success.end(); ++_iter2047)
       {
-        xfer += (*_iter2037).write(oprot);
->>>>>>> External metastore: clean after rebase
+        xfer += (*_iter2047).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -23068,25 +21800,14 @@ uint32_t ThriftHiveMetastore_get_partitions_with_auth_presult::read(::apache::th
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2010;
-            ::apache::thrift::protocol::TType _etype2013;
-            xfer += iprot->readListBegin(_etype2013, _size2010);
-            (*(this->success)).resize(_size2010);
-            uint32_t _i2014;
-            for (_i2014 = 0; _i2014 < _size2010; ++_i2014)
-            {
-              xfer += (*(this->success))[_i2014].read(iprot);
-=======
-            uint32_t _size2038;
-            ::apache::thrift::protocol::TType _etype2041;
-            xfer += iprot->readListBegin(_etype2041, _size2038);
-            (*(this->success)).resize(_size2038);
-            uint32_t _i2042;
-            for (_i2042 = 0; _i2042 < _size2038; ++_i2042)
+            uint32_t _size2048;
+            ::apache::thrift::protocol::TType _etype2051;
+            xfer += iprot->readListBegin(_etype2051, _size2048);
+            (*(this->success)).resize(_size2048);
+            uint32_t _i2052;
+            for (_i2052 = 0; _i2052 < _size2048; ++_i2052)
             {
-              xfer += (*(this->success))[_i2042].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += (*(this->success))[_i2052].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -23264,25 +21985,14 @@ uint32_t ThriftHiveMetastore_get_partitions_pspec_result::read(::apache::thrift:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2015;
-            ::apache::thrift::protocol::TType _etype2018;
-            xfer += iprot->readListBegin(_etype2018, _size2015);
-            this->success.resize(_size2015);
-            uint32_t _i2019;
-            for (_i2019 = 0; _i2019 < _size2015; ++_i2019)
-            {
-              xfer += this->success[_i2019].read(iprot);
-=======
-            uint32_t _size2043;
-            ::apache::thrift::protocol::TType _etype2046;
-            xfer += iprot->readListBegin(_etype2046, _size2043);
-            this->success.resize(_size2043);
-            uint32_t _i2047;
-            for (_i2047 = 0; _i2047 < _size2043; ++_i2047)
+            uint32_t _size2053;
+            ::apache::thrift::protocol::TType _etype2056;
+            xfer += iprot->readListBegin(_etype2056, _size2053);
+            this->success.resize(_size2053);
+            uint32_t _i2057;
+            for (_i2057 = 0; _i2057 < _size2053; ++_i2057)
             {
-              xfer += this->success[_i2047].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->success[_i2057].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -23329,17 +22039,10 @@ uint32_t ThriftHiveMetastore_get_partitions_pspec_result::write(::apache::thrift
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<PartitionSpec> ::const_iterator _iter2020;
-      for (_iter2020 = this->success.begin(); _iter2020 != this->success.end(); ++_iter2020)
+      std::vector<PartitionSpec> ::const_iterator _iter2058;
+      for (_iter2058 = this->success.begin(); _iter2058 != this->success.end(); ++_iter2058)
       {
-        xfer += (*_iter2020).write(oprot);
-=======
-      std::vector<PartitionSpec> ::const_iterator _iter2048;
-      for (_iter2048 = this->success.begin(); _iter2048 != this->success.end(); ++_iter2048)
-      {
-        xfer += (*_iter2048).write(oprot);
->>>>>>> External metastore: clean after rebase
+        xfer += (*_iter2058).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -23388,25 +22091,14 @@ uint32_t ThriftHiveMetastore_get_partitions_pspec_presult::read(::apache::thrift
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2021;
-            ::apache::thrift::protocol::TType _etype2024;
-            xfer += iprot->readListBegin(_etype2024, _size2021);
-            (*(this->success)).resize(_size2021);
-            uint32_t _i2025;
-            for (_i2025 = 0; _i2025 < _size2021; ++_i2025)
-            {
-              xfer += (*(this->success))[_i2025].read(iprot);
-=======
-            uint32_t _size2049;
-            ::apache::thrift::protocol::TType _etype2052;
-            xfer += iprot->readListBegin(_etype2052, _size2049);
-            (*(this->success)).resize(_size2049);
-            uint32_t _i2053;
-            for (_i2053 = 0; _i2053 < _size2049; ++_i2053)
+            uint32_t _size2059;
+            ::apache::thrift::protocol::TType _etype2062;
+            xfer += iprot->readListBegin(_etype2062, _size2059);
+            (*(this->success)).resize(_size2059);
+            uint32_t _i2063;
+            for (_i2063 = 0; _i2063 < _size2059; ++_i2063)
             {
-              xfer += (*(this->success))[_i2053].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += (*(this->success))[_i2063].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -23584,25 +22276,14 @@ uint32_t ThriftHiveMetastore_get_partition_names_result::read(::apache::thrift::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2026;
-            ::apache::thrift::protocol::TType _etype2029;
-            xfer += iprot->readListBegin(_etype2029, _size2026);
-            this->success.resize(_size2026);
-            uint32_t _i2030;
-            for (_i2030 = 0; _i2030 < _size2026; ++_i2030)
+            uint32_t _size2064;
+            ::apache::thrift::protocol::TType _etype2067;
+            xfer += iprot->readListBegin(_etype2067, _size2064);
+            this->success.resize(_size2064);
+            uint32_t _i2068;
+            for (_i2068 = 0; _i2068 < _size2064; ++_i2068)
             {
-              xfer += iprot->readString(this->success[_i2030]);
-=======
-            uint32_t _size2054;
-            ::apache::thrift::protocol::TType _etype2057;
-            xfer += iprot->readListBegin(_etype2057, _size2054);
-            this->success.resize(_size2054);
-            uint32_t _i2058;
-            for (_i2058 = 0; _i2058 < _size2054; ++_i2058)
-            {
-              xfer += iprot->readString(this->success[_i2058]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->success[_i2068]);
             }
             xfer += iprot->readListEnd();
           }
@@ -23649,17 +22330,10 @@ uint32_t ThriftHiveMetastore_get_partition_names_result::write(::apache::thrift:
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter2031;
-      for (_iter2031 = this->success.begin(); _iter2031 != this->success.end(); ++_iter2031)
-      {
-        xfer += oprot->writeString((*_iter2031));
-=======
-      std::vector<std::string> ::const_iterator _iter2059;
-      for (_iter2059 = this->success.begin(); _iter2059 != this->success.end(); ++_iter2059)
+      std::vector<std::string> ::const_iterator _iter2069;
+      for (_iter2069 = this->success.begin(); _iter2069 != this->success.end(); ++_iter2069)
       {
-        xfer += oprot->writeString((*_iter2059));
->>>>>>> External metastore: clean after rebase
+        xfer += oprot->writeString((*_iter2069));
       }
       xfer += oprot->writeListEnd();
     }
@@ -23708,25 +22382,14 @@ uint32_t ThriftHiveMetastore_get_partition_names_presult::read(::apache::thrift:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2032;
-            ::apache::thrift::protocol::TType _etype2035;
-            xfer += iprot->readListBegin(_etype2035, _size2032);
-            (*(this->success)).resize(_size2032);
-            uint32_t _i2036;
-            for (_i2036 = 0; _i2036 < _size2032; ++_i2036)
+            uint32_t _size2070;
+            ::apache::thrift::protocol::TType _etype2073;
+            xfer += iprot->readListBegin(_etype2073, _size2070);
+            (*(this->success)).resize(_size2070);
+            uint32_t _i2074;
+            for (_i2074 = 0; _i2074 < _size2070; ++_i2074)
             {
-              xfer += iprot->readString((*(this->success))[_i2036]);
-=======
-            uint32_t _size2060;
-            ::apache::thrift::protocol::TType _etype2063;
-            xfer += iprot->readListBegin(_etype2063, _size2060);
-            (*(this->success)).resize(_size2060);
-            uint32_t _i2064;
-            for (_i2064 = 0; _i2064 < _size2060; ++_i2064)
-            {
-              xfer += iprot->readString((*(this->success))[_i2064]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString((*(this->success))[_i2074]);
             }
             xfer += iprot->readListEnd();
           }
@@ -24036,25 +22699,14 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_args::read(::apache::thrift::prot
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
-<<<<<<< HEAD
-            uint32_t _size2037;
-            ::apache::thrift::protocol::TType _etype2040;
-            xfer += iprot->readListBegin(_etype2040, _size2037);
-            this->part_vals.resize(_size2037);
-            uint32_t _i2041;
-            for (_i2041 = 0; _i2041 < _size2037; ++_i2041)
-            {
-              xfer += iprot->readString(this->part_vals[_i2041]);
-=======
-            uint32_t _size2065;
-            ::apache::thrift::protocol::TType _etype2068;
-            xfer += iprot->readListBegin(_etype2068, _size2065);
-            this->part_vals.resize(_size2065);
-            uint32_t _i2069;
-            for (_i2069 = 0; _i2069 < _size2065; ++_i2069)
+            uint32_t _size2075;
+            ::apache::thrift::protocol::TType _etype2078;
+            xfer += iprot->readListBegin(_etype2078, _size2075);
+            this->part_vals.resize(_size2075);
+            uint32_t _i2079;
+            for (_i2079 = 0; _i2079 < _size2075; ++_i2079)
             {
-              xfer += iprot->readString(this->part_vals[_i2069]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->part_vals[_i2079]);
             }
             xfer += iprot->readListEnd();
           }
@@ -24099,17 +22751,10 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_args::write(::apache::thrift::pro
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter2042;
-    for (_iter2042 = this->part_vals.begin(); _iter2042 != this->part_vals.end(); ++_iter2042)
-    {
-      xfer += oprot->writeString((*_iter2042));
-=======
-    std::vector<std::string> ::const_iterator _iter2070;
-    for (_iter2070 = this->part_vals.begin(); _iter2070 != this->part_vals.end(); ++_iter2070)
+    std::vector<std::string> ::const_iterator _iter2080;
+    for (_iter2080 = this->part_vals.begin(); _iter2080 != this->part_vals.end(); ++_iter2080)
     {
-      xfer += oprot->writeString((*_iter2070));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2080));
     }
     xfer += oprot->writeListEnd();
   }
@@ -24145,17 +22790,10 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_pargs::write(::apache::thrift::pr
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter2043;
-    for (_iter2043 = (*(this->part_vals)).begin(); _iter2043 != (*(this->part_vals)).end(); ++_iter2043)
+    std::vector<std::string> ::const_iterator _iter2081;
+    for (_iter2081 = (*(this->part_vals)).begin(); _iter2081 != (*(this->part_vals)).end(); ++_iter2081)
     {
-      xfer += oprot->writeString((*_iter2043));
-=======
-    std::vector<std::string> ::const_iterator _iter2071;
-    for (_iter2071 = (*(this->part_vals)).begin(); _iter2071 != (*(this->part_vals)).end(); ++_iter2071)
-    {
-      xfer += oprot->writeString((*_iter2071));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2081));
     }
     xfer += oprot->writeListEnd();
   }
@@ -24200,25 +22838,14 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_result::read(::apache::thrift::pr
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2044;
-            ::apache::thrift::protocol::TType _etype2047;
-            xfer += iprot->readListBegin(_etype2047, _size2044);
-            this->success.resize(_size2044);
-            uint32_t _i2048;
-            for (_i2048 = 0; _i2048 < _size2044; ++_i2048)
-            {
-              xfer += this->success[_i2048].read(iprot);
-=======
-            uint32_t _size2072;
-            ::apache::thrift::protocol::TType _etype2075;
-            xfer += iprot->readListBegin(_etype2075, _size2072);
-            this->success.resize(_size2072);
-            uint32_t _i2076;
-            for (_i2076 = 0; _i2076 < _size2072; ++_i2076)
+            uint32_t _size2082;
+            ::apache::thrift::protocol::TType _etype2085;
+            xfer += iprot->readListBegin(_etype2085, _size2082);
+            this->success.resize(_size2082);
+            uint32_t _i2086;
+            for (_i2086 = 0; _i2086 < _size2082; ++_i2086)
             {
-              xfer += this->success[_i2076].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->success[_i2086].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -24265,17 +22892,10 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_result::write(::apache::thrift::p
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<Partition> ::const_iterator _iter2049;
-      for (_iter2049 = this->success.begin(); _iter2049 != this->success.end(); ++_iter2049)
+      std::vector<Partition> ::const_iterator _iter2087;
+      for (_iter2087 = this->success.begin(); _iter2087 != this->success.end(); ++_iter2087)
       {
-        xfer += (*_iter2049).write(oprot);
-=======
-      std::vector<Partition> ::const_iterator _iter2077;
-      for (_iter2077 = this->success.begin(); _iter2077 != this->success.end(); ++_iter2077)
-      {
-        xfer += (*_iter2077).write(oprot);
->>>>>>> External metastore: clean after rebase
+        xfer += (*_iter2087).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -24324,25 +22944,14 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_presult::read(::apache::thrift::p
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2050;
-            ::apache::thrift::protocol::TType _etype2053;
-            xfer += iprot->readListBegin(_etype2053, _size2050);
-            (*(this->success)).resize(_size2050);
-            uint32_t _i2054;
-            for (_i2054 = 0; _i2054 < _size2050; ++_i2054)
-            {
-              xfer += (*(this->success))[_i2054].read(iprot);
-=======
-            uint32_t _size2078;
-            ::apache::thrift::protocol::TType _etype2081;
-            xfer += iprot->readListBegin(_etype2081, _size2078);
-            (*(this->success)).resize(_size2078);
-            uint32_t _i2082;
-            for (_i2082 = 0; _i2082 < _size2078; ++_i2082)
+            uint32_t _size2088;
+            ::apache::thrift::protocol::TType _etype2091;
+            xfer += iprot->readListBegin(_etype2091, _size2088);
+            (*(this->success)).resize(_size2088);
+            uint32_t _i2092;
+            for (_i2092 = 0; _i2092 < _size2088; ++_i2092)
             {
-              xfer += (*(this->success))[_i2082].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += (*(this->success))[_i2092].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -24425,25 +23034,14 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_args::read(::apache::th
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
-<<<<<<< HEAD
-            uint32_t _size2055;
-            ::apache::thrift::protocol::TType _etype2058;
-            xfer += iprot->readListBegin(_etype2058, _size2055);
-            this->part_vals.resize(_size2055);
-            uint32_t _i2059;
-            for (_i2059 = 0; _i2059 < _size2055; ++_i2059)
-            {
-              xfer += iprot->readString(this->part_vals[_i2059]);
-=======
-            uint32_t _size2083;
-            ::apache::thrift::protocol::TType _etype2086;
-            xfer += iprot->readListBegin(_etype2086, _size2083);
-            this->part_vals.resize(_size2083);
-            uint32_t _i2087;
-            for (_i2087 = 0; _i2087 < _size2083; ++_i2087)
+            uint32_t _size2093;
+            ::apache::thrift::protocol::TType _etype2096;
+            xfer += iprot->readListBegin(_etype2096, _size2093);
+            this->part_vals.resize(_size2093);
+            uint32_t _i2097;
+            for (_i2097 = 0; _i2097 < _size2093; ++_i2097)
             {
-              xfer += iprot->readString(this->part_vals[_i2087]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->part_vals[_i2097]);
             }
             xfer += iprot->readListEnd();
           }
@@ -24472,25 +23070,14 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_args::read(::apache::th
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->group_names.clear();
-<<<<<<< HEAD
-            uint32_t _size2060;
-            ::apache::thrift::protocol::TType _etype2063;
-            xfer += iprot->readListBegin(_etype2063, _size2060);
-            this->group_names.resize(_size2060);
-            uint32_t _i2064;
-            for (_i2064 = 0; _i2064 < _size2060; ++_i2064)
-            {
-              xfer += iprot->readString(this->group_names[_i2064]);
-=======
-            uint32_t _size2088;
-            ::apache::thrift::protocol::TType _etype2091;
-            xfer += iprot->readListBegin(_etype2091, _size2088);
-            this->group_names.resize(_size2088);
-            uint32_t _i2092;
-            for (_i2092 = 0; _i2092 < _size2088; ++_i2092)
+            uint32_t _size2098;
+            ::apache::thrift::protocol::TType _etype2101;
+            xfer += iprot->readListBegin(_etype2101, _size2098);
+            this->group_names.resize(_size2098);
+            uint32_t _i2102;
+            for (_i2102 = 0; _i2102 < _size2098; ++_i2102)
             {
-              xfer += iprot->readString(this->group_names[_i2092]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->group_names[_i2102]);
             }
             xfer += iprot->readListEnd();
           }
@@ -24527,17 +23114,10 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_args::write(::apache::t
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter2065;
-    for (_iter2065 = this->part_vals.begin(); _iter2065 != this->part_vals.end(); ++_iter2065)
+    std::vector<std::string> ::const_iterator _iter2103;
+    for (_iter2103 = this->part_vals.begin(); _iter2103 != this->part_vals.end(); ++_iter2103)
     {
-      xfer += oprot->writeString((*_iter2065));
-=======
-    std::vector<std::string> ::const_iterator _iter2093;
-    for (_iter2093 = this->part_vals.begin(); _iter2093 != this->part_vals.end(); ++_iter2093)
-    {
-      xfer += oprot->writeString((*_iter2093));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2103));
     }
     xfer += oprot->writeListEnd();
   }
@@ -24554,17 +23134,10 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_args::write(::apache::t
   xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 6);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->group_names.size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter2066;
-    for (_iter2066 = this->group_names.begin(); _iter2066 != this->group_names.end(); ++_iter2066)
-    {
-      xfer += oprot->writeString((*_iter2066));
-=======
-    std::vector<std::string> ::const_iterator _iter2094;
-    for (_iter2094 = this->group_names.begin(); _iter2094 != this->group_names.end(); ++_iter2094)
+    std::vector<std::string> ::const_iterator _iter2104;
+    for (_iter2104 = this->group_names.begin(); _iter2104 != this->group_names.end(); ++_iter2104)
     {
-      xfer += oprot->writeString((*_iter2094));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2104));
     }
     xfer += oprot->writeListEnd();
   }
@@ -24596,17 +23169,10 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_pargs::write(::apache::
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter2067;
-    for (_iter2067 = (*(this->part_vals)).begin(); _iter2067 != (*(this->part_vals)).end(); ++_iter2067)
+    std::vector<std::string> ::const_iterator _iter2105;
+    for (_iter2105 = (*(this->part_vals)).begin(); _iter2105 != (*(this->part_vals)).end(); ++_iter2105)
     {
-      xfer += oprot->writeString((*_iter2067));
-=======
-    std::vector<std::string> ::const_iterator _iter2095;
-    for (_iter2095 = (*(this->part_vals)).begin(); _iter2095 != (*(this->part_vals)).end(); ++_iter2095)
-    {
-      xfer += oprot->writeString((*_iter2095));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2105));
     }
     xfer += oprot->writeListEnd();
   }
@@ -24623,17 +23189,10 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_pargs::write(::apache::
   xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 6);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->group_names)).size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter2068;
-    for (_iter2068 = (*(this->group_names)).begin(); _iter2068 != (*(this->group_names)).end(); ++_iter2068)
-    {
-      xfer += oprot->writeString((*_iter2068));
-=======
-    std::vector<std::string> ::const_iterator _iter2096;
-    for (_iter2096 = (*(this->group_names)).begin(); _iter2096 != (*(this->group_names)).end(); ++_iter2096)
+    std::vector<std::string> ::const_iterator _iter2106;
+    for (_iter2106 = (*(this->group_names)).begin(); _iter2106 != (*(this->group_names)).end(); ++_iter2106)
     {
-      xfer += oprot->writeString((*_iter2096));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2106));
     }
     xfer += oprot->writeListEnd();
   }
@@ -24674,25 +23233,14 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_result::read(::apache::
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2069;
-            ::apache::thrift::protocol::TType _etype2072;
-            xfer += iprot->readListBegin(_etype2072, _size2069);
-            this->success.resize(_size2069);
-            uint32_t _i2073;
-            for (_i2073 = 0; _i2073 < _size2069; ++_i2073)
+            uint32_t _size2107;
+            ::apache::thrift::protocol::TType _etype2110;
+            xfer += iprot->readListBegin(_etype2110, _size2107);
+            this->success.resize(_size2107);
+            uint32_t _i2111;
+            for (_i2111 = 0; _i2111 < _size2107; ++_i2111)
             {
-              xfer += this->success[_i2073].read(iprot);
-=======
-            uint32_t _size2097;
-            ::apache::thrift::protocol::TType _etype2100;
-            xfer += iprot->readListBegin(_etype2100, _size2097);
-            this->success.resize(_size2097);
-            uint32_t _i2101;
-            for (_i2101 = 0; _i2101 < _size2097; ++_i2101)
-            {
-              xfer += this->success[_i2101].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->success[_i2111].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -24739,17 +23287,10 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_result::write(::apache:
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<Partition> ::const_iterator _iter2074;
-      for (_iter2074 = this->success.begin(); _iter2074 != this->success.end(); ++_iter2074)
-      {
-        xfer += (*_iter2074).write(oprot);
-=======
-      std::vector<Partition> ::const_iterator _iter2102;
-      for (_iter2102 = this->success.begin(); _iter2102 != this->success.end(); ++_iter2102)
+      std::vector<Partition> ::const_iterator _iter2112;
+      for (_iter2112 = this->success.begin(); _iter2112 != this->success.end(); ++_iter2112)
       {
-        xfer += (*_iter2102).write(oprot);
->>>>>>> External metastore: clean after rebase
+        xfer += (*_iter2112).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -24798,25 +23339,14 @@ uint32_t ThriftHiveMetastore_get_partitions_ps_with_auth_presult::read(::apache:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2075;
-            ::apache::thrift::protocol::TType _etype2078;
-            xfer += iprot->readListBegin(_etype2078, _size2075);
-            (*(this->success)).resize(_size2075);
-            uint32_t _i2079;
-            for (_i2079 = 0; _i2079 < _size2075; ++_i2079)
-            {
-              xfer += (*(this->success))[_i2079].read(iprot);
-=======
-            uint32_t _size2103;
-            ::apache::thrift::protocol::TType _etype2106;
-            xfer += iprot->readListBegin(_etype2106, _size2103);
-            (*(this->success)).resize(_size2103);
-            uint32_t _i2107;
-            for (_i2107 = 0; _i2107 < _size2103; ++_i2107)
+            uint32_t _size2113;
+            ::apache::thrift::protocol::TType _etype2116;
+            xfer += iprot->readListBegin(_etype2116, _size2113);
+            (*(this->success)).resize(_size2113);
+            uint32_t _i2117;
+            for (_i2117 = 0; _i2117 < _size2113; ++_i2117)
             {
-              xfer += (*(this->success))[_i2107].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += (*(this->success))[_i2117].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -25126,25 +23656,14 @@ uint32_t ThriftHiveMetastore_get_partition_names_ps_args::read(::apache::thrift:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
-<<<<<<< HEAD
-            uint32_t _size2080;
-            ::apache::thrift::protocol::TType _etype2083;
-            xfer += iprot->readListBegin(_etype2083, _size2080);
-            this->part_vals.resize(_size2080);
-            uint32_t _i2084;
-            for (_i2084 = 0; _i2084 < _size2080; ++_i2084)
+            uint32_t _size2118;
+            ::apache::thrift::protocol::TType _etype2121;
+            xfer += iprot->readListBegin(_etype2121, _size2118);
+            this->part_vals.resize(_size2118);
+            uint32_t _i2122;
+            for (_i2122 = 0; _i2122 < _size2118; ++_i2122)
             {
-              xfer += iprot->readString(this->part_vals[_i2084]);
-=======
-            uint32_t _size2108;
-            ::apache::thrift::protocol::TType _etype2111;
-            xfer += iprot->readListBegin(_etype2111, _size2108);
-            this->part_vals.resize(_size2108);
-            uint32_t _i2112;
-            for (_i2112 = 0; _i2112 < _size2108; ++_i2112)
-            {
-              xfer += iprot->readString(this->part_vals[_i2112]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->part_vals[_i2122]);
             }
             xfer += iprot->readListEnd();
           }
@@ -25189,17 +23708,10 @@ uint32_t ThriftHiveMetastore_get_partition_names_ps_args::write(::apache::thrift
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter2085;
-    for (_iter2085 = this->part_vals.begin(); _iter2085 != this->part_vals.end(); ++_iter2085)
-    {
-      xfer += oprot->writeString((*_iter2085));
-=======
-    std::vector<std::string> ::const_iterator _iter2113;
-    for (_iter2113 = this->part_vals.begin(); _iter2113 != this->part_vals.end(); ++_iter2113)
+    std::vector<std::string> ::const_iterator _iter2123;
+    for (_iter2123 = this->part_vals.begin(); _iter2123 != this->part_vals.end(); ++_iter2123)
     {
-      xfer += oprot->writeString((*_iter2113));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2123));
     }
     xfer += oprot->writeListEnd();
   }
@@ -25235,17 +23747,10 @@ uint32_t ThriftHiveMetastore_get_partition_names_ps_pargs::write(::apache::thrif
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter2086;
-    for (_iter2086 = (*(this->part_vals)).begin(); _iter2086 != (*(this->part_vals)).end(); ++_iter2086)
+    std::vector<std::string> ::const_iterator _iter2124;
+    for (_iter2124 = (*(this->part_vals)).begin(); _iter2124 != (*(this->part_vals)).end(); ++_iter2124)
     {
-      xfer += oprot->writeString((*_iter2086));
-=======
-    std::vector<std::string> ::const_iterator _iter2114;
-    for (_iter2114 = (*(this->part_vals)).begin(); _iter2114 != (*(this->part_vals)).end(); ++_iter2114)
-    {
-      xfer += oprot->writeString((*_iter2114));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2124));
     }
     xfer += oprot->writeListEnd();
   }
@@ -25290,25 +23795,14 @@ uint32_t ThriftHiveMetastore_get_partition_names_ps_result::read(::apache::thrif
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2087;
-            ::apache::thrift::protocol::TType _etype2090;
-            xfer += iprot->readListBegin(_etype2090, _size2087);
-            this->success.resize(_size2087);
-            uint32_t _i2091;
-            for (_i2091 = 0; _i2091 < _size2087; ++_i2091)
-            {
-              xfer += iprot->readString(this->success[_i2091]);
-=======
-            uint32_t _size2115;
-            ::apache::thrift::protocol::TType _etype2118;
-            xfer += iprot->readListBegin(_etype2118, _size2115);
-            this->success.resize(_size2115);
-            uint32_t _i2119;
-            for (_i2119 = 0; _i2119 < _size2115; ++_i2119)
+            uint32_t _size2125;
+            ::apache::thrift::protocol::TType _etype2128;
+            xfer += iprot->readListBegin(_etype2128, _size2125);
+            this->success.resize(_size2125);
+            uint32_t _i2129;
+            for (_i2129 = 0; _i2129 < _size2125; ++_i2129)
             {
-              xfer += iprot->readString(this->success[_i2119]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->success[_i2129]);
             }
             xfer += iprot->readListEnd();
           }
@@ -25355,17 +23849,10 @@ uint32_t ThriftHiveMetastore_get_partition_names_ps_result::write(::apache::thri
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter2092;
-      for (_iter2092 = this->success.begin(); _iter2092 != this->success.end(); ++_iter2092)
+      std::vector<std::string> ::const_iterator _iter2130;
+      for (_iter2130 = this->success.begin(); _iter2130 != this->success.end(); ++_iter2130)
       {
-        xfer += oprot->writeString((*_iter2092));
-=======
-      std::vector<std::string> ::const_iterator _iter2120;
-      for (_iter2120 = this->success.begin(); _iter2120 != this->success.end(); ++_iter2120)
-      {
-        xfer += oprot->writeString((*_iter2120));
->>>>>>> External metastore: clean after rebase
+        xfer += oprot->writeString((*_iter2130));
       }
       xfer += oprot->writeListEnd();
     }
@@ -25414,25 +23901,14 @@ uint32_t ThriftHiveMetastore_get_partition_names_ps_presult::read(::apache::thri
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2093;
-            ::apache::thrift::protocol::TType _etype2096;
-            xfer += iprot->readListBegin(_etype2096, _size2093);
-            (*(this->success)).resize(_size2093);
-            uint32_t _i2097;
-            for (_i2097 = 0; _i2097 < _size2093; ++_i2097)
-            {
-              xfer += iprot->readString((*(this->success))[_i2097]);
-=======
-            uint32_t _size2121;
-            ::apache::thrift::protocol::TType _etype2124;
-            xfer += iprot->readListBegin(_etype2124, _size2121);
-            (*(this->success)).resize(_size2121);
-            uint32_t _i2125;
-            for (_i2125 = 0; _i2125 < _size2121; ++_i2125)
+            uint32_t _size2131;
+            ::apache::thrift::protocol::TType _etype2134;
+            xfer += iprot->readListBegin(_etype2134, _size2131);
+            (*(this->success)).resize(_size2131);
+            uint32_t _i2135;
+            for (_i2135 = 0; _i2135 < _size2131; ++_i2135)
             {
-              xfer += iprot->readString((*(this->success))[_i2125]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString((*(this->success))[_i2135]);
             }
             xfer += iprot->readListEnd();
           }
@@ -25805,25 +24281,14 @@ uint32_t ThriftHiveMetastore_get_partition_names_req_result::read(::apache::thri
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2098;
-            ::apache::thrift::protocol::TType _etype2101;
-            xfer += iprot->readListBegin(_etype2101, _size2098);
-            this->success.resize(_size2098);
-            uint32_t _i2102;
-            for (_i2102 = 0; _i2102 < _size2098; ++_i2102)
-            {
-              xfer += iprot->readString(this->success[_i2102]);
-=======
-            uint32_t _size2126;
-            ::apache::thrift::protocol::TType _etype2129;
-            xfer += iprot->readListBegin(_etype2129, _size2126);
-            this->success.resize(_size2126);
-            uint32_t _i2130;
-            for (_i2130 = 0; _i2130 < _size2126; ++_i2130)
+            uint32_t _size2136;
+            ::apache::thrift::protocol::TType _etype2139;
+            xfer += iprot->readListBegin(_etype2139, _size2136);
+            this->success.resize(_size2136);
+            uint32_t _i2140;
+            for (_i2140 = 0; _i2140 < _size2136; ++_i2140)
             {
-              xfer += iprot->readString(this->success[_i2130]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->success[_i2140]);
             }
             xfer += iprot->readListEnd();
           }
@@ -25870,17 +24335,10 @@ uint32_t ThriftHiveMetastore_get_partition_names_req_result::write(::apache::thr
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter2103;
-      for (_iter2103 = this->success.begin(); _iter2103 != this->success.end(); ++_iter2103)
+      std::vector<std::string> ::const_iterator _iter2141;
+      for (_iter2141 = this->success.begin(); _iter2141 != this->success.end(); ++_iter2141)
       {
-        xfer += oprot->writeString((*_iter2103));
-=======
-      std::vector<std::string> ::const_iterator _iter2131;
-      for (_iter2131 = this->success.begin(); _iter2131 != this->success.end(); ++_iter2131)
-      {
-        xfer += oprot->writeString((*_iter2131));
->>>>>>> External metastore: clean after rebase
+        xfer += oprot->writeString((*_iter2141));
       }
       xfer += oprot->writeListEnd();
     }
@@ -25929,25 +24387,14 @@ uint32_t ThriftHiveMetastore_get_partition_names_req_presult::read(::apache::thr
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2104;
-            ::apache::thrift::protocol::TType _etype2107;
-            xfer += iprot->readListBegin(_etype2107, _size2104);
-            (*(this->success)).resize(_size2104);
-            uint32_t _i2108;
-            for (_i2108 = 0; _i2108 < _size2104; ++_i2108)
-            {
-              xfer += iprot->readString((*(this->success))[_i2108]);
-=======
-            uint32_t _size2132;
-            ::apache::thrift::protocol::TType _etype2135;
-            xfer += iprot->readListBegin(_etype2135, _size2132);
-            (*(this->success)).resize(_size2132);
-            uint32_t _i2136;
-            for (_i2136 = 0; _i2136 < _size2132; ++_i2136)
+            uint32_t _size2142;
+            ::apache::thrift::protocol::TType _etype2145;
+            xfer += iprot->readListBegin(_etype2145, _size2142);
+            (*(this->success)).resize(_size2142);
+            uint32_t _i2146;
+            for (_i2146 = 0; _i2146 < _size2142; ++_i2146)
             {
-              xfer += iprot->readString((*(this->success))[_i2136]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString((*(this->success))[_i2146]);
             }
             xfer += iprot->readListEnd();
           }
@@ -26141,25 +24588,14 @@ uint32_t ThriftHiveMetastore_get_partitions_by_filter_result::read(::apache::thr
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2109;
-            ::apache::thrift::protocol::TType _etype2112;
-            xfer += iprot->readListBegin(_etype2112, _size2109);
-            this->success.resize(_size2109);
-            uint32_t _i2113;
-            for (_i2113 = 0; _i2113 < _size2109; ++_i2113)
-            {
-              xfer += this->success[_i2113].read(iprot);
-=======
-            uint32_t _size2137;
-            ::apache::thrift::protocol::TType _etype2140;
-            xfer += iprot->readListBegin(_etype2140, _size2137);
-            this->success.resize(_size2137);
-            uint32_t _i2141;
-            for (_i2141 = 0; _i2141 < _size2137; ++_i2141)
+            uint32_t _size2147;
+            ::apache::thrift::protocol::TType _etype2150;
+            xfer += iprot->readListBegin(_etype2150, _size2147);
+            this->success.resize(_size2147);
+            uint32_t _i2151;
+            for (_i2151 = 0; _i2151 < _size2147; ++_i2151)
             {
-              xfer += this->success[_i2141].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->success[_i2151].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -26206,17 +24642,10 @@ uint32_t ThriftHiveMetastore_get_partitions_by_filter_result::write(::apache::th
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<Partition> ::const_iterator _iter2114;
-      for (_iter2114 = this->success.begin(); _iter2114 != this->success.end(); ++_iter2114)
+      std::vector<Partition> ::const_iterator _iter2152;
+      for (_iter2152 = this->success.begin(); _iter2152 != this->success.end(); ++_iter2152)
       {
-        xfer += (*_iter2114).write(oprot);
-=======
-      std::vector<Partition> ::const_iterator _iter2142;
-      for (_iter2142 = this->success.begin(); _iter2142 != this->success.end(); ++_iter2142)
-      {
-        xfer += (*_iter2142).write(oprot);
->>>>>>> External metastore: clean after rebase
+        xfer += (*_iter2152).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -26265,25 +24694,14 @@ uint32_t ThriftHiveMetastore_get_partitions_by_filter_presult::read(::apache::th
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2115;
-            ::apache::thrift::protocol::TType _etype2118;
-            xfer += iprot->readListBegin(_etype2118, _size2115);
-            (*(this->success)).resize(_size2115);
-            uint32_t _i2119;
-            for (_i2119 = 0; _i2119 < _size2115; ++_i2119)
-            {
-              xfer += (*(this->success))[_i2119].read(iprot);
-=======
-            uint32_t _size2143;
-            ::apache::thrift::protocol::TType _etype2146;
-            xfer += iprot->readListBegin(_etype2146, _size2143);
-            (*(this->success)).resize(_size2143);
-            uint32_t _i2147;
-            for (_i2147 = 0; _i2147 < _size2143; ++_i2147)
+            uint32_t _size2153;
+            ::apache::thrift::protocol::TType _etype2156;
+            xfer += iprot->readListBegin(_etype2156, _size2153);
+            (*(this->success)).resize(_size2153);
+            uint32_t _i2157;
+            for (_i2157 = 0; _i2157 < _size2153; ++_i2157)
             {
-              xfer += (*(this->success))[_i2147].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += (*(this->success))[_i2157].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -26477,25 +24895,14 @@ uint32_t ThriftHiveMetastore_get_part_specs_by_filter_result::read(::apache::thr
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2120;
-            ::apache::thrift::protocol::TType _etype2123;
-            xfer += iprot->readListBegin(_etype2123, _size2120);
-            this->success.resize(_size2120);
-            uint32_t _i2124;
-            for (_i2124 = 0; _i2124 < _size2120; ++_i2124)
+            uint32_t _size2158;
+            ::apache::thrift::protocol::TType _etype2161;
+            xfer += iprot->readListBegin(_etype2161, _size2158);
+            this->success.resize(_size2158);
+            uint32_t _i2162;
+            for (_i2162 = 0; _i2162 < _size2158; ++_i2162)
             {
-              xfer += this->success[_i2124].read(iprot);
-=======
-            uint32_t _size2148;
-            ::apache::thrift::protocol::TType _etype2151;
-            xfer += iprot->readListBegin(_etype2151, _size2148);
-            this->success.resize(_size2148);
-            uint32_t _i2152;
-            for (_i2152 = 0; _i2152 < _size2148; ++_i2152)
-            {
-              xfer += this->success[_i2152].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->success[_i2162].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -26542,17 +24949,10 @@ uint32_t ThriftHiveMetastore_get_part_specs_by_filter_result::write(::apache::th
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<PartitionSpec> ::const_iterator _iter2125;
-      for (_iter2125 = this->success.begin(); _iter2125 != this->success.end(); ++_iter2125)
-      {
-        xfer += (*_iter2125).write(oprot);
-=======
-      std::vector<PartitionSpec> ::const_iterator _iter2153;
-      for (_iter2153 = this->success.begin(); _iter2153 != this->success.end(); ++_iter2153)
+      std::vector<PartitionSpec> ::const_iterator _iter2163;
+      for (_iter2163 = this->success.begin(); _iter2163 != this->success.end(); ++_iter2163)
       {
-        xfer += (*_iter2153).write(oprot);
->>>>>>> External metastore: clean after rebase
+        xfer += (*_iter2163).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -26601,25 +25001,14 @@ uint32_t ThriftHiveMetastore_get_part_specs_by_filter_presult::read(::apache::th
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2126;
-            ::apache::thrift::protocol::TType _etype2129;
-            xfer += iprot->readListBegin(_etype2129, _size2126);
-            (*(this->success)).resize(_size2126);
-            uint32_t _i2130;
-            for (_i2130 = 0; _i2130 < _size2126; ++_i2130)
+            uint32_t _size2164;
+            ::apache::thrift::protocol::TType _etype2167;
+            xfer += iprot->readListBegin(_etype2167, _size2164);
+            (*(this->success)).resize(_size2164);
+            uint32_t _i2168;
+            for (_i2168 = 0; _i2168 < _size2164; ++_i2168)
             {
-              xfer += (*(this->success))[_i2130].read(iprot);
-=======
-            uint32_t _size2154;
-            ::apache::thrift::protocol::TType _etype2157;
-            xfer += iprot->readListBegin(_etype2157, _size2154);
-            (*(this->success)).resize(_size2154);
-            uint32_t _i2158;
-            for (_i2158 = 0; _i2158 < _size2154; ++_i2158)
-            {
-              xfer += (*(this->success))[_i2158].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += (*(this->success))[_i2168].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -27415,25 +25804,14 @@ uint32_t ThriftHiveMetastore_get_partitions_by_names_args::read(::apache::thrift
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->names.clear();
-<<<<<<< HEAD
-            uint32_t _size2131;
-            ::apache::thrift::protocol::TType _etype2134;
-            xfer += iprot->readListBegin(_etype2134, _size2131);
-            this->names.resize(_size2131);
-            uint32_t _i2135;
-            for (_i2135 = 0; _i2135 < _size2131; ++_i2135)
+            uint32_t _size2169;
+            ::apache::thrift::protocol::TType _etype2172;
+            xfer += iprot->readListBegin(_etype2172, _size2169);
+            this->names.resize(_size2169);
+            uint32_t _i2173;
+            for (_i2173 = 0; _i2173 < _size2169; ++_i2173)
             {
-              xfer += iprot->readString(this->names[_i2135]);
-=======
-            uint32_t _size2159;
-            ::apache::thrift::protocol::TType _etype2162;
-            xfer += iprot->readListBegin(_etype2162, _size2159);
-            this->names.resize(_size2159);
-            uint32_t _i2163;
-            for (_i2163 = 0; _i2163 < _size2159; ++_i2163)
-            {
-              xfer += iprot->readString(this->names[_i2163]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->names[_i2173]);
             }
             xfer += iprot->readListEnd();
           }
@@ -27470,17 +25848,10 @@ uint32_t ThriftHiveMetastore_get_partitions_by_names_args::write(::apache::thrif
   xfer += oprot->writeFieldBegin("names", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->names.size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter2136;
-    for (_iter2136 = this->names.begin(); _iter2136 != this->names.end(); ++_iter2136)
-    {
-      xfer += oprot->writeString((*_iter2136));
-=======
-    std::vector<std::string> ::const_iterator _iter2164;
-    for (_iter2164 = this->names.begin(); _iter2164 != this->names.end(); ++_iter2164)
+    std::vector<std::string> ::const_iterator _iter2174;
+    for (_iter2174 = this->names.begin(); _iter2174 != this->names.end(); ++_iter2174)
     {
-      xfer += oprot->writeString((*_iter2164));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2174));
     }
     xfer += oprot->writeListEnd();
   }
@@ -27512,17 +25883,10 @@ uint32_t ThriftHiveMetastore_get_partitions_by_names_pargs::write(::apache::thri
   xfer += oprot->writeFieldBegin("names", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->names)).size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter2137;
-    for (_iter2137 = (*(this->names)).begin(); _iter2137 != (*(this->names)).end(); ++_iter2137)
-    {
-      xfer += oprot->writeString((*_iter2137));
-=======
-    std::vector<std::string> ::const_iterator _iter2165;
-    for (_iter2165 = (*(this->names)).begin(); _iter2165 != (*(this->names)).end(); ++_iter2165)
+    std::vector<std::string> ::const_iterator _iter2175;
+    for (_iter2175 = (*(this->names)).begin(); _iter2175 != (*(this->names)).end(); ++_iter2175)
     {
-      xfer += oprot->writeString((*_iter2165));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2175));
     }
     xfer += oprot->writeListEnd();
   }
@@ -27563,25 +25927,14 @@ uint32_t ThriftHiveMetastore_get_partitions_by_names_result::read(::apache::thri
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2138;
-            ::apache::thrift::protocol::TType _etype2141;
-            xfer += iprot->readListBegin(_etype2141, _size2138);
-            this->success.resize(_size2138);
-            uint32_t _i2142;
-            for (_i2142 = 0; _i2142 < _size2138; ++_i2142)
-            {
-              xfer += this->success[_i2142].read(iprot);
-=======
-            uint32_t _size2166;
-            ::apache::thrift::protocol::TType _etype2169;
-            xfer += iprot->readListBegin(_etype2169, _size2166);
-            this->success.resize(_size2166);
-            uint32_t _i2170;
-            for (_i2170 = 0; _i2170 < _size2166; ++_i2170)
+            uint32_t _size2176;
+            ::apache::thrift::protocol::TType _etype2179;
+            xfer += iprot->readListBegin(_etype2179, _size2176);
+            this->success.resize(_size2176);
+            uint32_t _i2180;
+            for (_i2180 = 0; _i2180 < _size2176; ++_i2180)
             {
-              xfer += this->success[_i2170].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->success[_i2180].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -27628,17 +25981,10 @@ uint32_t ThriftHiveMetastore_get_partitions_by_names_result::write(::apache::thr
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<Partition> ::const_iterator _iter2143;
-      for (_iter2143 = this->success.begin(); _iter2143 != this->success.end(); ++_iter2143)
+      std::vector<Partition> ::const_iterator _iter2181;
+      for (_iter2181 = this->success.begin(); _iter2181 != this->success.end(); ++_iter2181)
       {
-        xfer += (*_iter2143).write(oprot);
-=======
-      std::vector<Partition> ::const_iterator _iter2171;
-      for (_iter2171 = this->success.begin(); _iter2171 != this->success.end(); ++_iter2171)
-      {
-        xfer += (*_iter2171).write(oprot);
->>>>>>> External metastore: clean after rebase
+        xfer += (*_iter2181).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -27687,25 +26033,14 @@ uint32_t ThriftHiveMetastore_get_partitions_by_names_presult::read(::apache::thr
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2144;
-            ::apache::thrift::protocol::TType _etype2147;
-            xfer += iprot->readListBegin(_etype2147, _size2144);
-            (*(this->success)).resize(_size2144);
-            uint32_t _i2148;
-            for (_i2148 = 0; _i2148 < _size2144; ++_i2148)
-            {
-              xfer += (*(this->success))[_i2148].read(iprot);
-=======
-            uint32_t _size2172;
-            ::apache::thrift::protocol::TType _etype2175;
-            xfer += iprot->readListBegin(_etype2175, _size2172);
-            (*(this->success)).resize(_size2172);
-            uint32_t _i2176;
-            for (_i2176 = 0; _i2176 < _size2172; ++_i2176)
+            uint32_t _size2182;
+            ::apache::thrift::protocol::TType _etype2185;
+            xfer += iprot->readListBegin(_etype2185, _size2182);
+            (*(this->success)).resize(_size2182);
+            uint32_t _i2186;
+            for (_i2186 = 0; _i2186 < _size2182; ++_i2186)
             {
-              xfer += (*(this->success))[_i2176].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += (*(this->success))[_i2186].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -28254,25 +26589,14 @@ uint32_t ThriftHiveMetastore_alter_partitions_args::read(::apache::thrift::proto
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->new_parts.clear();
-<<<<<<< HEAD
-            uint32_t _size2149;
-            ::apache::thrift::protocol::TType _etype2152;
-            xfer += iprot->readListBegin(_etype2152, _size2149);
-            this->new_parts.resize(_size2149);
-            uint32_t _i2153;
-            for (_i2153 = 0; _i2153 < _size2149; ++_i2153)
+            uint32_t _size2187;
+            ::apache::thrift::protocol::TType _etype2190;
+            xfer += iprot->readListBegin(_etype2190, _size2187);
+            this->new_parts.resize(_size2187);
+            uint32_t _i2191;
+            for (_i2191 = 0; _i2191 < _size2187; ++_i2191)
             {
-              xfer += this->new_parts[_i2153].read(iprot);
-=======
-            uint32_t _size2177;
-            ::apache::thrift::protocol::TType _etype2180;
-            xfer += iprot->readListBegin(_etype2180, _size2177);
-            this->new_parts.resize(_size2177);
-            uint32_t _i2181;
-            for (_i2181 = 0; _i2181 < _size2177; ++_i2181)
-            {
-              xfer += this->new_parts[_i2181].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->new_parts[_i2191].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -28309,17 +26633,10 @@ uint32_t ThriftHiveMetastore_alter_partitions_args::write(::apache::thrift::prot
   xfer += oprot->writeFieldBegin("new_parts", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->new_parts.size()));
-<<<<<<< HEAD
-    std::vector<Partition> ::const_iterator _iter2154;
-    for (_iter2154 = this->new_parts.begin(); _iter2154 != this->new_parts.end(); ++_iter2154)
-    {
-      xfer += (*_iter2154).write(oprot);
-=======
-    std::vector<Partition> ::const_iterator _iter2182;
-    for (_iter2182 = this->new_parts.begin(); _iter2182 != this->new_parts.end(); ++_iter2182)
+    std::vector<Partition> ::const_iterator _iter2192;
+    for (_iter2192 = this->new_parts.begin(); _iter2192 != this->new_parts.end(); ++_iter2192)
     {
-      xfer += (*_iter2182).write(oprot);
->>>>>>> External metastore: clean after rebase
+      xfer += (*_iter2192).write(oprot);
     }
     xfer += oprot->writeListEnd();
   }
@@ -28351,17 +26668,10 @@ uint32_t ThriftHiveMetastore_alter_partitions_pargs::write(::apache::thrift::pro
   xfer += oprot->writeFieldBegin("new_parts", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->new_parts)).size()));
-<<<<<<< HEAD
-    std::vector<Partition> ::const_iterator _iter2155;
-    for (_iter2155 = (*(this->new_parts)).begin(); _iter2155 != (*(this->new_parts)).end(); ++_iter2155)
+    std::vector<Partition> ::const_iterator _iter2193;
+    for (_iter2193 = (*(this->new_parts)).begin(); _iter2193 != (*(this->new_parts)).end(); ++_iter2193)
     {
-      xfer += (*_iter2155).write(oprot);
-=======
-    std::vector<Partition> ::const_iterator _iter2183;
-    for (_iter2183 = (*(this->new_parts)).begin(); _iter2183 != (*(this->new_parts)).end(); ++_iter2183)
-    {
-      xfer += (*_iter2183).write(oprot);
->>>>>>> External metastore: clean after rebase
+      xfer += (*_iter2193).write(oprot);
     }
     xfer += oprot->writeListEnd();
   }
@@ -28546,25 +26856,14 @@ uint32_t ThriftHiveMetastore_alter_partitions_with_environment_context_args::rea
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->new_parts.clear();
-<<<<<<< HEAD
-            uint32_t _size2156;
-            ::apache::thrift::protocol::TType _etype2159;
-            xfer += iprot->readListBegin(_etype2159, _size2156);
-            this->new_parts.resize(_size2156);
-            uint32_t _i2160;
-            for (_i2160 = 0; _i2160 < _size2156; ++_i2160)
-            {
-              xfer += this->new_parts[_i2160].read(iprot);
-=======
-            uint32_t _size2184;
-            ::apache::thrift::protocol::TType _etype2187;
-            xfer += iprot->readListBegin(_etype2187, _size2184);
-            this->new_parts.resize(_size2184);
-            uint32_t _i2188;
-            for (_i2188 = 0; _i2188 < _size2184; ++_i2188)
+            uint32_t _size2194;
+            ::apache::thrift::protocol::TType _etype2197;
+            xfer += iprot->readListBegin(_etype2197, _size2194);
+            this->new_parts.resize(_size2194);
+            uint32_t _i2198;
+            for (_i2198 = 0; _i2198 < _size2194; ++_i2198)
             {
-              xfer += this->new_parts[_i2188].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->new_parts[_i2198].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -28609,17 +26908,10 @@ uint32_t ThriftHiveMetastore_alter_partitions_with_environment_context_args::wri
   xfer += oprot->writeFieldBegin("new_parts", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->new_parts.size()));
-<<<<<<< HEAD
-    std::vector<Partition> ::const_iterator _iter2161;
-    for (_iter2161 = this->new_parts.begin(); _iter2161 != this->new_parts.end(); ++_iter2161)
+    std::vector<Partition> ::const_iterator _iter2199;
+    for (_iter2199 = this->new_parts.begin(); _iter2199 != this->new_parts.end(); ++_iter2199)
     {
-      xfer += (*_iter2161).write(oprot);
-=======
-    std::vector<Partition> ::const_iterator _iter2189;
-    for (_iter2189 = this->new_parts.begin(); _iter2189 != this->new_parts.end(); ++_iter2189)
-    {
-      xfer += (*_iter2189).write(oprot);
->>>>>>> External metastore: clean after rebase
+      xfer += (*_iter2199).write(oprot);
     }
     xfer += oprot->writeListEnd();
   }
@@ -28655,17 +26947,10 @@ uint32_t ThriftHiveMetastore_alter_partitions_with_environment_context_pargs::wr
   xfer += oprot->writeFieldBegin("new_parts", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->new_parts)).size()));
-<<<<<<< HEAD
-    std::vector<Partition> ::const_iterator _iter2162;
-    for (_iter2162 = (*(this->new_parts)).begin(); _iter2162 != (*(this->new_parts)).end(); ++_iter2162)
-    {
-      xfer += (*_iter2162).write(oprot);
-=======
-    std::vector<Partition> ::const_iterator _iter2190;
-    for (_iter2190 = (*(this->new_parts)).begin(); _iter2190 != (*(this->new_parts)).end(); ++_iter2190)
+    std::vector<Partition> ::const_iterator _iter2200;
+    for (_iter2200 = (*(this->new_parts)).begin(); _iter2200 != (*(this->new_parts)).end(); ++_iter2200)
     {
-      xfer += (*_iter2190).write(oprot);
->>>>>>> External metastore: clean after rebase
+      xfer += (*_iter2200).write(oprot);
     }
     xfer += oprot->writeListEnd();
   }
@@ -29336,25 +27621,14 @@ uint32_t ThriftHiveMetastore_rename_partition_args::read(::apache::thrift::proto
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
-<<<<<<< HEAD
-            uint32_t _size2163;
-            ::apache::thrift::protocol::TType _etype2166;
-            xfer += iprot->readListBegin(_etype2166, _size2163);
-            this->part_vals.resize(_size2163);
-            uint32_t _i2167;
-            for (_i2167 = 0; _i2167 < _size2163; ++_i2167)
+            uint32_t _size2201;
+            ::apache::thrift::protocol::TType _etype2204;
+            xfer += iprot->readListBegin(_etype2204, _size2201);
+            this->part_vals.resize(_size2201);
+            uint32_t _i2205;
+            for (_i2205 = 0; _i2205 < _size2201; ++_i2205)
             {
-              xfer += iprot->readString(this->part_vals[_i2167]);
-=======
-            uint32_t _size2191;
-            ::apache::thrift::protocol::TType _etype2194;
-            xfer += iprot->readListBegin(_etype2194, _size2191);
-            this->part_vals.resize(_size2191);
-            uint32_t _i2195;
-            for (_i2195 = 0; _i2195 < _size2191; ++_i2195)
-            {
-              xfer += iprot->readString(this->part_vals[_i2195]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->part_vals[_i2205]);
             }
             xfer += iprot->readListEnd();
           }
@@ -29399,17 +27673,10 @@ uint32_t ThriftHiveMetastore_rename_partition_args::write(::apache::thrift::prot
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter2168;
-    for (_iter2168 = this->part_vals.begin(); _iter2168 != this->part_vals.end(); ++_iter2168)
-    {
-      xfer += oprot->writeString((*_iter2168));
-=======
-    std::vector<std::string> ::const_iterator _iter2196;
-    for (_iter2196 = this->part_vals.begin(); _iter2196 != this->part_vals.end(); ++_iter2196)
+    std::vector<std::string> ::const_iterator _iter2206;
+    for (_iter2206 = this->part_vals.begin(); _iter2206 != this->part_vals.end(); ++_iter2206)
     {
-      xfer += oprot->writeString((*_iter2196));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2206));
     }
     xfer += oprot->writeListEnd();
   }
@@ -29445,17 +27712,10 @@ uint32_t ThriftHiveMetastore_rename_partition_pargs::write(::apache::thrift::pro
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter2169;
-    for (_iter2169 = (*(this->part_vals)).begin(); _iter2169 != (*(this->part_vals)).end(); ++_iter2169)
+    std::vector<std::string> ::const_iterator _iter2207;
+    for (_iter2207 = (*(this->part_vals)).begin(); _iter2207 != (*(this->part_vals)).end(); ++_iter2207)
     {
-      xfer += oprot->writeString((*_iter2169));
-=======
-    std::vector<std::string> ::const_iterator _iter2197;
-    for (_iter2197 = (*(this->part_vals)).begin(); _iter2197 != (*(this->part_vals)).end(); ++_iter2197)
-    {
-      xfer += oprot->writeString((*_iter2197));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2207));
     }
     xfer += oprot->writeListEnd();
   }
@@ -29855,25 +28115,14 @@ uint32_t ThriftHiveMetastore_partition_name_has_valid_characters_args::read(::ap
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->part_vals.clear();
-<<<<<<< HEAD
-            uint32_t _size2170;
-            ::apache::thrift::protocol::TType _etype2173;
-            xfer += iprot->readListBegin(_etype2173, _size2170);
-            this->part_vals.resize(_size2170);
-            uint32_t _i2174;
-            for (_i2174 = 0; _i2174 < _size2170; ++_i2174)
-            {
-              xfer += iprot->readString(this->part_vals[_i2174]);
-=======
-            uint32_t _size2198;
-            ::apache::thrift::protocol::TType _etype2201;
-            xfer += iprot->readListBegin(_etype2201, _size2198);
-            this->part_vals.resize(_size2198);
-            uint32_t _i2202;
-            for (_i2202 = 0; _i2202 < _size2198; ++_i2202)
+            uint32_t _size2208;
+            ::apache::thrift::protocol::TType _etype2211;
+            xfer += iprot->readListBegin(_etype2211, _size2208);
+            this->part_vals.resize(_size2208);
+            uint32_t _i2212;
+            for (_i2212 = 0; _i2212 < _size2208; ++_i2212)
             {
-              xfer += iprot->readString(this->part_vals[_i2202]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->part_vals[_i2212]);
             }
             xfer += iprot->readListEnd();
           }
@@ -29910,17 +28159,10 @@ uint32_t ThriftHiveMetastore_partition_name_has_valid_characters_args::write(::a
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 1);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter2175;
-    for (_iter2175 = this->part_vals.begin(); _iter2175 != this->part_vals.end(); ++_iter2175)
+    std::vector<std::string> ::const_iterator _iter2213;
+    for (_iter2213 = this->part_vals.begin(); _iter2213 != this->part_vals.end(); ++_iter2213)
     {
-      xfer += oprot->writeString((*_iter2175));
-=======
-    std::vector<std::string> ::const_iterator _iter2203;
-    for (_iter2203 = this->part_vals.begin(); _iter2203 != this->part_vals.end(); ++_iter2203)
-    {
-      xfer += oprot->writeString((*_iter2203));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2213));
     }
     xfer += oprot->writeListEnd();
   }
@@ -29948,17 +28190,10 @@ uint32_t ThriftHiveMetastore_partition_name_has_valid_characters_pargs::write(::
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_LIST, 1);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter2176;
-    for (_iter2176 = (*(this->part_vals)).begin(); _iter2176 != (*(this->part_vals)).end(); ++_iter2176)
-    {
-      xfer += oprot->writeString((*_iter2176));
-=======
-    std::vector<std::string> ::const_iterator _iter2204;
-    for (_iter2204 = (*(this->part_vals)).begin(); _iter2204 != (*(this->part_vals)).end(); ++_iter2204)
+    std::vector<std::string> ::const_iterator _iter2214;
+    for (_iter2214 = (*(this->part_vals)).begin(); _iter2214 != (*(this->part_vals)).end(); ++_iter2214)
     {
-      xfer += oprot->writeString((*_iter2204));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2214));
     }
     xfer += oprot->writeListEnd();
   }
@@ -30433,25 +28668,14 @@ uint32_t ThriftHiveMetastore_partition_name_to_vals_result::read(::apache::thrif
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2177;
-            ::apache::thrift::protocol::TType _etype2180;
-            xfer += iprot->readListBegin(_etype2180, _size2177);
-            this->success.resize(_size2177);
-            uint32_t _i2181;
-            for (_i2181 = 0; _i2181 < _size2177; ++_i2181)
+            uint32_t _size2215;
+            ::apache::thrift::protocol::TType _etype2218;
+            xfer += iprot->readListBegin(_etype2218, _size2215);
+            this->success.resize(_size2215);
+            uint32_t _i2219;
+            for (_i2219 = 0; _i2219 < _size2215; ++_i2219)
             {
-              xfer += iprot->readString(this->success[_i2181]);
-=======
-            uint32_t _size2205;
-            ::apache::thrift::protocol::TType _etype2208;
-            xfer += iprot->readListBegin(_etype2208, _size2205);
-            this->success.resize(_size2205);
-            uint32_t _i2209;
-            for (_i2209 = 0; _i2209 < _size2205; ++_i2209)
-            {
-              xfer += iprot->readString(this->success[_i2209]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->success[_i2219]);
             }
             xfer += iprot->readListEnd();
           }
@@ -30490,17 +28714,10 @@ uint32_t ThriftHiveMetastore_partition_name_to_vals_result::write(::apache::thri
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter2182;
-      for (_iter2182 = this->success.begin(); _iter2182 != this->success.end(); ++_iter2182)
-      {
-        xfer += oprot->writeString((*_iter2182));
-=======
-      std::vector<std::string> ::const_iterator _iter2210;
-      for (_iter2210 = this->success.begin(); _iter2210 != this->success.end(); ++_iter2210)
+      std::vector<std::string> ::const_iterator _iter2220;
+      for (_iter2220 = this->success.begin(); _iter2220 != this->success.end(); ++_iter2220)
       {
-        xfer += oprot->writeString((*_iter2210));
->>>>>>> External metastore: clean after rebase
+        xfer += oprot->writeString((*_iter2220));
       }
       xfer += oprot->writeListEnd();
     }
@@ -30545,25 +28762,14 @@ uint32_t ThriftHiveMetastore_partition_name_to_vals_presult::read(::apache::thri
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2183;
-            ::apache::thrift::protocol::TType _etype2186;
-            xfer += iprot->readListBegin(_etype2186, _size2183);
-            (*(this->success)).resize(_size2183);
-            uint32_t _i2187;
-            for (_i2187 = 0; _i2187 < _size2183; ++_i2187)
+            uint32_t _size2221;
+            ::apache::thrift::protocol::TType _etype2224;
+            xfer += iprot->readListBegin(_etype2224, _size2221);
+            (*(this->success)).resize(_size2221);
+            uint32_t _i2225;
+            for (_i2225 = 0; _i2225 < _size2221; ++_i2225)
             {
-              xfer += iprot->readString((*(this->success))[_i2187]);
-=======
-            uint32_t _size2211;
-            ::apache::thrift::protocol::TType _etype2214;
-            xfer += iprot->readListBegin(_etype2214, _size2211);
-            (*(this->success)).resize(_size2211);
-            uint32_t _i2215;
-            for (_i2215 = 0; _i2215 < _size2211; ++_i2215)
-            {
-              xfer += iprot->readString((*(this->success))[_i2215]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString((*(this->success))[_i2225]);
             }
             xfer += iprot->readListEnd();
           }
@@ -30701,31 +28907,17 @@ uint32_t ThriftHiveMetastore_partition_name_to_spec_result::read(::apache::thrif
         if (ftype == ::apache::thrift::protocol::T_MAP) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2188;
-            ::apache::thrift::protocol::TType _ktype2189;
-            ::apache::thrift::protocol::TType _vtype2190;
-            xfer += iprot->readMapBegin(_ktype2189, _vtype2190, _size2188);
-            uint32_t _i2192;
-            for (_i2192 = 0; _i2192 < _size2188; ++_i2192)
-            {
-              std::string _key2193;
-              xfer += iprot->readString(_key2193);
-              std::string& _val2194 = this->success[_key2193];
-              xfer += iprot->readString(_val2194);
-=======
-            uint32_t _size2216;
-            ::apache::thrift::protocol::TType _ktype2217;
-            ::apache::thrift::protocol::TType _vtype2218;
-            xfer += iprot->readMapBegin(_ktype2217, _vtype2218, _size2216);
-            uint32_t _i2220;
-            for (_i2220 = 0; _i2220 < _size2216; ++_i2220)
+            uint32_t _size2226;
+            ::apache::thrift::protocol::TType _ktype2227;
+            ::apache::thrift::protocol::TType _vtype2228;
+            xfer += iprot->readMapBegin(_ktype2227, _vtype2228, _size2226);
+            uint32_t _i2230;
+            for (_i2230 = 0; _i2230 < _size2226; ++_i2230)
             {
-              std::string _key2221;
-              xfer += iprot->readString(_key2221);
-              std::string& _val2222 = this->success[_key2221];
-              xfer += iprot->readString(_val2222);
->>>>>>> External metastore: clean after rebase
+              std::string _key2231;
+              xfer += iprot->readString(_key2231);
+              std::string& _val2232 = this->success[_key2231];
+              xfer += iprot->readString(_val2232);
             }
             xfer += iprot->readMapEnd();
           }
@@ -30764,19 +28956,11 @@ uint32_t ThriftHiveMetastore_partition_name_to_spec_result::write(::apache::thri
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_MAP, 0);
     {
       xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::map<std::string, std::string> ::const_iterator _iter2195;
-      for (_iter2195 = this->success.begin(); _iter2195 != this->success.end(); ++_iter2195)
+      std::map<std::string, std::string> ::const_iterator _iter2233;
+      for (_iter2233 = this->success.begin(); _iter2233 != this->success.end(); ++_iter2233)
       {
-        xfer += oprot->writeString(_iter2195->first);
-        xfer += oprot->writeString(_iter2195->second);
-=======
-      std::map<std::string, std::string> ::const_iterator _iter2223;
-      for (_iter2223 = this->success.begin(); _iter2223 != this->success.end(); ++_iter2223)
-      {
-        xfer += oprot->writeString(_iter2223->first);
-        xfer += oprot->writeString(_iter2223->second);
->>>>>>> External metastore: clean after rebase
+        xfer += oprot->writeString(_iter2233->first);
+        xfer += oprot->writeString(_iter2233->second);
       }
       xfer += oprot->writeMapEnd();
     }
@@ -30821,31 +29005,17 @@ uint32_t ThriftHiveMetastore_partition_name_to_spec_presult::read(::apache::thri
         if (ftype == ::apache::thrift::protocol::T_MAP) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2196;
-            ::apache::thrift::protocol::TType _ktype2197;
-            ::apache::thrift::protocol::TType _vtype2198;
-            xfer += iprot->readMapBegin(_ktype2197, _vtype2198, _size2196);
-            uint32_t _i2200;
-            for (_i2200 = 0; _i2200 < _size2196; ++_i2200)
-            {
-              std::string _key2201;
-              xfer += iprot->readString(_key2201);
-              std::string& _val2202 = (*(this->success))[_key2201];
-              xfer += iprot->readString(_val2202);
-=======
-            uint32_t _size2224;
-            ::apache::thrift::protocol::TType _ktype2225;
-            ::apache::thrift::protocol::TType _vtype2226;
-            xfer += iprot->readMapBegin(_ktype2225, _vtype2226, _size2224);
-            uint32_t _i2228;
-            for (_i2228 = 0; _i2228 < _size2224; ++_i2228)
+            uint32_t _size2234;
+            ::apache::thrift::protocol::TType _ktype2235;
+            ::apache::thrift::protocol::TType _vtype2236;
+            xfer += iprot->readMapBegin(_ktype2235, _vtype2236, _size2234);
+            uint32_t _i2238;
+            for (_i2238 = 0; _i2238 < _size2234; ++_i2238)
             {
-              std::string _key2229;
-              xfer += iprot->readString(_key2229);
-              std::string& _val2230 = (*(this->success))[_key2229];
-              xfer += iprot->readString(_val2230);
->>>>>>> External metastore: clean after rebase
+              std::string _key2239;
+              xfer += iprot->readString(_key2239);
+              std::string& _val2240 = (*(this->success))[_key2239];
+              xfer += iprot->readString(_val2240);
             }
             xfer += iprot->readMapEnd();
           }
@@ -30920,31 +29090,17 @@ uint32_t ThriftHiveMetastore_markPartitionForEvent_args::read(::apache::thrift::
         if (ftype == ::apache::thrift::protocol::T_MAP) {
           {
             this->part_vals.clear();
-<<<<<<< HEAD
-            uint32_t _size2203;
-            ::apache::thrift::protocol::TType _ktype2204;
-            ::apache::thrift::protocol::TType _vtype2205;
-            xfer += iprot->readMapBegin(_ktype2204, _vtype2205, _size2203);
-            uint32_t _i2207;
-            for (_i2207 = 0; _i2207 < _size2203; ++_i2207)
-            {
-              std::string _key2208;
-              xfer += iprot->readString(_key2208);
-              std::string& _val2209 = this->part_vals[_key2208];
-              xfer += iprot->readString(_val2209);
-=======
-            uint32_t _size2231;
-            ::apache::thrift::protocol::TType _ktype2232;
-            ::apache::thrift::protocol::TType _vtype2233;
-            xfer += iprot->readMapBegin(_ktype2232, _vtype2233, _size2231);
-            uint32_t _i2235;
-            for (_i2235 = 0; _i2235 < _size2231; ++_i2235)
+            uint32_t _size2241;
+            ::apache::thrift::protocol::TType _ktype2242;
+            ::apache::thrift::protocol::TType _vtype2243;
+            xfer += iprot->readMapBegin(_ktype2242, _vtype2243, _size2241);
+            uint32_t _i2245;
+            for (_i2245 = 0; _i2245 < _size2241; ++_i2245)
             {
-              std::string _key2236;
-              xfer += iprot->readString(_key2236);
-              std::string& _val2237 = this->part_vals[_key2236];
-              xfer += iprot->readString(_val2237);
->>>>>>> External metastore: clean after rebase
+              std::string _key2246;
+              xfer += iprot->readString(_key2246);
+              std::string& _val2247 = this->part_vals[_key2246];
+              xfer += iprot->readString(_val2247);
             }
             xfer += iprot->readMapEnd();
           }
@@ -30955,15 +29111,9 @@ uint32_t ThriftHiveMetastore_markPartitionForEvent_args::read(::apache::thrift::
         break;
       case 4:
         if (ftype == ::apache::thrift::protocol::T_I32) {
-<<<<<<< HEAD
-          int32_t ecast2210;
-          xfer += iprot->readI32(ecast2210);
-          this->eventType = (PartitionEventType::type)ecast2210;
-=======
-          int32_t ecast2238;
-          xfer += iprot->readI32(ecast2238);
-          this->eventType = (PartitionEventType::type)ecast2238;
->>>>>>> External metastore: clean after rebase
+          int32_t ecast2248;
+          xfer += iprot->readI32(ecast2248);
+          this->eventType = (PartitionEventType::type)ecast2248;
           this->__isset.eventType = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -30997,19 +29147,11 @@ uint32_t ThriftHiveMetastore_markPartitionForEvent_args::write(::apache::thrift:
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_MAP, 3);
   {
     xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
-<<<<<<< HEAD
-    std::map<std::string, std::string> ::const_iterator _iter2211;
-    for (_iter2211 = this->part_vals.begin(); _iter2211 != this->part_vals.end(); ++_iter2211)
-    {
-      xfer += oprot->writeString(_iter2211->first);
-      xfer += oprot->writeString(_iter2211->second);
-=======
-    std::map<std::string, std::string> ::const_iterator _iter2239;
-    for (_iter2239 = this->part_vals.begin(); _iter2239 != this->part_vals.end(); ++_iter2239)
+    std::map<std::string, std::string> ::const_iterator _iter2249;
+    for (_iter2249 = this->part_vals.begin(); _iter2249 != this->part_vals.end(); ++_iter2249)
     {
-      xfer += oprot->writeString(_iter2239->first);
-      xfer += oprot->writeString(_iter2239->second);
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString(_iter2249->first);
+      xfer += oprot->writeString(_iter2249->second);
     }
     xfer += oprot->writeMapEnd();
   }
@@ -31045,19 +29187,11 @@ uint32_t ThriftHiveMetastore_markPartitionForEvent_pargs::write(::apache::thrift
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_MAP, 3);
   {
     xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
-<<<<<<< HEAD
-    std::map<std::string, std::string> ::const_iterator _iter2212;
-    for (_iter2212 = (*(this->part_vals)).begin(); _iter2212 != (*(this->part_vals)).end(); ++_iter2212)
-    {
-      xfer += oprot->writeString(_iter2212->first);
-      xfer += oprot->writeString(_iter2212->second);
-=======
-    std::map<std::string, std::string> ::const_iterator _iter2240;
-    for (_iter2240 = (*(this->part_vals)).begin(); _iter2240 != (*(this->part_vals)).end(); ++_iter2240)
+    std::map<std::string, std::string> ::const_iterator _iter2250;
+    for (_iter2250 = (*(this->part_vals)).begin(); _iter2250 != (*(this->part_vals)).end(); ++_iter2250)
     {
-      xfer += oprot->writeString(_iter2240->first);
-      xfer += oprot->writeString(_iter2240->second);
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString(_iter2250->first);
+      xfer += oprot->writeString(_iter2250->second);
     }
     xfer += oprot->writeMapEnd();
   }
@@ -31326,31 +29460,17 @@ uint32_t ThriftHiveMetastore_isPartitionMarkedForEvent_args::read(::apache::thri
         if (ftype == ::apache::thrift::protocol::T_MAP) {
           {
             this->part_vals.clear();
-<<<<<<< HEAD
-            uint32_t _size2213;
-            ::apache::thrift::protocol::TType _ktype2214;
-            ::apache::thrift::protocol::TType _vtype2215;
-            xfer += iprot->readMapBegin(_ktype2214, _vtype2215, _size2213);
-            uint32_t _i2217;
-            for (_i2217 = 0; _i2217 < _size2213; ++_i2217)
-            {
-              std::string _key2218;
-              xfer += iprot->readString(_key2218);
-              std::string& _val2219 = this->part_vals[_key2218];
-              xfer += iprot->readString(_val2219);
-=======
-            uint32_t _size2241;
-            ::apache::thrift::protocol::TType _ktype2242;
-            ::apache::thrift::protocol::TType _vtype2243;
-            xfer += iprot->readMapBegin(_ktype2242, _vtype2243, _size2241);
-            uint32_t _i2245;
-            for (_i2245 = 0; _i2245 < _size2241; ++_i2245)
+            uint32_t _size2251;
+            ::apache::thrift::protocol::TType _ktype2252;
+            ::apache::thrift::protocol::TType _vtype2253;
+            xfer += iprot->readMapBegin(_ktype2252, _vtype2253, _size2251);
+            uint32_t _i2255;
+            for (_i2255 = 0; _i2255 < _size2251; ++_i2255)
             {
-              std::string _key2246;
-              xfer += iprot->readString(_key2246);
-              std::string& _val2247 = this->part_vals[_key2246];
-              xfer += iprot->readString(_val2247);
->>>>>>> External metastore: clean after rebase
+              std::string _key2256;
+              xfer += iprot->readString(_key2256);
+              std::string& _val2257 = this->part_vals[_key2256];
+              xfer += iprot->readString(_val2257);
             }
             xfer += iprot->readMapEnd();
           }
@@ -31361,15 +29481,9 @@ uint32_t ThriftHiveMetastore_isPartitionMarkedForEvent_args::read(::apache::thri
         break;
       case 4:
         if (ftype == ::apache::thrift::protocol::T_I32) {
-<<<<<<< HEAD
-          int32_t ecast2220;
-          xfer += iprot->readI32(ecast2220);
-          this->eventType = (PartitionEventType::type)ecast2220;
-=======
-          int32_t ecast2248;
-          xfer += iprot->readI32(ecast2248);
-          this->eventType = (PartitionEventType::type)ecast2248;
->>>>>>> External metastore: clean after rebase
+          int32_t ecast2258;
+          xfer += iprot->readI32(ecast2258);
+          this->eventType = (PartitionEventType::type)ecast2258;
           this->__isset.eventType = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -31403,19 +29517,11 @@ uint32_t ThriftHiveMetastore_isPartitionMarkedForEvent_args::write(::apache::thr
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_MAP, 3);
   {
     xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->part_vals.size()));
-<<<<<<< HEAD
-    std::map<std::string, std::string> ::const_iterator _iter2221;
-    for (_iter2221 = this->part_vals.begin(); _iter2221 != this->part_vals.end(); ++_iter2221)
+    std::map<std::string, std::string> ::const_iterator _iter2259;
+    for (_iter2259 = this->part_vals.begin(); _iter2259 != this->part_vals.end(); ++_iter2259)
     {
-      xfer += oprot->writeString(_iter2221->first);
-      xfer += oprot->writeString(_iter2221->second);
-=======
-    std::map<std::string, std::string> ::const_iterator _iter2249;
-    for (_iter2249 = this->part_vals.begin(); _iter2249 != this->part_vals.end(); ++_iter2249)
-    {
-      xfer += oprot->writeString(_iter2249->first);
-      xfer += oprot->writeString(_iter2249->second);
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString(_iter2259->first);
+      xfer += oprot->writeString(_iter2259->second);
     }
     xfer += oprot->writeMapEnd();
   }
@@ -31451,19 +29557,11 @@ uint32_t ThriftHiveMetastore_isPartitionMarkedForEvent_pargs::write(::apache::th
   xfer += oprot->writeFieldBegin("part_vals", ::apache::thrift::protocol::T_MAP, 3);
   {
     xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_STRING, ::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->part_vals)).size()));
-<<<<<<< HEAD
-    std::map<std::string, std::string> ::const_iterator _iter2222;
-    for (_iter2222 = (*(this->part_vals)).begin(); _iter2222 != (*(this->part_vals)).end(); ++_iter2222)
-    {
-      xfer += oprot->writeString(_iter2222->first);
-      xfer += oprot->writeString(_iter2222->second);
-=======
-    std::map<std::string, std::string> ::const_iterator _iter2250;
-    for (_iter2250 = (*(this->part_vals)).begin(); _iter2250 != (*(this->part_vals)).end(); ++_iter2250)
+    std::map<std::string, std::string> ::const_iterator _iter2260;
+    for (_iter2260 = (*(this->part_vals)).begin(); _iter2260 != (*(this->part_vals)).end(); ++_iter2260)
     {
-      xfer += oprot->writeString(_iter2250->first);
-      xfer += oprot->writeString(_iter2250->second);
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString(_iter2260->first);
+      xfer += oprot->writeString(_iter2260->second);
     }
     xfer += oprot->writeMapEnd();
   }
@@ -37405,25 +35503,14 @@ uint32_t ThriftHiveMetastore_get_functions_result::read(::apache::thrift::protoc
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2223;
-            ::apache::thrift::protocol::TType _etype2226;
-            xfer += iprot->readListBegin(_etype2226, _size2223);
-            this->success.resize(_size2223);
-            uint32_t _i2227;
-            for (_i2227 = 0; _i2227 < _size2223; ++_i2227)
-            {
-              xfer += iprot->readString(this->success[_i2227]);
-=======
-            uint32_t _size2251;
-            ::apache::thrift::protocol::TType _etype2254;
-            xfer += iprot->readListBegin(_etype2254, _size2251);
-            this->success.resize(_size2251);
-            uint32_t _i2255;
-            for (_i2255 = 0; _i2255 < _size2251; ++_i2255)
+            uint32_t _size2261;
+            ::apache::thrift::protocol::TType _etype2264;
+            xfer += iprot->readListBegin(_etype2264, _size2261);
+            this->success.resize(_size2261);
+            uint32_t _i2265;
+            for (_i2265 = 0; _i2265 < _size2261; ++_i2265)
             {
-              xfer += iprot->readString(this->success[_i2255]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->success[_i2265]);
             }
             xfer += iprot->readListEnd();
           }
@@ -37462,17 +35549,10 @@ uint32_t ThriftHiveMetastore_get_functions_result::write(::apache::thrift::proto
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter2228;
-      for (_iter2228 = this->success.begin(); _iter2228 != this->success.end(); ++_iter2228)
+      std::vector<std::string> ::const_iterator _iter2266;
+      for (_iter2266 = this->success.begin(); _iter2266 != this->success.end(); ++_iter2266)
       {
-        xfer += oprot->writeString((*_iter2228));
-=======
-      std::vector<std::string> ::const_iterator _iter2256;
-      for (_iter2256 = this->success.begin(); _iter2256 != this->success.end(); ++_iter2256)
-      {
-        xfer += oprot->writeString((*_iter2256));
->>>>>>> External metastore: clean after rebase
+        xfer += oprot->writeString((*_iter2266));
       }
       xfer += oprot->writeListEnd();
     }
@@ -37517,25 +35597,14 @@ uint32_t ThriftHiveMetastore_get_functions_presult::read(::apache::thrift::proto
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2229;
-            ::apache::thrift::protocol::TType _etype2232;
-            xfer += iprot->readListBegin(_etype2232, _size2229);
-            (*(this->success)).resize(_size2229);
-            uint32_t _i2233;
-            for (_i2233 = 0; _i2233 < _size2229; ++_i2233)
-            {
-              xfer += iprot->readString((*(this->success))[_i2233]);
-=======
-            uint32_t _size2257;
-            ::apache::thrift::protocol::TType _etype2260;
-            xfer += iprot->readListBegin(_etype2260, _size2257);
-            (*(this->success)).resize(_size2257);
-            uint32_t _i2261;
-            for (_i2261 = 0; _i2261 < _size2257; ++_i2261)
+            uint32_t _size2267;
+            ::apache::thrift::protocol::TType _etype2270;
+            xfer += iprot->readListBegin(_etype2270, _size2267);
+            (*(this->success)).resize(_size2267);
+            uint32_t _i2271;
+            for (_i2271 = 0; _i2271 < _size2267; ++_i2271)
             {
-              xfer += iprot->readString((*(this->success))[_i2261]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString((*(this->success))[_i2271]);
             }
             xfer += iprot->readListEnd();
           }
@@ -38495,25 +36564,14 @@ uint32_t ThriftHiveMetastore_get_role_names_result::read(::apache::thrift::proto
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2234;
-            ::apache::thrift::protocol::TType _etype2237;
-            xfer += iprot->readListBegin(_etype2237, _size2234);
-            this->success.resize(_size2234);
-            uint32_t _i2238;
-            for (_i2238 = 0; _i2238 < _size2234; ++_i2238)
-            {
-              xfer += iprot->readString(this->success[_i2238]);
-=======
-            uint32_t _size2262;
-            ::apache::thrift::protocol::TType _etype2265;
-            xfer += iprot->readListBegin(_etype2265, _size2262);
-            this->success.resize(_size2262);
-            uint32_t _i2266;
-            for (_i2266 = 0; _i2266 < _size2262; ++_i2266)
+            uint32_t _size2272;
+            ::apache::thrift::protocol::TType _etype2275;
+            xfer += iprot->readListBegin(_etype2275, _size2272);
+            this->success.resize(_size2272);
+            uint32_t _i2276;
+            for (_i2276 = 0; _i2276 < _size2272; ++_i2276)
             {
-              xfer += iprot->readString(this->success[_i2266]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->success[_i2276]);
             }
             xfer += iprot->readListEnd();
           }
@@ -38552,17 +36610,10 @@ uint32_t ThriftHiveMetastore_get_role_names_result::write(::apache::thrift::prot
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter2239;
-      for (_iter2239 = this->success.begin(); _iter2239 != this->success.end(); ++_iter2239)
+      std::vector<std::string> ::const_iterator _iter2277;
+      for (_iter2277 = this->success.begin(); _iter2277 != this->success.end(); ++_iter2277)
       {
-        xfer += oprot->writeString((*_iter2239));
-=======
-      std::vector<std::string> ::const_iterator _iter2267;
-      for (_iter2267 = this->success.begin(); _iter2267 != this->success.end(); ++_iter2267)
-      {
-        xfer += oprot->writeString((*_iter2267));
->>>>>>> External metastore: clean after rebase
+        xfer += oprot->writeString((*_iter2277));
       }
       xfer += oprot->writeListEnd();
     }
@@ -38607,25 +36658,14 @@ uint32_t ThriftHiveMetastore_get_role_names_presult::read(::apache::thrift::prot
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2240;
-            ::apache::thrift::protocol::TType _etype2243;
-            xfer += iprot->readListBegin(_etype2243, _size2240);
-            (*(this->success)).resize(_size2240);
-            uint32_t _i2244;
-            for (_i2244 = 0; _i2244 < _size2240; ++_i2244)
-            {
-              xfer += iprot->readString((*(this->success))[_i2244]);
-=======
-            uint32_t _size2268;
-            ::apache::thrift::protocol::TType _etype2271;
-            xfer += iprot->readListBegin(_etype2271, _size2268);
-            (*(this->success)).resize(_size2268);
-            uint32_t _i2272;
-            for (_i2272 = 0; _i2272 < _size2268; ++_i2272)
+            uint32_t _size2278;
+            ::apache::thrift::protocol::TType _etype2281;
+            xfer += iprot->readListBegin(_etype2281, _size2278);
+            (*(this->success)).resize(_size2278);
+            uint32_t _i2282;
+            for (_i2282 = 0; _i2282 < _size2278; ++_i2282)
             {
-              xfer += iprot->readString((*(this->success))[_i2272]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString((*(this->success))[_i2282]);
             }
             xfer += iprot->readListEnd();
           }
@@ -38698,15 +36738,9 @@ uint32_t ThriftHiveMetastore_grant_role_args::read(::apache::thrift::protocol::T
         break;
       case 3:
         if (ftype == ::apache::thrift::protocol::T_I32) {
-<<<<<<< HEAD
-          int32_t ecast2245;
-          xfer += iprot->readI32(ecast2245);
-          this->principal_type = (PrincipalType::type)ecast2245;
-=======
-          int32_t ecast2273;
-          xfer += iprot->readI32(ecast2273);
-          this->principal_type = (PrincipalType::type)ecast2273;
->>>>>>> External metastore: clean after rebase
+          int32_t ecast2283;
+          xfer += iprot->readI32(ecast2283);
+          this->principal_type = (PrincipalType::type)ecast2283;
           this->__isset.principal_type = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -38722,15 +36756,9 @@ uint32_t ThriftHiveMetastore_grant_role_args::read(::apache::thrift::protocol::T
         break;
       case 5:
         if (ftype == ::apache::thrift::protocol::T_I32) {
-<<<<<<< HEAD
-          int32_t ecast2246;
-          xfer += iprot->readI32(ecast2246);
-          this->grantorType = (PrincipalType::type)ecast2246;
-=======
-          int32_t ecast2274;
-          xfer += iprot->readI32(ecast2274);
-          this->grantorType = (PrincipalType::type)ecast2274;
->>>>>>> External metastore: clean after rebase
+          int32_t ecast2284;
+          xfer += iprot->readI32(ecast2284);
+          this->grantorType = (PrincipalType::type)ecast2284;
           this->__isset.grantorType = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -39001,15 +37029,9 @@ uint32_t ThriftHiveMetastore_revoke_role_args::read(::apache::thrift::protocol::
         break;
       case 3:
         if (ftype == ::apache::thrift::protocol::T_I32) {
-<<<<<<< HEAD
-          int32_t ecast2247;
-          xfer += iprot->readI32(ecast2247);
-          this->principal_type = (PrincipalType::type)ecast2247;
-=======
-          int32_t ecast2275;
-          xfer += iprot->readI32(ecast2275);
-          this->principal_type = (PrincipalType::type)ecast2275;
->>>>>>> External metastore: clean after rebase
+          int32_t ecast2285;
+          xfer += iprot->readI32(ecast2285);
+          this->principal_type = (PrincipalType::type)ecast2285;
           this->__isset.principal_type = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -39240,15 +37262,9 @@ uint32_t ThriftHiveMetastore_list_roles_args::read(::apache::thrift::protocol::T
         break;
       case 2:
         if (ftype == ::apache::thrift::protocol::T_I32) {
-<<<<<<< HEAD
-          int32_t ecast2248;
-          xfer += iprot->readI32(ecast2248);
-          this->principal_type = (PrincipalType::type)ecast2248;
-=======
-          int32_t ecast2276;
-          xfer += iprot->readI32(ecast2276);
-          this->principal_type = (PrincipalType::type)ecast2276;
->>>>>>> External metastore: clean after rebase
+          int32_t ecast2286;
+          xfer += iprot->readI32(ecast2286);
+          this->principal_type = (PrincipalType::type)ecast2286;
           this->__isset.principal_type = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -39337,25 +37353,14 @@ uint32_t ThriftHiveMetastore_list_roles_result::read(::apache::thrift::protocol:
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2249;
-            ::apache::thrift::protocol::TType _etype2252;
-            xfer += iprot->readListBegin(_etype2252, _size2249);
-            this->success.resize(_size2249);
-            uint32_t _i2253;
-            for (_i2253 = 0; _i2253 < _size2249; ++_i2253)
+            uint32_t _size2287;
+            ::apache::thrift::protocol::TType _etype2290;
+            xfer += iprot->readListBegin(_etype2290, _size2287);
+            this->success.resize(_size2287);
+            uint32_t _i2291;
+            for (_i2291 = 0; _i2291 < _size2287; ++_i2291)
             {
-              xfer += this->success[_i2253].read(iprot);
-=======
-            uint32_t _size2277;
-            ::apache::thrift::protocol::TType _etype2280;
-            xfer += iprot->readListBegin(_etype2280, _size2277);
-            this->success.resize(_size2277);
-            uint32_t _i2281;
-            for (_i2281 = 0; _i2281 < _size2277; ++_i2281)
-            {
-              xfer += this->success[_i2281].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->success[_i2291].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -39394,17 +37399,10 @@ uint32_t ThriftHiveMetastore_list_roles_result::write(::apache::thrift::protocol
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<Role> ::const_iterator _iter2254;
-      for (_iter2254 = this->success.begin(); _iter2254 != this->success.end(); ++_iter2254)
-      {
-        xfer += (*_iter2254).write(oprot);
-=======
-      std::vector<Role> ::const_iterator _iter2282;
-      for (_iter2282 = this->success.begin(); _iter2282 != this->success.end(); ++_iter2282)
+      std::vector<Role> ::const_iterator _iter2292;
+      for (_iter2292 = this->success.begin(); _iter2292 != this->success.end(); ++_iter2292)
       {
-        xfer += (*_iter2282).write(oprot);
->>>>>>> External metastore: clean after rebase
+        xfer += (*_iter2292).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -39449,25 +37447,14 @@ uint32_t ThriftHiveMetastore_list_roles_presult::read(::apache::thrift::protocol
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2255;
-            ::apache::thrift::protocol::TType _etype2258;
-            xfer += iprot->readListBegin(_etype2258, _size2255);
-            (*(this->success)).resize(_size2255);
-            uint32_t _i2259;
-            for (_i2259 = 0; _i2259 < _size2255; ++_i2259)
+            uint32_t _size2293;
+            ::apache::thrift::protocol::TType _etype2296;
+            xfer += iprot->readListBegin(_etype2296, _size2293);
+            (*(this->success)).resize(_size2293);
+            uint32_t _i2297;
+            for (_i2297 = 0; _i2297 < _size2293; ++_i2297)
             {
-              xfer += (*(this->success))[_i2259].read(iprot);
-=======
-            uint32_t _size2283;
-            ::apache::thrift::protocol::TType _etype2286;
-            xfer += iprot->readListBegin(_etype2286, _size2283);
-            (*(this->success)).resize(_size2283);
-            uint32_t _i2287;
-            for (_i2287 = 0; _i2287 < _size2283; ++_i2287)
-            {
-              xfer += (*(this->success))[_i2287].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += (*(this->success))[_i2297].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -40163,25 +38150,14 @@ uint32_t ThriftHiveMetastore_get_privilege_set_args::read(::apache::thrift::prot
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->group_names.clear();
-<<<<<<< HEAD
-            uint32_t _size2260;
-            ::apache::thrift::protocol::TType _etype2263;
-            xfer += iprot->readListBegin(_etype2263, _size2260);
-            this->group_names.resize(_size2260);
-            uint32_t _i2264;
-            for (_i2264 = 0; _i2264 < _size2260; ++_i2264)
-            {
-              xfer += iprot->readString(this->group_names[_i2264]);
-=======
-            uint32_t _size2288;
-            ::apache::thrift::protocol::TType _etype2291;
-            xfer += iprot->readListBegin(_etype2291, _size2288);
-            this->group_names.resize(_size2288);
-            uint32_t _i2292;
-            for (_i2292 = 0; _i2292 < _size2288; ++_i2292)
+            uint32_t _size2298;
+            ::apache::thrift::protocol::TType _etype2301;
+            xfer += iprot->readListBegin(_etype2301, _size2298);
+            this->group_names.resize(_size2298);
+            uint32_t _i2302;
+            for (_i2302 = 0; _i2302 < _size2298; ++_i2302)
             {
-              xfer += iprot->readString(this->group_names[_i2292]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->group_names[_i2302]);
             }
             xfer += iprot->readListEnd();
           }
@@ -40218,17 +38194,10 @@ uint32_t ThriftHiveMetastore_get_privilege_set_args::write(::apache::thrift::pro
   xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->group_names.size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter2265;
-    for (_iter2265 = this->group_names.begin(); _iter2265 != this->group_names.end(); ++_iter2265)
+    std::vector<std::string> ::const_iterator _iter2303;
+    for (_iter2303 = this->group_names.begin(); _iter2303 != this->group_names.end(); ++_iter2303)
     {
-      xfer += oprot->writeString((*_iter2265));
-=======
-    std::vector<std::string> ::const_iterator _iter2293;
-    for (_iter2293 = this->group_names.begin(); _iter2293 != this->group_names.end(); ++_iter2293)
-    {
-      xfer += oprot->writeString((*_iter2293));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2303));
     }
     xfer += oprot->writeListEnd();
   }
@@ -40260,17 +38229,10 @@ uint32_t ThriftHiveMetastore_get_privilege_set_pargs::write(::apache::thrift::pr
   xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 3);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->group_names)).size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter2266;
-    for (_iter2266 = (*(this->group_names)).begin(); _iter2266 != (*(this->group_names)).end(); ++_iter2266)
-    {
-      xfer += oprot->writeString((*_iter2266));
-=======
-    std::vector<std::string> ::const_iterator _iter2294;
-    for (_iter2294 = (*(this->group_names)).begin(); _iter2294 != (*(this->group_names)).end(); ++_iter2294)
+    std::vector<std::string> ::const_iterator _iter2304;
+    for (_iter2304 = (*(this->group_names)).begin(); _iter2304 != (*(this->group_names)).end(); ++_iter2304)
     {
-      xfer += oprot->writeString((*_iter2294));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2304));
     }
     xfer += oprot->writeListEnd();
   }
@@ -40445,15 +38407,9 @@ uint32_t ThriftHiveMetastore_list_privileges_args::read(::apache::thrift::protoc
         break;
       case 2:
         if (ftype == ::apache::thrift::protocol::T_I32) {
-<<<<<<< HEAD
-          int32_t ecast2267;
-          xfer += iprot->readI32(ecast2267);
-          this->principal_type = (PrincipalType::type)ecast2267;
-=======
-          int32_t ecast2295;
-          xfer += iprot->readI32(ecast2295);
-          this->principal_type = (PrincipalType::type)ecast2295;
->>>>>>> External metastore: clean after rebase
+          int32_t ecast2305;
+          xfer += iprot->readI32(ecast2305);
+          this->principal_type = (PrincipalType::type)ecast2305;
           this->__isset.principal_type = true;
         } else {
           xfer += iprot->skip(ftype);
@@ -40558,25 +38514,14 @@ uint32_t ThriftHiveMetastore_list_privileges_result::read(::apache::thrift::prot
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2268;
-            ::apache::thrift::protocol::TType _etype2271;
-            xfer += iprot->readListBegin(_etype2271, _size2268);
-            this->success.resize(_size2268);
-            uint32_t _i2272;
-            for (_i2272 = 0; _i2272 < _size2268; ++_i2272)
+            uint32_t _size2306;
+            ::apache::thrift::protocol::TType _etype2309;
+            xfer += iprot->readListBegin(_etype2309, _size2306);
+            this->success.resize(_size2306);
+            uint32_t _i2310;
+            for (_i2310 = 0; _i2310 < _size2306; ++_i2310)
             {
-              xfer += this->success[_i2272].read(iprot);
-=======
-            uint32_t _size2296;
-            ::apache::thrift::protocol::TType _etype2299;
-            xfer += iprot->readListBegin(_etype2299, _size2296);
-            this->success.resize(_size2296);
-            uint32_t _i2300;
-            for (_i2300 = 0; _i2300 < _size2296; ++_i2300)
-            {
-              xfer += this->success[_i2300].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->success[_i2310].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -40615,17 +38560,10 @@ uint32_t ThriftHiveMetastore_list_privileges_result::write(::apache::thrift::pro
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<HiveObjectPrivilege> ::const_iterator _iter2273;
-      for (_iter2273 = this->success.begin(); _iter2273 != this->success.end(); ++_iter2273)
-      {
-        xfer += (*_iter2273).write(oprot);
-=======
-      std::vector<HiveObjectPrivilege> ::const_iterator _iter2301;
-      for (_iter2301 = this->success.begin(); _iter2301 != this->success.end(); ++_iter2301)
+      std::vector<HiveObjectPrivilege> ::const_iterator _iter2311;
+      for (_iter2311 = this->success.begin(); _iter2311 != this->success.end(); ++_iter2311)
       {
-        xfer += (*_iter2301).write(oprot);
->>>>>>> External metastore: clean after rebase
+        xfer += (*_iter2311).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -40670,25 +38608,14 @@ uint32_t ThriftHiveMetastore_list_privileges_presult::read(::apache::thrift::pro
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2274;
-            ::apache::thrift::protocol::TType _etype2277;
-            xfer += iprot->readListBegin(_etype2277, _size2274);
-            (*(this->success)).resize(_size2274);
-            uint32_t _i2278;
-            for (_i2278 = 0; _i2278 < _size2274; ++_i2278)
+            uint32_t _size2312;
+            ::apache::thrift::protocol::TType _etype2315;
+            xfer += iprot->readListBegin(_etype2315, _size2312);
+            (*(this->success)).resize(_size2312);
+            uint32_t _i2316;
+            for (_i2316 = 0; _i2316 < _size2312; ++_i2316)
             {
-              xfer += (*(this->success))[_i2278].read(iprot);
-=======
-            uint32_t _size2302;
-            ::apache::thrift::protocol::TType _etype2305;
-            xfer += iprot->readListBegin(_etype2305, _size2302);
-            (*(this->success)).resize(_size2302);
-            uint32_t _i2306;
-            for (_i2306 = 0; _i2306 < _size2302; ++_i2306)
-            {
-              xfer += (*(this->success))[_i2306].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += (*(this->success))[_i2316].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -41615,25 +39542,14 @@ uint32_t ThriftHiveMetastore_set_ugi_args::read(::apache::thrift::protocol::TPro
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->group_names.clear();
-<<<<<<< HEAD
-            uint32_t _size2279;
-            ::apache::thrift::protocol::TType _etype2282;
-            xfer += iprot->readListBegin(_etype2282, _size2279);
-            this->group_names.resize(_size2279);
-            uint32_t _i2283;
-            for (_i2283 = 0; _i2283 < _size2279; ++_i2283)
-            {
-              xfer += iprot->readString(this->group_names[_i2283]);
-=======
-            uint32_t _size2307;
-            ::apache::thrift::protocol::TType _etype2310;
-            xfer += iprot->readListBegin(_etype2310, _size2307);
-            this->group_names.resize(_size2307);
-            uint32_t _i2311;
-            for (_i2311 = 0; _i2311 < _size2307; ++_i2311)
+            uint32_t _size2317;
+            ::apache::thrift::protocol::TType _etype2320;
+            xfer += iprot->readListBegin(_etype2320, _size2317);
+            this->group_names.resize(_size2317);
+            uint32_t _i2321;
+            for (_i2321 = 0; _i2321 < _size2317; ++_i2321)
             {
-              xfer += iprot->readString(this->group_names[_i2311]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->group_names[_i2321]);
             }
             xfer += iprot->readListEnd();
           }
@@ -41666,17 +39582,10 @@ uint32_t ThriftHiveMetastore_set_ugi_args::write(::apache::thrift::protocol::TPr
   xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 2);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->group_names.size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter2284;
-    for (_iter2284 = this->group_names.begin(); _iter2284 != this->group_names.end(); ++_iter2284)
+    std::vector<std::string> ::const_iterator _iter2322;
+    for (_iter2322 = this->group_names.begin(); _iter2322 != this->group_names.end(); ++_iter2322)
     {
-      xfer += oprot->writeString((*_iter2284));
-=======
-    std::vector<std::string> ::const_iterator _iter2312;
-    for (_iter2312 = this->group_names.begin(); _iter2312 != this->group_names.end(); ++_iter2312)
-    {
-      xfer += oprot->writeString((*_iter2312));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2322));
     }
     xfer += oprot->writeListEnd();
   }
@@ -41704,17 +39613,10 @@ uint32_t ThriftHiveMetastore_set_ugi_pargs::write(::apache::thrift::protocol::TP
   xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 2);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>((*(this->group_names)).size()));
-<<<<<<< HEAD
-    std::vector<std::string> ::const_iterator _iter2285;
-    for (_iter2285 = (*(this->group_names)).begin(); _iter2285 != (*(this->group_names)).end(); ++_iter2285)
-    {
-      xfer += oprot->writeString((*_iter2285));
-=======
-    std::vector<std::string> ::const_iterator _iter2313;
-    for (_iter2313 = (*(this->group_names)).begin(); _iter2313 != (*(this->group_names)).end(); ++_iter2313)
+    std::vector<std::string> ::const_iterator _iter2323;
+    for (_iter2323 = (*(this->group_names)).begin(); _iter2323 != (*(this->group_names)).end(); ++_iter2323)
     {
-      xfer += oprot->writeString((*_iter2313));
->>>>>>> External metastore: clean after rebase
+      xfer += oprot->writeString((*_iter2323));
     }
     xfer += oprot->writeListEnd();
   }
@@ -41755,25 +39657,14 @@ uint32_t ThriftHiveMetastore_set_ugi_result::read(::apache::thrift::protocol::TP
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2286;
-            ::apache::thrift::protocol::TType _etype2289;
-            xfer += iprot->readListBegin(_etype2289, _size2286);
-            this->success.resize(_size2286);
-            uint32_t _i2290;
-            for (_i2290 = 0; _i2290 < _size2286; ++_i2290)
+            uint32_t _size2324;
+            ::apache::thrift::protocol::TType _etype2327;
+            xfer += iprot->readListBegin(_etype2327, _size2324);
+            this->success.resize(_size2324);
+            uint32_t _i2328;
+            for (_i2328 = 0; _i2328 < _size2324; ++_i2328)
             {
-              xfer += iprot->readString(this->success[_i2290]);
-=======
-            uint32_t _size2314;
-            ::apache::thrift::protocol::TType _etype2317;
-            xfer += iprot->readListBegin(_etype2317, _size2314);
-            this->success.resize(_size2314);
-            uint32_t _i2318;
-            for (_i2318 = 0; _i2318 < _size2314; ++_i2318)
-            {
-              xfer += iprot->readString(this->success[_i2318]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->success[_i2328]);
             }
             xfer += iprot->readListEnd();
           }
@@ -41812,17 +39703,10 @@ uint32_t ThriftHiveMetastore_set_ugi_result::write(::apache::thrift::protocol::T
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter2291;
-      for (_iter2291 = this->success.begin(); _iter2291 != this->success.end(); ++_iter2291)
-      {
-        xfer += oprot->writeString((*_iter2291));
-=======
-      std::vector<std::string> ::const_iterator _iter2319;
-      for (_iter2319 = this->success.begin(); _iter2319 != this->success.end(); ++_iter2319)
+      std::vector<std::string> ::const_iterator _iter2329;
+      for (_iter2329 = this->success.begin(); _iter2329 != this->success.end(); ++_iter2329)
       {
-        xfer += oprot->writeString((*_iter2319));
->>>>>>> External metastore: clean after rebase
+        xfer += oprot->writeString((*_iter2329));
       }
       xfer += oprot->writeListEnd();
     }
@@ -41867,25 +39751,14 @@ uint32_t ThriftHiveMetastore_set_ugi_presult::read(::apache::thrift::protocol::T
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2292;
-            ::apache::thrift::protocol::TType _etype2295;
-            xfer += iprot->readListBegin(_etype2295, _size2292);
-            (*(this->success)).resize(_size2292);
-            uint32_t _i2296;
-            for (_i2296 = 0; _i2296 < _size2292; ++_i2296)
-            {
-              xfer += iprot->readString((*(this->success))[_i2296]);
-=======
-            uint32_t _size2320;
-            ::apache::thrift::protocol::TType _etype2323;
-            xfer += iprot->readListBegin(_etype2323, _size2320);
-            (*(this->success)).resize(_size2320);
-            uint32_t _i2324;
-            for (_i2324 = 0; _i2324 < _size2320; ++_i2324)
+            uint32_t _size2330;
+            ::apache::thrift::protocol::TType _etype2333;
+            xfer += iprot->readListBegin(_etype2333, _size2330);
+            (*(this->success)).resize(_size2330);
+            uint32_t _i2334;
+            for (_i2334 = 0; _i2334 < _size2330; ++_i2334)
             {
-              xfer += iprot->readString((*(this->success))[_i2324]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString((*(this->success))[_i2334]);
             }
             xfer += iprot->readListEnd();
           }
@@ -43196,25 +41069,14 @@ uint32_t ThriftHiveMetastore_get_all_token_identifiers_result::read(::apache::th
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2297;
-            ::apache::thrift::protocol::TType _etype2300;
-            xfer += iprot->readListBegin(_etype2300, _size2297);
-            this->success.resize(_size2297);
-            uint32_t _i2301;
-            for (_i2301 = 0; _i2301 < _size2297; ++_i2301)
+            uint32_t _size2335;
+            ::apache::thrift::protocol::TType _etype2338;
+            xfer += iprot->readListBegin(_etype2338, _size2335);
+            this->success.resize(_size2335);
+            uint32_t _i2339;
+            for (_i2339 = 0; _i2339 < _size2335; ++_i2339)
             {
-              xfer += iprot->readString(this->success[_i2301]);
-=======
-            uint32_t _size2325;
-            ::apache::thrift::protocol::TType _etype2328;
-            xfer += iprot->readListBegin(_etype2328, _size2325);
-            this->success.resize(_size2325);
-            uint32_t _i2329;
-            for (_i2329 = 0; _i2329 < _size2325; ++_i2329)
-            {
-              xfer += iprot->readString(this->success[_i2329]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->success[_i2339]);
             }
             xfer += iprot->readListEnd();
           }
@@ -43245,17 +41107,10 @@ uint32_t ThriftHiveMetastore_get_all_token_identifiers_result::write(::apache::t
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter2302;
-      for (_iter2302 = this->success.begin(); _iter2302 != this->success.end(); ++_iter2302)
-      {
-        xfer += oprot->writeString((*_iter2302));
-=======
-      std::vector<std::string> ::const_iterator _iter2330;
-      for (_iter2330 = this->success.begin(); _iter2330 != this->success.end(); ++_iter2330)
+      std::vector<std::string> ::const_iterator _iter2340;
+      for (_iter2340 = this->success.begin(); _iter2340 != this->success.end(); ++_iter2340)
       {
-        xfer += oprot->writeString((*_iter2330));
->>>>>>> External metastore: clean after rebase
+        xfer += oprot->writeString((*_iter2340));
       }
       xfer += oprot->writeListEnd();
     }
@@ -43296,25 +41151,14 @@ uint32_t ThriftHiveMetastore_get_all_token_identifiers_presult::read(::apache::t
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2303;
-            ::apache::thrift::protocol::TType _etype2306;
-            xfer += iprot->readListBegin(_etype2306, _size2303);
-            (*(this->success)).resize(_size2303);
-            uint32_t _i2307;
-            for (_i2307 = 0; _i2307 < _size2303; ++_i2307)
-            {
-              xfer += iprot->readString((*(this->success))[_i2307]);
-=======
-            uint32_t _size2331;
-            ::apache::thrift::protocol::TType _etype2334;
-            xfer += iprot->readListBegin(_etype2334, _size2331);
-            (*(this->success)).resize(_size2331);
-            uint32_t _i2335;
-            for (_i2335 = 0; _i2335 < _size2331; ++_i2335)
+            uint32_t _size2341;
+            ::apache::thrift::protocol::TType _etype2344;
+            xfer += iprot->readListBegin(_etype2344, _size2341);
+            (*(this->success)).resize(_size2341);
+            uint32_t _i2345;
+            for (_i2345 = 0; _i2345 < _size2341; ++_i2345)
             {
-              xfer += iprot->readString((*(this->success))[_i2335]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString((*(this->success))[_i2345]);
             }
             xfer += iprot->readListEnd();
           }
@@ -44040,25 +41884,14 @@ uint32_t ThriftHiveMetastore_get_master_keys_result::read(::apache::thrift::prot
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2308;
-            ::apache::thrift::protocol::TType _etype2311;
-            xfer += iprot->readListBegin(_etype2311, _size2308);
-            this->success.resize(_size2308);
-            uint32_t _i2312;
-            for (_i2312 = 0; _i2312 < _size2308; ++_i2312)
+            uint32_t _size2346;
+            ::apache::thrift::protocol::TType _etype2349;
+            xfer += iprot->readListBegin(_etype2349, _size2346);
+            this->success.resize(_size2346);
+            uint32_t _i2350;
+            for (_i2350 = 0; _i2350 < _size2346; ++_i2350)
             {
-              xfer += iprot->readString(this->success[_i2312]);
-=======
-            uint32_t _size2336;
-            ::apache::thrift::protocol::TType _etype2339;
-            xfer += iprot->readListBegin(_etype2339, _size2336);
-            this->success.resize(_size2336);
-            uint32_t _i2340;
-            for (_i2340 = 0; _i2340 < _size2336; ++_i2340)
-            {
-              xfer += iprot->readString(this->success[_i2340]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->success[_i2350]);
             }
             xfer += iprot->readListEnd();
           }
@@ -44089,17 +41922,10 @@ uint32_t ThriftHiveMetastore_get_master_keys_result::write(::apache::thrift::pro
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter2313;
-      for (_iter2313 = this->success.begin(); _iter2313 != this->success.end(); ++_iter2313)
-      {
-        xfer += oprot->writeString((*_iter2313));
-=======
-      std::vector<std::string> ::const_iterator _iter2341;
-      for (_iter2341 = this->success.begin(); _iter2341 != this->success.end(); ++_iter2341)
+      std::vector<std::string> ::const_iterator _iter2351;
+      for (_iter2351 = this->success.begin(); _iter2351 != this->success.end(); ++_iter2351)
       {
-        xfer += oprot->writeString((*_iter2341));
->>>>>>> External metastore: clean after rebase
+        xfer += oprot->writeString((*_iter2351));
       }
       xfer += oprot->writeListEnd();
     }
@@ -44140,25 +41966,14 @@ uint32_t ThriftHiveMetastore_get_master_keys_presult::read(::apache::thrift::pro
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2314;
-            ::apache::thrift::protocol::TType _etype2317;
-            xfer += iprot->readListBegin(_etype2317, _size2314);
-            (*(this->success)).resize(_size2314);
-            uint32_t _i2318;
-            for (_i2318 = 0; _i2318 < _size2314; ++_i2318)
-            {
-              xfer += iprot->readString((*(this->success))[_i2318]);
-=======
-            uint32_t _size2342;
-            ::apache::thrift::protocol::TType _etype2345;
-            xfer += iprot->readListBegin(_etype2345, _size2342);
-            (*(this->success)).resize(_size2342);
-            uint32_t _i2346;
-            for (_i2346 = 0; _i2346 < _size2342; ++_i2346)
+            uint32_t _size2352;
+            ::apache::thrift::protocol::TType _etype2355;
+            xfer += iprot->readListBegin(_etype2355, _size2352);
+            (*(this->success)).resize(_size2352);
+            uint32_t _i2356;
+            for (_i2356 = 0; _i2356 < _size2352; ++_i2356)
             {
-              xfer += iprot->readString((*(this->success))[_i2346]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString((*(this->success))[_i2356]);
             }
             xfer += iprot->readListEnd();
           }
@@ -49220,25 +47035,14 @@ uint32_t ThriftHiveMetastore_find_columns_with_stats_result::read(::apache::thri
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2319;
-            ::apache::thrift::protocol::TType _etype2322;
-            xfer += iprot->readListBegin(_etype2322, _size2319);
-            this->success.resize(_size2319);
-            uint32_t _i2323;
-            for (_i2323 = 0; _i2323 < _size2319; ++_i2323)
+            uint32_t _size2357;
+            ::apache::thrift::protocol::TType _etype2360;
+            xfer += iprot->readListBegin(_etype2360, _size2357);
+            this->success.resize(_size2357);
+            uint32_t _i2361;
+            for (_i2361 = 0; _i2361 < _size2357; ++_i2361)
             {
-              xfer += iprot->readString(this->success[_i2323]);
-=======
-            uint32_t _size2347;
-            ::apache::thrift::protocol::TType _etype2350;
-            xfer += iprot->readListBegin(_etype2350, _size2347);
-            this->success.resize(_size2347);
-            uint32_t _i2351;
-            for (_i2351 = 0; _i2351 < _size2347; ++_i2351)
-            {
-              xfer += iprot->readString(this->success[_i2351]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString(this->success[_i2361]);
             }
             xfer += iprot->readListEnd();
           }
@@ -49269,17 +47073,10 @@ uint32_t ThriftHiveMetastore_find_columns_with_stats_result::write(::apache::thr
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter2324;
-      for (_iter2324 = this->success.begin(); _iter2324 != this->success.end(); ++_iter2324)
-      {
-        xfer += oprot->writeString((*_iter2324));
-=======
-      std::vector<std::string> ::const_iterator _iter2352;
-      for (_iter2352 = this->success.begin(); _iter2352 != this->success.end(); ++_iter2352)
+      std::vector<std::string> ::const_iterator _iter2362;
+      for (_iter2362 = this->success.begin(); _iter2362 != this->success.end(); ++_iter2362)
       {
-        xfer += oprot->writeString((*_iter2352));
->>>>>>> External metastore: clean after rebase
+        xfer += oprot->writeString((*_iter2362));
       }
       xfer += oprot->writeListEnd();
     }
@@ -49320,25 +47117,14 @@ uint32_t ThriftHiveMetastore_find_columns_with_stats_presult::read(::apache::thr
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2325;
-            ::apache::thrift::protocol::TType _etype2328;
-            xfer += iprot->readListBegin(_etype2328, _size2325);
-            (*(this->success)).resize(_size2325);
-            uint32_t _i2329;
-            for (_i2329 = 0; _i2329 < _size2325; ++_i2329)
-            {
-              xfer += iprot->readString((*(this->success))[_i2329]);
-=======
-            uint32_t _size2353;
-            ::apache::thrift::protocol::TType _etype2356;
-            xfer += iprot->readListBegin(_etype2356, _size2353);
-            (*(this->success)).resize(_size2353);
-            uint32_t _i2357;
-            for (_i2357 = 0; _i2357 < _size2353; ++_i2357)
+            uint32_t _size2363;
+            ::apache::thrift::protocol::TType _etype2366;
+            xfer += iprot->readListBegin(_etype2366, _size2363);
+            (*(this->success)).resize(_size2363);
+            uint32_t _i2367;
+            for (_i2367 = 0; _i2367 < _size2363; ++_i2367)
             {
-              xfer += iprot->readString((*(this->success))[_i2357]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString((*(this->success))[_i2367]);
             }
             xfer += iprot->readListEnd();
           }
@@ -58306,25 +56092,14 @@ uint32_t ThriftHiveMetastore_get_schema_all_versions_result::read(::apache::thri
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2330;
-            ::apache::thrift::protocol::TType _etype2333;
-            xfer += iprot->readListBegin(_etype2333, _size2330);
-            this->success.resize(_size2330);
-            uint32_t _i2334;
-            for (_i2334 = 0; _i2334 < _size2330; ++_i2334)
-            {
-              xfer += this->success[_i2334].read(iprot);
-=======
-            uint32_t _size2358;
-            ::apache::thrift::protocol::TType _etype2361;
-            xfer += iprot->readListBegin(_etype2361, _size2358);
-            this->success.resize(_size2358);
-            uint32_t _i2362;
-            for (_i2362 = 0; _i2362 < _size2358; ++_i2362)
+            uint32_t _size2368;
+            ::apache::thrift::protocol::TType _etype2371;
+            xfer += iprot->readListBegin(_etype2371, _size2368);
+            this->success.resize(_size2368);
+            uint32_t _i2372;
+            for (_i2372 = 0; _i2372 < _size2368; ++_i2372)
             {
-              xfer += this->success[_i2362].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->success[_i2372].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -58371,17 +56146,10 @@ uint32_t ThriftHiveMetastore_get_schema_all_versions_result::write(::apache::thr
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<SchemaVersion> ::const_iterator _iter2335;
-      for (_iter2335 = this->success.begin(); _iter2335 != this->success.end(); ++_iter2335)
+      std::vector<SchemaVersion> ::const_iterator _iter2373;
+      for (_iter2373 = this->success.begin(); _iter2373 != this->success.end(); ++_iter2373)
       {
-        xfer += (*_iter2335).write(oprot);
-=======
-      std::vector<SchemaVersion> ::const_iterator _iter2363;
-      for (_iter2363 = this->success.begin(); _iter2363 != this->success.end(); ++_iter2363)
-      {
-        xfer += (*_iter2363).write(oprot);
->>>>>>> External metastore: clean after rebase
+        xfer += (*_iter2373).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -58430,25 +56198,14 @@ uint32_t ThriftHiveMetastore_get_schema_all_versions_presult::read(::apache::thr
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2336;
-            ::apache::thrift::protocol::TType _etype2339;
-            xfer += iprot->readListBegin(_etype2339, _size2336);
-            (*(this->success)).resize(_size2336);
-            uint32_t _i2340;
-            for (_i2340 = 0; _i2340 < _size2336; ++_i2340)
-            {
-              xfer += (*(this->success))[_i2340].read(iprot);
-=======
-            uint32_t _size2364;
-            ::apache::thrift::protocol::TType _etype2367;
-            xfer += iprot->readListBegin(_etype2367, _size2364);
-            (*(this->success)).resize(_size2364);
-            uint32_t _i2368;
-            for (_i2368 = 0; _i2368 < _size2364; ++_i2368)
+            uint32_t _size2374;
+            ::apache::thrift::protocol::TType _etype2377;
+            xfer += iprot->readListBegin(_etype2377, _size2374);
+            (*(this->success)).resize(_size2374);
+            uint32_t _i2378;
+            for (_i2378 = 0; _i2378 < _size2374; ++_i2378)
             {
-              xfer += (*(this->success))[_i2368].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += (*(this->success))[_i2378].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -60501,25 +58258,14 @@ uint32_t ThriftHiveMetastore_get_runtime_stats_result::read(::apache::thrift::pr
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2341;
-            ::apache::thrift::protocol::TType _etype2344;
-            xfer += iprot->readListBegin(_etype2344, _size2341);
-            this->success.resize(_size2341);
-            uint32_t _i2345;
-            for (_i2345 = 0; _i2345 < _size2341; ++_i2345)
-            {
-              xfer += this->success[_i2345].read(iprot);
-=======
-            uint32_t _size2369;
-            ::apache::thrift::protocol::TType _etype2372;
-            xfer += iprot->readListBegin(_etype2372, _size2369);
-            this->success.resize(_size2369);
-            uint32_t _i2373;
-            for (_i2373 = 0; _i2373 < _size2369; ++_i2373)
+            uint32_t _size2379;
+            ::apache::thrift::protocol::TType _etype2382;
+            xfer += iprot->readListBegin(_etype2382, _size2379);
+            this->success.resize(_size2379);
+            uint32_t _i2383;
+            for (_i2383 = 0; _i2383 < _size2379; ++_i2383)
             {
-              xfer += this->success[_i2373].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += this->success[_i2383].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -60558,17 +58304,10 @@ uint32_t ThriftHiveMetastore_get_runtime_stats_result::write(::apache::thrift::p
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<RuntimeStat> ::const_iterator _iter2346;
-      for (_iter2346 = this->success.begin(); _iter2346 != this->success.end(); ++_iter2346)
+      std::vector<RuntimeStat> ::const_iterator _iter2384;
+      for (_iter2384 = this->success.begin(); _iter2384 != this->success.end(); ++_iter2384)
       {
-        xfer += (*_iter2346).write(oprot);
-=======
-      std::vector<RuntimeStat> ::const_iterator _iter2374;
-      for (_iter2374 = this->success.begin(); _iter2374 != this->success.end(); ++_iter2374)
-      {
-        xfer += (*_iter2374).write(oprot);
->>>>>>> External metastore: clean after rebase
+        xfer += (*_iter2384).write(oprot);
       }
       xfer += oprot->writeListEnd();
     }
@@ -60613,25 +58352,14 @@ uint32_t ThriftHiveMetastore_get_runtime_stats_presult::read(::apache::thrift::p
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2347;
-            ::apache::thrift::protocol::TType _etype2350;
-            xfer += iprot->readListBegin(_etype2350, _size2347);
-            (*(this->success)).resize(_size2347);
-            uint32_t _i2351;
-            for (_i2351 = 0; _i2351 < _size2347; ++_i2351)
-            {
-              xfer += (*(this->success))[_i2351].read(iprot);
-=======
-            uint32_t _size2375;
-            ::apache::thrift::protocol::TType _etype2378;
-            xfer += iprot->readListBegin(_etype2378, _size2375);
-            (*(this->success)).resize(_size2375);
-            uint32_t _i2379;
-            for (_i2379 = 0; _i2379 < _size2375; ++_i2379)
+            uint32_t _size2385;
+            ::apache::thrift::protocol::TType _etype2388;
+            xfer += iprot->readListBegin(_etype2388, _size2385);
+            (*(this->success)).resize(_size2385);
+            uint32_t _i2389;
+            for (_i2389 = 0; _i2389 < _size2385; ++_i2389)
             {
-              xfer += (*(this->success))[_i2379].read(iprot);
->>>>>>> External metastore: clean after rebase
+              xfer += (*(this->success))[_i2389].read(iprot);
             }
             xfer += iprot->readListEnd();
           }
@@ -63046,137 +60774,108 @@ uint32_t ThriftHiveMetastore_get_all_stored_procedures_result::read(::apache::th
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-<<<<<<< HEAD
-            uint32_t _size2352;
-            ::apache::thrift::protocol::TType _etype2355;
-            xfer += iprot->readListBegin(_etype2355, _size2352);
-            this->success.resize(_size2352);
-            uint32_t _i2356;
-            for (_i2356 = 0; _i2356 < _size2352; ++_i2356)
+            uint32_t _size2390;
+            ::apache::thrift::protocol::TType _etype2393;
+            xfer += iprot->readListBegin(_etype2393, _size2390);
+            this->success.resize(_size2390);
+            uint32_t _i2394;
+            for (_i2394 = 0; _i2394 < _size2390; ++_i2394)
             {
-              xfer += iprot->readString(this->success[_i2356]);
-=======
-            uint32_t _size2380;
-            ::apache::thrift::protocol::TType _etype2383;
-            xfer += iprot->readListBegin(_etype2383, _size2380);
-            this->success.resize(_size2380);
-            uint32_t _i2384;
-            for (_i2384 = 0; _i2384 < _size2380; ++_i2384)
+              xfer += iprot->readString(this->success[_i2394]);
+            }
+            xfer += iprot->readListEnd();
+          }
+          this->__isset.success = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      case 1:
+        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+          xfer += this->o1.read(iprot);
+          this->__isset.o1 = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
+      default:
+        xfer += iprot->skip(ftype);
+        break;
+    }
+    xfer += iprot->readFieldEnd();
+  }
+
+  xfer += iprot->readStructEnd();
+
+  return xfer;
+}
+
+uint32_t ThriftHiveMetastore_get_all_stored_procedures_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
+
+  uint32_t xfer = 0;
+
+  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_all_stored_procedures_result");
+
+  if (this->__isset.success) {
+    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
+    {
+      xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
+      std::vector<std::string> ::const_iterator _iter2395;
+      for (_iter2395 = this->success.begin(); _iter2395 != this->success.end(); ++_iter2395)
+      {
+        xfer += oprot->writeString((*_iter2395));
+      }
+      xfer += oprot->writeListEnd();
+    }
+    xfer += oprot->writeFieldEnd();
+  } else if (this->__isset.o1) {
+    xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
+    xfer += this->o1.write(oprot);
+    xfer += oprot->writeFieldEnd();
+  }
+  xfer += oprot->writeFieldStop();
+  xfer += oprot->writeStructEnd();
+  return xfer;
+}
+
+
+ThriftHiveMetastore_get_all_stored_procedures_presult::~ThriftHiveMetastore_get_all_stored_procedures_presult() noexcept {
+}
+
+
+uint32_t ThriftHiveMetastore_get_all_stored_procedures_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
+
+  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
+  uint32_t xfer = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TType ftype;
+  int16_t fid;
+
+  xfer += iprot->readStructBegin(fname);
+
+  using ::apache::thrift::protocol::TProtocolException;
+
+
+  while (true)
+  {
+    xfer += iprot->readFieldBegin(fname, ftype, fid);
+    if (ftype == ::apache::thrift::protocol::T_STOP) {
+      break;
+    }
+    switch (fid)
+    {
+      case 0:
+        if (ftype == ::apache::thrift::protocol::T_LIST) {
+          {
+            (*(this->success)).clear();
+            uint32_t _size2396;
+            ::apache::thrift::protocol::TType _etype2399;
+            xfer += iprot->readListBegin(_etype2399, _size2396);
+            (*(this->success)).resize(_size2396);
+            uint32_t _i2400;
+            for (_i2400 = 0; _i2400 < _size2396; ++_i2400)
             {
-              xfer += iprot->readString(this->success[_i2384]);
->>>>>>> External metastore: clean after rebase
-            }
-            xfer += iprot->readListEnd();
-          }
-          this->__isset.success = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      case 1:
-        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
-          xfer += this->o1.read(iprot);
-          this->__isset.o1 = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
-      default:
-        xfer += iprot->skip(ftype);
-        break;
-    }
-    xfer += iprot->readFieldEnd();
-  }
-
-  xfer += iprot->readStructEnd();
-
-  return xfer;
-}
-
-uint32_t ThriftHiveMetastore_get_all_stored_procedures_result::write(::apache::thrift::protocol::TProtocol* oprot) const {
-
-  uint32_t xfer = 0;
-
-  xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_all_stored_procedures_result");
-
-  if (this->__isset.success) {
-    xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
-    {
-      xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter2357;
-      for (_iter2357 = this->success.begin(); _iter2357 != this->success.end(); ++_iter2357)
-      {
-        xfer += oprot->writeString((*_iter2357));
-=======
-      std::vector<std::string> ::const_iterator _iter2385;
-      for (_iter2385 = this->success.begin(); _iter2385 != this->success.end(); ++_iter2385)
-      {
-        xfer += oprot->writeString((*_iter2385));
->>>>>>> External metastore: clean after rebase
-      }
-      xfer += oprot->writeListEnd();
-    }
-    xfer += oprot->writeFieldEnd();
-  } else if (this->__isset.o1) {
-    xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1);
-    xfer += this->o1.write(oprot);
-    xfer += oprot->writeFieldEnd();
-  }
-  xfer += oprot->writeFieldStop();
-  xfer += oprot->writeStructEnd();
-  return xfer;
-}
-
-
-ThriftHiveMetastore_get_all_stored_procedures_presult::~ThriftHiveMetastore_get_all_stored_procedures_presult() noexcept {
-}
-
-
-uint32_t ThriftHiveMetastore_get_all_stored_procedures_presult::read(::apache::thrift::protocol::TProtocol* iprot) {
-
-  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
-  uint32_t xfer = 0;
-  std::string fname;
-  ::apache::thrift::protocol::TType ftype;
-  int16_t fid;
-
-  xfer += iprot->readStructBegin(fname);
-
-  using ::apache::thrift::protocol::TProtocolException;
-
-
-  while (true)
-  {
-    xfer += iprot->readFieldBegin(fname, ftype, fid);
-    if (ftype == ::apache::thrift::protocol::T_STOP) {
-      break;
-    }
-    switch (fid)
-    {
-      case 0:
-        if (ftype == ::apache::thrift::protocol::T_LIST) {
-          {
-            (*(this->success)).clear();
-<<<<<<< HEAD
-            uint32_t _size2358;
-            ::apache::thrift::protocol::TType _etype2361;
-            xfer += iprot->readListBegin(_etype2361, _size2358);
-            (*(this->success)).resize(_size2358);
-            uint32_t _i2362;
-            for (_i2362 = 0; _i2362 < _size2358; ++_i2362)
-            {
-              xfer += iprot->readString((*(this->success))[_i2362]);
-=======
-            uint32_t _size2386;
-            ::apache::thrift::protocol::TType _etype2389;
-            xfer += iprot->readListBegin(_etype2389, _size2386);
-            (*(this->success)).resize(_size2386);
-            uint32_t _i2390;
-            for (_i2390 = 0; _i2390 < _size2386; ++_i2390)
-            {
-              xfer += iprot->readString((*(this->success))[_i2390]);
->>>>>>> External metastore: clean after rebase
+              xfer += iprot->readString((*(this->success))[_i2400]);
             }
             xfer += iprot->readListEnd();
           }
@@ -63708,14 +61407,14 @@ uint32_t ThriftHiveMetastore_get_all_packages_result::read(::apache::thrift::pro
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->success.clear();
-            uint32_t _size2363;
-            ::apache::thrift::protocol::TType _etype2366;
-            xfer += iprot->readListBegin(_etype2366, _size2363);
-            this->success.resize(_size2363);
-            uint32_t _i2367;
-            for (_i2367 = 0; _i2367 < _size2363; ++_i2367)
+            uint32_t _size2401;
+            ::apache::thrift::protocol::TType _etype2404;
+            xfer += iprot->readListBegin(_etype2404, _size2401);
+            this->success.resize(_size2401);
+            uint32_t _i2405;
+            for (_i2405 = 0; _i2405 < _size2401; ++_i2405)
             {
-              xfer += iprot->readString(this->success[_i2367]);
+              xfer += iprot->readString(this->success[_i2405]);
             }
             xfer += iprot->readListEnd();
           }
@@ -63754,10 +61453,10 @@ uint32_t ThriftHiveMetastore_get_all_packages_result::write(::apache::thrift::pr
     xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->success.size()));
-      std::vector<std::string> ::const_iterator _iter2368;
-      for (_iter2368 = this->success.begin(); _iter2368 != this->success.end(); ++_iter2368)
+      std::vector<std::string> ::const_iterator _iter2406;
+      for (_iter2406 = this->success.begin(); _iter2406 != this->success.end(); ++_iter2406)
       {
-        xfer += oprot->writeString((*_iter2368));
+        xfer += oprot->writeString((*_iter2406));
       }
       xfer += oprot->writeListEnd();
     }
@@ -63802,14 +61501,14 @@ uint32_t ThriftHiveMetastore_get_all_packages_presult::read(::apache::thrift::pr
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             (*(this->success)).clear();
-            uint32_t _size2369;
-            ::apache::thrift::protocol::TType _etype2372;
-            xfer += iprot->readListBegin(_etype2372, _size2369);
-            (*(this->success)).resize(_size2369);
-            uint32_t _i2373;
-            for (_i2373 = 0; _i2373 < _size2369; ++_i2373)
+            uint32_t _size2407;
+            ::apache::thrift::protocol::TType _etype2410;
+            xfer += iprot->readListBegin(_etype2410, _size2407);
+            (*(this->success)).resize(_size2407);
+            uint32_t _i2411;
+            for (_i2411 = 0; _i2411 < _size2407; ++_i2411)
             {
-              xfer += iprot->readString((*(this->success))[_i2373]);
+              xfer += iprot->readString((*(this->success))[_i2411]);
             }
             xfer += iprot->readListEnd();
           }
@@ -64086,321 +61785,7 @@ void ThriftHiveMetastoreClient::recv_getMetaConf(std::string& _return)
   throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "getMetaConf failed: unknown result");
 }
 
-<<<<<<< HEAD
 void ThriftHiveMetastoreClient::setMetaConf(const std::string& key, const std::string& value)
-=======
-void ThriftHiveMetastoreClient::create_dataconnector(const DataConnector& connector)
-{
-  send_create_dataconnector(connector);
-  recv_create_dataconnector();
-}
-
-void ThriftHiveMetastoreClient::send_create_dataconnector(const DataConnector& connector)
-{
-  int32_t cseqid = 0;
-  oprot_->writeMessageBegin("create_dataconnector", ::apache::thrift::protocol::T_CALL, cseqid);
-
-  ThriftHiveMetastore_create_dataconnector_pargs args;
-  args.connector = &connector;
-  args.write(oprot_);
-
-  oprot_->writeMessageEnd();
-  oprot_->getTransport()->writeEnd();
-  oprot_->getTransport()->flush();
-}
-
-void ThriftHiveMetastoreClient::recv_create_dataconnector()
-{
-
-  int32_t rseqid = 0;
-  std::string fname;
-  ::apache::thrift::protocol::TMessageType mtype;
-
-  iprot_->readMessageBegin(fname, mtype, rseqid);
-  if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
-    ::apache::thrift::TApplicationException x;
-    x.read(iprot_);
-    iprot_->readMessageEnd();
-    iprot_->getTransport()->readEnd();
-    throw x;
-  }
-  if (mtype != ::apache::thrift::protocol::T_REPLY) {
-    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
-    iprot_->readMessageEnd();
-    iprot_->getTransport()->readEnd();
-  }
-  if (fname.compare("create_dataconnector") != 0) {
-    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
-    iprot_->readMessageEnd();
-    iprot_->getTransport()->readEnd();
-  }
-  ThriftHiveMetastore_create_dataconnector_presult result;
-  result.read(iprot_);
-  iprot_->readMessageEnd();
-  iprot_->getTransport()->readEnd();
-
-  if (result.__isset.o1) {
-    throw result.o1;
-  }
-  if (result.__isset.o2) {
-    throw result.o2;
-  }
-  if (result.__isset.o3) {
-    throw result.o3;
-  }
-  return;
-}
-
-void ThriftHiveMetastoreClient::get_dataconnector_req(DataConnector& _return, const GetDataConnectorRequest& request)
-{
-  send_get_dataconnector_req(request);
-  recv_get_dataconnector_req(_return);
-}
-
-void ThriftHiveMetastoreClient::send_get_dataconnector_req(const GetDataConnectorRequest& request)
-{
-  int32_t cseqid = 0;
-  oprot_->writeMessageBegin("get_dataconnector_req", ::apache::thrift::protocol::T_CALL, cseqid);
-
-  ThriftHiveMetastore_get_dataconnector_req_pargs args;
-  args.request = &request;
-  args.write(oprot_);
-
-  oprot_->writeMessageEnd();
-  oprot_->getTransport()->writeEnd();
-  oprot_->getTransport()->flush();
-}
-
-void ThriftHiveMetastoreClient::recv_get_dataconnector_req(DataConnector& _return)
-{
-
-  int32_t rseqid = 0;
-  std::string fname;
-  ::apache::thrift::protocol::TMessageType mtype;
-
-  iprot_->readMessageBegin(fname, mtype, rseqid);
-  if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
-    ::apache::thrift::TApplicationException x;
-    x.read(iprot_);
-    iprot_->readMessageEnd();
-    iprot_->getTransport()->readEnd();
-    throw x;
-  }
-  if (mtype != ::apache::thrift::protocol::T_REPLY) {
-    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
-    iprot_->readMessageEnd();
-    iprot_->getTransport()->readEnd();
-  }
-  if (fname.compare("get_dataconnector_req") != 0) {
-    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
-    iprot_->readMessageEnd();
-    iprot_->getTransport()->readEnd();
-  }
-  ThriftHiveMetastore_get_dataconnector_req_presult result;
-  result.success = &_return;
-  result.read(iprot_);
-  iprot_->readMessageEnd();
-  iprot_->getTransport()->readEnd();
-
-  if (result.__isset.success) {
-    // _return pointer has now been filled
-    return;
-  }
-  if (result.__isset.o1) {
-    throw result.o1;
-  }
-  if (result.__isset.o2) {
-    throw result.o2;
-  }
-  throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_dataconnector_req failed: unknown result");
-}
-
-void ThriftHiveMetastoreClient::drop_dataconnector(const std::string& name, const bool ifNotExists, const bool checkReferences)
-{
-  send_drop_dataconnector(name, ifNotExists, checkReferences);
-  recv_drop_dataconnector();
-}
-
-void ThriftHiveMetastoreClient::send_drop_dataconnector(const std::string& name, const bool ifNotExists, const bool checkReferences)
-{
-  int32_t cseqid = 0;
-  oprot_->writeMessageBegin("drop_dataconnector", ::apache::thrift::protocol::T_CALL, cseqid);
-
-  ThriftHiveMetastore_drop_dataconnector_pargs args;
-  args.name = &name;
-  args.ifNotExists = &ifNotExists;
-  args.checkReferences = &checkReferences;
-  args.write(oprot_);
-
-  oprot_->writeMessageEnd();
-  oprot_->getTransport()->writeEnd();
-  oprot_->getTransport()->flush();
-}
-
-void ThriftHiveMetastoreClient::recv_drop_dataconnector()
-{
-
-  int32_t rseqid = 0;
-  std::string fname;
-  ::apache::thrift::protocol::TMessageType mtype;
-
-  iprot_->readMessageBegin(fname, mtype, rseqid);
-  if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
-    ::apache::thrift::TApplicationException x;
-    x.read(iprot_);
-    iprot_->readMessageEnd();
-    iprot_->getTransport()->readEnd();
-    throw x;
-  }
-  if (mtype != ::apache::thrift::protocol::T_REPLY) {
-    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
-    iprot_->readMessageEnd();
-    iprot_->getTransport()->readEnd();
-  }
-  if (fname.compare("drop_dataconnector") != 0) {
-    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
-    iprot_->readMessageEnd();
-    iprot_->getTransport()->readEnd();
-  }
-  ThriftHiveMetastore_drop_dataconnector_presult result;
-  result.read(iprot_);
-  iprot_->readMessageEnd();
-  iprot_->getTransport()->readEnd();
-
-  if (result.__isset.o1) {
-    throw result.o1;
-  }
-  if (result.__isset.o2) {
-    throw result.o2;
-  }
-  if (result.__isset.o3) {
-    throw result.o3;
-  }
-  return;
-}
-
-void ThriftHiveMetastoreClient::get_dataconnectors(std::vector<std::string> & _return)
-{
-  send_get_dataconnectors();
-  recv_get_dataconnectors(_return);
-}
-
-void ThriftHiveMetastoreClient::send_get_dataconnectors()
-{
-  int32_t cseqid = 0;
-  oprot_->writeMessageBegin("get_dataconnectors", ::apache::thrift::protocol::T_CALL, cseqid);
-
-  ThriftHiveMetastore_get_dataconnectors_pargs args;
-  args.write(oprot_);
-
-  oprot_->writeMessageEnd();
-  oprot_->getTransport()->writeEnd();
-  oprot_->getTransport()->flush();
-}
-
-void ThriftHiveMetastoreClient::recv_get_dataconnectors(std::vector<std::string> & _return)
-{
-
-  int32_t rseqid = 0;
-  std::string fname;
-  ::apache::thrift::protocol::TMessageType mtype;
-
-  iprot_->readMessageBegin(fname, mtype, rseqid);
-  if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
-    ::apache::thrift::TApplicationException x;
-    x.read(iprot_);
-    iprot_->readMessageEnd();
-    iprot_->getTransport()->readEnd();
-    throw x;
-  }
-  if (mtype != ::apache::thrift::protocol::T_REPLY) {
-    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
-    iprot_->readMessageEnd();
-    iprot_->getTransport()->readEnd();
-  }
-  if (fname.compare("get_dataconnectors") != 0) {
-    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
-    iprot_->readMessageEnd();
-    iprot_->getTransport()->readEnd();
-  }
-  ThriftHiveMetastore_get_dataconnectors_presult result;
-  result.success = &_return;
-  result.read(iprot_);
-  iprot_->readMessageEnd();
-  iprot_->getTransport()->readEnd();
-
-  if (result.__isset.success) {
-    // _return pointer has now been filled
-    return;
-  }
-  if (result.__isset.o1) {
-    throw result.o1;
-  }
-  throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_dataconnectors failed: unknown result");
-}
-
-void ThriftHiveMetastoreClient::alter_dataconnector(const std::string& name, const DataConnector& connector)
-{
-  send_alter_dataconnector(name, connector);
-  recv_alter_dataconnector();
-}
-
-void ThriftHiveMetastoreClient::send_alter_dataconnector(const std::string& name, const DataConnector& connector)
-{
-  int32_t cseqid = 0;
-  oprot_->writeMessageBegin("alter_dataconnector", ::apache::thrift::protocol::T_CALL, cseqid);
-
-  ThriftHiveMetastore_alter_dataconnector_pargs args;
-  args.name = &name;
-  args.connector = &connector;
-  args.write(oprot_);
-
-  oprot_->writeMessageEnd();
-  oprot_->getTransport()->writeEnd();
-  oprot_->getTransport()->flush();
-}
-
-void ThriftHiveMetastoreClient::recv_alter_dataconnector()
-{
-
-  int32_t rseqid = 0;
-  std::string fname;
-  ::apache::thrift::protocol::TMessageType mtype;
-
-  iprot_->readMessageBegin(fname, mtype, rseqid);
-  if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
-    ::apache::thrift::TApplicationException x;
-    x.read(iprot_);
-    iprot_->readMessageEnd();
-    iprot_->getTransport()->readEnd();
-    throw x;
-  }
-  if (mtype != ::apache::thrift::protocol::T_REPLY) {
-    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
-    iprot_->readMessageEnd();
-    iprot_->getTransport()->readEnd();
-  }
-  if (fname.compare("alter_dataconnector") != 0) {
-    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
-    iprot_->readMessageEnd();
-    iprot_->getTransport()->readEnd();
-  }
-  ThriftHiveMetastore_alter_dataconnector_presult result;
-  result.read(iprot_);
-  iprot_->readMessageEnd();
-  iprot_->getTransport()->readEnd();
-
-  if (result.__isset.o1) {
-    throw result.o1;
-  }
-  if (result.__isset.o2) {
-    throw result.o2;
-  }
-  return;
-}
-
-void ThriftHiveMetastoreClient::get_type(Type& _return, const std::string& name)
->>>>>>> External metastore: clean after rebase
 {
   send_setMetaConf(key, value);
   recv_setMetaConf();
@@ -65202,6 +62587,316 @@ void ThriftHiveMetastoreClient::recv_alter_database()
   return;
 }
 
+void ThriftHiveMetastoreClient::create_dataconnector(const DataConnector& connector)
+{
+  send_create_dataconnector(connector);
+  recv_create_dataconnector();
+}
+
+void ThriftHiveMetastoreClient::send_create_dataconnector(const DataConnector& connector)
+{
+  int32_t cseqid = 0;
+  oprot_->writeMessageBegin("create_dataconnector", ::apache::thrift::protocol::T_CALL, cseqid);
+
+  ThriftHiveMetastore_create_dataconnector_pargs args;
+  args.connector = &connector;
+  args.write(oprot_);
+
+  oprot_->writeMessageEnd();
+  oprot_->getTransport()->writeEnd();
+  oprot_->getTransport()->flush();
+}
+
+void ThriftHiveMetastoreClient::recv_create_dataconnector()
+{
+
+  int32_t rseqid = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TMessageType mtype;
+
+  iprot_->readMessageBegin(fname, mtype, rseqid);
+  if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
+    ::apache::thrift::TApplicationException x;
+    x.read(iprot_);
+    iprot_->readMessageEnd();
+    iprot_->getTransport()->readEnd();
+    throw x;
+  }
+  if (mtype != ::apache::thrift::protocol::T_REPLY) {
+    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+    iprot_->readMessageEnd();
+    iprot_->getTransport()->readEnd();
+  }
+  if (fname.compare("create_dataconnector") != 0) {
+    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+    iprot_->readMessageEnd();
+    iprot_->getTransport()->readEnd();
+  }
+  ThriftHiveMetastore_create_dataconnector_presult result;
+  result.read(iprot_);
+  iprot_->readMessageEnd();
+  iprot_->getTransport()->readEnd();
+
+  if (result.__isset.o1) {
+    throw result.o1;
+  }
+  if (result.__isset.o2) {
+    throw result.o2;
+  }
+  if (result.__isset.o3) {
+    throw result.o3;
+  }
+  return;
+}
+
+void ThriftHiveMetastoreClient::get_dataconnector_req(DataConnector& _return, const GetDataConnectorRequest& request)
+{
+  send_get_dataconnector_req(request);
+  recv_get_dataconnector_req(_return);
+}
+
+void ThriftHiveMetastoreClient::send_get_dataconnector_req(const GetDataConnectorRequest& request)
+{
+  int32_t cseqid = 0;
+  oprot_->writeMessageBegin("get_dataconnector_req", ::apache::thrift::protocol::T_CALL, cseqid);
+
+  ThriftHiveMetastore_get_dataconnector_req_pargs args;
+  args.request = &request;
+  args.write(oprot_);
+
+  oprot_->writeMessageEnd();
+  oprot_->getTransport()->writeEnd();
+  oprot_->getTransport()->flush();
+}
+
+void ThriftHiveMetastoreClient::recv_get_dataconnector_req(DataConnector& _return)
+{
+
+  int32_t rseqid = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TMessageType mtype;
+
+  iprot_->readMessageBegin(fname, mtype, rseqid);
+  if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
+    ::apache::thrift::TApplicationException x;
+    x.read(iprot_);
+    iprot_->readMessageEnd();
+    iprot_->getTransport()->readEnd();
+    throw x;
+  }
+  if (mtype != ::apache::thrift::protocol::T_REPLY) {
+    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+    iprot_->readMessageEnd();
+    iprot_->getTransport()->readEnd();
+  }
+  if (fname.compare("get_dataconnector_req") != 0) {
+    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+    iprot_->readMessageEnd();
+    iprot_->getTransport()->readEnd();
+  }
+  ThriftHiveMetastore_get_dataconnector_req_presult result;
+  result.success = &_return;
+  result.read(iprot_);
+  iprot_->readMessageEnd();
+  iprot_->getTransport()->readEnd();
+
+  if (result.__isset.success) {
+    // _return pointer has now been filled
+    return;
+  }
+  if (result.__isset.o1) {
+    throw result.o1;
+  }
+  if (result.__isset.o2) {
+    throw result.o2;
+  }
+  throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_dataconnector_req failed: unknown result");
+}
+
+void ThriftHiveMetastoreClient::drop_dataconnector(const std::string& name, const bool ifNotExists, const bool checkReferences)
+{
+  send_drop_dataconnector(name, ifNotExists, checkReferences);
+  recv_drop_dataconnector();
+}
+
+void ThriftHiveMetastoreClient::send_drop_dataconnector(const std::string& name, const bool ifNotExists, const bool checkReferences)
+{
+  int32_t cseqid = 0;
+  oprot_->writeMessageBegin("drop_dataconnector", ::apache::thrift::protocol::T_CALL, cseqid);
+
+  ThriftHiveMetastore_drop_dataconnector_pargs args;
+  args.name = &name;
+  args.ifNotExists = &ifNotExists;
+  args.checkReferences = &checkReferences;
+  args.write(oprot_);
+
+  oprot_->writeMessageEnd();
+  oprot_->getTransport()->writeEnd();
+  oprot_->getTransport()->flush();
+}
+
+void ThriftHiveMetastoreClient::recv_drop_dataconnector()
+{
+
+  int32_t rseqid = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TMessageType mtype;
+
+  iprot_->readMessageBegin(fname, mtype, rseqid);
+  if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
+    ::apache::thrift::TApplicationException x;
+    x.read(iprot_);
+    iprot_->readMessageEnd();
+    iprot_->getTransport()->readEnd();
+    throw x;
+  }
+  if (mtype != ::apache::thrift::protocol::T_REPLY) {
+    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+    iprot_->readMessageEnd();
+    iprot_->getTransport()->readEnd();
+  }
+  if (fname.compare("drop_dataconnector") != 0) {
+    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+    iprot_->readMessageEnd();
+    iprot_->getTransport()->readEnd();
+  }
+  ThriftHiveMetastore_drop_dataconnector_presult result;
+  result.read(iprot_);
+  iprot_->readMessageEnd();
+  iprot_->getTransport()->readEnd();
+
+  if (result.__isset.o1) {
+    throw result.o1;
+  }
+  if (result.__isset.o2) {
+    throw result.o2;
+  }
+  if (result.__isset.o3) {
+    throw result.o3;
+  }
+  return;
+}
+
+void ThriftHiveMetastoreClient::get_dataconnectors(std::vector<std::string> & _return)
+{
+  send_get_dataconnectors();
+  recv_get_dataconnectors(_return);
+}
+
+void ThriftHiveMetastoreClient::send_get_dataconnectors()
+{
+  int32_t cseqid = 0;
+  oprot_->writeMessageBegin("get_dataconnectors", ::apache::thrift::protocol::T_CALL, cseqid);
+
+  ThriftHiveMetastore_get_dataconnectors_pargs args;
+  args.write(oprot_);
+
+  oprot_->writeMessageEnd();
+  oprot_->getTransport()->writeEnd();
+  oprot_->getTransport()->flush();
+}
+
+void ThriftHiveMetastoreClient::recv_get_dataconnectors(std::vector<std::string> & _return)
+{
+
+  int32_t rseqid = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TMessageType mtype;
+
+  iprot_->readMessageBegin(fname, mtype, rseqid);
+  if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
+    ::apache::thrift::TApplicationException x;
+    x.read(iprot_);
+    iprot_->readMessageEnd();
+    iprot_->getTransport()->readEnd();
+    throw x;
+  }
+  if (mtype != ::apache::thrift::protocol::T_REPLY) {
+    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+    iprot_->readMessageEnd();
+    iprot_->getTransport()->readEnd();
+  }
+  if (fname.compare("get_dataconnectors") != 0) {
+    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+    iprot_->readMessageEnd();
+    iprot_->getTransport()->readEnd();
+  }
+  ThriftHiveMetastore_get_dataconnectors_presult result;
+  result.success = &_return;
+  result.read(iprot_);
+  iprot_->readMessageEnd();
+  iprot_->getTransport()->readEnd();
+
+  if (result.__isset.success) {
+    // _return pointer has now been filled
+    return;
+  }
+  if (result.__isset.o1) {
+    throw result.o1;
+  }
+  throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_dataconnectors failed: unknown result");
+}
+
+void ThriftHiveMetastoreClient::alter_dataconnector(const std::string& name, const DataConnector& connector)
+{
+  send_alter_dataconnector(name, connector);
+  recv_alter_dataconnector();
+}
+
+void ThriftHiveMetastoreClient::send_alter_dataconnector(const std::string& name, const DataConnector& connector)
+{
+  int32_t cseqid = 0;
+  oprot_->writeMessageBegin("alter_dataconnector", ::apache::thrift::protocol::T_CALL, cseqid);
+
+  ThriftHiveMetastore_alter_dataconnector_pargs args;
+  args.name = &name;
+  args.connector = &connector;
+  args.write(oprot_);
+
+  oprot_->writeMessageEnd();
+  oprot_->getTransport()->writeEnd();
+  oprot_->getTransport()->flush();
+}
+
+void ThriftHiveMetastoreClient::recv_alter_dataconnector()
+{
+
+  int32_t rseqid = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TMessageType mtype;
+
+  iprot_->readMessageBegin(fname, mtype, rseqid);
+  if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
+    ::apache::thrift::TApplicationException x;
+    x.read(iprot_);
+    iprot_->readMessageEnd();
+    iprot_->getTransport()->readEnd();
+    throw x;
+  }
+  if (mtype != ::apache::thrift::protocol::T_REPLY) {
+    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+    iprot_->readMessageEnd();
+    iprot_->getTransport()->readEnd();
+  }
+  if (fname.compare("alter_dataconnector") != 0) {
+    iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+    iprot_->readMessageEnd();
+    iprot_->getTransport()->readEnd();
+  }
+  ThriftHiveMetastore_alter_dataconnector_presult result;
+  result.read(iprot_);
+  iprot_->readMessageEnd();
+  iprot_->getTransport()->readEnd();
+
+  if (result.__isset.o1) {
+    throw result.o1;
+  }
+  if (result.__isset.o2) {
+    throw result.o2;
+  }
+  return;
+}
+
 void ThriftHiveMetastoreClient::get_type(Type& _return, const std::string& name)
 {
   send_get_type(name);
@@ -80478,311 +78173,7 @@ void ThriftHiveMetastoreProcessor::process_setMetaConf(int32_t seqid, ::apache::
   }
 }
 
-<<<<<<< HEAD
 void ThriftHiveMetastoreProcessor::process_create_catalog(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
-=======
-void ThriftHiveMetastoreProcessor::process_create_dataconnector(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
-{
-  void* ctx = NULL;
-  if (this->eventHandler_.get() != NULL) {
-    ctx = this->eventHandler_->getContext("ThriftHiveMetastore.create_dataconnector", callContext);
-  }
-  ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "ThriftHiveMetastore.create_dataconnector");
-
-  if (this->eventHandler_.get() != NULL) {
-    this->eventHandler_->preRead(ctx, "ThriftHiveMetastore.create_dataconnector");
-  }
-
-  ThriftHiveMetastore_create_dataconnector_args args;
-  args.read(iprot);
-  iprot->readMessageEnd();
-  uint32_t bytes = iprot->getTransport()->readEnd();
-
-  if (this->eventHandler_.get() != NULL) {
-    this->eventHandler_->postRead(ctx, "ThriftHiveMetastore.create_dataconnector", bytes);
-  }
-
-  ThriftHiveMetastore_create_dataconnector_result result;
-  try {
-    iface_->create_dataconnector(args.connector);
-  } catch (AlreadyExistsException &o1) {
-    result.o1 = o1;
-    result.__isset.o1 = true;
-  } catch (InvalidObjectException &o2) {
-    result.o2 = o2;
-    result.__isset.o2 = true;
-  } catch (MetaException &o3) {
-    result.o3 = o3;
-    result.__isset.o3 = true;
-  } catch (const std::exception& e) {
-    if (this->eventHandler_.get() != NULL) {
-      this->eventHandler_->handlerError(ctx, "ThriftHiveMetastore.create_dataconnector");
-    }
-
-    ::apache::thrift::TApplicationException x(e.what());
-    oprot->writeMessageBegin("create_dataconnector", ::apache::thrift::protocol::T_EXCEPTION, seqid);
-    x.write(oprot);
-    oprot->writeMessageEnd();
-    oprot->getTransport()->writeEnd();
-    oprot->getTransport()->flush();
-    return;
-  }
-
-  if (this->eventHandler_.get() != NULL) {
-    this->eventHandler_->preWrite(ctx, "ThriftHiveMetastore.create_dataconnector");
-  }
-
-  oprot->writeMessageBegin("create_dataconnector", ::apache::thrift::protocol::T_REPLY, seqid);
-  result.write(oprot);
-  oprot->writeMessageEnd();
-  bytes = oprot->getTransport()->writeEnd();
-  oprot->getTransport()->flush();
-
-  if (this->eventHandler_.get() != NULL) {
-    this->eventHandler_->postWrite(ctx, "ThriftHiveMetastore.create_dataconnector", bytes);
-  }
-}
-
-void ThriftHiveMetastoreProcessor::process_get_dataconnector_req(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
-{
-  void* ctx = NULL;
-  if (this->eventHandler_.get() != NULL) {
-    ctx = this->eventHandler_->getContext("ThriftHiveMetastore.get_dataconnector_req", callContext);
-  }
-  ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "ThriftHiveMetastore.get_dataconnector_req");
-
-  if (this->eventHandler_.get() != NULL) {
-    this->eventHandler_->preRead(ctx, "ThriftHiveMetastore.get_dataconnector_req");
-  }
-
-  ThriftHiveMetastore_get_dataconnector_req_args args;
-  args.read(iprot);
-  iprot->readMessageEnd();
-  uint32_t bytes = iprot->getTransport()->readEnd();
-
-  if (this->eventHandler_.get() != NULL) {
-    this->eventHandler_->postRead(ctx, "ThriftHiveMetastore.get_dataconnector_req", bytes);
-  }
-
-  ThriftHiveMetastore_get_dataconnector_req_result result;
-  try {
-    iface_->get_dataconnector_req(result.success, args.request);
-    result.__isset.success = true;
-  } catch (NoSuchObjectException &o1) {
-    result.o1 = o1;
-    result.__isset.o1 = true;
-  } catch (MetaException &o2) {
-    result.o2 = o2;
-    result.__isset.o2 = true;
-  } catch (const std::exception& e) {
-    if (this->eventHandler_.get() != NULL) {
-      this->eventHandler_->handlerError(ctx, "ThriftHiveMetastore.get_dataconnector_req");
-    }
-
-    ::apache::thrift::TApplicationException x(e.what());
-    oprot->writeMessageBegin("get_dataconnector_req", ::apache::thrift::protocol::T_EXCEPTION, seqid);
-    x.write(oprot);
-    oprot->writeMessageEnd();
-    oprot->getTransport()->writeEnd();
-    oprot->getTransport()->flush();
-    return;
-  }
-
-  if (this->eventHandler_.get() != NULL) {
-    this->eventHandler_->preWrite(ctx, "ThriftHiveMetastore.get_dataconnector_req");
-  }
-
-  oprot->writeMessageBegin("get_dataconnector_req", ::apache::thrift::protocol::T_REPLY, seqid);
-  result.write(oprot);
-  oprot->writeMessageEnd();
-  bytes = oprot->getTransport()->writeEnd();
-  oprot->getTransport()->flush();
-
-  if (this->eventHandler_.get() != NULL) {
-    this->eventHandler_->postWrite(ctx, "ThriftHiveMetastore.get_dataconnector_req", bytes);
-  }
-}
-
-void ThriftHiveMetastoreProcessor::process_drop_dataconnector(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
-{
-  void* ctx = NULL;
-  if (this->eventHandler_.get() != NULL) {
-    ctx = this->eventHandler_->getContext("ThriftHiveMetastore.drop_dataconnector", callContext);
-  }
-  ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "ThriftHiveMetastore.drop_dataconnector");
-
-  if (this->eventHandler_.get() != NULL) {
-    this->eventHandler_->preRead(ctx, "ThriftHiveMetastore.drop_dataconnector");
-  }
-
-  ThriftHiveMetastore_drop_dataconnector_args args;
-  args.read(iprot);
-  iprot->readMessageEnd();
-  uint32_t bytes = iprot->getTransport()->readEnd();
-
-  if (this->eventHandler_.get() != NULL) {
-    this->eventHandler_->postRead(ctx, "ThriftHiveMetastore.drop_dataconnector", bytes);
-  }
-
-  ThriftHiveMetastore_drop_dataconnector_result result;
-  try {
-    iface_->drop_dataconnector(args.name, args.ifNotExists, args.checkReferences);
-  } catch (NoSuchObjectException &o1) {
-    result.o1 = o1;
-    result.__isset.o1 = true;
-  } catch (InvalidOperationException &o2) {
-    result.o2 = o2;
-    result.__isset.o2 = true;
-  } catch (MetaException &o3) {
-    result.o3 = o3;
-    result.__isset.o3 = true;
-  } catch (const std::exception& e) {
-    if (this->eventHandler_.get() != NULL) {
-      this->eventHandler_->handlerError(ctx, "ThriftHiveMetastore.drop_dataconnector");
-    }
-
-    ::apache::thrift::TApplicationException x(e.what());
-    oprot->writeMessageBegin("drop_dataconnector", ::apache::thrift::protocol::T_EXCEPTION, seqid);
-    x.write(oprot);
-    oprot->writeMessageEnd();
-    oprot->getTransport()->writeEnd();
-    oprot->getTransport()->flush();
-    return;
-  }
-
-  if (this->eventHandler_.get() != NULL) {
-    this->eventHandler_->preWrite(ctx, "ThriftHiveMetastore.drop_dataconnector");
-  }
-
-  oprot->writeMessageBegin("drop_dataconnector", ::apache::thrift::protocol::T_REPLY, seqid);
-  result.write(oprot);
-  oprot->writeMessageEnd();
-  bytes = oprot->getTransport()->writeEnd();
-  oprot->getTransport()->flush();
-
-  if (this->eventHandler_.get() != NULL) {
-    this->eventHandler_->postWrite(ctx, "ThriftHiveMetastore.drop_dataconnector", bytes);
-  }
-}
-
-void ThriftHiveMetastoreProcessor::process_get_dataconnectors(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
-{
-  void* ctx = NULL;
-  if (this->eventHandler_.get() != NULL) {
-    ctx = this->eventHandler_->getContext("ThriftHiveMetastore.get_dataconnectors", callContext);
-  }
-  ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "ThriftHiveMetastore.get_dataconnectors");
-
-  if (this->eventHandler_.get() != NULL) {
-    this->eventHandler_->preRead(ctx, "ThriftHiveMetastore.get_dataconnectors");
-  }
-
-  ThriftHiveMetastore_get_dataconnectors_args args;
-  args.read(iprot);
-  iprot->readMessageEnd();
-  uint32_t bytes = iprot->getTransport()->readEnd();
-
-  if (this->eventHandler_.get() != NULL) {
-    this->eventHandler_->postRead(ctx, "ThriftHiveMetastore.get_dataconnectors", bytes);
-  }
-
-  ThriftHiveMetastore_get_dataconnectors_result result;
-  try {
-    iface_->get_dataconnectors(result.success);
-    result.__isset.success = true;
-  } catch (MetaException &o1) {
-    result.o1 = o1;
-    result.__isset.o1 = true;
-  } catch (const std::exception& e) {
-    if (this->eventHandler_.get() != NULL) {
-      this->eventHandler_->handlerError(ctx, "ThriftHiveMetastore.get_dataconnectors");
-    }
-
-    ::apache::thrift::TApplicationException x(e.what());
-    oprot->writeMessageBegin("get_dataconnectors", ::apache::thrift::protocol::T_EXCEPTION, seqid);
-    x.write(oprot);
-    oprot->writeMessageEnd();
-    oprot->getTransport()->writeEnd();
-    oprot->getTransport()->flush();
-    return;
-  }
-
-  if (this->eventHandler_.get() != NULL) {
-    this->eventHandler_->preWrite(ctx, "ThriftHiveMetastore.get_dataconnectors");
-  }
-
-  oprot->writeMessageBegin("get_dataconnectors", ::apache::thrift::protocol::T_REPLY, seqid);
-  result.write(oprot);
-  oprot->writeMessageEnd();
-  bytes = oprot->getTransport()->writeEnd();
-  oprot->getTransport()->flush();
-
-  if (this->eventHandler_.get() != NULL) {
-    this->eventHandler_->postWrite(ctx, "ThriftHiveMetastore.get_dataconnectors", bytes);
-  }
-}
-
-void ThriftHiveMetastoreProcessor::process_alter_dataconnector(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
-{
-  void* ctx = NULL;
-  if (this->eventHandler_.get() != NULL) {
-    ctx = this->eventHandler_->getContext("ThriftHiveMetastore.alter_dataconnector", callContext);
-  }
-  ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "ThriftHiveMetastore.alter_dataconnector");
-
-  if (this->eventHandler_.get() != NULL) {
-    this->eventHandler_->preRead(ctx, "ThriftHiveMetastore.alter_dataconnector");
-  }
-
-  ThriftHiveMetastore_alter_dataconnector_args args;
-  args.read(iprot);
-  iprot->readMessageEnd();
-  uint32_t bytes = iprot->getTransport()->readEnd();
-
-  if (this->eventHandler_.get() != NULL) {
-    this->eventHandler_->postRead(ctx, "ThriftHiveMetastore.alter_dataconnector", bytes);
-  }
-
-  ThriftHiveMetastore_alter_dataconnector_result result;
-  try {
-    iface_->alter_dataconnector(args.name, args.connector);
-  } catch (MetaException &o1) {
-    result.o1 = o1;
-    result.__isset.o1 = true;
-  } catch (NoSuchObjectException &o2) {
-    result.o2 = o2;
-    result.__isset.o2 = true;
-  } catch (const std::exception& e) {
-    if (this->eventHandler_.get() != NULL) {
-      this->eventHandler_->handlerError(ctx, "ThriftHiveMetastore.alter_dataconnector");
-    }
-
-    ::apache::thrift::TApplicationException x(e.what());
-    oprot->writeMessageBegin("alter_dataconnector", ::apache::thrift::protocol::T_EXCEPTION, seqid);
-    x.write(oprot);
-    oprot->writeMessageEnd();
-    oprot->getTransport()->writeEnd();
-    oprot->getTransport()->flush();
-    return;
-  }
-
-  if (this->eventHandler_.get() != NULL) {
-    this->eventHandler_->preWrite(ctx, "ThriftHiveMetastore.alter_dataconnector");
-  }
-
-  oprot->writeMessageBegin("alter_dataconnector", ::apache::thrift::protocol::T_REPLY, seqid);
-  result.write(oprot);
-  oprot->writeMessageEnd();
-  bytes = oprot->getTransport()->writeEnd();
-  oprot->getTransport()->flush();
-
-  if (this->eventHandler_.get() != NULL) {
-    this->eventHandler_->postWrite(ctx, "ThriftHiveMetastore.alter_dataconnector", bytes);
-  }
-}
-
-void ThriftHiveMetastoreProcessor::process_get_type(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
->>>>>>> External metastore: clean after rebase
 {
   void* ctx = NULL;
   if (this->eventHandler_.get() != NULL) {
@@ -81502,6 +78893,306 @@ void ThriftHiveMetastoreProcessor::process_alter_database(int32_t seqid, ::apach
   }
 }
 
+void ThriftHiveMetastoreProcessor::process_create_dataconnector(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
+{
+  void* ctx = NULL;
+  if (this->eventHandler_.get() != NULL) {
+    ctx = this->eventHandler_->getContext("ThriftHiveMetastore.create_dataconnector", callContext);
+  }
+  ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "ThriftHiveMetastore.create_dataconnector");
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->preRead(ctx, "ThriftHiveMetastore.create_dataconnector");
+  }
+
+  ThriftHiveMetastore_create_dataconnector_args args;
+  args.read(iprot);
+  iprot->readMessageEnd();
+  uint32_t bytes = iprot->getTransport()->readEnd();
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->postRead(ctx, "ThriftHiveMetastore.create_dataconnector", bytes);
+  }
+
+  ThriftHiveMetastore_create_dataconnector_result result;
+  try {
+    iface_->create_dataconnector(args.connector);
+  } catch (AlreadyExistsException &o1) {
+    result.o1 = o1;
+    result.__isset.o1 = true;
+  } catch (InvalidObjectException &o2) {
+    result.o2 = o2;
+    result.__isset.o2 = true;
+  } catch (MetaException &o3) {
+    result.o3 = o3;
+    result.__isset.o3 = true;
+  } catch (const std::exception& e) {
+    if (this->eventHandler_.get() != NULL) {
+      this->eventHandler_->handlerError(ctx, "ThriftHiveMetastore.create_dataconnector");
+    }
+
+    ::apache::thrift::TApplicationException x(e.what());
+    oprot->writeMessageBegin("create_dataconnector", ::apache::thrift::protocol::T_EXCEPTION, seqid);
+    x.write(oprot);
+    oprot->writeMessageEnd();
+    oprot->getTransport()->writeEnd();
+    oprot->getTransport()->flush();
+    return;
+  }
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->preWrite(ctx, "ThriftHiveMetastore.create_dataconnector");
+  }
+
+  oprot->writeMessageBegin("create_dataconnector", ::apache::thrift::protocol::T_REPLY, seqid);
+  result.write(oprot);
+  oprot->writeMessageEnd();
+  bytes = oprot->getTransport()->writeEnd();
+  oprot->getTransport()->flush();
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->postWrite(ctx, "ThriftHiveMetastore.create_dataconnector", bytes);
+  }
+}
+
+void ThriftHiveMetastoreProcessor::process_get_dataconnector_req(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
+{
+  void* ctx = NULL;
+  if (this->eventHandler_.get() != NULL) {
+    ctx = this->eventHandler_->getContext("ThriftHiveMetastore.get_dataconnector_req", callContext);
+  }
+  ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "ThriftHiveMetastore.get_dataconnector_req");
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->preRead(ctx, "ThriftHiveMetastore.get_dataconnector_req");
+  }
+
+  ThriftHiveMetastore_get_dataconnector_req_args args;
+  args.read(iprot);
+  iprot->readMessageEnd();
+  uint32_t bytes = iprot->getTransport()->readEnd();
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->postRead(ctx, "ThriftHiveMetastore.get_dataconnector_req", bytes);
+  }
+
+  ThriftHiveMetastore_get_dataconnector_req_result result;
+  try {
+    iface_->get_dataconnector_req(result.success, args.request);
+    result.__isset.success = true;
+  } catch (NoSuchObjectException &o1) {
+    result.o1 = o1;
+    result.__isset.o1 = true;
+  } catch (MetaException &o2) {
+    result.o2 = o2;
+    result.__isset.o2 = true;
+  } catch (const std::exception& e) {
+    if (this->eventHandler_.get() != NULL) {
+      this->eventHandler_->handlerError(ctx, "ThriftHiveMetastore.get_dataconnector_req");
+    }
+
+    ::apache::thrift::TApplicationException x(e.what());
+    oprot->writeMessageBegin("get_dataconnector_req", ::apache::thrift::protocol::T_EXCEPTION, seqid);
+    x.write(oprot);
+    oprot->writeMessageEnd();
+    oprot->getTransport()->writeEnd();
+    oprot->getTransport()->flush();
+    return;
+  }
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->preWrite(ctx, "ThriftHiveMetastore.get_dataconnector_req");
+  }
+
+  oprot->writeMessageBegin("get_dataconnector_req", ::apache::thrift::protocol::T_REPLY, seqid);
+  result.write(oprot);
+  oprot->writeMessageEnd();
+  bytes = oprot->getTransport()->writeEnd();
+  oprot->getTransport()->flush();
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->postWrite(ctx, "ThriftHiveMetastore.get_dataconnector_req", bytes);
+  }
+}
+
+void ThriftHiveMetastoreProcessor::process_drop_dataconnector(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
+{
+  void* ctx = NULL;
+  if (this->eventHandler_.get() != NULL) {
+    ctx = this->eventHandler_->getContext("ThriftHiveMetastore.drop_dataconnector", callContext);
+  }
+  ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "ThriftHiveMetastore.drop_dataconnector");
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->preRead(ctx, "ThriftHiveMetastore.drop_dataconnector");
+  }
+
+  ThriftHiveMetastore_drop_dataconnector_args args;
+  args.read(iprot);
+  iprot->readMessageEnd();
+  uint32_t bytes = iprot->getTransport()->readEnd();
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->postRead(ctx, "ThriftHiveMetastore.drop_dataconnector", bytes);
+  }
+
+  ThriftHiveMetastore_drop_dataconnector_result result;
+  try {
+    iface_->drop_dataconnector(args.name, args.ifNotExists, args.checkReferences);
+  } catch (NoSuchObjectException &o1) {
+    result.o1 = o1;
+    result.__isset.o1 = true;
+  } catch (InvalidOperationException &o2) {
+    result.o2 = o2;
+    result.__isset.o2 = true;
+  } catch (MetaException &o3) {
+    result.o3 = o3;
+    result.__isset.o3 = true;
+  } catch (const std::exception& e) {
+    if (this->eventHandler_.get() != NULL) {
+      this->eventHandler_->handlerError(ctx, "ThriftHiveMetastore.drop_dataconnector");
+    }
+
+    ::apache::thrift::TApplicationException x(e.what());
+    oprot->writeMessageBegin("drop_dataconnector", ::apache::thrift::protocol::T_EXCEPTION, seqid);
+    x.write(oprot);
+    oprot->writeMessageEnd();
+    oprot->getTransport()->writeEnd();
+    oprot->getTransport()->flush();
+    return;
+  }
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->preWrite(ctx, "ThriftHiveMetastore.drop_dataconnector");
+  }
+
+  oprot->writeMessageBegin("drop_dataconnector", ::apache::thrift::protocol::T_REPLY, seqid);
+  result.write(oprot);
+  oprot->writeMessageEnd();
+  bytes = oprot->getTransport()->writeEnd();
+  oprot->getTransport()->flush();
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->postWrite(ctx, "ThriftHiveMetastore.drop_dataconnector", bytes);
+  }
+}
+
+void ThriftHiveMetastoreProcessor::process_get_dataconnectors(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
+{
+  void* ctx = NULL;
+  if (this->eventHandler_.get() != NULL) {
+    ctx = this->eventHandler_->getContext("ThriftHiveMetastore.get_dataconnectors", callContext);
+  }
+  ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "ThriftHiveMetastore.get_dataconnectors");
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->preRead(ctx, "ThriftHiveMetastore.get_dataconnectors");
+  }
+
+  ThriftHiveMetastore_get_dataconnectors_args args;
+  args.read(iprot);
+  iprot->readMessageEnd();
+  uint32_t bytes = iprot->getTransport()->readEnd();
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->postRead(ctx, "ThriftHiveMetastore.get_dataconnectors", bytes);
+  }
+
+  ThriftHiveMetastore_get_dataconnectors_result result;
+  try {
+    iface_->get_dataconnectors(result.success);
+    result.__isset.success = true;
+  } catch (MetaException &o1) {
+    result.o1 = o1;
+    result.__isset.o1 = true;
+  } catch (const std::exception& e) {
+    if (this->eventHandler_.get() != NULL) {
+      this->eventHandler_->handlerError(ctx, "ThriftHiveMetastore.get_dataconnectors");
+    }
+
+    ::apache::thrift::TApplicationException x(e.what());
+    oprot->writeMessageBegin("get_dataconnectors", ::apache::thrift::protocol::T_EXCEPTION, seqid);
+    x.write(oprot);
+    oprot->writeMessageEnd();
+    oprot->getTransport()->writeEnd();
+    oprot->getTransport()->flush();
+    return;
+  }
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->preWrite(ctx, "ThriftHiveMetastore.get_dataconnectors");
+  }
+
+  oprot->writeMessageBegin("get_dataconnectors", ::apache::thrift::protocol::T_REPLY, seqid);
+  result.write(oprot);
+  oprot->writeMessageEnd();
+  bytes = oprot->getTransport()->writeEnd();
+  oprot->getTransport()->flush();
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->postWrite(ctx, "ThriftHiveMetastore.get_dataconnectors", bytes);
+  }
+}
+
+void ThriftHiveMetastoreProcessor::process_alter_dataconnector(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
+{
+  void* ctx = NULL;
+  if (this->eventHandler_.get() != NULL) {
+    ctx = this->eventHandler_->getContext("ThriftHiveMetastore.alter_dataconnector", callContext);
+  }
+  ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "ThriftHiveMetastore.alter_dataconnector");
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->preRead(ctx, "ThriftHiveMetastore.alter_dataconnector");
+  }
+
+  ThriftHiveMetastore_alter_dataconnector_args args;
+  args.read(iprot);
+  iprot->readMessageEnd();
+  uint32_t bytes = iprot->getTransport()->readEnd();
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->postRead(ctx, "ThriftHiveMetastore.alter_dataconnector", bytes);
+  }
+
+  ThriftHiveMetastore_alter_dataconnector_result result;
+  try {
+    iface_->alter_dataconnector(args.name, args.connector);
+  } catch (MetaException &o1) {
+    result.o1 = o1;
+    result.__isset.o1 = true;
+  } catch (NoSuchObjectException &o2) {
+    result.o2 = o2;
+    result.__isset.o2 = true;
+  } catch (const std::exception& e) {
+    if (this->eventHandler_.get() != NULL) {
+      this->eventHandler_->handlerError(ctx, "ThriftHiveMetastore.alter_dataconnector");
+    }
+
+    ::apache::thrift::TApplicationException x(e.what());
+    oprot->writeMessageBegin("alter_dataconnector", ::apache::thrift::protocol::T_EXCEPTION, seqid);
+    x.write(oprot);
+    oprot->writeMessageEnd();
+    oprot->getTransport()->writeEnd();
+    oprot->getTransport()->flush();
+    return;
+  }
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->preWrite(ctx, "ThriftHiveMetastore.alter_dataconnector");
+  }
+
+  oprot->writeMessageBegin("alter_dataconnector", ::apache::thrift::protocol::T_REPLY, seqid);
+  result.write(oprot);
+  oprot->writeMessageEnd();
+  bytes = oprot->getTransport()->writeEnd();
+  oprot->getTransport()->flush();
+
+  if (this->eventHandler_.get() != NULL) {
+    this->eventHandler_->postWrite(ctx, "ThriftHiveMetastore.alter_dataconnector", bytes);
+  }
+}
+
 void ThriftHiveMetastoreProcessor::process_get_type(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext)
 {
   void* ctx = NULL;
@@ -96449,189 +94140,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_create_database(const int32_t seq
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
       }
-      if (fname.compare("create_database") != 0) {
-        iprot_->skip(::apache::thrift::protocol::T_STRUCT);
-        iprot_->readMessageEnd();
-        iprot_->getTransport()->readEnd();
-
-        // in a bad state, don't commit
-        using ::apache::thrift::protocol::TProtocolException;
-        throw TProtocolException(TProtocolException::INVALID_DATA);
-      }
-      ThriftHiveMetastore_create_database_presult result;
-      result.read(iprot_);
-      iprot_->readMessageEnd();
-      iprot_->getTransport()->readEnd();
-
-      if (result.__isset.o1) {
-        sentry.commit();
-        throw result.o1;
-      }
-      if (result.__isset.o2) {
-        sentry.commit();
-        throw result.o2;
-      }
-      if (result.__isset.o3) {
-        sentry.commit();
-        throw result.o3;
-      }
-      sentry.commit();
-      return;
-    }
-    // seqid != rseqid
-    this->sync_->updatePending(fname, mtype, rseqid);
-
-    // this will temporarily unlock the readMutex, and let other clients get work done
-    this->sync_->waitForWork(seqid);
-  } // end while(true)
-}
-
-void ThriftHiveMetastoreConcurrentClient::get_database(Database& _return, const std::string& name)
-{
-  int32_t seqid = send_get_database(name);
-  recv_get_database(_return, seqid);
-}
-
-int32_t ThriftHiveMetastoreConcurrentClient::send_get_database(const std::string& name)
-{
-  int32_t cseqid = this->sync_->generateSeqId();
-  ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("get_database", ::apache::thrift::protocol::T_CALL, cseqid);
-
-  ThriftHiveMetastore_get_database_pargs args;
-  args.name = &name;
-  args.write(oprot_);
-
-  oprot_->writeMessageEnd();
-  oprot_->getTransport()->writeEnd();
-  oprot_->getTransport()->flush();
-
-  sentry.commit();
-  return cseqid;
-}
-
-void ThriftHiveMetastoreConcurrentClient::recv_get_database(Database& _return, const int32_t seqid)
-{
-
-  int32_t rseqid = 0;
-  std::string fname;
-  ::apache::thrift::protocol::TMessageType mtype;
-
-  // the read mutex gets dropped and reacquired as part of waitForWork()
-  // The destructor of this sentry wakes up other clients
-  ::apache::thrift::async::TConcurrentRecvSentry sentry(this->sync_.get(), seqid);
-
-  while(true) {
-    if(!this->sync_->getPending(fname, mtype, rseqid)) {
-      iprot_->readMessageBegin(fname, mtype, rseqid);
-    }
-    if(seqid == rseqid) {
-      if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
-        ::apache::thrift::TApplicationException x;
-        x.read(iprot_);
-        iprot_->readMessageEnd();
-        iprot_->getTransport()->readEnd();
-        sentry.commit();
-        throw x;
-      }
-      if (mtype != ::apache::thrift::protocol::T_REPLY) {
-        iprot_->skip(::apache::thrift::protocol::T_STRUCT);
-        iprot_->readMessageEnd();
-        iprot_->getTransport()->readEnd();
-      }
-      if (fname.compare("get_database") != 0) {
-        iprot_->skip(::apache::thrift::protocol::T_STRUCT);
-        iprot_->readMessageEnd();
-        iprot_->getTransport()->readEnd();
-
-        // in a bad state, don't commit
-        using ::apache::thrift::protocol::TProtocolException;
-        throw TProtocolException(TProtocolException::INVALID_DATA);
-      }
-      ThriftHiveMetastore_get_database_presult result;
-      result.success = &_return;
-      result.read(iprot_);
-      iprot_->readMessageEnd();
-      iprot_->getTransport()->readEnd();
-
-      if (result.__isset.success) {
-        // _return pointer has now been filled
-        sentry.commit();
-        return;
-      }
-      if (result.__isset.o1) {
-        sentry.commit();
-        throw result.o1;
-      }
-      if (result.__isset.o2) {
-        sentry.commit();
-        throw result.o2;
-      }
-      // in a bad state, don't commit
-      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_database failed: unknown result");
-    }
-    // seqid != rseqid
-    this->sync_->updatePending(fname, mtype, rseqid);
-
-    // this will temporarily unlock the readMutex, and let other clients get work done
-    this->sync_->waitForWork(seqid);
-  } // end while(true)
-}
-
-void ThriftHiveMetastoreConcurrentClient::get_database_req(Database& _return, const GetDatabaseRequest& request)
-{
-  int32_t seqid = send_get_database_req(request);
-  recv_get_database_req(_return, seqid);
-}
-
-int32_t ThriftHiveMetastoreConcurrentClient::send_get_database_req(const GetDatabaseRequest& request)
-{
-  int32_t cseqid = this->sync_->generateSeqId();
-  ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("get_database_req", ::apache::thrift::protocol::T_CALL, cseqid);
-
-  ThriftHiveMetastore_get_database_req_pargs args;
-  args.request = &request;
-  args.write(oprot_);
-
-  oprot_->writeMessageEnd();
-  oprot_->getTransport()->writeEnd();
-  oprot_->getTransport()->flush();
-
-  sentry.commit();
-  return cseqid;
-}
-
-void ThriftHiveMetastoreConcurrentClient::recv_get_database_req(Database& _return, const int32_t seqid)
-{
-
-  int32_t rseqid = 0;
-  std::string fname;
-  ::apache::thrift::protocol::TMessageType mtype;
-
-  // the read mutex gets dropped and reacquired as part of waitForWork()
-  // The destructor of this sentry wakes up other clients
-  ::apache::thrift::async::TConcurrentRecvSentry sentry(this->sync_.get(), seqid);
-
-  while(true) {
-    if(!this->sync_->getPending(fname, mtype, rseqid)) {
-      iprot_->readMessageBegin(fname, mtype, rseqid);
-    }
-    if(seqid == rseqid) {
-      if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
-        ::apache::thrift::TApplicationException x;
-        x.read(iprot_);
-        iprot_->readMessageEnd();
-        iprot_->getTransport()->readEnd();
-        sentry.commit();
-        throw x;
-      }
-      if (mtype != ::apache::thrift::protocol::T_REPLY) {
-        iprot_->skip(::apache::thrift::protocol::T_STRUCT);
-        iprot_->readMessageEnd();
-        iprot_->getTransport()->readEnd();
-      }
-      if (fname.compare("get_database_req") != 0) {
+      if (fname.compare("create_database") != 0) {
         iprot_->skip(::apache::thrift::protocol::T_STRUCT);
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
@@ -96640,17 +94149,11 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_database_req(Database& _retur
         using ::apache::thrift::protocol::TProtocolException;
         throw TProtocolException(TProtocolException::INVALID_DATA);
       }
-      ThriftHiveMetastore_get_database_req_presult result;
-      result.success = &_return;
+      ThriftHiveMetastore_create_database_presult result;
       result.read(iprot_);
       iprot_->readMessageEnd();
       iprot_->getTransport()->readEnd();
 
-      if (result.__isset.success) {
-        // _return pointer has now been filled
-        sentry.commit();
-        return;
-      }
       if (result.__isset.o1) {
         sentry.commit();
         throw result.o1;
@@ -96659,8 +94162,12 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_database_req(Database& _retur
         sentry.commit();
         throw result.o2;
       }
-      // in a bad state, don't commit
-      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_database_req failed: unknown result");
+      if (result.__isset.o3) {
+        sentry.commit();
+        throw result.o3;
+      }
+      sentry.commit();
+      return;
     }
     // seqid != rseqid
     this->sync_->updatePending(fname, mtype, rseqid);
@@ -96670,22 +94177,20 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_database_req(Database& _retur
   } // end while(true)
 }
 
-void ThriftHiveMetastoreConcurrentClient::drop_database(const std::string& name, const bool deleteData, const bool cascade)
+void ThriftHiveMetastoreConcurrentClient::get_database(Database& _return, const std::string& name)
 {
-  int32_t seqid = send_drop_database(name, deleteData, cascade);
-  recv_drop_database(seqid);
+  int32_t seqid = send_get_database(name);
+  recv_get_database(_return, seqid);
 }
 
-int32_t ThriftHiveMetastoreConcurrentClient::send_drop_database(const std::string& name, const bool deleteData, const bool cascade)
+int32_t ThriftHiveMetastoreConcurrentClient::send_get_database(const std::string& name)
 {
   int32_t cseqid = this->sync_->generateSeqId();
   ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("drop_database", ::apache::thrift::protocol::T_CALL, cseqid);
+  oprot_->writeMessageBegin("get_database", ::apache::thrift::protocol::T_CALL, cseqid);
 
-  ThriftHiveMetastore_drop_database_pargs args;
+  ThriftHiveMetastore_get_database_pargs args;
   args.name = &name;
-  args.deleteData = &deleteData;
-  args.cascade = &cascade;
   args.write(oprot_);
 
   oprot_->writeMessageEnd();
@@ -96696,7 +94201,7 @@ int32_t ThriftHiveMetastoreConcurrentClient::send_drop_database(const std::strin
   return cseqid;
 }
 
-void ThriftHiveMetastoreConcurrentClient::recv_drop_database(const int32_t seqid)
+void ThriftHiveMetastoreConcurrentClient::recv_get_database(Database& _return, const int32_t seqid)
 {
 
   int32_t rseqid = 0;
@@ -96725,7 +94230,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_drop_database(const int32_t seqid
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
       }
-      if (fname.compare("drop_database") != 0) {
+      if (fname.compare("get_database") != 0) {
         iprot_->skip(::apache::thrift::protocol::T_STRUCT);
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
@@ -96734,11 +94239,17 @@ void ThriftHiveMetastoreConcurrentClient::recv_drop_database(const int32_t seqid
         using ::apache::thrift::protocol::TProtocolException;
         throw TProtocolException(TProtocolException::INVALID_DATA);
       }
-      ThriftHiveMetastore_drop_database_presult result;
+      ThriftHiveMetastore_get_database_presult result;
+      result.success = &_return;
       result.read(iprot_);
       iprot_->readMessageEnd();
       iprot_->getTransport()->readEnd();
 
+      if (result.__isset.success) {
+        // _return pointer has now been filled
+        sentry.commit();
+        return;
+      }
       if (result.__isset.o1) {
         sentry.commit();
         throw result.o1;
@@ -96747,12 +94258,8 @@ void ThriftHiveMetastoreConcurrentClient::recv_drop_database(const int32_t seqid
         sentry.commit();
         throw result.o2;
       }
-      if (result.__isset.o3) {
-        sentry.commit();
-        throw result.o3;
-      }
-      sentry.commit();
-      return;
+      // in a bad state, don't commit
+      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_database failed: unknown result");
     }
     // seqid != rseqid
     this->sync_->updatePending(fname, mtype, rseqid);
@@ -96762,20 +94269,20 @@ void ThriftHiveMetastoreConcurrentClient::recv_drop_database(const int32_t seqid
   } // end while(true)
 }
 
-void ThriftHiveMetastoreConcurrentClient::get_databases(std::vector<std::string> & _return, const std::string& pattern)
+void ThriftHiveMetastoreConcurrentClient::get_database_req(Database& _return, const GetDatabaseRequest& request)
 {
-  int32_t seqid = send_get_databases(pattern);
-  recv_get_databases(_return, seqid);
+  int32_t seqid = send_get_database_req(request);
+  recv_get_database_req(_return, seqid);
 }
 
-int32_t ThriftHiveMetastoreConcurrentClient::send_get_databases(const std::string& pattern)
+int32_t ThriftHiveMetastoreConcurrentClient::send_get_database_req(const GetDatabaseRequest& request)
 {
   int32_t cseqid = this->sync_->generateSeqId();
   ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("get_databases", ::apache::thrift::protocol::T_CALL, cseqid);
+  oprot_->writeMessageBegin("get_database_req", ::apache::thrift::protocol::T_CALL, cseqid);
 
-  ThriftHiveMetastore_get_databases_pargs args;
-  args.pattern = &pattern;
+  ThriftHiveMetastore_get_database_req_pargs args;
+  args.request = &request;
   args.write(oprot_);
 
   oprot_->writeMessageEnd();
@@ -96786,7 +94293,7 @@ int32_t ThriftHiveMetastoreConcurrentClient::send_get_databases(const std::strin
   return cseqid;
 }
 
-void ThriftHiveMetastoreConcurrentClient::recv_get_databases(std::vector<std::string> & _return, const int32_t seqid)
+void ThriftHiveMetastoreConcurrentClient::recv_get_database_req(Database& _return, const int32_t seqid)
 {
 
   int32_t rseqid = 0;
@@ -96815,7 +94322,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_databases(std::vector<std::st
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
       }
-      if (fname.compare("get_databases") != 0) {
+      if (fname.compare("get_database_req") != 0) {
         iprot_->skip(::apache::thrift::protocol::T_STRUCT);
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
@@ -96824,7 +94331,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_databases(std::vector<std::st
         using ::apache::thrift::protocol::TProtocolException;
         throw TProtocolException(TProtocolException::INVALID_DATA);
       }
-      ThriftHiveMetastore_get_databases_presult result;
+      ThriftHiveMetastore_get_database_req_presult result;
       result.success = &_return;
       result.read(iprot_);
       iprot_->readMessageEnd();
@@ -96839,8 +94346,12 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_databases(std::vector<std::st
         sentry.commit();
         throw result.o1;
       }
+      if (result.__isset.o2) {
+        sentry.commit();
+        throw result.o2;
+      }
       // in a bad state, don't commit
-      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_databases failed: unknown result");
+      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_database_req failed: unknown result");
     }
     // seqid != rseqid
     this->sync_->updatePending(fname, mtype, rseqid);
@@ -96850,19 +94361,22 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_databases(std::vector<std::st
   } // end while(true)
 }
 
-void ThriftHiveMetastoreConcurrentClient::get_all_databases(std::vector<std::string> & _return)
+void ThriftHiveMetastoreConcurrentClient::drop_database(const std::string& name, const bool deleteData, const bool cascade)
 {
-  int32_t seqid = send_get_all_databases();
-  recv_get_all_databases(_return, seqid);
+  int32_t seqid = send_drop_database(name, deleteData, cascade);
+  recv_drop_database(seqid);
 }
 
-int32_t ThriftHiveMetastoreConcurrentClient::send_get_all_databases()
+int32_t ThriftHiveMetastoreConcurrentClient::send_drop_database(const std::string& name, const bool deleteData, const bool cascade)
 {
   int32_t cseqid = this->sync_->generateSeqId();
   ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("get_all_databases", ::apache::thrift::protocol::T_CALL, cseqid);
+  oprot_->writeMessageBegin("drop_database", ::apache::thrift::protocol::T_CALL, cseqid);
 
-  ThriftHiveMetastore_get_all_databases_pargs args;
+  ThriftHiveMetastore_drop_database_pargs args;
+  args.name = &name;
+  args.deleteData = &deleteData;
+  args.cascade = &cascade;
   args.write(oprot_);
 
   oprot_->writeMessageEnd();
@@ -96873,7 +94387,7 @@ int32_t ThriftHiveMetastoreConcurrentClient::send_get_all_databases()
   return cseqid;
 }
 
-void ThriftHiveMetastoreConcurrentClient::recv_get_all_databases(std::vector<std::string> & _return, const int32_t seqid)
+void ThriftHiveMetastoreConcurrentClient::recv_drop_database(const int32_t seqid)
 {
 
   int32_t rseqid = 0;
@@ -96902,7 +94416,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_all_databases(std::vector<std
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
       }
-      if (fname.compare("get_all_databases") != 0) {
+      if (fname.compare("drop_database") != 0) {
         iprot_->skip(::apache::thrift::protocol::T_STRUCT);
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
@@ -96911,7 +94425,97 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_all_databases(std::vector<std
         using ::apache::thrift::protocol::TProtocolException;
         throw TProtocolException(TProtocolException::INVALID_DATA);
       }
-      ThriftHiveMetastore_get_all_databases_presult result;
+      ThriftHiveMetastore_drop_database_presult result;
+      result.read(iprot_);
+      iprot_->readMessageEnd();
+      iprot_->getTransport()->readEnd();
+
+      if (result.__isset.o1) {
+        sentry.commit();
+        throw result.o1;
+      }
+      if (result.__isset.o2) {
+        sentry.commit();
+        throw result.o2;
+      }
+      if (result.__isset.o3) {
+        sentry.commit();
+        throw result.o3;
+      }
+      sentry.commit();
+      return;
+    }
+    // seqid != rseqid
+    this->sync_->updatePending(fname, mtype, rseqid);
+
+    // this will temporarily unlock the readMutex, and let other clients get work done
+    this->sync_->waitForWork(seqid);
+  } // end while(true)
+}
+
+void ThriftHiveMetastoreConcurrentClient::get_databases(std::vector<std::string> & _return, const std::string& pattern)
+{
+  int32_t seqid = send_get_databases(pattern);
+  recv_get_databases(_return, seqid);
+}
+
+int32_t ThriftHiveMetastoreConcurrentClient::send_get_databases(const std::string& pattern)
+{
+  int32_t cseqid = this->sync_->generateSeqId();
+  ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
+  oprot_->writeMessageBegin("get_databases", ::apache::thrift::protocol::T_CALL, cseqid);
+
+  ThriftHiveMetastore_get_databases_pargs args;
+  args.pattern = &pattern;
+  args.write(oprot_);
+
+  oprot_->writeMessageEnd();
+  oprot_->getTransport()->writeEnd();
+  oprot_->getTransport()->flush();
+
+  sentry.commit();
+  return cseqid;
+}
+
+void ThriftHiveMetastoreConcurrentClient::recv_get_databases(std::vector<std::string> & _return, const int32_t seqid)
+{
+
+  int32_t rseqid = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TMessageType mtype;
+
+  // the read mutex gets dropped and reacquired as part of waitForWork()
+  // The destructor of this sentry wakes up other clients
+  ::apache::thrift::async::TConcurrentRecvSentry sentry(this->sync_.get(), seqid);
+
+  while(true) {
+    if(!this->sync_->getPending(fname, mtype, rseqid)) {
+      iprot_->readMessageBegin(fname, mtype, rseqid);
+    }
+    if(seqid == rseqid) {
+      if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
+        ::apache::thrift::TApplicationException x;
+        x.read(iprot_);
+        iprot_->readMessageEnd();
+        iprot_->getTransport()->readEnd();
+        sentry.commit();
+        throw x;
+      }
+      if (mtype != ::apache::thrift::protocol::T_REPLY) {
+        iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+        iprot_->readMessageEnd();
+        iprot_->getTransport()->readEnd();
+      }
+      if (fname.compare("get_databases") != 0) {
+        iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+        iprot_->readMessageEnd();
+        iprot_->getTransport()->readEnd();
+
+        // in a bad state, don't commit
+        using ::apache::thrift::protocol::TProtocolException;
+        throw TProtocolException(TProtocolException::INVALID_DATA);
+      }
+      ThriftHiveMetastore_get_databases_presult result;
       result.success = &_return;
       result.read(iprot_);
       iprot_->readMessageEnd();
@@ -96927,7 +94531,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_all_databases(std::vector<std
         throw result.o1;
       }
       // in a bad state, don't commit
-      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_all_databases failed: unknown result");
+      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_databases failed: unknown result");
     }
     // seqid != rseqid
     this->sync_->updatePending(fname, mtype, rseqid);
@@ -96937,21 +94541,19 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_all_databases(std::vector<std
   } // end while(true)
 }
 
-void ThriftHiveMetastoreConcurrentClient::alter_database(const std::string& dbname, const Database& db)
+void ThriftHiveMetastoreConcurrentClient::get_all_databases(std::vector<std::string> & _return)
 {
-  int32_t seqid = send_alter_database(dbname, db);
-  recv_alter_database(seqid);
+  int32_t seqid = send_get_all_databases();
+  recv_get_all_databases(_return, seqid);
 }
 
-int32_t ThriftHiveMetastoreConcurrentClient::send_alter_database(const std::string& dbname, const Database& db)
+int32_t ThriftHiveMetastoreConcurrentClient::send_get_all_databases()
 {
   int32_t cseqid = this->sync_->generateSeqId();
   ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("alter_database", ::apache::thrift::protocol::T_CALL, cseqid);
+  oprot_->writeMessageBegin("get_all_databases", ::apache::thrift::protocol::T_CALL, cseqid);
 
-  ThriftHiveMetastore_alter_database_pargs args;
-  args.dbname = &dbname;
-  args.db = &db;
+  ThriftHiveMetastore_get_all_databases_pargs args;
   args.write(oprot_);
 
   oprot_->writeMessageEnd();
@@ -96962,7 +94564,7 @@ int32_t ThriftHiveMetastoreConcurrentClient::send_alter_database(const std::stri
   return cseqid;
 }
 
-void ThriftHiveMetastoreConcurrentClient::recv_alter_database(const int32_t seqid)
+void ThriftHiveMetastoreConcurrentClient::recv_get_all_databases(std::vector<std::string> & _return, const int32_t seqid)
 {
 
   int32_t rseqid = 0;
@@ -96991,7 +94593,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_alter_database(const int32_t seqi
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
       }
-      if (fname.compare("alter_database") != 0) {
+      if (fname.compare("get_all_databases") != 0) {
         iprot_->skip(::apache::thrift::protocol::T_STRUCT);
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
@@ -97000,21 +94602,23 @@ void ThriftHiveMetastoreConcurrentClient::recv_alter_database(const int32_t seqi
         using ::apache::thrift::protocol::TProtocolException;
         throw TProtocolException(TProtocolException::INVALID_DATA);
       }
-      ThriftHiveMetastore_alter_database_presult result;
+      ThriftHiveMetastore_get_all_databases_presult result;
+      result.success = &_return;
       result.read(iprot_);
       iprot_->readMessageEnd();
       iprot_->getTransport()->readEnd();
 
-      if (result.__isset.o1) {
+      if (result.__isset.success) {
+        // _return pointer has now been filled
         sentry.commit();
-        throw result.o1;
+        return;
       }
-      if (result.__isset.o2) {
+      if (result.__isset.o1) {
         sentry.commit();
-        throw result.o2;
+        throw result.o1;
       }
-      sentry.commit();
-      return;
+      // in a bad state, don't commit
+      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_all_databases failed: unknown result");
     }
     // seqid != rseqid
     this->sync_->updatePending(fname, mtype, rseqid);
@@ -97024,20 +94628,21 @@ void ThriftHiveMetastoreConcurrentClient::recv_alter_database(const int32_t seqi
   } // end while(true)
 }
 
-void ThriftHiveMetastoreConcurrentClient::get_type(Type& _return, const std::string& name)
+void ThriftHiveMetastoreConcurrentClient::alter_database(const std::string& dbname, const Database& db)
 {
-  int32_t seqid = send_get_type(name);
-  recv_get_type(_return, seqid);
+  int32_t seqid = send_alter_database(dbname, db);
+  recv_alter_database(seqid);
 }
 
-int32_t ThriftHiveMetastoreConcurrentClient::send_get_type(const std::string& name)
+int32_t ThriftHiveMetastoreConcurrentClient::send_alter_database(const std::string& dbname, const Database& db)
 {
   int32_t cseqid = this->sync_->generateSeqId();
   ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("get_type", ::apache::thrift::protocol::T_CALL, cseqid);
+  oprot_->writeMessageBegin("alter_database", ::apache::thrift::protocol::T_CALL, cseqid);
 
-  ThriftHiveMetastore_get_type_pargs args;
-  args.name = &name;
+  ThriftHiveMetastore_alter_database_pargs args;
+  args.dbname = &dbname;
+  args.db = &db;
   args.write(oprot_);
 
   oprot_->writeMessageEnd();
@@ -97048,7 +94653,7 @@ int32_t ThriftHiveMetastoreConcurrentClient::send_get_type(const std::string& na
   return cseqid;
 }
 
-void ThriftHiveMetastoreConcurrentClient::recv_get_type(Type& _return, const int32_t seqid)
+void ThriftHiveMetastoreConcurrentClient::recv_alter_database(const int32_t seqid)
 {
 
   int32_t rseqid = 0;
@@ -97077,7 +94682,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_type(Type& _return, const int
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
       }
-      if (fname.compare("get_type") != 0) {
+      if (fname.compare("alter_database") != 0) {
         iprot_->skip(::apache::thrift::protocol::T_STRUCT);
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
@@ -97086,17 +94691,11 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_type(Type& _return, const int
         using ::apache::thrift::protocol::TProtocolException;
         throw TProtocolException(TProtocolException::INVALID_DATA);
       }
-      ThriftHiveMetastore_get_type_presult result;
-      result.success = &_return;
+      ThriftHiveMetastore_alter_database_presult result;
       result.read(iprot_);
       iprot_->readMessageEnd();
       iprot_->getTransport()->readEnd();
 
-      if (result.__isset.success) {
-        // _return pointer has now been filled
-        sentry.commit();
-        return;
-      }
       if (result.__isset.o1) {
         sentry.commit();
         throw result.o1;
@@ -97105,8 +94704,8 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_type(Type& _return, const int
         sentry.commit();
         throw result.o2;
       }
-      // in a bad state, don't commit
-      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_type failed: unknown result");
+      sentry.commit();
+      return;
     }
     // seqid != rseqid
     this->sync_->updatePending(fname, mtype, rseqid);
@@ -97116,20 +94715,20 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_type(Type& _return, const int
   } // end while(true)
 }
 
-bool ThriftHiveMetastoreConcurrentClient::create_type(const Type& type)
+void ThriftHiveMetastoreConcurrentClient::create_dataconnector(const DataConnector& connector)
 {
-  int32_t seqid = send_create_type(type);
-  return recv_create_type(seqid);
+  int32_t seqid = send_create_dataconnector(connector);
+  recv_create_dataconnector(seqid);
 }
 
-int32_t ThriftHiveMetastoreConcurrentClient::send_create_type(const Type& type)
+int32_t ThriftHiveMetastoreConcurrentClient::send_create_dataconnector(const DataConnector& connector)
 {
   int32_t cseqid = this->sync_->generateSeqId();
   ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("create_type", ::apache::thrift::protocol::T_CALL, cseqid);
+  oprot_->writeMessageBegin("create_dataconnector", ::apache::thrift::protocol::T_CALL, cseqid);
 
-  ThriftHiveMetastore_create_type_pargs args;
-  args.type = &type;
+  ThriftHiveMetastore_create_dataconnector_pargs args;
+  args.connector = &connector;
   args.write(oprot_);
 
   oprot_->writeMessageEnd();
@@ -97140,7 +94739,7 @@ int32_t ThriftHiveMetastoreConcurrentClient::send_create_type(const Type& type)
   return cseqid;
 }
 
-bool ThriftHiveMetastoreConcurrentClient::recv_create_type(const int32_t seqid)
+void ThriftHiveMetastoreConcurrentClient::recv_create_dataconnector(const int32_t seqid)
 {
 
   int32_t rseqid = 0;
@@ -97169,10 +94768,7 @@ bool ThriftHiveMetastoreConcurrentClient::recv_create_type(const int32_t seqid)
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
       }
-<<<<<<< HEAD
-      if (fname.compare("create_type") != 0) {
-=======
-      if (fname.compare("get_catalogs") != 0) {
+      if (fname.compare("create_dataconnector") != 0) {
         iprot_->skip(::apache::thrift::protocol::T_STRUCT);
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
@@ -97181,23 +94777,25 @@ bool ThriftHiveMetastoreConcurrentClient::recv_create_type(const int32_t seqid)
         using ::apache::thrift::protocol::TProtocolException;
         throw TProtocolException(TProtocolException::INVALID_DATA);
       }
-      ThriftHiveMetastore_get_catalogs_presult result;
-      result.success = &_return;
+      ThriftHiveMetastore_create_dataconnector_presult result;
       result.read(iprot_);
       iprot_->readMessageEnd();
       iprot_->getTransport()->readEnd();
 
-      if (result.__isset.success) {
-        // _return pointer has now been filled
-        sentry.commit();
-        return;
-      }
       if (result.__isset.o1) {
         sentry.commit();
         throw result.o1;
       }
-      // in a bad state, don't commit
-      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_catalogs failed: unknown result");
+      if (result.__isset.o2) {
+        sentry.commit();
+        throw result.o2;
+      }
+      if (result.__isset.o3) {
+        sentry.commit();
+        throw result.o3;
+      }
+      sentry.commit();
+      return;
     }
     // seqid != rseqid
     this->sync_->updatePending(fname, mtype, rseqid);
@@ -97207,20 +94805,20 @@ bool ThriftHiveMetastoreConcurrentClient::recv_create_type(const int32_t seqid)
   } // end while(true)
 }
 
-void ThriftHiveMetastoreConcurrentClient::drop_catalog(const DropCatalogRequest& catName)
+void ThriftHiveMetastoreConcurrentClient::get_dataconnector_req(DataConnector& _return, const GetDataConnectorRequest& request)
 {
-  int32_t seqid = send_drop_catalog(catName);
-  recv_drop_catalog(seqid);
+  int32_t seqid = send_get_dataconnector_req(request);
+  recv_get_dataconnector_req(_return, seqid);
 }
 
-int32_t ThriftHiveMetastoreConcurrentClient::send_drop_catalog(const DropCatalogRequest& catName)
+int32_t ThriftHiveMetastoreConcurrentClient::send_get_dataconnector_req(const GetDataConnectorRequest& request)
 {
   int32_t cseqid = this->sync_->generateSeqId();
   ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("drop_catalog", ::apache::thrift::protocol::T_CALL, cseqid);
+  oprot_->writeMessageBegin("get_dataconnector_req", ::apache::thrift::protocol::T_CALL, cseqid);
 
-  ThriftHiveMetastore_drop_catalog_pargs args;
-  args.catName = &catName;
+  ThriftHiveMetastore_get_dataconnector_req_pargs args;
+  args.request = &request;
   args.write(oprot_);
 
   oprot_->writeMessageEnd();
@@ -97231,7 +94829,7 @@ int32_t ThriftHiveMetastoreConcurrentClient::send_drop_catalog(const DropCatalog
   return cseqid;
 }
 
-void ThriftHiveMetastoreConcurrentClient::recv_drop_catalog(const int32_t seqid)
+void ThriftHiveMetastoreConcurrentClient::recv_get_dataconnector_req(DataConnector& _return, const int32_t seqid)
 {
 
   int32_t rseqid = 0;
@@ -97260,7 +94858,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_drop_catalog(const int32_t seqid)
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
       }
-      if (fname.compare("drop_catalog") != 0) {
+      if (fname.compare("get_dataconnector_req") != 0) {
         iprot_->skip(::apache::thrift::protocol::T_STRUCT);
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
@@ -97269,11 +94867,17 @@ void ThriftHiveMetastoreConcurrentClient::recv_drop_catalog(const int32_t seqid)
         using ::apache::thrift::protocol::TProtocolException;
         throw TProtocolException(TProtocolException::INVALID_DATA);
       }
-      ThriftHiveMetastore_drop_catalog_presult result;
+      ThriftHiveMetastore_get_dataconnector_req_presult result;
+      result.success = &_return;
       result.read(iprot_);
       iprot_->readMessageEnd();
       iprot_->getTransport()->readEnd();
 
+      if (result.__isset.success) {
+        // _return pointer has now been filled
+        sentry.commit();
+        return;
+      }
       if (result.__isset.o1) {
         sentry.commit();
         throw result.o1;
@@ -97282,12 +94886,8 @@ void ThriftHiveMetastoreConcurrentClient::recv_drop_catalog(const int32_t seqid)
         sentry.commit();
         throw result.o2;
       }
-      if (result.__isset.o3) {
-        sentry.commit();
-        throw result.o3;
-      }
-      sentry.commit();
-      return;
+      // in a bad state, don't commit
+      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_dataconnector_req failed: unknown result");
     }
     // seqid != rseqid
     this->sync_->updatePending(fname, mtype, rseqid);
@@ -97297,20 +94897,22 @@ void ThriftHiveMetastoreConcurrentClient::recv_drop_catalog(const int32_t seqid)
   } // end while(true)
 }
 
-void ThriftHiveMetastoreConcurrentClient::create_database(const Database& database)
+void ThriftHiveMetastoreConcurrentClient::drop_dataconnector(const std::string& name, const bool ifNotExists, const bool checkReferences)
 {
-  int32_t seqid = send_create_database(database);
-  recv_create_database(seqid);
+  int32_t seqid = send_drop_dataconnector(name, ifNotExists, checkReferences);
+  recv_drop_dataconnector(seqid);
 }
 
-int32_t ThriftHiveMetastoreConcurrentClient::send_create_database(const Database& database)
+int32_t ThriftHiveMetastoreConcurrentClient::send_drop_dataconnector(const std::string& name, const bool ifNotExists, const bool checkReferences)
 {
   int32_t cseqid = this->sync_->generateSeqId();
   ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("create_database", ::apache::thrift::protocol::T_CALL, cseqid);
+  oprot_->writeMessageBegin("drop_dataconnector", ::apache::thrift::protocol::T_CALL, cseqid);
 
-  ThriftHiveMetastore_create_database_pargs args;
-  args.database = &database;
+  ThriftHiveMetastore_drop_dataconnector_pargs args;
+  args.name = &name;
+  args.ifNotExists = &ifNotExists;
+  args.checkReferences = &checkReferences;
   args.write(oprot_);
 
   oprot_->writeMessageEnd();
@@ -97321,7 +94923,7 @@ int32_t ThriftHiveMetastoreConcurrentClient::send_create_database(const Database
   return cseqid;
 }
 
-void ThriftHiveMetastoreConcurrentClient::recv_create_database(const int32_t seqid)
+void ThriftHiveMetastoreConcurrentClient::recv_drop_dataconnector(const int32_t seqid)
 {
 
   int32_t rseqid = 0;
@@ -97350,7 +94952,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_create_database(const int32_t seq
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
       }
-      if (fname.compare("create_database") != 0) {
+      if (fname.compare("drop_dataconnector") != 0) {
         iprot_->skip(::apache::thrift::protocol::T_STRUCT);
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
@@ -97359,7 +94961,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_create_database(const int32_t seq
         using ::apache::thrift::protocol::TProtocolException;
         throw TProtocolException(TProtocolException::INVALID_DATA);
       }
-      ThriftHiveMetastore_create_database_presult result;
+      ThriftHiveMetastore_drop_dataconnector_presult result;
       result.read(iprot_);
       iprot_->readMessageEnd();
       iprot_->getTransport()->readEnd();
@@ -97387,20 +94989,19 @@ void ThriftHiveMetastoreConcurrentClient::recv_create_database(const int32_t seq
   } // end while(true)
 }
 
-void ThriftHiveMetastoreConcurrentClient::get_database(Database& _return, const std::string& name)
+void ThriftHiveMetastoreConcurrentClient::get_dataconnectors(std::vector<std::string> & _return)
 {
-  int32_t seqid = send_get_database(name);
-  recv_get_database(_return, seqid);
+  int32_t seqid = send_get_dataconnectors();
+  recv_get_dataconnectors(_return, seqid);
 }
 
-int32_t ThriftHiveMetastoreConcurrentClient::send_get_database(const std::string& name)
+int32_t ThriftHiveMetastoreConcurrentClient::send_get_dataconnectors()
 {
   int32_t cseqid = this->sync_->generateSeqId();
   ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("get_database", ::apache::thrift::protocol::T_CALL, cseqid);
+  oprot_->writeMessageBegin("get_dataconnectors", ::apache::thrift::protocol::T_CALL, cseqid);
 
-  ThriftHiveMetastore_get_database_pargs args;
-  args.name = &name;
+  ThriftHiveMetastore_get_dataconnectors_pargs args;
   args.write(oprot_);
 
   oprot_->writeMessageEnd();
@@ -97411,7 +95012,7 @@ int32_t ThriftHiveMetastoreConcurrentClient::send_get_database(const std::string
   return cseqid;
 }
 
-void ThriftHiveMetastoreConcurrentClient::recv_get_database(Database& _return, const int32_t seqid)
+void ThriftHiveMetastoreConcurrentClient::recv_get_dataconnectors(std::vector<std::string> & _return, const int32_t seqid)
 {
 
   int32_t rseqid = 0;
@@ -97440,7 +95041,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_database(Database& _return, c
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
       }
-      if (fname.compare("get_database") != 0) {
+      if (fname.compare("get_dataconnectors") != 0) {
         iprot_->skip(::apache::thrift::protocol::T_STRUCT);
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
@@ -97449,7 +95050,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_database(Database& _return, c
         using ::apache::thrift::protocol::TProtocolException;
         throw TProtocolException(TProtocolException::INVALID_DATA);
       }
-      ThriftHiveMetastore_get_database_presult result;
+      ThriftHiveMetastore_get_dataconnectors_presult result;
       result.success = &_return;
       result.read(iprot_);
       iprot_->readMessageEnd();
@@ -97464,12 +95065,8 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_database(Database& _return, c
         sentry.commit();
         throw result.o1;
       }
-      if (result.__isset.o2) {
-        sentry.commit();
-        throw result.o2;
-      }
       // in a bad state, don't commit
-      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_database failed: unknown result");
+      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_dataconnectors failed: unknown result");
     }
     // seqid != rseqid
     this->sync_->updatePending(fname, mtype, rseqid);
@@ -97479,20 +95076,21 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_database(Database& _return, c
   } // end while(true)
 }
 
-void ThriftHiveMetastoreConcurrentClient::get_database_req(Database& _return, const GetDatabaseRequest& request)
+void ThriftHiveMetastoreConcurrentClient::alter_dataconnector(const std::string& name, const DataConnector& connector)
 {
-  int32_t seqid = send_get_database_req(request);
-  recv_get_database_req(_return, seqid);
+  int32_t seqid = send_alter_dataconnector(name, connector);
+  recv_alter_dataconnector(seqid);
 }
 
-int32_t ThriftHiveMetastoreConcurrentClient::send_get_database_req(const GetDatabaseRequest& request)
+int32_t ThriftHiveMetastoreConcurrentClient::send_alter_dataconnector(const std::string& name, const DataConnector& connector)
 {
   int32_t cseqid = this->sync_->generateSeqId();
   ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("get_database_req", ::apache::thrift::protocol::T_CALL, cseqid);
+  oprot_->writeMessageBegin("alter_dataconnector", ::apache::thrift::protocol::T_CALL, cseqid);
 
-  ThriftHiveMetastore_get_database_req_pargs args;
-  args.request = &request;
+  ThriftHiveMetastore_alter_dataconnector_pargs args;
+  args.name = &name;
+  args.connector = &connector;
   args.write(oprot_);
 
   oprot_->writeMessageEnd();
@@ -97503,7 +95101,7 @@ int32_t ThriftHiveMetastoreConcurrentClient::send_get_database_req(const GetData
   return cseqid;
 }
 
-void ThriftHiveMetastoreConcurrentClient::recv_get_database_req(Database& _return, const int32_t seqid)
+void ThriftHiveMetastoreConcurrentClient::recv_alter_dataconnector(const int32_t seqid)
 {
 
   int32_t rseqid = 0;
@@ -97532,8 +95130,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_database_req(Database& _retur
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
       }
-      if (fname.compare("get_database_req") != 0) {
->>>>>>> External metastore: clean after rebase
+      if (fname.compare("alter_dataconnector") != 0) {
         iprot_->skip(::apache::thrift::protocol::T_STRUCT);
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
@@ -97542,21 +95139,11 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_database_req(Database& _retur
         using ::apache::thrift::protocol::TProtocolException;
         throw TProtocolException(TProtocolException::INVALID_DATA);
       }
-<<<<<<< HEAD
-      bool _return;
-      ThriftHiveMetastore_create_type_presult result;
-=======
-      ThriftHiveMetastore_get_database_req_presult result;
->>>>>>> External metastore: clean after rebase
-      result.success = &_return;
+      ThriftHiveMetastore_alter_dataconnector_presult result;
       result.read(iprot_);
       iprot_->readMessageEnd();
       iprot_->getTransport()->readEnd();
 
-      if (result.__isset.success) {
-        sentry.commit();
-        return _return;
-      }
       if (result.__isset.o1) {
         sentry.commit();
         throw result.o1;
@@ -97565,17 +95152,8 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_database_req(Database& _retur
         sentry.commit();
         throw result.o2;
       }
-<<<<<<< HEAD
-      if (result.__isset.o3) {
-        sentry.commit();
-        throw result.o3;
-      }
-      // in a bad state, don't commit
-      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "create_type failed: unknown result");
-=======
-      // in a bad state, don't commit
-      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_database_req failed: unknown result");
->>>>>>> External metastore: clean after rebase
+      sentry.commit();
+      return;
     }
     // seqid != rseqid
     this->sync_->updatePending(fname, mtype, rseqid);
@@ -97585,39 +95163,20 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_database_req(Database& _retur
   } // end while(true)
 }
 
-<<<<<<< HEAD
-bool ThriftHiveMetastoreConcurrentClient::drop_type(const std::string& type)
-{
-  int32_t seqid = send_drop_type(type);
-  return recv_drop_type(seqid);
-}
-
-int32_t ThriftHiveMetastoreConcurrentClient::send_drop_type(const std::string& type)
-{
-  int32_t cseqid = this->sync_->generateSeqId();
-  ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("drop_type", ::apache::thrift::protocol::T_CALL, cseqid);
-
-  ThriftHiveMetastore_drop_type_pargs args;
-  args.type = &type;
-=======
-void ThriftHiveMetastoreConcurrentClient::drop_database(const std::string& name, const bool deleteData, const bool cascade)
+void ThriftHiveMetastoreConcurrentClient::get_type(Type& _return, const std::string& name)
 {
-  int32_t seqid = send_drop_database(name, deleteData, cascade);
-  recv_drop_database(seqid);
+  int32_t seqid = send_get_type(name);
+  recv_get_type(_return, seqid);
 }
 
-int32_t ThriftHiveMetastoreConcurrentClient::send_drop_database(const std::string& name, const bool deleteData, const bool cascade)
+int32_t ThriftHiveMetastoreConcurrentClient::send_get_type(const std::string& name)
 {
   int32_t cseqid = this->sync_->generateSeqId();
   ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("drop_database", ::apache::thrift::protocol::T_CALL, cseqid);
+  oprot_->writeMessageBegin("get_type", ::apache::thrift::protocol::T_CALL, cseqid);
 
-  ThriftHiveMetastore_drop_database_pargs args;
+  ThriftHiveMetastore_get_type_pargs args;
   args.name = &name;
-  args.deleteData = &deleteData;
-  args.cascade = &cascade;
->>>>>>> External metastore: clean after rebase
   args.write(oprot_);
 
   oprot_->writeMessageEnd();
@@ -97628,11 +95187,7 @@ int32_t ThriftHiveMetastoreConcurrentClient::send_drop_database(const std::strin
   return cseqid;
 }
 
-<<<<<<< HEAD
-bool ThriftHiveMetastoreConcurrentClient::recv_drop_type(const int32_t seqid)
-=======
-void ThriftHiveMetastoreConcurrentClient::recv_drop_database(const int32_t seqid)
->>>>>>> External metastore: clean after rebase
+void ThriftHiveMetastoreConcurrentClient::recv_get_type(Type& _return, const int32_t seqid)
 {
 
   int32_t rseqid = 0;
@@ -97661,11 +95216,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_drop_database(const int32_t seqid
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
       }
-<<<<<<< HEAD
-      if (fname.compare("drop_type") != 0) {
-=======
-      if (fname.compare("drop_database") != 0) {
->>>>>>> External metastore: clean after rebase
+      if (fname.compare("get_type") != 0) {
         iprot_->skip(::apache::thrift::protocol::T_STRUCT);
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
@@ -97674,20 +95225,16 @@ void ThriftHiveMetastoreConcurrentClient::recv_drop_database(const int32_t seqid
         using ::apache::thrift::protocol::TProtocolException;
         throw TProtocolException(TProtocolException::INVALID_DATA);
       }
-<<<<<<< HEAD
-      bool _return;
-      ThriftHiveMetastore_drop_type_presult result;
+      ThriftHiveMetastore_get_type_presult result;
       result.success = &_return;
-=======
-      ThriftHiveMetastore_drop_database_presult result;
->>>>>>> External metastore: clean after rebase
       result.read(iprot_);
       iprot_->readMessageEnd();
       iprot_->getTransport()->readEnd();
 
       if (result.__isset.success) {
+        // _return pointer has now been filled
         sentry.commit();
-        return _return;
+        return;
       }
       if (result.__isset.o1) {
         sentry.commit();
@@ -97698,7 +95245,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_drop_database(const int32_t seqid
         throw result.o2;
       }
       // in a bad state, don't commit
-      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "drop_type failed: unknown result");
+      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_type failed: unknown result");
     }
     // seqid != rseqid
     this->sync_->updatePending(fname, mtype, rseqid);
@@ -97708,37 +95255,20 @@ void ThriftHiveMetastoreConcurrentClient::recv_drop_database(const int32_t seqid
   } // end while(true)
 }
 
-<<<<<<< HEAD
-void ThriftHiveMetastoreConcurrentClient::get_type_all(std::map<std::string, Type> & _return, const std::string& name)
-{
-  int32_t seqid = send_get_type_all(name);
-  recv_get_type_all(_return, seqid);
-}
-
-int32_t ThriftHiveMetastoreConcurrentClient::send_get_type_all(const std::string& name)
-{
-  int32_t cseqid = this->sync_->generateSeqId();
-  ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("get_type_all", ::apache::thrift::protocol::T_CALL, cseqid);
-
-  ThriftHiveMetastore_get_type_all_pargs args;
-  args.name = &name;
-=======
-void ThriftHiveMetastoreConcurrentClient::get_databases(std::vector<std::string> & _return, const std::string& pattern)
+bool ThriftHiveMetastoreConcurrentClient::create_type(const Type& type)
 {
-  int32_t seqid = send_get_databases(pattern);
-  recv_get_databases(_return, seqid);
+  int32_t seqid = send_create_type(type);
+  return recv_create_type(seqid);
 }
 
-int32_t ThriftHiveMetastoreConcurrentClient::send_get_databases(const std::string& pattern)
+int32_t ThriftHiveMetastoreConcurrentClient::send_create_type(const Type& type)
 {
   int32_t cseqid = this->sync_->generateSeqId();
   ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("get_databases", ::apache::thrift::protocol::T_CALL, cseqid);
+  oprot_->writeMessageBegin("create_type", ::apache::thrift::protocol::T_CALL, cseqid);
 
-  ThriftHiveMetastore_get_databases_pargs args;
-  args.pattern = &pattern;
->>>>>>> External metastore: clean after rebase
+  ThriftHiveMetastore_create_type_pargs args;
+  args.type = &type;
   args.write(oprot_);
 
   oprot_->writeMessageEnd();
@@ -97749,11 +95279,7 @@ int32_t ThriftHiveMetastoreConcurrentClient::send_get_databases(const std::strin
   return cseqid;
 }
 
-<<<<<<< HEAD
-void ThriftHiveMetastoreConcurrentClient::recv_get_type_all(std::map<std::string, Type> & _return, const int32_t seqid)
-=======
-void ThriftHiveMetastoreConcurrentClient::recv_get_databases(std::vector<std::string> & _return, const int32_t seqid)
->>>>>>> External metastore: clean after rebase
+bool ThriftHiveMetastoreConcurrentClient::recv_create_type(const int32_t seqid)
 {
 
   int32_t rseqid = 0;
@@ -97782,11 +95308,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_databases(std::vector<std::st
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
       }
-<<<<<<< HEAD
-      if (fname.compare("get_type_all") != 0) {
-=======
-      if (fname.compare("get_databases") != 0) {
->>>>>>> External metastore: clean after rebase
+      if (fname.compare("create_type") != 0) {
         iprot_->skip(::apache::thrift::protocol::T_STRUCT);
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
@@ -97795,39 +95317,31 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_databases(std::vector<std::st
         using ::apache::thrift::protocol::TProtocolException;
         throw TProtocolException(TProtocolException::INVALID_DATA);
       }
-<<<<<<< HEAD
-      ThriftHiveMetastore_get_type_all_presult result;
-=======
-      ThriftHiveMetastore_get_databases_presult result;
->>>>>>> External metastore: clean after rebase
+      bool _return;
+      ThriftHiveMetastore_create_type_presult result;
       result.success = &_return;
       result.read(iprot_);
       iprot_->readMessageEnd();
       iprot_->getTransport()->readEnd();
 
       if (result.__isset.success) {
-        // _return pointer has now been filled
-<<<<<<< HEAD
         sentry.commit();
-        return;
+        return _return;
+      }
+      if (result.__isset.o1) {
+        sentry.commit();
+        throw result.o1;
       }
       if (result.__isset.o2) {
-=======
->>>>>>> External metastore: clean after rebase
         sentry.commit();
-        return;
+        throw result.o2;
       }
-<<<<<<< HEAD
-      // in a bad state, don't commit
-      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_type_all failed: unknown result");
-=======
-      if (result.__isset.o1) {
+      if (result.__isset.o3) {
         sentry.commit();
-        throw result.o1;
+        throw result.o3;
       }
       // in a bad state, don't commit
-      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_databases failed: unknown result");
->>>>>>> External metastore: clean after rebase
+      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "create_type failed: unknown result");
     }
     // seqid != rseqid
     this->sync_->updatePending(fname, mtype, rseqid);
@@ -97837,37 +95351,20 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_databases(std::vector<std::st
   } // end while(true)
 }
 
-<<<<<<< HEAD
-void ThriftHiveMetastoreConcurrentClient::get_fields(std::vector<FieldSchema> & _return, const std::string& db_name, const std::string& table_name)
-{
-  int32_t seqid = send_get_fields(db_name, table_name);
-  recv_get_fields(_return, seqid);
-}
-
-int32_t ThriftHiveMetastoreConcurrentClient::send_get_fields(const std::string& db_name, const std::string& table_name)
-{
-  int32_t cseqid = this->sync_->generateSeqId();
-  ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("get_fields", ::apache::thrift::protocol::T_CALL, cseqid);
-
-  ThriftHiveMetastore_get_fields_pargs args;
-  args.db_name = &db_name;
-  args.table_name = &table_name;
-=======
-void ThriftHiveMetastoreConcurrentClient::get_all_databases(std::vector<std::string> & _return)
+bool ThriftHiveMetastoreConcurrentClient::drop_type(const std::string& type)
 {
-  int32_t seqid = send_get_all_databases();
-  recv_get_all_databases(_return, seqid);
+  int32_t seqid = send_drop_type(type);
+  return recv_drop_type(seqid);
 }
 
-int32_t ThriftHiveMetastoreConcurrentClient::send_get_all_databases()
+int32_t ThriftHiveMetastoreConcurrentClient::send_drop_type(const std::string& type)
 {
   int32_t cseqid = this->sync_->generateSeqId();
   ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("get_all_databases", ::apache::thrift::protocol::T_CALL, cseqid);
+  oprot_->writeMessageBegin("drop_type", ::apache::thrift::protocol::T_CALL, cseqid);
 
-  ThriftHiveMetastore_get_all_databases_pargs args;
->>>>>>> External metastore: clean after rebase
+  ThriftHiveMetastore_drop_type_pargs args;
+  args.type = &type;
   args.write(oprot_);
 
   oprot_->writeMessageEnd();
@@ -97878,11 +95375,7 @@ int32_t ThriftHiveMetastoreConcurrentClient::send_get_all_databases()
   return cseqid;
 }
 
-<<<<<<< HEAD
-void ThriftHiveMetastoreConcurrentClient::recv_get_fields(std::vector<FieldSchema> & _return, const int32_t seqid)
-=======
-void ThriftHiveMetastoreConcurrentClient::recv_get_all_databases(std::vector<std::string> & _return, const int32_t seqid)
->>>>>>> External metastore: clean after rebase
+bool ThriftHiveMetastoreConcurrentClient::recv_drop_type(const int32_t seqid)
 {
 
   int32_t rseqid = 0;
@@ -97911,11 +95404,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_all_databases(std::vector<std
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
       }
-<<<<<<< HEAD
-      if (fname.compare("get_fields") != 0) {
-=======
-      if (fname.compare("get_all_databases") != 0) {
->>>>>>> External metastore: clean after rebase
+      if (fname.compare("drop_type") != 0) {
         iprot_->skip(::apache::thrift::protocol::T_STRUCT);
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
@@ -97924,40 +95413,27 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_all_databases(std::vector<std
         using ::apache::thrift::protocol::TProtocolException;
         throw TProtocolException(TProtocolException::INVALID_DATA);
       }
-<<<<<<< HEAD
-      ThriftHiveMetastore_get_fields_presult result;
-=======
-      ThriftHiveMetastore_get_all_databases_presult result;
->>>>>>> External metastore: clean after rebase
+      bool _return;
+      ThriftHiveMetastore_drop_type_presult result;
       result.success = &_return;
       result.read(iprot_);
       iprot_->readMessageEnd();
       iprot_->getTransport()->readEnd();
 
       if (result.__isset.success) {
-        // _return pointer has now been filled
         sentry.commit();
-        return;
+        return _return;
       }
       if (result.__isset.o1) {
         sentry.commit();
         throw result.o1;
       }
-<<<<<<< HEAD
       if (result.__isset.o2) {
         sentry.commit();
         throw result.o2;
       }
-      if (result.__isset.o3) {
-        sentry.commit();
-        throw result.o3;
-      }
-      // in a bad state, don't commit
-      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_fields failed: unknown result");
-=======
       // in a bad state, don't commit
-      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_all_databases failed: unknown result");
->>>>>>> External metastore: clean after rebase
+      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "drop_type failed: unknown result");
     }
     // seqid != rseqid
     this->sync_->updatePending(fname, mtype, rseqid);
@@ -97967,40 +95443,20 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_all_databases(std::vector<std
   } // end while(true)
 }
 
-<<<<<<< HEAD
-void ThriftHiveMetastoreConcurrentClient::get_fields_with_environment_context(std::vector<FieldSchema> & _return, const std::string& db_name, const std::string& table_name, const EnvironmentContext& environment_context)
-{
-  int32_t seqid = send_get_fields_with_environment_context(db_name, table_name, environment_context);
-  recv_get_fields_with_environment_context(_return, seqid);
-}
-
-int32_t ThriftHiveMetastoreConcurrentClient::send_get_fields_with_environment_context(const std::string& db_name, const std::string& table_name, const EnvironmentContext& environment_context)
-{
-  int32_t cseqid = this->sync_->generateSeqId();
-  ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("get_fields_with_environment_context", ::apache::thrift::protocol::T_CALL, cseqid);
-
-  ThriftHiveMetastore_get_fields_with_environment_context_pargs args;
-  args.db_name = &db_name;
-  args.table_name = &table_name;
-  args.environment_context = &environment_context;
-=======
-void ThriftHiveMetastoreConcurrentClient::alter_database(const std::string& dbname, const Database& db)
+void ThriftHiveMetastoreConcurrentClient::get_type_all(std::map<std::string, Type> & _return, const std::string& name)
 {
-  int32_t seqid = send_alter_database(dbname, db);
-  recv_alter_database(seqid);
+  int32_t seqid = send_get_type_all(name);
+  recv_get_type_all(_return, seqid);
 }
 
-int32_t ThriftHiveMetastoreConcurrentClient::send_alter_database(const std::string& dbname, const Database& db)
+int32_t ThriftHiveMetastoreConcurrentClient::send_get_type_all(const std::string& name)
 {
   int32_t cseqid = this->sync_->generateSeqId();
   ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("alter_database", ::apache::thrift::protocol::T_CALL, cseqid);
+  oprot_->writeMessageBegin("get_type_all", ::apache::thrift::protocol::T_CALL, cseqid);
 
-  ThriftHiveMetastore_alter_database_pargs args;
-  args.dbname = &dbname;
-  args.db = &db;
->>>>>>> External metastore: clean after rebase
+  ThriftHiveMetastore_get_type_all_pargs args;
+  args.name = &name;
   args.write(oprot_);
 
   oprot_->writeMessageEnd();
@@ -98011,11 +95467,7 @@ int32_t ThriftHiveMetastoreConcurrentClient::send_alter_database(const std::stri
   return cseqid;
 }
 
-<<<<<<< HEAD
-void ThriftHiveMetastoreConcurrentClient::recv_get_fields_with_environment_context(std::vector<FieldSchema> & _return, const int32_t seqid)
-=======
-void ThriftHiveMetastoreConcurrentClient::recv_alter_database(const int32_t seqid)
->>>>>>> External metastore: clean after rebase
+void ThriftHiveMetastoreConcurrentClient::recv_get_type_all(std::map<std::string, Type> & _return, const int32_t seqid)
 {
 
   int32_t rseqid = 0;
@@ -98044,11 +95496,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_alter_database(const int32_t seqi
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
       }
-<<<<<<< HEAD
-      if (fname.compare("get_fields_with_environment_context") != 0) {
-=======
-      if (fname.compare("alter_database") != 0) {
->>>>>>> External metastore: clean after rebase
+      if (fname.compare("get_type_all") != 0) {
         iprot_->skip(::apache::thrift::protocol::T_STRUCT);
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
@@ -98057,35 +95505,23 @@ void ThriftHiveMetastoreConcurrentClient::recv_alter_database(const int32_t seqi
         using ::apache::thrift::protocol::TProtocolException;
         throw TProtocolException(TProtocolException::INVALID_DATA);
       }
-<<<<<<< HEAD
-      ThriftHiveMetastore_get_fields_with_environment_context_presult result;
+      ThriftHiveMetastore_get_type_all_presult result;
       result.success = &_return;
-=======
-      ThriftHiveMetastore_alter_database_presult result;
->>>>>>> External metastore: clean after rebase
       result.read(iprot_);
       iprot_->readMessageEnd();
       iprot_->getTransport()->readEnd();
 
-      if (result.__isset.o1) {
+      if (result.__isset.success) {
+        // _return pointer has now been filled
         sentry.commit();
-        throw result.o1;
+        return;
       }
       if (result.__isset.o2) {
         sentry.commit();
         throw result.o2;
       }
-<<<<<<< HEAD
-      if (result.__isset.o3) {
-        sentry.commit();
-        throw result.o3;
-      }
       // in a bad state, don't commit
-      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_fields_with_environment_context failed: unknown result");
-=======
-      sentry.commit();
-      return;
->>>>>>> External metastore: clean after rebase
+      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_type_all failed: unknown result");
     }
     // seqid != rseqid
     this->sync_->updatePending(fname, mtype, rseqid);
@@ -98095,37 +95531,21 @@ void ThriftHiveMetastoreConcurrentClient::recv_alter_database(const int32_t seqi
   } // end while(true)
 }
 
-<<<<<<< HEAD
-void ThriftHiveMetastoreConcurrentClient::get_fields_req(GetFieldsResponse& _return, const GetFieldsRequest& req)
-{
-  int32_t seqid = send_get_fields_req(req);
-  recv_get_fields_req(_return, seqid);
-}
-
-int32_t ThriftHiveMetastoreConcurrentClient::send_get_fields_req(const GetFieldsRequest& req)
-{
-  int32_t cseqid = this->sync_->generateSeqId();
-  ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("get_fields_req", ::apache::thrift::protocol::T_CALL, cseqid);
-
-  ThriftHiveMetastore_get_fields_req_pargs args;
-  args.req = &req;
-=======
-void ThriftHiveMetastoreConcurrentClient::create_dataconnector(const DataConnector& connector)
+void ThriftHiveMetastoreConcurrentClient::get_fields(std::vector<FieldSchema> & _return, const std::string& db_name, const std::string& table_name)
 {
-  int32_t seqid = send_create_dataconnector(connector);
-  recv_create_dataconnector(seqid);
+  int32_t seqid = send_get_fields(db_name, table_name);
+  recv_get_fields(_return, seqid);
 }
 
-int32_t ThriftHiveMetastoreConcurrentClient::send_create_dataconnector(const DataConnector& connector)
+int32_t ThriftHiveMetastoreConcurrentClient::send_get_fields(const std::string& db_name, const std::string& table_name)
 {
   int32_t cseqid = this->sync_->generateSeqId();
   ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("create_dataconnector", ::apache::thrift::protocol::T_CALL, cseqid);
+  oprot_->writeMessageBegin("get_fields", ::apache::thrift::protocol::T_CALL, cseqid);
 
-  ThriftHiveMetastore_create_dataconnector_pargs args;
-  args.connector = &connector;
->>>>>>> External metastore: clean after rebase
+  ThriftHiveMetastore_get_fields_pargs args;
+  args.db_name = &db_name;
+  args.table_name = &table_name;
   args.write(oprot_);
 
   oprot_->writeMessageEnd();
@@ -98136,11 +95556,7 @@ int32_t ThriftHiveMetastoreConcurrentClient::send_create_dataconnector(const Dat
   return cseqid;
 }
 
-<<<<<<< HEAD
-void ThriftHiveMetastoreConcurrentClient::recv_get_fields_req(GetFieldsResponse& _return, const int32_t seqid)
-=======
-void ThriftHiveMetastoreConcurrentClient::recv_create_dataconnector(const int32_t seqid)
->>>>>>> External metastore: clean after rebase
+void ThriftHiveMetastoreConcurrentClient::recv_get_fields(std::vector<FieldSchema> & _return, const int32_t seqid)
 {
 
   int32_t rseqid = 0;
@@ -98169,11 +95585,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_create_dataconnector(const int32_
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
       }
-<<<<<<< HEAD
-      if (fname.compare("get_fields_req") != 0) {
-=======
-      if (fname.compare("create_dataconnector") != 0) {
->>>>>>> External metastore: clean after rebase
+      if (fname.compare("get_fields") != 0) {
         iprot_->skip(::apache::thrift::protocol::T_STRUCT);
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
@@ -98182,12 +95594,8 @@ void ThriftHiveMetastoreConcurrentClient::recv_create_dataconnector(const int32_
         using ::apache::thrift::protocol::TProtocolException;
         throw TProtocolException(TProtocolException::INVALID_DATA);
       }
-<<<<<<< HEAD
-      ThriftHiveMetastore_get_fields_req_presult result;
+      ThriftHiveMetastore_get_fields_presult result;
       result.success = &_return;
-=======
-      ThriftHiveMetastore_create_dataconnector_presult result;
->>>>>>> External metastore: clean after rebase
       result.read(iprot_);
       iprot_->readMessageEnd();
       iprot_->getTransport()->readEnd();
@@ -98210,7 +95618,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_create_dataconnector(const int32_
         throw result.o3;
       }
       // in a bad state, don't commit
-      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_fields_req failed: unknown result");
+      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_fields failed: unknown result");
     }
     // seqid != rseqid
     this->sync_->updatePending(fname, mtype, rseqid);
@@ -98220,38 +95628,118 @@ void ThriftHiveMetastoreConcurrentClient::recv_create_dataconnector(const int32_
   } // end while(true)
 }
 
-<<<<<<< HEAD
-void ThriftHiveMetastoreConcurrentClient::get_schema(std::vector<FieldSchema> & _return, const std::string& db_name, const std::string& table_name)
+void ThriftHiveMetastoreConcurrentClient::get_fields_with_environment_context(std::vector<FieldSchema> & _return, const std::string& db_name, const std::string& table_name, const EnvironmentContext& environment_context)
 {
-  int32_t seqid = send_get_schema(db_name, table_name);
-  recv_get_schema(_return, seqid);
+  int32_t seqid = send_get_fields_with_environment_context(db_name, table_name, environment_context);
+  recv_get_fields_with_environment_context(_return, seqid);
 }
 
-int32_t ThriftHiveMetastoreConcurrentClient::send_get_schema(const std::string& db_name, const std::string& table_name)
+int32_t ThriftHiveMetastoreConcurrentClient::send_get_fields_with_environment_context(const std::string& db_name, const std::string& table_name, const EnvironmentContext& environment_context)
 {
   int32_t cseqid = this->sync_->generateSeqId();
   ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("get_schema", ::apache::thrift::protocol::T_CALL, cseqid);
+  oprot_->writeMessageBegin("get_fields_with_environment_context", ::apache::thrift::protocol::T_CALL, cseqid);
 
-  ThriftHiveMetastore_get_schema_pargs args;
+  ThriftHiveMetastore_get_fields_with_environment_context_pargs args;
   args.db_name = &db_name;
   args.table_name = &table_name;
-=======
-void ThriftHiveMetastoreConcurrentClient::get_dataconnector_req(DataConnector& _return, const GetDataConnectorRequest& request)
+  args.environment_context = &environment_context;
+  args.write(oprot_);
+
+  oprot_->writeMessageEnd();
+  oprot_->getTransport()->writeEnd();
+  oprot_->getTransport()->flush();
+
+  sentry.commit();
+  return cseqid;
+}
+
+void ThriftHiveMetastoreConcurrentClient::recv_get_fields_with_environment_context(std::vector<FieldSchema> & _return, const int32_t seqid)
 {
-  int32_t seqid = send_get_dataconnector_req(request);
-  recv_get_dataconnector_req(_return, seqid);
+
+  int32_t rseqid = 0;
+  std::string fname;
+  ::apache::thrift::protocol::TMessageType mtype;
+
+  // the read mutex gets dropped and reacquired as part of waitForWork()
+  // The destructor of this sentry wakes up other clients
+  ::apache::thrift::async::TConcurrentRecvSentry sentry(this->sync_.get(), seqid);
+
+  while(true) {
+    if(!this->sync_->getPending(fname, mtype, rseqid)) {
+      iprot_->readMessageBegin(fname, mtype, rseqid);
+    }
+    if(seqid == rseqid) {
+      if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {
+        ::apache::thrift::TApplicationException x;
+        x.read(iprot_);
+        iprot_->readMessageEnd();
+        iprot_->getTransport()->readEnd();
+        sentry.commit();
+        throw x;
+      }
+      if (mtype != ::apache::thrift::protocol::T_REPLY) {
+        iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+        iprot_->readMessageEnd();
+        iprot_->getTransport()->readEnd();
+      }
+      if (fname.compare("get_fields_with_environment_context") != 0) {
+        iprot_->skip(::apache::thrift::protocol::T_STRUCT);
+        iprot_->readMessageEnd();
+        iprot_->getTransport()->readEnd();
+
+        // in a bad state, don't commit
+        using ::apache::thrift::protocol::TProtocolException;
+        throw TProtocolException(TProtocolException::INVALID_DATA);
+      }
+      ThriftHiveMetastore_get_fields_with_environment_context_presult result;
+      result.success = &_return;
+      result.read(iprot_);
+      iprot_->readMessageEnd();
+      iprot_->getTransport()->readEnd();
+
+      if (result.__isset.success) {
+        // _return pointer has now been filled
+        sentry.commit();
+        return;
+      }
+      if (result.__isset.o1) {
+        sentry.commit();
+        throw result.o1;
+      }
+      if (result.__isset.o2) {
+        sentry.commit();
+        throw result.o2;
+      }
+      if (result.__isset.o3) {
+        sentry.commit();
+        throw result.o3;
+      }
+      // in a bad state, don't commit
+      throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_fields_with_environment_context failed: unknown result");
+    }
+    // seqid != rseqid
+    this->sync_->updatePending(fname, mtype, rseqid);
+
+    // this will temporarily unlock the readMutex, and let other clients get work done
+    this->sync_->waitForWork(seqid);
+  } // end while(true)
 }
 
-int32_t ThriftHiveMetastoreConcurrentClient::send_get_dataconnector_req(const GetDataConnectorRequest& request)
+void ThriftHiveMetastoreConcurrentClient::get_fields_req(GetFieldsResponse& _return, const GetFieldsRequest& req)
+{
+  int32_t seqid = send_get_fields_req(req);
+  recv_get_fields_req(_return, seqid);
+}
+
+int32_t ThriftHiveMetastoreConcurrentClient::send_get_fields_req(const GetFieldsRequest& req)
 {
   int32_t cseqid = this->sync_->generateSeqId();
   ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());
-  oprot_->writeMessageBegin("get_dataconnector_req", ::apache::thrift::protocol::T_CALL, cseqid);
+  oprot_->writeMessageBegin("get_fields_req", ::apache::thrift::protocol::T_CALL, cseqid);
 
-  ThriftHiveMetastore_get_dataconnector_req_pargs args;
-  args.request = &request;
->>>>>>> External metastore: clean after rebase
+  ThriftHiveMetastore_get_fields_req_pargs args;
+  args.req = &req;
   args.write(oprot_);
 
   oprot_->writeMessageEnd();
@@ -98262,11 +95750,7 @@ int32_t ThriftHiveMetastoreConcurrentClient::send_get_dataconnector_req(const Ge
   return cseqid;
 }
 
-<<<<<<< HEAD
-void ThriftHiveMetastoreConcurrentClient::recv_get_schema(std::vector<FieldSchema> & _return, const int32_t seqid)
-=======
-void ThriftHiveMetastoreConcurrentClient::recv_get_dataconnector_req(DataConnector& _return, const int32_t seqid)
->>>>>>> External metastore: clean after rebase
+void ThriftHiveMetastoreConcurrentClient::recv_get_fields_req(GetFieldsResponse& _return, const int32_t seqid)
 {
 
   int32_t rseqid = 0;
@@ -98295,11 +95779,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_dataconnector_req(DataConnect
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
       }
-<<<<<<< HEAD
-      if (fname.compare("get_schema") != 0) {
-=======
-      if (fname.compare("get_dataconnector_req") != 0) {
->>>>>>> External metastore: clean after rebase
+      if (fname.compare("get_fields_req") != 0) {
         iprot_->skip(::apache::thrift::protocol::T_STRUCT);
         iprot_->readMessageEnd();
         iprot_->getTransport()->readEnd();
@@ -98308,11 +95788,7 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_dataconnector_req(DataConnect
         using ::apache::thrift::protocol::TProtocolException;
         throw TProtocolException(TProtocolException::INVALID_DATA);
       }
-<<<<<<< HEAD
-      ThriftHiveMetastore_get_schema_presult result;
-=======
-      ThriftHiveMetastore_get_dataconnector_req_presult result;
->>>>>>> External metastore: clean after rebase
+      ThriftHiveMetastore_get_fields_req_presult result;
       result.success = &_return;
       result.read(iprot_);
       iprot_->readMessageEnd();
@@ -98331,17 +95807,12 @@ void ThriftHiveMetastoreConcurrentClient::recv_get_dataconnector_req(DataConnect
         sentry.commit();
         throw result.o2;
       }
-<<<<<<< HEAD
       if (result.__isset.o3) {
         sentry.commit();
         throw result.o3;
       }
... 12724 lines suppressed ...

[hive] 24/38: HIVE-24396: Unhandled longvarchar and integer types for derby

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 3e41782d7c23e9e76a4e2f5f0876b4fd6e6b9a8d
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Tue Dec 1 01:02:29 2020 -0500

    HIVE-24396: Unhandled longvarchar and integer types for derby
---
 .../apache/hadoop/hive/metastore/HiveMetaStore.java   | 17 ++++++++---------
 .../dataconnector/jdbc/DerbySQLConnectorProvider.java | 19 ++++++++++++++++++-
 .../dataconnector/jdbc/MySQLConnectorProvider.java    |  1 +
 .../jdbc/PostgreSQLConnectorProvider.java             |  3 +++
 4 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
index 88261e2..7288ca3 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
@@ -2366,15 +2366,9 @@ public class HiveMetaStore extends ThriftHiveMetastore {
       List<String> processorCapabilities = req.getProcessorCapabilities();
       String processorId = req.getProcessorIdentifier();
 
-      Database db = null;
-      try {
-        db = ms.getDatabase(tbl.getCatName(), tbl.getDbName());
-      } catch (Exception e) {
-        LOG.info("Database {} does exist, exception: {}", tbl.getDbName(), e.getMessage());
-        return;
-      }
+      Database db = get_database_core(tbl.getCatName(), tbl.getDbName());
       if (db != null && db.getType().equals(DatabaseType.REMOTE)) {
-        boolean success = DataConnectorProviderFactory.getDataConnectorProvider(db).createTable(tbl);
+        DataConnectorProviderFactory.getDataConnectorProvider(db).createTable(tbl);
         return;
       }
 
@@ -4533,7 +4527,12 @@ public class HiveMetaStore extends ThriftHiveMetastore {
       Database db = null;
       try {
         ms.openTransaction();
-        db = ms.getDatabase(catName, dbName);
+        try {
+          db = ms.getDatabase(catName, dbName);
+        } catch (NoSuchObjectException notExists) {
+          throw new InvalidObjectException("Unable to add partitions because "
+              + "database or table " + dbName + "." + tblName + " does not exist");
+        }
         if (db.getType() == DatabaseType.REMOTE)
           throw new MetaException("Operation add_partitions_pspec not supported on tables in REMOTE database");
         tbl = ms.getTable(catName, dbName, tblName, null);
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/DerbySQLConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/DerbySQLConnectorProvider.java
index 1cf90bc..c212098 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/DerbySQLConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/DerbySQLConnectorProvider.java
@@ -1,5 +1,6 @@
 package org.apache.hadoop.hive.metastore.dataconnector.jdbc;
 
+import org.apache.hadoop.hive.metastore.ColumnType;
 import org.apache.hadoop.hive.metastore.api.DataConnector;
 import org.apache.hadoop.hive.metastore.api.MetaException;
 import org.apache.hadoop.hive.metastore.api.Table;
@@ -63,7 +64,23 @@ public class DerbySQLConnectorProvider extends AbstractJDBCConnectorProvider {
 
   protected String getDataType(String dbDataType, int size) {
     String mappedType = super.getDataType(dbDataType, size);
-    // map any db specific types here. or return
+    if (!mappedType.equalsIgnoreCase(ColumnType.VOID_TYPE_NAME)) {
+      return mappedType;
+    }
+
+    // map any db specific types here.
+    switch (dbDataType.toLowerCase())
+    {
+    case "integer":
+      mappedType = ColumnType.INT_TYPE_NAME;
+      break;
+    case "long varchar":
+      mappedType = ColumnType.STRING_TYPE_NAME;
+      break;
+    default:
+      mappedType = ColumnType.VOID_TYPE_NAME;
+      break;
+    }
     return mappedType;
   }
 }
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConnectorProvider.java
index cb80c4f..17d5a8b 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConnectorProvider.java
@@ -80,6 +80,7 @@ public class MySQLConnectorProvider extends AbstractJDBCConnectorProvider {
     {
     default:
       mappedType = ColumnType.VOID_TYPE_NAME;
+      break;
     }
     return mappedType;
   }
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/PostgreSQLConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/PostgreSQLConnectorProvider.java
index 1e7c65a..51bc97e 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/PostgreSQLConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/PostgreSQLConnectorProvider.java
@@ -57,10 +57,13 @@ public class PostgreSQLConnectorProvider extends AbstractJDBCConnectorProvider {
     {
     case "bpchar":
       mappedType = ColumnType.CHAR_TYPE_NAME + wrapSize(size);
+      break;
     case "int8":
       mappedType = ColumnType.BIGINT_TYPE_NAME;
+      break;
     default:
       mappedType = ColumnType.VOID_TYPE_NAME;
+      break;
     }
     return mappedType;
   }

[hive] 36/38: HIVE-24396: Conflict from rebase to master

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit cd90398b358556a732961e4b6289aa0e5bd06c81
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Fri Mar 26 10:23:34 2021 -0400

    HIVE-24396: Conflict from rebase to master
---
 .../gen/thrift/gen-cpp/hive_metastore_types.cpp    | 384 ++++-----------------
 1 file changed, 72 insertions(+), 312 deletions(-)

diff --git a/standalone-metastore/metastore-common/src/gen/thrift/gen-cpp/hive_metastore_types.cpp b/standalone-metastore/metastore-common/src/gen/thrift/gen-cpp/hive_metastore_types.cpp
index f854c48..24b915f 100644
--- a/standalone-metastore/metastore-common/src/gen/thrift/gen-cpp/hive_metastore_types.cpp
+++ b/standalone-metastore/metastore-common/src/gen/thrift/gen-cpp/hive_metastore_types.cpp
@@ -19008,24 +19008,7 @@ void swap(GetPartitionsByNamesRequest &a, GetPartitionsByNamesRequest &b) {
   swap(a.__isset, b.__isset);
 }
 
-<<<<<<< HEAD
-GetPartitionsByNamesRequest::GetPartitionsByNamesRequest(const GetPartitionsByNamesRequest& other714) {
-  db_name = other714.db_name;
-  tbl_name = other714.tbl_name;
-  names = other714.names;
-  get_col_stats = other714.get_col_stats;
-  processorCapabilities = other714.processorCapabilities;
-  processorIdentifier = other714.processorIdentifier;
-  engine = other714.engine;
-  validWriteIdList = other714.validWriteIdList;
-  getFileMetadata = other714.getFileMetadata;
-  id = other714.id;
-  __isset = other714.__isset;
-}
-GetPartitionsByNamesRequest& GetPartitionsByNamesRequest::operator=(const GetPartitionsByNamesRequest& other715) {
-=======
 GetPartitionsByNamesRequest::GetPartitionsByNamesRequest(const GetPartitionsByNamesRequest& other715) {
->>>>>>> HIVE-24396: Build failure due to duplicate db definitions
   db_name = other715.db_name;
   tbl_name = other715.tbl_name;
   names = other715.names;
@@ -25631,27 +25614,27 @@ void swap(CompactionRequest &a, CompactionRequest &b) {
   swap(a.__isset, b.__isset);
 }
 
-CompactionRequest::CompactionRequest(const CompactionRequest& other930) {
-  dbname = other930.dbname;
-  tablename = other930.tablename;
-  partitionname = other930.partitionname;
-  type = other930.type;
-  runas = other930.runas;
-  properties = other930.properties;
-  initiatorId = other930.initiatorId;
-  initiatorVersion = other930.initiatorVersion;
-  __isset = other930.__isset;
-}
-CompactionRequest& CompactionRequest::operator=(const CompactionRequest& other931) {
-  dbname = other931.dbname;
-  tablename = other931.tablename;
-  partitionname = other931.partitionname;
-  type = other931.type;
-  runas = other931.runas;
-  properties = other931.properties;
-  initiatorId = other931.initiatorId;
-  initiatorVersion = other931.initiatorVersion;
-  __isset = other931.__isset;
+CompactionRequest::CompactionRequest(const CompactionRequest& other942) {
+  dbname = other942.dbname;
+  tablename = other942.tablename;
+  partitionname = other942.partitionname;
+  type = other942.type;
+  runas = other942.runas;
+  properties = other942.properties;
+  initiatorId = other942.initiatorId;
+  initiatorVersion = other942.initiatorVersion;
+  __isset = other942.__isset;
+}
+CompactionRequest& CompactionRequest::operator=(const CompactionRequest& other943) {
+  dbname = other943.dbname;
+  tablename = other943.tablename;
+  partitionname = other943.partitionname;
+  type = other943.type;
+  runas = other943.runas;
+  properties = other943.properties;
+  initiatorId = other943.initiatorId;
+  initiatorVersion = other943.initiatorVersion;
+  __isset = other943.__isset;
   return *this;
 }
 void CompactionRequest::printTo(std::ostream& out) const {
@@ -26783,47 +26766,47 @@ void swap(ShowCompactResponseElement &a, ShowCompactResponseElement &b) {
   swap(a.__isset, b.__isset);
 }
 
-ShowCompactResponseElement::ShowCompactResponseElement(const ShowCompactResponseElement& other942) {
-  dbname = other942.dbname;
-  tablename = other942.tablename;
-  partitionname = other942.partitionname;
-  type = other942.type;
-  state = other942.state;
-  workerid = other942.workerid;
-  start = other942.start;
-  runAs = other942.runAs;
-  hightestTxnId = other942.hightestTxnId;
-  metaInfo = other942.metaInfo;
-  endTime = other942.endTime;
-  hadoopJobId = other942.hadoopJobId;
-  id = other942.id;
-  errorMessage = other942.errorMessage;
-  enqueueTime = other942.enqueueTime;
-  workerVersion = other942.workerVersion;
-  initiatorId = other942.initiatorId;
-  initiatorVersion = other942.initiatorVersion;
-  __isset = other942.__isset;
-}
-ShowCompactResponseElement& ShowCompactResponseElement::operator=(const ShowCompactResponseElement& other943) {
-  dbname = other943.dbname;
-  tablename = other943.tablename;
-  partitionname = other943.partitionname;
-  type = other943.type;
-  state = other943.state;
-  workerid = other943.workerid;
-  start = other943.start;
-  runAs = other943.runAs;
-  hightestTxnId = other943.hightestTxnId;
-  metaInfo = other943.metaInfo;
-  endTime = other943.endTime;
-  hadoopJobId = other943.hadoopJobId;
-  id = other943.id;
-  errorMessage = other943.errorMessage;
-  enqueueTime = other943.enqueueTime;
-  workerVersion = other943.workerVersion;
-  initiatorId = other943.initiatorId;
-  initiatorVersion = other943.initiatorVersion;
-  __isset = other943.__isset;
+ShowCompactResponseElement::ShowCompactResponseElement(const ShowCompactResponseElement& other954) {
+  dbname = other954.dbname;
+  tablename = other954.tablename;
+  partitionname = other954.partitionname;
+  type = other954.type;
+  state = other954.state;
+  workerid = other954.workerid;
+  start = other954.start;
+  runAs = other954.runAs;
+  hightestTxnId = other954.hightestTxnId;
+  metaInfo = other954.metaInfo;
+  endTime = other954.endTime;
+  hadoopJobId = other954.hadoopJobId;
+  id = other954.id;
+  errorMessage = other954.errorMessage;
+  enqueueTime = other954.enqueueTime;
+  workerVersion = other954.workerVersion;
+  initiatorId = other954.initiatorId;
+  initiatorVersion = other954.initiatorVersion;
+  __isset = other954.__isset;
+}
+ShowCompactResponseElement& ShowCompactResponseElement::operator=(const ShowCompactResponseElement& other955) {
+  dbname = other955.dbname;
+  tablename = other955.tablename;
+  partitionname = other955.partitionname;
+  type = other955.type;
+  state = other955.state;
+  workerid = other955.workerid;
+  start = other955.start;
+  runAs = other955.runAs;
+  hightestTxnId = other955.hightestTxnId;
+  metaInfo = other955.metaInfo;
+  endTime = other955.endTime;
+  hadoopJobId = other955.hadoopJobId;
+  id = other955.id;
+  errorMessage = other955.errorMessage;
+  enqueueTime = other955.enqueueTime;
+  workerVersion = other955.workerVersion;
+  initiatorId = other955.initiatorId;
+  initiatorVersion = other955.initiatorVersion;
+  __isset = other955.__isset;
   return *this;
 }
 void ShowCompactResponseElement::printTo(std::ostream& out) const {
@@ -31211,16 +31194,6 @@ uint32_t GetTableRequest::read(::apache::thrift::protocol::TProtocol* iprot) {
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->processorCapabilities.clear();
-<<<<<<< HEAD
-            uint32_t _size1142;
-            ::apache::thrift::protocol::TType _etype1145;
-            xfer += iprot->readListBegin(_etype1145, _size1142);
-            this->processorCapabilities.resize(_size1142);
-            uint32_t _i1146;
-            for (_i1146 = 0; _i1146 < _size1142; ++_i1146)
-            {
-              xfer += iprot->readString(this->processorCapabilities[_i1146]);
-=======
             uint32_t _size1154;
             ::apache::thrift::protocol::TType _etype1157;
             xfer += iprot->readListBegin(_etype1157, _size1154);
@@ -31229,7 +31202,6 @@ uint32_t GetTableRequest::read(::apache::thrift::protocol::TProtocol* iprot) {
             for (_i1158 = 0; _i1158 < _size1154; ++_i1158)
             {
               xfer += iprot->readString(this->processorCapabilities[_i1158]);
->>>>>>> HIVE-24396: Build failure due to duplicate db definitions
             }
             xfer += iprot->readListEnd();
           }
@@ -31315,17 +31287,10 @@ uint32_t GetTableRequest::write(::apache::thrift::protocol::TProtocol* oprot) co
     xfer += oprot->writeFieldBegin("processorCapabilities", ::apache::thrift::protocol::T_LIST, 8);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->processorCapabilities.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter1147;
-      for (_iter1147 = this->processorCapabilities.begin(); _iter1147 != this->processorCapabilities.end(); ++_iter1147)
-      {
-        xfer += oprot->writeString((*_iter1147));
-=======
       std::vector<std::string> ::const_iterator _iter1159;
       for (_iter1159 = this->processorCapabilities.begin(); _iter1159 != this->processorCapabilities.end(); ++_iter1159)
       {
         xfer += oprot->writeString((*_iter1159));
->>>>>>> HIVE-24396: Build failure due to duplicate db definitions
       }
       xfer += oprot->writeListEnd();
     }
@@ -31366,33 +31331,6 @@ void swap(GetTableRequest &a, GetTableRequest &b) {
   swap(a.__isset, b.__isset);
 }
 
-<<<<<<< HEAD
-GetTableRequest::GetTableRequest(const GetTableRequest& other1148) {
-  dbName = other1148.dbName;
-  tblName = other1148.tblName;
-  capabilities = other1148.capabilities;
-  catName = other1148.catName;
-  validWriteIdList = other1148.validWriteIdList;
-  getColumnStats = other1148.getColumnStats;
-  processorCapabilities = other1148.processorCapabilities;
-  processorIdentifier = other1148.processorIdentifier;
-  engine = other1148.engine;
-  id = other1148.id;
-  __isset = other1148.__isset;
-}
-GetTableRequest& GetTableRequest::operator=(const GetTableRequest& other1149) {
-  dbName = other1149.dbName;
-  tblName = other1149.tblName;
-  capabilities = other1149.capabilities;
-  catName = other1149.catName;
-  validWriteIdList = other1149.validWriteIdList;
-  getColumnStats = other1149.getColumnStats;
-  processorCapabilities = other1149.processorCapabilities;
-  processorIdentifier = other1149.processorIdentifier;
-  engine = other1149.engine;
-  id = other1149.id;
-  __isset = other1149.__isset;
-=======
 GetTableRequest::GetTableRequest(const GetTableRequest& other1160) {
   dbName = other1160.dbName;
   tblName = other1160.tblName;
@@ -31418,7 +31356,6 @@ GetTableRequest& GetTableRequest::operator=(const GetTableRequest& other1161) {
   engine = other1161.engine;
   id = other1161.id;
   __isset = other1161.__isset;
->>>>>>> HIVE-24396: Build failure due to duplicate db definitions
   return *this;
 }
 void GetTableRequest::printTo(std::ostream& out) const {
@@ -31535,17 +31472,6 @@ void swap(GetTableResult &a, GetTableResult &b) {
   swap(a.__isset, b.__isset);
 }
 
-<<<<<<< HEAD
-GetTableResult::GetTableResult(const GetTableResult& other1150) {
-  table = other1150.table;
-  isStatsCompliant = other1150.isStatsCompliant;
-  __isset = other1150.__isset;
-}
-GetTableResult& GetTableResult::operator=(const GetTableResult& other1151) {
-  table = other1151.table;
-  isStatsCompliant = other1151.isStatsCompliant;
-  __isset = other1151.__isset;
-=======
 GetTableResult::GetTableResult(const GetTableResult& other1162) {
   table = other1162.table;
   isStatsCompliant = other1162.isStatsCompliant;
@@ -31555,7 +31481,6 @@ GetTableResult& GetTableResult::operator=(const GetTableResult& other1163) {
   table = other1163.table;
   isStatsCompliant = other1163.isStatsCompliant;
   __isset = other1163.__isset;
->>>>>>> HIVE-24396: Build failure due to duplicate db definitions
   return *this;
 }
 void GetTableResult::printTo(std::ostream& out) const {
@@ -31645,16 +31570,6 @@ uint32_t GetTablesRequest::read(::apache::thrift::protocol::TProtocol* iprot) {
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->tblNames.clear();
-<<<<<<< HEAD
-            uint32_t _size1152;
-            ::apache::thrift::protocol::TType _etype1155;
-            xfer += iprot->readListBegin(_etype1155, _size1152);
-            this->tblNames.resize(_size1152);
-            uint32_t _i1156;
-            for (_i1156 = 0; _i1156 < _size1152; ++_i1156)
-            {
-              xfer += iprot->readString(this->tblNames[_i1156]);
-=======
             uint32_t _size1164;
             ::apache::thrift::protocol::TType _etype1167;
             xfer += iprot->readListBegin(_etype1167, _size1164);
@@ -31663,7 +31578,6 @@ uint32_t GetTablesRequest::read(::apache::thrift::protocol::TProtocol* iprot) {
             for (_i1168 = 0; _i1168 < _size1164; ++_i1168)
             {
               xfer += iprot->readString(this->tblNames[_i1168]);
->>>>>>> HIVE-24396: Build failure due to duplicate db definitions
             }
             xfer += iprot->readListEnd();
           }
@@ -31692,16 +31606,6 @@ uint32_t GetTablesRequest::read(::apache::thrift::protocol::TProtocol* iprot) {
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->processorCapabilities.clear();
-<<<<<<< HEAD
-            uint32_t _size1157;
-            ::apache::thrift::protocol::TType _etype1160;
-            xfer += iprot->readListBegin(_etype1160, _size1157);
-            this->processorCapabilities.resize(_size1157);
-            uint32_t _i1161;
-            for (_i1161 = 0; _i1161 < _size1157; ++_i1161)
-            {
-              xfer += iprot->readString(this->processorCapabilities[_i1161]);
-=======
             uint32_t _size1169;
             ::apache::thrift::protocol::TType _etype1172;
             xfer += iprot->readListBegin(_etype1172, _size1169);
@@ -31710,7 +31614,6 @@ uint32_t GetTablesRequest::read(::apache::thrift::protocol::TProtocol* iprot) {
             for (_i1173 = 0; _i1173 < _size1169; ++_i1173)
             {
               xfer += iprot->readString(this->processorCapabilities[_i1173]);
->>>>>>> HIVE-24396: Build failure due to duplicate db definitions
             }
             xfer += iprot->readListEnd();
           }
@@ -31762,17 +31665,10 @@ uint32_t GetTablesRequest::write(::apache::thrift::protocol::TProtocol* oprot) c
     xfer += oprot->writeFieldBegin("tblNames", ::apache::thrift::protocol::T_LIST, 2);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->tblNames.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter1162;
-      for (_iter1162 = this->tblNames.begin(); _iter1162 != this->tblNames.end(); ++_iter1162)
-      {
-        xfer += oprot->writeString((*_iter1162));
-=======
       std::vector<std::string> ::const_iterator _iter1174;
       for (_iter1174 = this->tblNames.begin(); _iter1174 != this->tblNames.end(); ++_iter1174)
       {
         xfer += oprot->writeString((*_iter1174));
->>>>>>> HIVE-24396: Build failure due to duplicate db definitions
       }
       xfer += oprot->writeListEnd();
     }
@@ -31792,17 +31688,10 @@ uint32_t GetTablesRequest::write(::apache::thrift::protocol::TProtocol* oprot) c
     xfer += oprot->writeFieldBegin("processorCapabilities", ::apache::thrift::protocol::T_LIST, 5);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->processorCapabilities.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter1163;
-      for (_iter1163 = this->processorCapabilities.begin(); _iter1163 != this->processorCapabilities.end(); ++_iter1163)
-      {
-        xfer += oprot->writeString((*_iter1163));
-=======
       std::vector<std::string> ::const_iterator _iter1175;
       for (_iter1175 = this->processorCapabilities.begin(); _iter1175 != this->processorCapabilities.end(); ++_iter1175)
       {
         xfer += oprot->writeString((*_iter1175));
->>>>>>> HIVE-24396: Build failure due to duplicate db definitions
       }
       xfer += oprot->writeListEnd();
     }
@@ -31835,27 +31724,6 @@ void swap(GetTablesRequest &a, GetTablesRequest &b) {
   swap(a.__isset, b.__isset);
 }
 
-<<<<<<< HEAD
-GetTablesRequest::GetTablesRequest(const GetTablesRequest& other1164) {
-  dbName = other1164.dbName;
-  tblNames = other1164.tblNames;
-  capabilities = other1164.capabilities;
-  catName = other1164.catName;
-  processorCapabilities = other1164.processorCapabilities;
-  processorIdentifier = other1164.processorIdentifier;
-  projectionSpec = other1164.projectionSpec;
-  __isset = other1164.__isset;
-}
-GetTablesRequest& GetTablesRequest::operator=(const GetTablesRequest& other1165) {
-  dbName = other1165.dbName;
-  tblNames = other1165.tblNames;
-  capabilities = other1165.capabilities;
-  catName = other1165.catName;
-  processorCapabilities = other1165.processorCapabilities;
-  processorIdentifier = other1165.processorIdentifier;
-  projectionSpec = other1165.projectionSpec;
-  __isset = other1165.__isset;
-=======
 GetTablesRequest::GetTablesRequest(const GetTablesRequest& other1176) {
   dbName = other1176.dbName;
   tblNames = other1176.tblNames;
@@ -31875,7 +31743,6 @@ GetTablesRequest& GetTablesRequest::operator=(const GetTablesRequest& other1177)
   processorIdentifier = other1177.processorIdentifier;
   projectionSpec = other1177.projectionSpec;
   __isset = other1177.__isset;
->>>>>>> HIVE-24396: Build failure due to duplicate db definitions
   return *this;
 }
 void GetTablesRequest::printTo(std::ostream& out) const {
@@ -31932,16 +31799,6 @@ uint32_t GetTablesResult::read(::apache::thrift::protocol::TProtocol* iprot) {
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->tables.clear();
-<<<<<<< HEAD
-            uint32_t _size1166;
-            ::apache::thrift::protocol::TType _etype1169;
-            xfer += iprot->readListBegin(_etype1169, _size1166);
-            this->tables.resize(_size1166);
-            uint32_t _i1170;
-            for (_i1170 = 0; _i1170 < _size1166; ++_i1170)
-            {
-              xfer += this->tables[_i1170].read(iprot);
-=======
             uint32_t _size1178;
             ::apache::thrift::protocol::TType _etype1181;
             xfer += iprot->readListBegin(_etype1181, _size1178);
@@ -31950,7 +31807,6 @@ uint32_t GetTablesResult::read(::apache::thrift::protocol::TProtocol* iprot) {
             for (_i1182 = 0; _i1182 < _size1178; ++_i1182)
             {
               xfer += this->tables[_i1182].read(iprot);
->>>>>>> HIVE-24396: Build failure due to duplicate db definitions
             }
             xfer += iprot->readListEnd();
           }
@@ -31981,17 +31837,10 @@ uint32_t GetTablesResult::write(::apache::thrift::protocol::TProtocol* oprot) co
   xfer += oprot->writeFieldBegin("tables", ::apache::thrift::protocol::T_LIST, 1);
   {
     xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->tables.size()));
-<<<<<<< HEAD
-    std::vector<Table> ::const_iterator _iter1171;
-    for (_iter1171 = this->tables.begin(); _iter1171 != this->tables.end(); ++_iter1171)
-    {
-      xfer += (*_iter1171).write(oprot);
-=======
     std::vector<Table> ::const_iterator _iter1183;
     for (_iter1183 = this->tables.begin(); _iter1183 != this->tables.end(); ++_iter1183)
     {
       xfer += (*_iter1183).write(oprot);
->>>>>>> HIVE-24396: Build failure due to duplicate db definitions
     }
     xfer += oprot->writeListEnd();
   }
@@ -32007,19 +31856,11 @@ void swap(GetTablesResult &a, GetTablesResult &b) {
   swap(a.tables, b.tables);
 }
 
-<<<<<<< HEAD
-GetTablesResult::GetTablesResult(const GetTablesResult& other1172) {
-  tables = other1172.tables;
-}
-GetTablesResult& GetTablesResult::operator=(const GetTablesResult& other1173) {
-  tables = other1173.tables;
-=======
 GetTablesResult::GetTablesResult(const GetTablesResult& other1184) {
   tables = other1184.tables;
 }
 GetTablesResult& GetTablesResult::operator=(const GetTablesResult& other1185) {
   tables = other1185.tables;
->>>>>>> HIVE-24396: Build failure due to duplicate db definitions
   return *this;
 }
 void GetTablesResult::printTo(std::ostream& out) const {
@@ -32140,16 +31981,6 @@ uint32_t GetTablesExtRequest::read(::apache::thrift::protocol::TProtocol* iprot)
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->processorCapabilities.clear();
-<<<<<<< HEAD
-            uint32_t _size1174;
-            ::apache::thrift::protocol::TType _etype1177;
-            xfer += iprot->readListBegin(_etype1177, _size1174);
-            this->processorCapabilities.resize(_size1174);
-            uint32_t _i1178;
-            for (_i1178 = 0; _i1178 < _size1174; ++_i1178)
-            {
-              xfer += iprot->readString(this->processorCapabilities[_i1178]);
-=======
             uint32_t _size1186;
             ::apache::thrift::protocol::TType _etype1189;
             xfer += iprot->readListBegin(_etype1189, _size1186);
@@ -32158,7 +31989,6 @@ uint32_t GetTablesExtRequest::read(::apache::thrift::protocol::TProtocol* iprot)
             for (_i1190 = 0; _i1190 < _size1186; ++_i1190)
             {
               xfer += iprot->readString(this->processorCapabilities[_i1190]);
->>>>>>> HIVE-24396: Build failure due to duplicate db definitions
             }
             xfer += iprot->readListEnd();
           }
@@ -32225,17 +32055,10 @@ uint32_t GetTablesExtRequest::write(::apache::thrift::protocol::TProtocol* oprot
     xfer += oprot->writeFieldBegin("processorCapabilities", ::apache::thrift::protocol::T_LIST, 6);
     {
       xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->processorCapabilities.size()));
-<<<<<<< HEAD
-      std::vector<std::string> ::const_iterator _iter1179;
-      for (_iter1179 = this->processorCapabilities.begin(); _iter1179 != this->processorCapabilities.end(); ++_iter1179)
-      {
-        xfer += oprot->writeString((*_iter1179));
-=======
       std::vector<std::string> ::const_iterator _iter1191;
       for (_iter1191 = this->processorCapabilities.begin(); _iter1191 != this->processorCapabilities.end(); ++_iter1191)
       {
         xfer += oprot->writeString((*_iter1191));
->>>>>>> HIVE-24396: Build failure due to duplicate db definitions
       }
       xfer += oprot->writeListEnd();
     }
@@ -32263,27 +32086,6 @@ void swap(GetTablesExtRequest &a, GetTablesExtRequest &b) {
   swap(a.__isset, b.__isset);
 }
 
-<<<<<<< HEAD
-GetTablesExtRequest::GetTablesExtRequest(const GetTablesExtRequest& other1180) {
-  catalog = other1180.catalog;
-  database = other1180.database;
-  tableNamePattern = other1180.tableNamePattern;
-  requestedFields = other1180.requestedFields;
-  limit = other1180.limit;
-  processorCapabilities = other1180.processorCapabilities;
-  processorIdentifier = other1180.processorIdentifier;
-  __isset = other1180.__isset;
-}
-GetTablesExtRequest& GetTablesExtRequest::operator=(const GetTablesExtRequest& other1181) {
-  catalog = other1181.catalog;
-  database = other1181.database;
-  tableNamePattern = other1181.tableNamePattern;
-  requestedFields = other1181.requestedFields;
-  limit = other1181.limit;
-  processorCapabilities = other1181.processorCapabilities;
-  processorIdentifier = other1181.processorIdentifier;
-  __isset = other1181.__isset;
-=======
 GetTablesExtRequest::GetTablesExtRequest(const GetTablesExtRequest& other1192) {
   catalog = other1192.catalog;
   database = other1192.database;
@@ -32303,7 +32105,6 @@ GetTablesExtRequest& GetTablesExtRequest::operator=(const GetTablesExtRequest& o
   processorCapabilities = other1193.processorCapabilities;
   processorIdentifier = other1193.processorIdentifier;
   __isset = other1193.__isset;
->>>>>>> HIVE-24396: Build failure due to duplicate db definitions
   return *this;
 }
 void GetTablesExtRequest::printTo(std::ostream& out) const {
@@ -32391,16 +32192,6 @@ uint32_t ExtendedTableInfo::read(::apache::thrift::protocol::TProtocol* iprot) {
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->requiredReadCapabilities.clear();
-<<<<<<< HEAD
-            uint32_t _size1182;
-            ::apache::thrift::protocol::TType _etype1185;
-            xfer += iprot->readListBegin(_etype1185, _size1182);
-            this->requiredReadCapabilities.resize(_size1182);
-            uint32_t _i1186;
-            for (_i1186 = 0; _i1186 < _size1182; ++_i1186)
-            {
-              xfer += iprot->readString(this->requiredReadCapabilities[_i1186]);
-=======
             uint32_t _size1194;
             ::apache::thrift::protocol::TType _etype1197;
             xfer += iprot->readListBegin(_etype1197, _size1194);
@@ -32409,7 +32200,6 @@ uint32_t ExtendedTableInfo::read(::apache::thrift::protocol::TProtocol* iprot) {
             for (_i1198 = 0; _i1198 < _size1194; ++_i1198)
             {
               xfer += iprot->readString(this->requiredReadCapabilities[_i1198]);
->>>>>>> HIVE-24396: Build failure due to duplicate db definitions
             }
             xfer += iprot->readListEnd();
           }
@@ -32422,16 +32212,6 @@ uint32_t ExtendedTableInfo::read(::apache::thrift::protocol::TProtocol* iprot) {
         if (ftype == ::apache::thrift::protocol::T_LIST) {
           {
             this->requiredWriteCapabilities.clear();
-<<<<<<< HEAD
-            uint32_t _size1187;
-            ::apache::thrift::protocol::TType _etype1190;
-            xfer += iprot->readListBegin(_etype1190, _size1187);
-            this->requiredWriteCapabilities.resize(_size1187);
-            uint32_t _i1191;
-            for (_i1191 = 0; _i1191 < _size1187; ++_i1191)
-            {
-              xfer += iprot->readString(this->requiredWriteCapabilities[_i1191]);
-=======
             uint32_t _size1199;
             ::apache::thrift::protocol::TType _etype1202;
             xfer += iprot->readListBegin(_etype1202, _size1199);
@@ -32440,7 +32220,6 @@ uint32_t ExtendedTableInfo::read(::apache::thrift::protocol::TProtocol* iprot) {
             for (_i1203 = 0; _i1203 < _size1199; ++_i1203)
             {
               xfer += iprot->readString(this->requiredWriteCapabilities[_i1203]);
->>>>>>> HIVE-24396: Build failure due to duplicate db definitions
             }
             xfer += iprot->readListEnd();
           }
@@ -33002,6 +32781,14 @@ uint32_t TableMeta::read(::apache::thrift::protocol::TProtocol* iprot) {
           xfer += iprot->skip(ftype);
         }
         break;
+      case 2:
+        if (ftype == ::apache::thrift::protocol::T_BOOL) {
+          xfer += iprot->readBool(this->sourceTablesCompacted);
+          isset_sourceTablesCompacted = true;
+        } else {
+          xfer += iprot->skip(ftype);
+        }
+        break;
       default:
         xfer += iprot->skip(ftype);
         break;
@@ -33140,14 +32927,6 @@ uint32_t Materialization::read(::apache::thrift::protocol::TProtocol* iprot) {
           xfer += iprot->skip(ftype);
         }
         break;
-      case 2:
-        if (ftype == ::apache::thrift::protocol::T_BOOL) {
-          xfer += iprot->readBool(this->sourceTablesCompacted);
-          isset_sourceTablesCompacted = true;
-        } else {
-          xfer += iprot->skip(ftype);
-        }
-        break;
       default:
         xfer += iprot->skip(ftype);
         break;
@@ -33188,32 +32967,13 @@ void swap(Materialization &a, Materialization &b) {
   swap(a.sourceTablesCompacted, b.sourceTablesCompacted);
 }
 
-<<<<<<< HEAD
-<<<<<<< HEAD
-Materialization::Materialization(const Materialization& other1210) {
-  sourceTablesUpdateDeleteModified = other1210.sourceTablesUpdateDeleteModified;
-  sourceTablesCompacted = other1210.sourceTablesCompacted;
-}
-Materialization& Materialization::operator=(const Materialization& other1211) {
-  sourceTablesUpdateDeleteModified = other1211.sourceTablesUpdateDeleteModified;
-<<<<<<< HEAD
-  sourceTablesCompacted = other1211.sourceTablesCompacted;
-=======
-=======
-Materialization::Materialization(const Materialization& other1214) {
-  sourceTablesUpdateDeleteModified = other1214.sourceTablesUpdateDeleteModified;
-}
-Materialization& Materialization::operator=(const Materialization& other1215) {
-  sourceTablesUpdateDeleteModified = other1215.sourceTablesUpdateDeleteModified;
->>>>>>> External metastore: clean after rebase
->>>>>>> External metastore: clean after rebase
-=======
 Materialization::Materialization(const Materialization& other1222) {
   sourceTablesUpdateDeleteModified = other1222.sourceTablesUpdateDeleteModified;
+  sourceTablesCompacted = other1222.sourceTablesCompacted;
 }
 Materialization& Materialization::operator=(const Materialization& other1223) {
   sourceTablesUpdateDeleteModified = other1223.sourceTablesUpdateDeleteModified;
->>>>>>> HIVE-24396: Build failure due to duplicate db definitions
+  sourceTablesCompacted = other1223.sourceTablesCompacted;
   return *this;
 }
 void Materialization::printTo(std::ostream& out) const {

[hive] 27/38: HIVE-24396: Fix in connector provider to return null instead of blank Table

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 4319d29a2e2c3cd19c2c4249b32675229c0f4c9c
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Tue Dec 1 15:57:11 2020 -0500

    HIVE-24396: Fix in connector provider to return null instead of blank Table
---
 .../metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
index 12ce799..4027555 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
@@ -173,7 +173,6 @@ public abstract class AbstractJDBCConnectorProvider extends AbstractDataConnecto
       // rs = fetchTableMetadata(tableName);
       rs = fetchTableViaDBMetaData(tableName);
       List<FieldSchema> cols = new ArrayList<>();
-      // TODO throw exception is RS is empty
       while (rs.next()) {
         FieldSchema fs = new FieldSchema();
         fs.setName(rs.getString("COLUMN_NAME"));
@@ -182,6 +181,11 @@ public abstract class AbstractJDBCConnectorProvider extends AbstractDataConnecto
         cols.add(fs);
       }
 
+      if (cols.size() == 0) {
+        // table does not exists or could not be fetched
+        return null;
+      }
+
       table = buildTableFromColsList(tableName, cols);
       //Setting the table properties.
       table.getParameters().put(JDBC_DATABASE_TYPE, this.type);

[hive] 12/38: Missed change from the rebase

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 6369daa9396d567d896ee2c6057a706a690a0cd9
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Fri Nov 20 12:30:09 2020 -0500

    Missed change from the rebase
---
 .../org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java
index 39aae11..b7d826c 100644
--- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java
+++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java
@@ -53,7 +53,7 @@ import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.metastore.api.FileMetadataExprType;
 import org.apache.hadoop.hive.metastore.api.Function;
 import org.apache.hadoop.hive.metastore.api.GetPartitionsFilterSpec;
-import org.apache.hadoop.hive.metastore.api.GetPartitionsProjectionSpec;
+import org.apache.hadoop.hive.metastore.api.GetProjectionsSpec;
 import org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege;
 import org.apache.hadoop.hive.metastore.api.HiveObjectRef;
 import org.apache.hadoop.hive.metastore.api.ISchema;

[hive] 35/38: HIVE-24396: Changes from additional feedback from code review (Naveen Gangam)

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 53edee9d42af1cc09660e0bd63c44ac1f2b6d7c7
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Fri Mar 26 10:00:07 2021 -0400

    HIVE-24396: Changes from additional feedback from code review (Naveen Gangam)
---
 .../ddl/database/create/CreateDatabaseOperation.java   |  4 +++-
 .../ql/ddl/database/desc/DescDatabaseOperation.java    | 18 +++++++++++-------
 .../alter/AbstractAlterDataConnectorOperation.java     |  4 ++--
 .../alter/url/AlterDataConnectorSetUrlOperation.java   | 11 +++--------
 .../show/ShowDataConnectorsOperation.java              |  2 +-
 .../java/org/apache/hadoop/hive/ql/metadata/Hive.java  |  8 ++------
 ql/src/test/queries/clientpositive/dataconnector.q     |  6 +++---
 .../hadoop/hive/metastore/HiveMetaStoreClient.java     |  2 +-
 .../apache/hadoop/hive/metastore/IMetaStoreClient.java |  2 +-
 .../jdbc/AbstractJDBCConnectorProvider.java            |  4 +++-
 .../dataconnector/jdbc/DerbySQLConnectorProvider.java  |  2 +-
 .../dataconnector/jdbc/MySQLConnectorProvider.java     |  2 +-
 .../hive/metastore/HiveMetaStoreClientPreCatalog.java  |  2 +-
 .../hadoop/hive/metastore/TestHiveMetaStore.java       | 10 +++-------
 14 files changed, 36 insertions(+), 41 deletions(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseOperation.java
index d02b039..c4961b2 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseOperation.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseOperation.java
@@ -58,10 +58,12 @@ public class CreateDatabaseOperation extends DDLOperation<CreateDatabaseDesc> {
         if (database.getLocationUri().equalsIgnoreCase(database.getManagedLocationUri())) {
           throw new HiveException("Managed and external locations for database cannot be the same");
         }
-      } else {
+      } else if (desc.getDatabaseType() == DatabaseType.REMOTE) {
         makeLocationQualified(database);
         database.setConnector_name(desc.getConnectorName());
         database.setRemote_dbname(desc.getRemoteDbName());
+      } else { // should never be here
+        throw new HiveException("Unsupported database type " + database.getType() + " for " + database.getName());
       }
       context.getDb().createDatabase(database, desc.getIfNotExists());
     } catch (AlreadyExistsException ex) {
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseOperation.java
index 0a19ccc..332e36e 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseOperation.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseOperation.java
@@ -32,6 +32,8 @@ import org.apache.hadoop.hive.ql.ddl.DDLOperationContext;
 import org.apache.hadoop.hive.ql.ddl.ShowUtils;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
 
+import static org.apache.hadoop.hive.metastore.api.DatabaseType.NATIVE;
+
 /**
  * Operation process of describing a database.
  */
@@ -49,25 +51,27 @@ public class DescDatabaseOperation extends DDLOperation<DescDatabaseDesc> {
       }
 
       SortedMap<String, String> params = null;
+      String location = "";
       if (desc.isExtended()) {
         params = new TreeMap<>(database.getParameters());
       }
 
-      String location = "";
       DescDatabaseFormatter formatter = DescDatabaseFormatter.getFormatter(context.getConf());
-      if (database.getType() == DatabaseType.NATIVE) {
+      switch(database.getType()) {
+      case NATIVE:
         location = database.getLocationUri();
         if (HiveConf.getBoolVar(context.getConf(), HiveConf.ConfVars.HIVE_IN_TEST)) {
           location = "location/in/test";
         }
-        // database.setRemote_dbname("");
-        // database.setConnector_name("");
-
         formatter.showDatabaseDescription(outStream, database.getName(), database.getDescription(), location,
-          database.getManagedLocationUri(), database.getOwnerName(), database.getOwnerType(), params, "", "");
-      } else {
+            database.getManagedLocationUri(), database.getOwnerName(), database.getOwnerType(), params, "", "");
+        break;
+      case REMOTE:
         formatter.showDatabaseDescription(outStream, database.getName(), database.getDescription(), "", "",
           database.getOwnerName(), database.getOwnerType(), params, database.getConnector_name(), database.getRemote_dbname());
+        break;
+      default:
+          throw new HiveException("Unsupported database type " + database.getType() + " for " + database.getName());
       }
     } catch (Exception e) {
       throw new HiveException(e, ErrorMsg.GENERIC_ERROR);
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorOperation.java
index a29dd4a..84093e7 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorOperation.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/AbstractAlterDataConnectorOperation.java
@@ -39,11 +39,11 @@ public abstract class AbstractAlterDataConnectorOperation<T extends AbstractAlte
     String dcName = desc.getConnectorName();
     DataConnector connector = context.getDb().getDataConnector(dcName);
     if (connector == null) {
-      throw new HiveException(ErrorMsg.DATACONNECTOR_ALREADY_EXISTS, dcName);
+      throw new HiveException(ErrorMsg.DATACONNECTOR_NOT_EXISTS, dcName);
     }
 
     Map<String, String> params = connector.getParameters();
-    if ((null != desc.getReplicationSpec()) &&
+    if ((desc.getReplicationSpec() != null) &&
         !desc.getReplicationSpec().allowEventReplacementInto(params)) {
       LOG.debug("DDLTask: Alter Connector {} is skipped as connector is newer than update", dcName);
       return 0; // no replacement, the existing connector state is newer than our update.
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlOperation.java
index d9caee0..190e833 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlOperation.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/alter/url/AlterDataConnectorSetUrlOperation.java
@@ -43,20 +43,15 @@ public class AlterDataConnectorSetUrlOperation extends
     try {
       String newUrl = desc.getURL();
 
-      if (newUrl.equalsIgnoreCase(connector.getUrl())) {
-        throw new HiveException("Old and New URL's for data connector cannot be the same");
+      if (StringUtils.isBlank(newUrl) || newUrl.equals(connector.getUrl())) {
+        throw new HiveException("New URL for data connector cannot be blank or the same as the current one");
       }
 
       URI newURI = new URI(newUrl);
       if (!newURI.isAbsolute() || StringUtils.isBlank(newURI.getScheme())) {
         throw new HiveException(ErrorMsg.INVALID_PATH, newUrl); // TODO make a new error message for URL
       }
-
-      if (newUrl.equals(connector.getUrl())) {
-        LOG.info("Alter Connector skipped. No change in url.");
-      } else {
-        connector.setUrl(newUrl);
-      }
+      connector.setUrl(newUrl);
       return;
     } catch (URISyntaxException e) {
       throw new HiveException(e);
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsOperation.java
index 22b10d8..b019036 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsOperation.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/dataconnector/show/ShowDataConnectorsOperation.java
@@ -42,7 +42,7 @@ public class ShowDataConnectorsOperation extends DDLOperation<ShowDataConnectors
 
   @Override
   public int execute() throws HiveException {
-    List<String> connectors = context.getDb().getAllDataConnectors();
+    List<String> connectors = context.getDb().getAllDataConnectorNames();
     if (desc.getPattern() != null) {
       LOG.debug("pattern: {}", desc.getPattern());
       Pattern pattern = Pattern.compile(UDFLike.likePatternToRegExp(desc.getPattern()), Pattern.CASE_INSENSITIVE);
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
index c2c6d7f..31170f6 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
@@ -52,7 +52,6 @@ import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
-import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
@@ -74,7 +73,6 @@ import javax.jdo.JDODataStoreException;
 
 import com.google.common.collect.ImmutableList;
 
-import org.apache.calcite.plan.RelOptMaterialization;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.lang3.ObjectUtils;
@@ -103,7 +101,6 @@ import org.apache.hadoop.hive.conf.Constants;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
 import org.apache.hadoop.hive.metastore.api.GetPartitionsByNamesRequest;
-import org.apache.hadoop.hive.metastore.api.GetPartitionsByNamesResult;
 import org.apache.hadoop.hive.ql.io.HdfsUtils;
 import org.apache.hadoop.hive.metastore.HiveMetaException;
 import org.apache.hadoop.hive.metastore.HiveMetaHook;
@@ -219,7 +216,6 @@ import org.apache.hadoop.mapred.InputFormat;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.hive.common.util.HiveVersionInfo;
-import org.apache.hive.common.util.TxnIdUtils;
 import org.apache.thrift.TException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -928,9 +924,9 @@ public class Hive {
    * @return List of all dataconnector names.
    * @throws HiveException
    */
-  public List<String> getAllDataConnectors() throws HiveException {
+  public List<String> getAllDataConnectorNames() throws HiveException {
     try {
-      return getMSC().getAllDataConnectors();
+      return getMSC().getAllDataConnectorNames();
     } catch (NoSuchObjectException e) {
       return null;
     } catch (Exception e) {
diff --git a/ql/src/test/queries/clientpositive/dataconnector.q b/ql/src/test/queries/clientpositive/dataconnector.q
index c21524a..a89c7db 100644
--- a/ql/src/test/queries/clientpositive/dataconnector.q
+++ b/ql/src/test/queries/clientpositive/dataconnector.q
@@ -11,7 +11,7 @@ WITH DCPROPERTIES (
 "hive.sql.dbcp.password"="hive1");
 SHOW CONNECTORS;
 
--- CREATE INE already exists
+-- CREATE IF NOT EXISTS already
 CREATE CONNECTOR IF NOT EXISTS mysql_test
 TYPE 'mysql'
 URL 'jdbc:mysql://nightly1.apache.org:3306/hive1'
@@ -21,7 +21,7 @@ WITH DCPROPERTIES (
 "hive.sql.dbcp.password"="hive1");
 SHOW CONNECTORS;
 
--- CREATE INE already exists
+-- CREATE IF NOT EXISTS already
 CREATE CONNECTOR IF NOT EXISTS derby_test
 TYPE 'derby'
 URL 'jdbc:derby:./target/tmp/junit_metastore_db;create=true'
@@ -34,7 +34,7 @@ WITH DCPROPERTIES (
 DROP CONNECTOR mysql_test;
 SHOW CONNECTORS;
 
--- DROP IE exists
+-- DROP IF exists
 DROP CONNECTOR IF EXISTS mysql_test;
 SHOW CONNECTORS;
 
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
index 9dbaacc..0455454 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
@@ -1177,7 +1177,7 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
    * @throws TException thrift transport error
    */
   @Override
-  public List<String> getAllDataConnectors() throws MetaException, TException {
+  public List<String> getAllDataConnectorNames() throws MetaException, TException {
     return client.get_dataconnectors();
   }
 
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java
index 38a9888..3f9da12 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java
@@ -2038,7 +2038,7 @@ public interface IMetaStoreClient {
    * @throws MetaException error accessing RDBMS.
    * @throws TException thrift transport error
    */
-  List<String> getAllDataConnectors() throws MetaException, TException;
+  List<String> getAllDataConnectorNames() throws MetaException, TException;
 
   /**
    * Drop a partition.
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
index 4027555..72a6efb 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
@@ -145,6 +145,7 @@ public abstract class AbstractJDBCConnectorProvider extends AbstractDataConnecto
       }
     } catch (SQLException sqle) {
       LOG.warn("Could not retrieve table names from remote datasource, cause:" + sqle.getMessage());
+      throw new MetaException("Error retrieving remote table:" + sqle);
     } finally {
       try {
         if (rs != null) {
@@ -214,12 +215,13 @@ public abstract class AbstractJDBCConnectorProvider extends AbstractDataConnecto
     }
   }
 
-  private ResultSet fetchTableViaDBMetaData(String tableName) {
+  private ResultSet fetchTableViaDBMetaData(String tableName) throws SQLException {
     ResultSet rs = null;
     try {
       rs = getConnection().getMetaData().getColumns(scoped_db, null, tableName, null);
     } catch (SQLException sqle) {
       LOG.warn("Could not retrieve column names from JDBC table, cause:" + sqle.getMessage());
+      throw sqle;
     }
     return rs;
   }
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/DerbySQLConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/DerbySQLConnectorProvider.java
index c212098..9830974 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/DerbySQLConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/DerbySQLConnectorProvider.java
@@ -35,7 +35,7 @@ public class DerbySQLConnectorProvider extends AbstractJDBCConnectorProvider {
       rs = getConnection().getMetaData().getTables(scoped_db, null, null, new String[] { "TABLE" });
     } catch (SQLException sqle) {
       LOG.warn("Could not retrieve table names from remote datasource, cause:" + sqle.getMessage());
-      throw new MetaException("Could not retrieve table names from remote datasource, cause:" + sqle.getMessage());
+      throw new MetaException("Could not retrieve table names from remote datasource, cause:" + sqle);
     }
     return rs;
   }
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConnectorProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConnectorProvider.java
index 17d5a8b..9b8b434 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConnectorProvider.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/MySQLConnectorProvider.java
@@ -33,7 +33,7 @@ public class MySQLConnectorProvider extends AbstractJDBCConnectorProvider {
       rs = getConnection().getMetaData().getTables(scoped_db, null, null, new String[] { "TABLE" });
     } catch (SQLException sqle) {
       LOG.warn("Could not retrieve table names from remote datasource, cause:" + sqle.getMessage());
-      throw new MetaException("Could not retrieve table names from remote datasource, cause:" + sqle.getMessage());
+      throw new MetaException("Could not retrieve table names from remote datasource, cause:" + sqle);
     }
     return rs;
   }
diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClientPreCatalog.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClientPreCatalog.java
index 4d33ac4..6c44e0f 100644
--- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClientPreCatalog.java
+++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClientPreCatalog.java
@@ -1274,7 +1274,7 @@ public class HiveMetaStoreClientPreCatalog implements IMetaStoreClient, AutoClos
 
   /** {@inheritDoc} */
   @Override
-  public List<String> getAllDataConnectors() throws MetaException {
+  public List<String> getAllDataConnectorNames() throws MetaException {
     try {
       client.get_dataconnectors(); // TODO run thru filterhook
     } catch (Exception e) {
diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
index f11724d..c53f1bc 100644
--- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
+++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
@@ -19,7 +19,6 @@
 package org.apache.hadoop.hive.metastore;
 
 import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
@@ -29,11 +28,9 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
@@ -50,7 +47,6 @@ import org.apache.hadoop.hive.metastore.api.GetPartitionsFilterSpec;
 import org.apache.hadoop.hive.metastore.api.GetProjectionsSpec;
 import org.apache.hadoop.hive.metastore.api.GetPartitionsRequest;
 import org.apache.hadoop.hive.metastore.api.GetPartitionsResponse;
-import org.apache.hadoop.hive.metastore.api.PartitionSpec;
 import org.apache.hadoop.hive.metastore.api.PartitionSpecWithSharedSD;
 import org.apache.hadoop.hive.metastore.api.PartitionWithoutSD;
 import org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder;
@@ -3538,7 +3534,7 @@ public abstract class TestHiveMetaStore {
       assertEquals("type of data connector returned is different from the type inserted", postgres_type, dConn.getType());
       assertEquals("url of the data connector returned is different from the url inserted", postgres_url, dConn.getUrl());
 
-      List<String> connectors = client.getAllDataConnectors();
+      List<String> connectors = client.getAllDataConnectorNames();
       assertEquals("Number of dataconnectors returned is not as expected", 2, connectors.size());
 
       DataConnector connector1 = new DataConnector(connector);
@@ -3566,11 +3562,11 @@ public abstract class TestHiveMetaStore {
       assertEquals("Data connector owner type not as expected", PrincipalType.ROLE, dConn.getOwnerType());
 
       client.dropDataConnector(connector_name1, false, false);
-      connectors = client.getAllDataConnectors();
+      connectors = client.getAllDataConnectorNames();
       assertEquals("Number of dataconnectors returned is not as expected", 1, connectors.size());
 
       client.dropDataConnector(connector_name2, false, false);
-      connectors = client.getAllDataConnectors();
+      connectors = client.getAllDataConnectorNames();
       assertEquals("Number of dataconnectors returned is not as expected", 0, connectors.size());
     } catch (Throwable e) {
       System.err.println(StringUtils.stringifyException(e));

[hive] 29/38: HIVE-24396: Fix for NPE in get_database_core with null catalog name

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 506621c86e9d0c9751c256ebdac78db75e0720ce
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Tue Dec 1 22:26:42 2020 -0500

    HIVE-24396: Fix for NPE in get_database_core with null catalog name
---
 .../main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java  | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
index 638b426..d66d928 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
@@ -2376,6 +2376,10 @@ public class HiveMetaStore extends ThriftHiveMetastore {
             + " is not a valid object name");
       }
 
+      if (!tbl.isSetCatName()) {
+        tbl.setCatName(getDefaultCatalog(conf));
+      }
+
       Database db = get_database_core(tbl.getCatName(), tbl.getDbName());
       if (db != null && db.getType().equals(DatabaseType.REMOTE)) {
         DataConnectorProviderFactory.getDataConnectorProvider(db).createTable(tbl);
@@ -2427,9 +2431,6 @@ public class HiveMetaStore extends ThriftHiveMetastore {
       boolean success = false, madeDir = false;
       boolean isReplicated = false;
       try {
-        if (!tbl.isSetCatName()) {
-          tbl.setCatName(getDefaultCatalog(conf));
-        }
         firePreEvent(new PreCreateTableEvent(tbl, this));
 
         ms.openTransaction();

[hive] 25/38: HIVE-24396: Fix to CachedStore to make DBs NATIVE and fix to create_table_core on null DBs

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 4779e8680a05272f258375086e3fefcbd01ca3f0
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Tue Dec 1 11:03:24 2020 -0500

    HIVE-24396: Fix to CachedStore to make DBs NATIVE and fix to create_table_core on null DBs
---
 .../apache/hadoop/hive/metastore/HiveMetaStore.java   | 19 ++++++++++---------
 .../hadoop/hive/metastore/cache/CachedStore.java      |  3 +++
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
index 7288ca3..26552d1 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
@@ -2366,6 +2366,16 @@ public class HiveMetaStore extends ThriftHiveMetastore {
       List<String> processorCapabilities = req.getProcessorCapabilities();
       String processorId = req.getProcessorIdentifier();
 
+      // To preserve backward compatibility throw MetaException in case of null database
+      if (tbl.getDbName() == null) {
+        throw new MetaException("Null database name is not allowed");
+      }
+
+      if (!MetaStoreUtils.validateName(tbl.getTableName(), conf)) {
+        throw new InvalidObjectException(tbl.getTableName()
+            + " is not a valid object name");
+      }
+
       Database db = get_database_core(tbl.getCatName(), tbl.getDbName());
       if (db != null && db.getType().equals(DatabaseType.REMOTE)) {
         DataConnectorProviderFactory.getDataConnectorProvider(db).createTable(tbl);
@@ -2384,15 +2394,6 @@ public class HiveMetaStore extends ThriftHiveMetastore {
         tbl.unsetColStats();
       }
 
-      // To preserve backward compatibility throw MetaException in case of null database
-      if (tbl.getDbName() == null) {
-        throw new MetaException("Null database name is not allowed");
-      }
-
-      if (!MetaStoreUtils.validateName(tbl.getTableName(), conf)) {
-        throw new InvalidObjectException(tbl.getTableName()
-            + " is not a valid object name");
-      }
       String validate = MetaStoreServerUtils.validateTblColumns(tbl.getSd().getCols());
       if (validate != null) {
         throw new InvalidObjectException("Invalid column " + validate);
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java
index 8ddaf4c..0a0f8fd 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java
@@ -1102,6 +1102,9 @@ public class CachedStore implements RawStore, Configurable {
   }
 
   @Override public void createDatabase(Database db) throws InvalidObjectException, MetaException {
+    if (db.getType() == null) {
+      db.setType(DatabaseType.NATIVE);
+    }
     rawStore.createDatabase(db);
     // in case of event based cache update, cache will be updated during commit.
     if (!canUseEvents) {

[hive] 06/38: HIVE-24396: Build failure in itests due to unimplemented interface methods

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 0b9a4f4304d4b7c7a6ab77fad1b1bae26cb7eede
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Tue Nov 17 00:42:47 2020 -0500

    HIVE-24396: Build failure in itests due to unimplemented interface methods
---
 .../hcatalog/listener/DummyRawStoreFailEvent.java  | 27 ++++++++++++++++++++++
 .../ql/ddl/database/create/CreateDatabaseDesc.java |  3 +--
 .../database/create/CreateDatabaseOperation.java   |  3 +--
 3 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java b/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java
index f93a3c7..2d7ad24 100644
--- a/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java
+++ b/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java
@@ -51,6 +51,7 @@ import org.apache.hadoop.hive.metastore.api.AlreadyExistsException;
 import org.apache.hadoop.hive.metastore.api.ColumnStatistics;
 import org.apache.hadoop.hive.metastore.api.CreationMetadata;
 import org.apache.hadoop.hive.metastore.api.CurrentNotificationEventId;
+import org.apache.hadoop.hive.metastore.api.DataConnector;
 import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.metastore.api.FileMetadataExprType;
@@ -245,6 +246,32 @@ public class DummyRawStoreFailEvent implements RawStore, Configurable {
   }
 
   @Override
+  public List<String> getAllDataConnectors() throws MetaException {
+    return objectStore.getAllDataConnectors();
+  }
+
+  @Override
+  public DataConnector getDataConnector(String connectorName) throws NoSuchObjectException {
+    return objectStore.getDataConnector(connectorName);
+  }
+
+  @Override
+  public boolean alterDataConnector(String connectorName, DataConnector connector)
+      throws MetaException, NoSuchObjectException {
+    return objectStore.alterDataConnector(connectorName, connector);
+  }
+
+  @Override
+  public boolean dropDataConnector(String connector) throws MetaException, NoSuchObjectException {
+    return objectStore.dropDataConnector(connector);
+  }
+
+  @Override
+  public void createDataConnector(DataConnector connector) throws MetaException, InvalidObjectException {
+    objectStore.createDataConnector(connector);
+  }
+
+  @Override
   public boolean createType(Type type) {
     return objectStore.createType(type);
   }
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseDesc.java
index 45df31c..1590133 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseDesc.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseDesc.java
@@ -34,7 +34,6 @@ import javax.xml.crypto.Data;
 @Explain(displayName = "Create Database", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
 public class CreateDatabaseDesc implements DDLDesc, Serializable {
   private static final long serialVersionUID = 1L;
-  public static final String REMOTEDB_LOCATION = "REMOTE_LOCATION".intern();
 
   private final String databaseName;
   private final String comment;
@@ -57,9 +56,9 @@ public class CreateDatabaseDesc implements DDLDesc, Serializable {
     this.comment = comment;
     if (dbtype != null && dbtype.equalsIgnoreCase("REMOTE")) {
       this.dbType = DatabaseType.REMOTE;
-      this.locationUri = REMOTEDB_LOCATION; // this is non-null in the HMSDB
       this.connectorName = connectorName;
       this.remoteDbName = remoteDbName;
+      this.locationUri = null;
       this.managedLocationUri = null;
     } else {
       this.dbType = DatabaseType.NATIVE;
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseOperation.java
index 97e318d..def742d 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseOperation.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseOperation.java
@@ -54,15 +54,14 @@ public class CreateDatabaseOperation extends DDLOperation<CreateDatabaseDesc> {
         if (desc.getManagedLocationUri() != null) {
           database.setManagedLocationUri(desc.getManagedLocationUri());
         }
-        makeLocationQualified(database);
         if (database.getLocationUri().equalsIgnoreCase(database.getManagedLocationUri())) {
           throw new HiveException("Managed and external locations for database cannot be the same");
         }
       } else {
-        database.setLocationUri(CreateDatabaseDesc.REMOTEDB_LOCATION);
         database.setConnector_name(desc.getConnectorName());
         database.setRemote_dbname(desc.getRemoteDbName());
       }
+      makeLocationQualified(database);
       context.getDb().createDatabase(database, desc.getIfNotExists());
     } catch (AlreadyExistsException ex) {
       //it would be better if AlreadyExistsException had an errorCode field....

[hive] 32/38: HIVE-24396: Incorporating feedback from the initial review (Naveen Gangam)

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit b9150e1c571bf050f879b29425b5a3b09e3a740a
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Fri Mar 19 00:18:02 2021 -0400

    HIVE-24396: Incorporating feedback from the initial review (Naveen Gangam)
    
    Test fix for test failure, not to be committed
---
 .../hcatalog/listener/DummyRawStoreFailEvent.java  |  4 ++--
 .../org/apache/hadoop/hive/ql/parse/HiveParser.g   |  1 -
 .../database/create/CreateDatabaseAnalyzer.java    |  8 +++----
 .../ddl/database/desc/DescDatabaseFormatter.java   |  4 ++--
 .../apache/hadoop/hive/metastore/HMSHandler.java   |  3 ++-
 .../apache/hadoop/hive/metastore/ObjectStore.java  |  8 +++----
 .../org/apache/hadoop/hive/metastore/RawStore.java |  4 ++--
 .../hadoop/hive/metastore/cache/CachedStore.java   |  4 ++--
 .../metastore/DummyRawStoreControlledCommit.java   | 22 ++---------------
 .../metastore/DummyRawStoreForJdoConnection.java   |  2 +-
 .../upgrade-3.1.3000-to-4.0.0.postgres.sql         | 28 ++++++++++++++++++++++
 11 files changed, 48 insertions(+), 40 deletions(-)

diff --git a/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java b/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java
index 2d7ad24..7d7360b 100644
--- a/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java
+++ b/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java
@@ -246,8 +246,8 @@ public class DummyRawStoreFailEvent implements RawStore, Configurable {
   }
 
   @Override
-  public List<String> getAllDataConnectors() throws MetaException {
-    return objectStore.getAllDataConnectors();
+  public List<String> getAllDataConnectorNames() throws MetaException {
+    return objectStore.getAllDataConnectorNames();
   }
 
   @Override
diff --git a/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g b/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
index 1375e4a..2163ec9 100644
--- a/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
+++ b/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
@@ -364,7 +364,6 @@ TOK_ALTERDATABASE_PROPERTIES;
 TOK_ALTERDATABASE_OWNER;
 TOK_ALTERDATABASE_LOCATION;
 TOK_ALTERDATABASE_MANAGEDLOCATION;
-TOK_DATACONNECTORPROPERTIES;
 TOK_ALTERDATACONNECTOR_PROPERTIES;
 TOK_ALTERDATACONNECTOR_OWNER;
 TOK_ALTERDATACONNECTOR_URL;
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseAnalyzer.java
index d342db0..14ab9bf 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/create/CreateDatabaseAnalyzer.java
@@ -49,7 +49,7 @@ public class CreateDatabaseAnalyzer extends BaseSemanticAnalyzer {
     String comment = null;
     String locationUri = null;
     String managedLocationUri = null;
-    String type = "NATIVE";
+    String type = DatabaseType.NATIVE.name();
     String connectorName = null;
     Map<String, String> props = null;
 
@@ -74,12 +74,10 @@ public class CreateDatabaseAnalyzer extends BaseSemanticAnalyzer {
         outputs.add(toWriteEntity(managedLocationUri));
         break;
       case HiveParser.TOK_DATACONNECTOR:
-        type = "REMOTE";
-        // locationUri = "REMOTE_DATABASE"; // TODO
+        type = DatabaseType.REMOTE.name();
         ASTNode nextNode = (ASTNode) root.getChild(i);
         connectorName = ((ASTNode)nextNode).getChild(0).getText();
         outputs.add(toWriteEntity(connectorName));
-        // outputs.remove(toWriteEntity(locationUri));
         if (managedLocationUri != null) {
           outputs.remove(toWriteEntity(managedLocationUri));
           managedLocationUri = null;
@@ -92,7 +90,7 @@ public class CreateDatabaseAnalyzer extends BaseSemanticAnalyzer {
 
     CreateDatabaseDesc desc = null;
     Database database = new Database(databaseName, comment, locationUri, props);
-    if (type.equalsIgnoreCase("NATIVE")) {
+    if (type.equalsIgnoreCase(DatabaseType.NATIVE.name())) {
       desc = new CreateDatabaseDesc(databaseName, comment, locationUri, managedLocationUri, ifNotExists, props);
       database.setType(DatabaseType.NATIVE);
       // database = new Database(databaseName, comment, locationUri, props);
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseFormatter.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseFormatter.java
index 5e10c3b..327aa5c 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseFormatter.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/database/desc/DescDatabaseFormatter.java
@@ -71,10 +71,10 @@ abstract class DescDatabaseFormatter {
       if (ownerType != null) {
         builder.put("ownerType", ownerType.name());
       }
-      if (null != connectorName) {
+      if (connectorName != null) {
         builder.put("connector_name", connectorName);
       }
-      if (null != remoteDbName) {
+      if (remoteDbName != null) {
         builder.put("remote_dbname", remoteDbName);
       }
       if (MapUtils.isNotEmpty(params)) {
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
index 17b81a6..bf0623e 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
@@ -805,6 +805,7 @@ public class HMSHandler extends FacebookBase implements IHMSHandler {
       db.setCatalogName(DEFAULT_CATALOG_NAME);
       long time = System.currentTimeMillis() / 1000;
       db.setCreateTime((int) time);
+      db.setType(DatabaseType.NATIVE);
       ms.createDatabase(db);
       LOG.info("Successfully created a default database with name: "+DEFAULT_DATABASE_NAME);
     }
@@ -2110,7 +2111,7 @@ public class HMSHandler extends FacebookBase implements IHMSHandler {
     List<String> ret = null;
     Exception ex = null;
     try {
-      ret = getMS().getAllDataConnectors();
+      ret = getMS().getAllDataConnectorNames();
       ret = FilterUtils.filterDataConnectorsIfEnabled(isServerFilterEnabled, filterHook, ret);
     } catch (MetaException e) {
       ex = e;
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
index 7ade2fc..8f6e7be 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
@@ -786,9 +786,9 @@ public class ObjectStore implements RawStore, Configurable {
     mdb.setDataConnectorName(db.getConnector_name());
     mdb.setRemoteDatabaseName(db.getRemote_dbname());
     if (db.getType() == null) {
-      mdb.setType("NATIVE");
+      mdb.setType(DatabaseType.NATIVE.name());
     } else {
-      mdb.setType(db.getType().toString());
+      mdb.setType(db.getType().name());
     }
     PrincipalType ownerType = db.getOwnerType();
     mdb.setOwnerType((null == ownerType ? PrincipalType.USER.name() : ownerType.name()));
@@ -885,7 +885,7 @@ public class ObjectStore implements RawStore, Configurable {
     String type = org.apache.commons.lang3.StringUtils.defaultIfBlank(mdb.getOwnerType(), null);
     PrincipalType principalType = (type == null) ? null : PrincipalType.valueOf(type);
     db.setOwnerType(principalType);
-    if (mdb.getType().equalsIgnoreCase("NATIVE")) {
+    if (mdb.getType().equalsIgnoreCase(DatabaseType.NATIVE.name())) {
       db.setType(DatabaseType.NATIVE);
       db.setLocationUri(mdb.getLocationUri());
       db.setManagedLocationUri(org.apache.commons.lang3.StringUtils.defaultIfBlank(mdb.getManagedLocationUri(), null));
@@ -1095,7 +1095,7 @@ public class ObjectStore implements RawStore, Configurable {
   }
 
   @Override
-  public List<String> getAllDataConnectors() throws MetaException {
+  public List<String> getAllDataConnectorNames() throws MetaException {
     boolean commited = false;
     List<String> connectors = null;
     Query query = null;
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/RawStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/RawStore.java
index 39e3079..4a15345 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/RawStore.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/RawStore.java
@@ -251,7 +251,7 @@ public interface RawStore extends Configurable {
 
   /**
    * Create a dataconnector.
-   * @param db dataconnector to create.
+   * @param dataConnector dataconnector to create.
    * @throws InvalidObjectException not sure it actually ever throws this.
    * @throws MetaException if something goes wrong, usually in writing it to the dataconnector.
    */
@@ -293,7 +293,7 @@ public interface RawStore extends Configurable {
    * @return list of names of all dataconnectors
    * @throws MetaException something went wrong, usually with the database.
    */
-  List<String> getAllDataConnectors() throws MetaException;
+  List<String> getAllDataConnectorNames() throws MetaException;
 
   boolean createType(Type type);
 
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java
index 0a0f8fd..b792f78 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java
@@ -1191,8 +1191,8 @@ public class CachedStore implements RawStore, Configurable {
   }
 
   @Override
-  public List<String> getAllDataConnectors() throws MetaException {
-      return rawStore.getAllDataConnectors();
+  public List<String> getAllDataConnectorNames() throws MetaException {
+      return rawStore.getAllDataConnectorNames();
   }
   
   @Override public boolean createType(Type type) {
diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java
index 29038c5..1cbaeeb 100644
--- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java
+++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java
@@ -45,27 +45,21 @@ import org.apache.hadoop.conf.Configurable;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.metastore.api.AggrStats;
 import org.apache.hadoop.hive.metastore.api.AlreadyExistsException;
-import org.apache.hadoop.hive.metastore.api.Catalog;
 import org.apache.hadoop.hive.metastore.api.ColumnStatistics;
-import org.apache.hadoop.hive.metastore.api.CreationMetadata;
 import org.apache.hadoop.hive.metastore.api.CurrentNotificationEventId;
 import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.metastore.api.DataConnector;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.metastore.api.FileMetadataExprType;
 import org.apache.hadoop.hive.metastore.api.Function;
-import org.apache.hadoop.hive.metastore.api.GetPartitionsFilterSpec;
-import org.apache.hadoop.hive.metastore.api.GetProjectionsSpec;
 import org.apache.hadoop.hive.metastore.api.GetReplicationMetricsRequest;
 import org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege;
 import org.apache.hadoop.hive.metastore.api.HiveObjectRef;
 import org.apache.hadoop.hive.metastore.api.ISchema;
-import org.apache.hadoop.hive.metastore.api.ISchemaName;
 import org.apache.hadoop.hive.metastore.api.InvalidInputException;
 import org.apache.hadoop.hive.metastore.api.InvalidObjectException;
 import org.apache.hadoop.hive.metastore.api.InvalidOperationException;
 import org.apache.hadoop.hive.metastore.api.InvalidPartitionException;
-import org.apache.hadoop.hive.metastore.api.ListStoredProcedureRequest;
 import org.apache.hadoop.hive.metastore.api.MetaException;
 import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
@@ -83,7 +77,6 @@ import org.apache.hadoop.hive.metastore.api.Role;
 import org.apache.hadoop.hive.metastore.api.RolePrincipalGrant;
 import org.apache.hadoop.hive.metastore.api.RuntimeStat;
 import org.apache.hadoop.hive.metastore.api.ReplicationMetricList;
-import org.apache.hadoop.hive.metastore.api.SQLAllTableConstraints;
 import org.apache.hadoop.hive.metastore.api.SQLCheckConstraint;
 import org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint;
 import org.apache.hadoop.hive.metastore.api.SQLForeignKey;
@@ -97,16 +90,13 @@ import org.apache.hadoop.hive.metastore.api.ScheduledQueryPollRequest;
 import org.apache.hadoop.hive.metastore.api.ScheduledQueryPollResponse;
 import org.apache.hadoop.hive.metastore.api.ScheduledQueryProgressInfo;
 import org.apache.hadoop.hive.metastore.api.SchemaVersion;
-import org.apache.hadoop.hive.metastore.api.SchemaVersionDescriptor;
 import org.apache.hadoop.hive.metastore.api.SerDeInfo;
-import org.apache.hadoop.hive.metastore.api.StoredProcedure;
 import org.apache.hadoop.hive.metastore.api.Table;
 import org.apache.hadoop.hive.metastore.api.TableMeta;
 import org.apache.hadoop.hive.metastore.api.Type;
 import org.apache.hadoop.hive.metastore.api.UnknownDBException;
 import org.apache.hadoop.hive.metastore.api.UnknownPartitionException;
 import org.apache.hadoop.hive.metastore.api.UnknownTableException;
-import org.apache.hadoop.hive.metastore.api.WMFullResourcePlan;
 import org.apache.hadoop.hive.metastore.api.WMMapping;
 import org.apache.hadoop.hive.metastore.api.WMNullablePool;
 import org.apache.hadoop.hive.metastore.api.WMNullableResourcePlan;
@@ -116,14 +106,6 @@ import org.apache.hadoop.hive.metastore.api.WMTrigger;
 import org.apache.hadoop.hive.metastore.api.WMValidateResourcePlanResponse;
 import org.apache.hadoop.hive.metastore.api.WriteEventInfo;
 
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.hadoop.conf.Configurable;
-import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy;
 import org.apache.hadoop.hive.metastore.utils.MetaStoreServerUtils.ColStatsObjWithSourceInfo;
 import org.apache.thrift.TException;
@@ -277,8 +259,8 @@ public class DummyRawStoreControlledCommit implements RawStore, Configurable {
   }
 
   @Override
-  public List<String> getAllDataConnectors() throws MetaException {
-    return objectStore.getAllDataConnectors();
+  public List<String> getAllDataConnectorNames() throws MetaException {
+    return objectStore.getAllDataConnectorNames();
   }
 
   @Override
diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java
index b7d826c..ea789ff 100644
--- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java
+++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java
@@ -265,7 +265,7 @@ public class DummyRawStoreForJdoConnection implements RawStore {
   }
 
   @Override
-  public List<String> getAllDataConnectors() throws MetaException {
+  public List<String> getAllDataConnectorNames() throws MetaException {
     return Collections.emptyList();
   }
 
diff --git a/standalone-metastore/metastore-server/src/test/resources/sql/postgres/upgrade-3.1.3000-to-4.0.0.postgres.sql b/standalone-metastore/metastore-server/src/test/resources/sql/postgres/upgrade-3.1.3000-to-4.0.0.postgres.sql
index 0dd407f..7851b08 100644
--- a/standalone-metastore/metastore-server/src/test/resources/sql/postgres/upgrade-3.1.3000-to-4.0.0.postgres.sql
+++ b/standalone-metastore/metastore-server/src/test/resources/sql/postgres/upgrade-3.1.3000-to-4.0.0.postgres.sql
@@ -80,6 +80,34 @@ ALTER TABLE "COMPLETED_COMPACTIONS" ADD "CC_INITIATOR_ID" varchar(128);
 ALTER TABLE "COMPLETED_COMPACTIONS" ADD "CC_INITIATOR_VERSION" varchar(128);
 ALTER TABLE "COMPLETED_COMPACTIONS" ADD "CC_WORKER_VERSION" varchar(128);
 
+-- HIVE-24770
+UPDATE "SERDES" SET "SLIB"='org.apache.hadoop.hive.serde2.MultiDelimitSerDe' where "SLIB"='org.apache.hadoop.hive.contrib.serde2.MultiDelimitSerDe';
+
+-- HIVE-24396
+-- Create DataConnectors and DataConnector_Params tables
+CREATE TABLE "DATACONNECTORS" (
+  "NAME" character varying(128) NOT NULL,
+  "TYPE" character varying(32) NOT NULL,
+  "URL" character varying(4000) NOT NULL,
+  "COMMENT" character varying(256),
+  "OWNER_NAME" character varying(256),
+  "OWNER_TYPE" character varying(10),
+  "CREATE_TIME" INTEGER NOT NULL,
+  PRIMARY KEY ("NAME")
+);
+
+CREATE TABLE "DATACONNECTOR_PARAMS" (
+  "NAME" character varying(128) NOT NULL,
+  "PARAM_KEY" character varying(180) NOT NULL,
+  "PARAM_VALUE" character varying(4000),
+  PRIMARY KEY ("NAME", "PARAM_KEY"),
+  CONSTRAINT "DATACONNECTOR_NAME_FK1" FOREIGN KEY ("NAME") REFERENCES "DATACONNECTORS"("NAME") ON DELETE CASCADE
+);
+ALTER TABLE "DBS" ADD "TYPE" character varying(32) DEFAULT 'NATIVE' NOT NULL;
+ALTER TABLE "DBS" ADD "DATACONNECTOR_NAME" character varying(128);
+ALTER TABLE "DBS" ADD "REMOTE_DBNAME" character varying(128);
+UPDATE "DBS" SET "TYPE"= 'NATIVE' WHERE "TYPE" IS NULL;
+
 -- These lines need to be last. Insert any changes above.
 UPDATE "VERSION" SET "SCHEMA_VERSION"='4.0.0', "VERSION_COMMENT"='Hive release version 4.0.0' where "VER_ID"=1;
 SELECT 'Finished upgrading MetaStore schema from 3.1.3000 to 4.0.0';

[hive] 20/38: Retain case on table names during query processing

Posted by ng...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 0b60db92c316c6a08e5808755ae99cb38ee238e4
Author: Naveen Gangam <ng...@cloudera.com>
AuthorDate: Wed Nov 25 17:28:14 2020 -0500

    Retain case on table names during query processing
---
 ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
index 13a1bae..9bb6689 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
@@ -1117,7 +1117,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
 
     ASTNode tableTree = (ASTNode) (tabref.getChild(0));
 
-    String tabIdName = getUnescapedName(tableTree).toLowerCase();
+    String tabIdName = getUnescapedName(tableTree);
 
     String alias = findSimpleTableName(tabref, aliasIndex);