查询在执行前挂起(查询计划需要很长时间)

ohtdti5x  于 2021-06-26  发布在  Hive
关注(0)|答案(0)|浏览(221)

我试图执行下面的查询(在配置单元表上),但由于某些原因,它甚至在开始执行之前就挂起了。只是挂起后,我粘贴到repl,也没有出现在网页界面。
Spark壳的启动参数如下:

$ spark-shell --num-executors=10 --executor-cores=3 --executor-memory=16G --conf spark.sql.adaptive.enabled=true

testtable有一些记录,testtable\u stg有大约1亿条记录。查询中有15列,为了简化,我在这里只包含了6列。

{
     {
       spark.table("testtable_stg")
         .selectExpr(
           """md5(concat(coalesce(nullif(test1,'null'),'val'),
             coalesce(nullif(test2,'null'),'val'),
             coalesce(nullif(test3,'null'),'val'),
             coalesce(nullif(test4,'null'),'val'),
             cast(coalesce(test5,'2222-22-22') as date),
           )) as sk""",
           "coalesce(nullif(test1,'null'),'val') as test1",
           "coalesce(nullif(test2,'null'),'val') as test2",
           "coalesce(nullif(test3,'null'),'val') as test3",
           "coalesce(nullif(test4,'null'),'val') as test4",
           "cast(coalesce(test5,'2222-22-22') as date) as test5",
           "CAST(from_unixtime(unix_timestamp()) AS TIMESTAMP) as dt"
         )
     }.join(spark.table("testtable"), Seq("sk"), "leftanti")
       .write
       .format("parquet")
       .mode("Append")
       .saveAsTable("testtable")
}

当我把它粘贴到repl而不写的时候,就没事了。但是,当我想对这个df调用任何操作(即显示、保存)甚至解释计划时,它就会冻结。
我想我最终会找到运行此查询的解决方案。但我更感兴趣的是Spark行为,它只是挂起。我正在这个集群上运行数千个查询。但通常我会得到一些信息(如警告、错误等)。但在这个特定的查询中,它只是挂起。
更新
我开始从select语句中逐个删除列,最后得到了查询计划。列越少,生成查询计划的速度就越快。然而,对于所有的列来说,它需要很长时间,因为在执行查询之前,查询计划似乎已经生成了很长时间。有没有办法加快速度?我试着增加司机的记忆,但没有成功。我用的是spark 2.1和2.2。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题