1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

sparksession経由でhiveにアクセスできない場合

Last updated at Posted at 2017-02-23
  • sparksession経由でhiveにアクセスできない
  • spark-shellからはsparksession経由ではアクセスできる.
  • 一般的な対処法は試した
    • hive-site.xmlを--filesオプションで設定する
    • sparkそのものはhive enableでbuildする
    • core-site.xml, hive-site.xml, hdfs-site.xmlはconf dirに配置
    • hive-site.xmlでは適切にmetastore urlを設定している

対処法は

spark.sql.catalogImplementation=hive

を明示的にsparkconfに設定する.

sparksession生成時に,enablehivesupportするだけではだめだった.

lazy val spark = {
    SparkSession
      .builder()
      .appName(s"${this.getClass.getSimpleName}")
      .config("spark.sql.warehouse.dir", "/user/hive/warehouse")
      .enableHiveSupport()
      .getOrCreate()
  }

↑だけでは,hiveにアクセスできず,下の実施してアクセスできた.

lazy val sc = {
    val conf = new SparkConf().setAppName(s"${this.getClass.getSimpleName} action=$action date: ${date.toString("yyyy-MM-dd")} hour: $hour")
    conf.set("spark.sql.catalogImplementation", "hive")
    val sc = new SparkContext(conf)
    sc
  }
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?