You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by brajmohan saxena <br...@gmail.com> on 2016/04/05 05:57:18 UTC

Hive Metadata tables of a schema

Hi,

How can I access Hive metadata tables of a particular Server and Schema in
a C program or through JDBC client.

I have one application running on Client and my Hiveserver2 running on
Remote machine.

So if i provide Server name and Schema name in my client C program ,I
should be able to get all the tables belongs that Schema.

So Is there any Hive API where i can provide the Server and Schema name and
get the tables of that schema.

Thanks in advance,

Regards
Braj

Re: Hive Metadata tables of a schema

Posted by David Morel <dm...@amakuru.net>.
Better use HCatalog for this.

David
Le 5 avr. 2016 10:14, "Mich Talebzadeh" <mi...@gmail.com> a
écrit :

> So you want to interrogate Hive metastore and get information about
> objects for a given schema/database in Hive.
>
> These info are kept in Hive metastore database running on an RDBVMS say
> Oracle. There are dozens of tables in Hive specific schema.
>
> For example table DBS contains Hive databases etc
>
> hiveuser@MYDB.MICH.LOCAL> select name from DBS;
> NAME
>
> --------------------------------------------------------------------------------------------------------------------------------
> oraclehadoop
> test
> mytable_db
> accounts
> asehadoop
> default
> iqhadoop
> 7 rows selected.
>
> However, to get tables etc you need to understand the Hive schema tables
> and relationships among the tables. There is no package or proc to provide
> the info you need. You need to write your own queries.
>
> HTH
>
>
> Dr Mich Talebzadeh
>
>
>
> LinkedIn * https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw
> <https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw>*
>
>
>
> http://talebzadehmich.wordpress.com
>
>
>
> On 5 April 2016 at 04:57, brajmohan saxena <br...@gmail.com>
> wrote:
>
>> Hi,
>>
>> How can I access Hive metadata tables of a particular Server and Schema
>> in a C program or through JDBC client.
>>
>> I have one application running on Client and my Hiveserver2 running on
>> Remote machine.
>>
>> So if i provide Server name and Schema name in my client C program ,I
>> should be able to get all the tables belongs that Schema.
>>
>> So Is there any Hive API where i can provide the Server and Schema name
>> and get the tables of that schema.
>>
>> Thanks in advance,
>>
>> Regards
>> Braj
>>
>>
>>
>

Re: Hive Metadata tables of a schema

Posted by David Morel <dm...@amakuru.net>.
Better use HCatalog for this.

David
Le 5 avr. 2016 10:14, "Mich Talebzadeh" <mi...@gmail.com> a
écrit :

> So you want to interrogate Hive metastore and get information about
> objects for a given schema/database in Hive.
>
> These info are kept in Hive metastore database running on an RDBVMS say
> Oracle. There are dozens of tables in Hive specific schema.
>
> For example table DBS contains Hive databases etc
>
> hiveuser@MYDB.MICH.LOCAL> select name from DBS;
> NAME
>
> --------------------------------------------------------------------------------------------------------------------------------
> oraclehadoop
> test
> mytable_db
> accounts
> asehadoop
> default
> iqhadoop
> 7 rows selected.
>
> However, to get tables etc you need to understand the Hive schema tables
> and relationships among the tables. There is no package or proc to provide
> the info you need. You need to write your own queries.
>
> HTH
>
>
> Dr Mich Talebzadeh
>
>
>
> LinkedIn * https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw
> <https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw>*
>
>
>
> http://talebzadehmich.wordpress.com
>
>
>
> On 5 April 2016 at 04:57, brajmohan saxena <br...@gmail.com>
> wrote:
>
>> Hi,
>>
>> How can I access Hive metadata tables of a particular Server and Schema
>> in a C program or through JDBC client.
>>
>> I have one application running on Client and my Hiveserver2 running on
>> Remote machine.
>>
>> So if i provide Server name and Schema name in my client C program ,I
>> should be able to get all the tables belongs that Schema.
>>
>> So Is there any Hive API where i can provide the Server and Schema name
>> and get the tables of that schema.
>>
>> Thanks in advance,
>>
>> Regards
>> Braj
>>
>>
>>
>

Re: Hive Metadata tables of a schema

Posted by Mich Talebzadeh <mi...@gmail.com>.
So you want to interrogate Hive metastore and get information about objects
for a given schema/database in Hive.

These info are kept in Hive metastore database running on an RDBVMS say
Oracle. There are dozens of tables in Hive specific schema.

For example table DBS contains Hive databases etc

hiveuser@MYDB.MICH.LOCAL> select name from DBS;
NAME
--------------------------------------------------------------------------------------------------------------------------------
oraclehadoop
test
mytable_db
accounts
asehadoop
default
iqhadoop
7 rows selected.

However, to get tables etc you need to understand the Hive schema tables
and relationships among the tables. There is no package or proc to provide
the info you need. You need to write your own queries.

HTH


Dr Mich Talebzadeh



LinkedIn * https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw
<https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw>*



http://talebzadehmich.wordpress.com



On 5 April 2016 at 04:57, brajmohan saxena <br...@gmail.com> wrote:

> Hi,
>
> How can I access Hive metadata tables of a particular Server and Schema in
> a C program or through JDBC client.
>
> I have one application running on Client and my Hiveserver2 running on
> Remote machine.
>
> So if i provide Server name and Schema name in my client C program ,I
> should be able to get all the tables belongs that Schema.
>
> So Is there any Hive API where i can provide the Server and Schema name
> and get the tables of that schema.
>
> Thanks in advance,
>
> Regards
> Braj
>
>
>

RE: Hive Metadata tables of a schema

Posted by Rachna Jotwani <rj...@dag.com>.
Hacatalog example in java…

private void testHCatalogAPI() throws NoSuchObjectException, TException, HCatException {
            HCatClient hcatClient = null;
            try {
                  HiveConf hcatConf = new HiveConf();
                  hcatConf.setVar(HiveConf.ConfVars.METASTOREURIS, "thrift://vm-hadoop:9083");
                  hcatConf.set(HCatConstants.HCAT_HIVE_CLIENT_DISABLE_CACHE, "true");
              hcatClient = HCatClient.create(new Configuration(hcatConf));

                  List<String> dbs = hcatClient.listDatabaseNamesByPattern("*");
                  for (String db: dbs) {
                        List<String> tables = hcatClient.listTableNamesByPattern(db, "*");
                        for (String table: tables) {
                              System.out.println("Table Name is: " + table);
                              HCatTable tbl = hcatClient.getTable(db, table);
                              System.out.println("Table Type is: " + tbl.getTabletype());
                              System.out.println("Table Props are: " + tbl.getTblProps());
                              List<HCatFieldSchema> fields = tbl.getCols();
                              for (HCatFieldSchema f: fields) {
                                    System.out.println("Field Name is: " + f.getName());
                                    System.out.println("Field Type String is: " + f.getTypeString());
                                    System.out.println("Field Type Category is: " + f.getTypeString());
                                    if (f.getCategory().equals(HCatFieldSchema.Category.STRUCT)) {
                                          HCatSchema schema = f.getStructSubSchema();
                                          List<String> structFields = schema.getFieldNames();
                                          for (String fieldName: structFields) {
                                                System.out.println("Struct Field Name is: " + fieldName);
                                          }
                                    }
                              }
                        }
                  }

            } finally {
                  if (hcatClient != null)
                        hcatClient.close();
                  System.out.println("END");
            }
      }


From: brajmohan saxena [mailto:braj.saxena.13@gmail.com]
Sent: Monday, April 4, 2016 8:57 PM
To: dev@hive.apache.org
Subject: Hive Metadata tables of a schema

Hi,

How can I access Hive metadata tables of a particular Server and Schema in a C program or through JDBC client.

I have one application running on Client and my Hiveserver2 running on Remote machine.

So if i provide Server name and Schema name in my client C program ,I should be able to get all the tables belongs that Schema.

So Is there any Hive API where i can provide the Server and Schema name and get the tables of that schema.

Thanks in advance,

Regards
Braj