Ejemplo n.º 1
0
def CreateSparkSession(master,
                       appname,
                       configofk=None,
                       configofv=None,
                       conf=None):
    '''
    master: 指定master URL地址,可以是本地local,或者spark,或mesos等。
    appname: 应用程序命名。
    configofk: 指定要设置的参数,如:"spark.eventLog.enabled"
    configofv: 指定要设置参数的值,可以是布尔值,数值等,具体参数设置可参考:https://spark.apache.org/docs/latest/configuration.html。
    conf: 传入SparkConf()形式的参数。
    '''
    global spark
    spark = SparkSession.master(master).builder.appName(appname).config(
        configofk, configofv, conf).getOrCreate()
    return spark