You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Bernard Quizon <be...@cheetahdigital.com> on 2019/05/08 11:12:26 UTC

Embedded Hive Server Error on Table Creation

Hi,

So I'm using Hive 3.1.0 and I'm trying to get an embedded HiveServer2
instance to work but I'm running into an issue.

Here's my sample code:

System.setProperty("hive.execution.engine", "tez")
System.setProperty("javax.jdo.option.ConnectionURL",
"jdbc:derby:;databaseName=/tmp/hive/metastore_db;create=true")
System.setProperty("hive.metastore.warehouse.dir",
"file:////tmp/hive/warehouse")
System.setProperty("hive.metastore.metadb.dir",
"file:///tmp/hive/metastore_db")
System.setProperty("hive.metastore.local", "true")
System.setProperty("fs.defaultFS", "file:///")

val config = new HiveConf()
hiveServer2 = new HiveServer2()
hiveServer2.init(config)
hiveServer2.start()
Thread.sleep(5000)

Try(Class.forName("org.apache.hive.jdbc.HiveDriver"))

val hiveConnection = DriverManager.getConnection(s"jdbc:hive2:///", "", "")
val stmt = hiveConnection.createStatement
stmt.execute(s"CREATE DATABASE IF NOT EXISTS tmp")
 stmt.execute(
s"""|CREATE TABLE IF NOT EXISTS tmp.test_table(
      |  col1 STRING,
      |  col2 STRING
      |)
      |COMMENT 'test'
      |STORED AS ORC
      |TBLPROPERTIES ('transactional'='true')""".stripMargin
)

Here's the actual error I'm getting:

2019-05-08 19:02:55,147 WARN  [main] thrift.ThriftCLIService
(ThriftCLIService.java:ExecuteStatement(571)) - Error executing statement:
org.apache.hive.service.cli.HiveSQLException: Error while compiling
statement: FAILED: IllegalStateException Unexpected Exception thrown:
Unable to fetch table test_table. Exception thrown when executing query :
SELECT DISTINCT 'org.apache.hadoop.hive.metastore.model.MTable' AS
NUCLEUS_TYPE,A0.CREATE_TIME,A0.LAST_ACCESS_TIME,A0.OWNER,A0.OWNER_TYPE,A0.RETENTION,A0.IS_REWRITE_ENABLED,A0.TBL_NAME,A0.TBL_TYPE,A0.WRITE_ID,A0.TBL_ID
FROM TBLS A0 LEFT OUTER JOIN DBS B0 ON A0.DB_ID = B0.DB_ID WHERE
A0.TBL_NAME = ? AND B0."NAME" = ? AND B0.CTLG_NAME = ?
at
org.apache.hive.service.cli.operation.Operation.toSQLException(Operation.java:335)
at
org.apache.hive.service.cli.operation.SQLOperation.prepare(SQLOperation.java:199)
at
org.apache.hive.service.cli.operation.SQLOperation.runInternal(SQLOperation.java:262)
at org.apache.hive.service.cli.operation.Operation.run(Operation.java:247)
at
org.apache.hive.service.cli.session.HiveSessionImpl.executeStatementInternal(HiveSessionImpl.java:541)
at
org.apache.hive.service.cli.session.HiveSessionImpl.executeStatementAsync(HiveSessionImpl.java:527)
at
org.apache.hive.service.cli.CLIService.executeStatementAsync(CLIService.java:315)
at
org.apache.hive.service.cli.thrift.ThriftCLIService.ExecuteStatement(ThriftCLIService.java:562)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at
org.apache.hive.jdbc.HiveConnection$SynchronizedHandler.invoke(HiveConnection.java:1572)
at com.sun.proxy.$Proxy22.ExecuteStatement(Unknown Source)
at
org.apache.hive.jdbc.HiveStatement.runAsyncOnServer(HiveStatement.java:323)
at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:265)
at
com.cheetahdigital.hive.HiveEmbeddedServer$.main(HiveEmbeddedServer.scala:54)
at com.cheetahdigital.hive.HiveEmbeddedServer.main(HiveEmbeddedServer.scala)

It's throwing an exception whenever I create a table, creating a database
works.

Thanks,
Bernard