Databricks dbutils lösen NullPointerException aus

Oct 07 2020

Der Versuch, mithilfe von Databricks dbutils das Geheimnis von Azure Key Vault zu lesen, hat jedoch die folgende Ausnahme:

    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)

Unten ist das Code-Snippet:

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

Unten ist der 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>

Es schlug fehl, wenn es von Databricks als Spark-Submit-Job ausgeführt wurde, aber es funktionierte, wenn versucht wurde, die Option Set Jar zu verwenden.

Antworten

marat Oct 12 2020 at 03:30

Laut Dokumentation sind Databricks Utilities nicht für Spark-Submit-Jobs verfügbar. Wenn Sie Databricks Utilities verwenden möchten, verwenden Sie stattdessen JAR-Jobs.