diff options
Diffstat (limited to 'co-purchase-analysis/src/main/scala/Main.scala')
-rw-r--r-- | co-purchase-analysis/src/main/scala/Main.scala | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/co-purchase-analysis/src/main/scala/Main.scala b/co-purchase-analysis/src/main/scala/Main.scala index ec113b3..8c3e907 100644 --- a/co-purchase-analysis/src/main/scala/Main.scala +++ b/co-purchase-analysis/src/main/scala/Main.scala @@ -75,15 +75,21 @@ object CoPurchaseAnalysis { * Configured SparkSession instance */ def createSparkSession(appName: String, master: String): SparkSession = { - SparkSession.builder + var session = SparkSession.builder .appName(appName) .config("spark.master", master) - .config("spark.hadoop.google.cloud.auth.service.account.enable", "true") - .config( - "spark.hadoop.google.cloud.auth.service.account.json.keyfile", - System.getenv("GOOGLE_APPLICATION_CREDENTIALS") - ) - .getOrCreate() + + val creds = System.getenv("GOOGLE_APPLICATION_CREDENTIALS") + if (creds != null) { + session + .config("spark.hadoop.google.cloud.auth.service.account.enable", "true") + .config( + "spark.hadoop.google.cloud.auth.service.account.json.keyfile", + creds + ) + } + + session.getOrCreate() } /** Parses a single line from the input file into an OrderProduct instance. |