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

okumin commented on HIVE-27473:
-------------------------------

This might not be as trivial as I originally expected. 
SessionHiveMetaStoreClient and HiveMetaStoreClientWithLocalCache are coupled 
with not IMetaStoreClient but HiveMetaStoreClient.

Let's see the case of `getTable`. The public endpoint is defined as 
[IMetaStoreClient#getTable|https://github.com/apache/hive/blob/b02cef4fe943b9aba597dcdfd3b8f3d3a5efca3e/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java#L735].
 However, SessionHiveMetaStoreClient, HiveMetaStoreClientWithLocalCache, and 
HiveMetaStoreClient are coupled with not only the public API,`getTable`, but 
also another non-public API, `getTableInternal`.

1. A client calls 
[SessionHiveMetaStoreClient#getTable|https://github.com/apache/hive/blob/b02cef4fe943b9aba597dcdfd3b8f3d3a5efca3e/ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java#L277]
2. The method checks if a tmp table exists. If it doesn't exist, the method 
calls 
[super.getTable|https://github.com/apache/hive/blob/b02cef4fe943b9aba597dcdfd3b8f3d3a5efca3e/ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java#L284]
3. 
[HiveMetaStoreClient#getTable|https://github.com/apache/hive/blob/b02cef4fe943b9aba597dcdfd3b8f3d3a5efca3e/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java#L2780]
 is invoked
4. The method calls 
[getTableInternal|https://github.com/apache/hive/blob/b02cef4fe943b9aba597dcdfd3b8f3d3a5efca3e/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java#L2790]
5. 
[SessionHiveMetaStoreClient#getTableInternal|https://github.com/apache/hive/blob/b02cef4fe943b9aba597dcdfd3b8f3d3a5efca3e/ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java#L2094]
 is invoked
6. The method checks query level cache. If not cached, 
[super.getTableInternal|https://github.com/apache/hive/blob/b02cef4fe943b9aba597dcdfd3b8f3d3a5efca3e/ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java#L2108]
 is called
7. 
[HiveMetaStoreClientWithLocalCache#getTableInternal|https://github.com/apache/hive/blob/b02cef4fe943b9aba597dcdfd3b8f3d3a5efca3e/ql/src/java/org/apache/hadoop/hive/ql/metadata/HiveMetaStoreClientWithLocalCache.java#L273]
 is invoked
8. The method checks if metastore client cache. If not cached, 
[super.getTableInternal|https://github.com/apache/hive/blob/b02cef4fe943b9aba597dcdfd3b8f3d3a5efca3e/ql/src/java/org/apache/hadoop/hive/ql/metadata/HiveMetaStoreClientWithLocalCache.java#L282]
 is called
9. 
[HiveMetaStoreClient#getTableInternal|https://github.com/apache/hive/blob/b02cef4fe943b9aba597dcdfd3b8f3d3a5efca3e/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java#L2731]
 is invoked and the actual access to HMS happens

 

Those have mutual dependencies, meaning SessionHiveMetaStoreClient invokes 
steps implemented in HiveMetaStoreClient. HiveMetaStoreClient also invokes 
steps implemented in SessionHiveMetaStoreClient. I guess we need to restructure 
the dependency in order to make them composable.

> Make SessionHiveMetaStoreClient and HiveMetaStoreClientWithLocalCache 
> composable
> --------------------------------------------------------------------------------
>
>                 Key: HIVE-27473
>                 URL: https://issues.apache.org/jira/browse/HIVE-27473
>             Project: Hive
>          Issue Type: Improvement
>          Components: Hive
>    Affects Versions: 4.0.0-alpha-2
>            Reporter: okumin
>            Assignee: okumin
>            Priority: Major
>
> Currently, we implement the two classes using inheritance. It assumes we 
> always use a single implementation of IMetaStoreClient.
> Some community members have been willing to make IMetaStoreClient pluggable 
> as proposed in HIVE-12679. Considering the use case, we should provide the 
> additional traits with composition over inheritance.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to