有什么方法可以针对 AWS Glue 运行本地主 Spark SQL 查询吗?
在我的本地电脑上启动此代码:
SparkSession.builder()
.master("local")
.enableHiveSupport()
.config("hive.metastore.client.factory.class", "com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory")
.getOrCreate()
.sql("show databases"); // this query isn't running against AWS Glue
编辑 根据一些示例,似乎
hive.metastore.uris
配置键应该允许指定特定的元存储 url,但是,尚不清楚如何获取glue的相关值
SparkSession.builder()
.master("local")
.enableHiveSupport()
.config("hive.metastore.client.factory.class", "com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory")
.config("hive.metastore.uris", "thrift://???:9083")
.getOrCreate()
.sql("show databases"); // this query isn't running against AWS Glue
亚马逊提供的这个客户端应该可以解决问题。 (还没试过)
https://github.com/awslabs/aws-glue-data-catalog-client-for-apache-hive-metastore
要使用 AWS Glue 元数据存储通过远程 AWS S3 在本地运行 Spark,请按照我在成功构建和测试修补的 Hive 库和相关 AWS Glue 类后为社区创建的这些发行说明(如 Ophir 在之前的文章中所建议的)发帖)。
我已经共享了预构建的 JAR,因此您不必自己动手。但你可以,我鼓励你这样做。
确保
sha512sum
命令成功。
cd /tmp
wget https://github.com/jirislav/aws-glue-data-catalog-client-for-apache-hive-metastore/releases/download/spark-3.3.0/spark-3.3.0-jars.zip
sha512sum -c <(curl -sL https://github.com/jirislav/aws-glue-data-catalog-client-for-apache-hive-metastore/releases/download/spark-3.3.0/spark-3.3.0-jars.zip.sha512)
cd "$SPARK_HOME/jars"
unzip /tmp/spark-3.3.0-jars.zip
最后按照发行说明中的讨论调整
SPARK_CONF_DIR
。