Databricks dbutils抛出NullPointerException [英] Databricks dbutils throwing NullPointerException

查看:167
本文介绍了Databricks dbutils抛出NullPointerException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用databricks dbutils从Azure Key Vault读取机密,但遇到以下异常:

Trying to read secret from Azure Key Vault using databricks dbutils, but facing the following exception:

    OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0
Warning: Ignoring non-Spark config property: eventLog.rolloverIntervalSeconds
Exception in thread "main" java.lang.NullPointerException
    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 com.databricks.dbutils_v1.DBUtilsHolder$$anon$1.invoke(DBUtilsHolder.scala:17)

下面是代码段:

Object secret = DBUtilsHolder.dbutils().secrets().get("<scope>", "<key>");
System.out.println("secret " + secret.toString());

下面是pom:

<dependencies>
    <!-- https://mvnrepository.com/artifact/org.apache.spark/spark-core -->
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-core_2.11</artifactId>
      <version>2.4.5</version>
      <scope>provided</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.spark/spark-sql -->
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-sql_2.11</artifactId>
      <version>2.4.5</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.airlift</groupId>
      <artifactId>airline</artifactId>
      <version>0.8</version>
    </dependency>
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>1.18.12</version>
      <scope>provided</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.databricks/dbutils-api -->
    <dependency>
      <groupId>com.databricks</groupId>
      <artifactId>dbutils-api_2.11</artifactId>
      <version>0.0.4</version>
      <scope>provided</scope>
    </dependency>
<dependencies>

从Databricks作为火花提交作业运行时失败,但是在尝试使用Set Jar选项时起作用.

It failed when run from Databricks as spark-submit Job, but it worked when tried using Set Jar option.

推荐答案

根据

According to the documentation, Databricks Utilities are not available for spark-submit jobs. If you want to use Databricks Utilities, use JAR jobs instead.

这篇关于Databricks dbutils抛出NullPointerException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆