emr-container pyspark作业无限期运行

j9per5c4  于 2022-12-22  发布在  Spark
关注(0)|答案(1)|浏览(149)

下面是我的Python脚本:

import calendar
import pydeequ
import boto3
import psycopg2
import os
import pyspark

from py4j import *
from pyspark.sql import SparkSession,Row
from pydeequ.profiles import *
from pydeequ.suggestions import *
from pydeequ.repository import *
from pydeequ.analyzers import *
from pyspark.sql import SparkSession
from botocore.config import Config
from datetime import datetime,timedelta,date
from pyspark.conf import SparkConf
from pydeequ.checks import *
from pydeequ.verification import *
from py4j.java_gateway import java_import

print(os.system("""pyspark --version"""))

spark = (SparkSession.builder \
        .appName('run_dq_for_xpertrak_pathtrak') \
        .enableHiveSupport() \
        .config(conf=SparkConf()) \
        .config("spark.jars.packages", pydeequ.deequ_maven_coord) \
        .config("spark.jars.excludes", pydeequ.f2j_maven_coord) \
        .getOrCreate())

java_import(spark._sc._jvm, "org.apache.spark.sql.*")

print('here---')
print(spark)

junk = spark.sql("""SELECT * FROM xpertrak.pathtrak LIMIT 10""")

print(junk)

在AWS emr-containers(即EMR on EKS)中,此作业成功运行,UI显示作业确实已完成。但是,当我在上面的脚本底部包含或附加以下代码行时,作业在技术上已完成(基于简单日志打印),但UI从未从运行状态更改...

print('checking')
check = Check(spark, level=CheckLevel.Warning, description="Data Validation Check")
checkResult = VerificationSuite(spark) \
    .onData(junk) \
    .addCheck(
        check.hasSize(lambda x: x >= 5000000)
    ).run()
print(checkResult)
print('check')

这是AWS控制台/UI的外观:

是什么导致了这种异常?

pprl5pva

pprl5pva1#

根据here中AWS提供的文档,添加以下内容成功结束作业:

spark.sparkContext._gateway.shutdown_callback_server()
spark.stop()

相关问题