What is the difference between hive jdbc client and hive metastore java api

Hi guys, I used hive jdbc, but after that I found out that there is a hive metastore java api ( here ), through which you can connect to the hive again and manipulate the database of bushes

But I was wondering what is the difference between these two ways.

Sorry if you ask for something obvious, but any information would be much appreciated.

+6
source share
2 answers

As far as I understand, there are two ways to connect to Hive

  • using a bush metadata server, which then connects in the background to relational db, such as mysql, to manifest the schema. This is usually done on port 9083.
  • a hive jdbc server called HiveServer2 that runs on port 10001, usually ...

Now, in earlier versions of the bush, hiveserver2 was not so stable before, and in fact support for multithreading was also limited. I would suggest that this arena may have improved.

So, for the JDBC api - yes, this will allow you to communicate using JDBC and sql.

There are apparently 2 functions for linking the metastor.

  • to execute SQL queries - DML
  • to perform DDL operations.

DDL -

for DDL, the metastore API is useful, org.apache.hadoop.hive.metastore.HiveMetaStoreClient HiveMetaStoreClient can be used for this purpose

DML -

what I found useful in this regard is org.apache.hadoop.hive.ql.Driver https://hive.apache.org/javadocs/r0.13.1/api/ql/org/apache/hadoop/hive/ ql / Driver.html hive.ql.Driver class This class has a method called run() that allows you to execute an SQL statement and return a result. eg. you can do the following

 Driver driver = new Driver(hiveConf); HiveMetaStoreClient client = new HiveMetaStoreClient(hiveConf); SessionState.start(new CliSessionState(hiveConf)); driver.run("select * from employee); // DDL example client.dropTable(db, table); 
+6
source

the hive metastor, as the name indicates, is the repository for the hive db metadata. This store is usually an RDBMS. Metastore api supports interaction with RDBMS to mess around / set up metadata, not actual dive / data data. For normal use, you will never want / will not use these. I think they are intended for people working on creating tool kits for working with the metastore, and not for everyday use.

+1
source

Source: https://habr.com/ru/post/975871/


All Articles