Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not create empty table using execute query, NullPointerException. #257

Open
ghost opened this issue Nov 17, 2018 · 3 comments
Open

Can not create empty table using execute query, NullPointerException. #257

ghost opened this issue Nov 17, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Nov 17, 2018

Code:
val df = hive.executeQuery("CREATE TABLE default.test2 (dvc string) STORED AS ORC")

Exception:
java.lang.RuntimeException: java.io.IOException: shadehive.org.apache.hive.service.cli.HiveSQLException: java.io.IOException: java.lang.NullPointerException
  at com.hortonworks.spark.sql.hive.llap.HiveWarehouseDataSourceReader.readSchema(HiveWarehouseDataSourceReader.java:130)
  at org.apache.spark.sql.execution.datasources.v2.DataSourceV2Relation$.apply(DataSourceV2Relation.scala:56)
  at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:224)
  at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:164)
  at com.hortonworks.spark.sql.hive.llap.HiveWarehouseSessionImpl.executeQuery(HiveWarehouseSessionImpl.java:62)
  ... 165 elided
@AlusaChen
Copy link

you can try:

hive.executeUpdate("CREATE TABLE default.test2 (dvc string) STORED AS ORC")
val df = hive.table("default.test2")

or

hive.setDatabase("default")
hive.createTable("test2").column("dvc", "string").create()
val df = hive.table("default.test2")

@sdanielzafar
Copy link

sdanielzafar commented Apr 7, 2019

When I run this I get:

scala> val df = hive.table("test2")
19/04/07 16:08:09 ERROR HiveWarehouseDataSourceReader: Unable to read table schema
java.lang.RuntimeException: java.lang.IllegalArgumentException: Expected test2 to be in the form db.table

@mdrijwan123
Copy link

hive.executeQuery is for reading from the query. If you want to create table use queryUpdate. It's for Alter, Update, Create etc.

More details go to:
https://docs.cloudera.com/HDPDocuments/HDP3/HDP-3.1.5/integrating-hive/content/hive-read-write-operations.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants