How to set and get static variables from spark?

前端 未结 4 1323
孤独总比滥情好
孤独总比滥情好 2020-12-06 07:09

I have a class as this:

public class Test {
    private static String name;

    public static String getName() {
        return name;
    }

    public stati         


        
4条回答
  •  猫巷女王i
    2020-12-06 07:35

    I would like to add one more approach this makes sense only when if you have a few variables which cab ne passed in runtime as arguments.

    spark Configuration --> --conf "spark.executor.extraJavaOptions=-DcutomField=${value}" and when you need data in transformations you can call System.getProperty("cutomField");

    you can find more details here

    Note: above discussed does not make sense when we have a significant number of variables . in those cases, I would prefer @Daniel Langdon approaches.

提交回复
热议问题