RE: Hive Metadata tables of a schema

2016-04-05 Thread Rachna Jotwani
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 dbs = hcatClient.listDatabaseNamesByPattern("*");
  for (String db: dbs) {
List 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 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 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...@gmail.com]
Sent: Monday, April 4, 2016 8:57 PM
To: d...@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




Re: Hive Metadata tables of a schema

2016-04-05 Thread David Morel
Better use HCatalog for this.

David
Le 5 avr. 2016 10:14, "Mich Talebzadeh"  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
>
> hiveu...@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=AAEWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw
> *
>
>
>
> http://talebzadehmich.wordpress.com
>
>
>
> On 5 April 2016 at 04:57, brajmohan saxena 
> 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

2016-04-05 Thread Mich Talebzadeh
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

hiveu...@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=AAEWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw
*



http://talebzadehmich.wordpress.com



On 5 April 2016 at 04:57, brajmohan saxena  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
>
>
>


Hive Metadata tables of a schema

2016-04-04 Thread brajmohan saxena
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