You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by Anurag Kumar Dwivedi <an...@gmail.com> on 2025/01/29 10:49:30 UTC

How to Fetch Databases for a Specific Catalog in HMS?

*Hi Hive Community,*

I have a question regarding handling databases across multiple catalogs in
HMS.

As per the HMS design, it accepts catalog names in all API calls, either by
appending the database name with the catalog name using # or by setting the
catalog name in the request object of _req methods as optional. Suppose an
HMS client starts passing the catalog name in all API calls. Since the HMS
schema ensures that the combination of database_name and catalog_name is
unique in the DBS table, users can create the same database name in
different catalogs (e.g., database1 in both catalog1 and catalog2).

Given this setup, here's the scenario I need clarification on:

If a user wants to retrieve all databases belonging to a specific catalog,
is there an HMS API available for this? Currently, get_all_databases()
returns a list of database names but doesn't differentiate which catalog
they belong to. This becomes problematic when the same database name exists
in different catalogs, as the HMS client won't be able to filter and
associate each database with its respective catalog.

Is there a recommended way or any API to get database details based on the
catalog name so that HMS clients can filter and use the correct databases
accordingly?

Thanks for your help!

Thanks & Regards
  Anurag Dwivedi
  Mob - 9331339700

Re: How to Fetch Databases for a Specific Catalog in HMS?

Posted by Anurag Kumar Dwivedi <an...@gmail.com>.
Hi Ayush,

Yes, I saw the method and was able to retrieve the databases by the catalog
name as per my usecase.

By the way, thank you for your input. I really appreciate it.

Regards
Anurag Dwivedi
Mob - 9331339700




On Wed, Jan 29, 2025 at 5:11 PM Ayush Saxena <ay...@gmail.com> wrote:

> Hi Anurag,
> I am just checking the code, Have you tried the get_databases(String
> pattern) method? [1], Looking at the code, it seems to have a way to fetch
> the databases within a catalog [2].
>
> -Ayush
>
>
> [1]
> https://github.com/apache/hive/blob/4f22ecde118a35bb5217cb09dba4bb094494f249/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java#L1882
>
> [2]
> https://github.com/apache/hive/blob/4f22ecde118a35bb5217cb09dba4bb094494f249/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java#L1890
>
> On Wed, 29 Jan 2025 at 16:20, Anurag Kumar Dwivedi <an...@gmail.com>
> wrote:
>
>> *Hi Hive Community,*
>>
>> I have a question regarding handling databases across multiple catalogs
>> in HMS.
>>
>> As per the HMS design, it accepts catalog names in all API calls, either
>> by appending the database name with the catalog name using # or by
>> setting the catalog name in the request object of _req methods as
>> optional. Suppose an HMS client starts passing the catalog name in all API
>> calls. Since the HMS schema ensures that the combination of database_name
>> and catalog_name is unique in the DBS table, users can create the same
>> database name in different catalogs (e.g., database1 in both catalog1
>> and catalog2).
>>
>> Given this setup, here's the scenario I need clarification on:
>>
>> If a user wants to retrieve all databases belonging to a specific
>> catalog, is there an HMS API available for this? Currently,
>> get_all_databases() returns a list of database names but doesn't
>> differentiate which catalog they belong to. This becomes problematic when
>> the same database name exists in different catalogs, as the HMS client
>> won't be able to filter and associate each database with its respective
>> catalog.
>>
>> Is there a recommended way or any API to get database details based on
>> the catalog name so that HMS clients can filter and use the correct
>> databases accordingly?
>>
>> Thanks for your help!
>>
>> Thanks & Regards
>>   Anurag Dwivedi
>>   Mob - 9331339700
>>
>>
>>

Re: How to Fetch Databases for a Specific Catalog in HMS?

Posted by Ayush Saxena <ay...@gmail.com>.
Hi Anurag,
I am just checking the code, Have you tried the get_databases(String
pattern) method? [1], Looking at the code, it seems to have a way to fetch
the databases within a catalog [2].

-Ayush


[1]
https://github.com/apache/hive/blob/4f22ecde118a35bb5217cb09dba4bb094494f249/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java#L1882

[2]
https://github.com/apache/hive/blob/4f22ecde118a35bb5217cb09dba4bb094494f249/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java#L1890

On Wed, 29 Jan 2025 at 16:20, Anurag Kumar Dwivedi <an...@gmail.com>
wrote:

> *Hi Hive Community,*
>
> I have a question regarding handling databases across multiple catalogs in
> HMS.
>
> As per the HMS design, it accepts catalog names in all API calls, either
> by appending the database name with the catalog name using # or by
> setting the catalog name in the request object of _req methods as
> optional. Suppose an HMS client starts passing the catalog name in all API
> calls. Since the HMS schema ensures that the combination of database_name
> and catalog_name is unique in the DBS table, users can create the same
> database name in different catalogs (e.g., database1 in both catalog1 and
> catalog2).
>
> Given this setup, here's the scenario I need clarification on:
>
> If a user wants to retrieve all databases belonging to a specific catalog,
> is there an HMS API available for this? Currently, get_all_databases()
> returns a list of database names but doesn't differentiate which catalog
> they belong to. This becomes problematic when the same database name exists
> in different catalogs, as the HMS client won't be able to filter and
> associate each database with its respective catalog.
>
> Is there a recommended way or any API to get database details based on the
> catalog name so that HMS clients can filter and use the correct databases
> accordingly?
>
> Thanks for your help!
>
> Thanks & Regards
>   Anurag Dwivedi
>   Mob - 9331339700
>
>
>