gpt4 book ai didi

apache-spark - spark.table 失败,java.io.Exception : No FileSystem for Scheme: abfs

转载 作者:行者123 更新时间:2023-12-03 14:48:56 27 4
gpt4 key购买 nike

我们有一个自定义文件系统类,它是 hadoop.fs.FileSystem 的扩展。该文件系统的 uri 方案为 abfs:///。已在此数据上创建了外部配置单元表。

CREATE EXTERNAL TABLE testingCustomFileSystem (a string, b int, c double) PARTITIONED BY dt
STORED AS PARQUET
LOCATION 'abfs://<host>:<port>/user/name/path/to/data/'

使用 loginbeeline,我可以查询表并获取结果。

现在我正在尝试使用 spark.table('testingCustomFileSystem') 将同一个表加载到 spark 数据帧中,它会抛出以下异常
    java.io.IOException: No FileSystem for scheme: abfs
at org.apache.hadoop.fs.FileSystem.getFileSystemClass(FileSystem.java:2586)
at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2593)
at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:91)
at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2632)
at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2614)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:370)
at org.apache.hadoop.fs.Path.getFileSystem(Path.java:296)
at org.apache.spark.sql.execution.datasources.CatalogFileIndex$$anonfun$2.apply(CatalogFileIndex.scala:77)
at org.apache.spark.sql.execution.datasources.CatalogFileIndex$$anonfun$2.apply(CatalogFileIndex.scala:75)
at scala.collection.immutable.Stream.map(Stream.scala:418)

包含 CustomFileSystem(定义 abfs://方案)的 jar 已加载到类路径中并且也可用。

spark.table 如何解析元存储中的 hive 表定义并解析 uri?。

最佳答案

在查看spark中的配置后,我偶然注意到通过设置以下hadoop配置,我能够解决。

hadoopConfiguration.set("fs.abfs.impl",<fqcn of the FileSystemImplementation>)

在 Spark 中,此设置是在 sparkSession 创建期间完成的(仅使用 appName 和

喜欢
val spark = SparkSession
.builder()
.setAppName("Name")
.setMaster("yarn")
.getOrCreate()

spark.sparkContext
.hadoopConfiguration.set("fs.abfs.impl",<fqcn of the FileSystemImplementation>)

它奏效了!

关于apache-spark - spark.table 失败,java.io.Exception : No FileSystem for Scheme: abfs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55910776/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com