【发布时间】:2022-01-24 20:01:23
【问题描述】:
有什么方法可以在 spark 中设置 presto 的会话参数,同时从中构建 Dataframe。
public Dataset<Row> readPrestoTbl(){
Dataset<Row> stgTblDF = sparksession
.read()
.jdbc(dcrIdentity.getProperty(env + "." + "presto_url")
+ "?SSL="
+ dcrIdentity.getProperty(env + "."
+ "presto_client_SSL"), demoLckQuery, getDBProperties());
}
private Properties getDBProperties() {
Properties dbProperties = new Properties();
dbProperties.put("user", prestoCredentials.getUsername());
dbProperties.put("password", prestoCredentials.getPassword());
dbProperties.put("Driver", "io.prestosql.jdbc.PrestoDriver");
dbProperties.put("task.max-worker-threads", "10");
return dbProperties;
}
我设置 task.max-worker-threads 这个属性的方式是有任何选项来设置会话属性,例如 required_workers_count 或 query_max_run_time 等。
我也尝试了以下选项,但每次都显示无法识别的连接属性“sessionProperties”。
在添加属性时
dbProperties.put("sessionProperties","task.max-worker-threads:10");
在 spark 中加载时
.option("sessionProperties", "task.max-worker-threads:10")
【问题讨论】:
-
不,关于 url 属性的问题,对我来说很好用.. 我的是会话属性.. url 有点复杂
-
那么,请不要遗漏所有信息(日志,Spark版本,Trino服务器版本,代码等)。我无法使用 350 JDBC 驱动程序重现。
标签: apache-spark apache-spark-sql presto trino presto-jdbc