在 Spark SQL 中使用 Presto JDBC 时无法识别连接 属性 'url'

Unrecognized connection property 'url' when using Presto JDBC in Spark SQL

这是我的 spark sql 代码,我正在尝试根据本指南阅读 presto table; https://spark.apache.org/docs/latest/sql-data-sources-jdbc.html

 val df = spark.read
 .format("jdbc")
 .option("driver", "com.facebook.presto.jdbc.PrestoDriver")
 .option("url", "jdbc:presto://localhost:8889/mycatalog")
 .option("query", "select * from mydb.mytable limit 1")
 .option("user", "myuserid")
 .load()

我收到以下异常,unrecognized connection property 'url'

Exception in thread "main" java.sql.SQLException: Unrecognized connection property 'url'
at com.facebook.presto.jdbc.PrestoDriverUri.validateConnectionProperties(PrestoDriverUri.java:345)
at com.facebook.presto.jdbc.PrestoDriverUri.<init>(PrestoDriverUri.java:102)
at com.facebook.presto.jdbc.PrestoDriverUri.<init>(PrestoDriverUri.java:92)
at com.facebook.presto.jdbc.PrestoDriver.connect(PrestoDriver.java:87)
at org.apache.spark.sql.execution.datasources.jdbc.connection.BasicConnectionProvider.getConnection(BasicConnectionProvider.scala:49)
at org.apache.spark.sql.execution.datasources.jdbc.connection.ConnectionProvider$.create(ConnectionProvider.scala:68)
at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.$anonfun$createConnectionFactory(JdbcUtils.scala:62)
at org.apache.spark.sql.execution.datasources.jdbc.JDBCRDD$.resolveTable(JDBCRDD.scala:56)
at org.apache.spark.sql.execution.datasources.jdbc.JDBCRelation$.getSchema(JDBCRelation.scala:226)
at org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider.createRelation(JdbcRelationProvider.scala:35)
at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:354)
at org.apache.spark.sql.DataFrameReader.loadV1Source(DataFrameReader.scala:326)
at org.apache.spark.sql.DataFrameReader.$anonfun$load(DataFrameReader.scala:308)
at scala.Option.getOrElse(Option.scala:189)
at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:308)
at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:226)
at org.apache.spark.sql.DataFrameReader.jdbc(DataFrameReader.scala:341)

似乎此问题与 https://github.com/prestodb/presto/issues/9254  有关,其中 属性 url 在 Presto 中未被识别 属性,看起来需要修复火花方面?这个问题还有其他解决方法吗?

PS:

Spark Version: 3.1.1
presto-jdbc version: 0.245 

spark 或 presto 没有问题 JDBC driver。我不认为你指定的 URL 会起作用。

您应该将其更改为以下格式。

jdbc:presto://localhost:8889/mycatalog

更新

不确定它如何与 spark 版本 < 3 一起使用。作为解决方法,您可以使用 another jar where strict config check has been removed as specified here.

3.3 似乎修复了 spark 错误

https://issues.apache.org/jira/browse/SPARK-36163