Skip to content

Commit

Permalink
try
Browse files Browse the repository at this point in the history
  • Loading branch information
cloud-fan committed Feb 13, 2025
1 parent 0a10232 commit dee71fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,12 @@ private List<String> buildPySparkShellCommand(Map<String, String> env) throws IO
if (remoteStr != null) {
env.put("SPARK_REMOTE", remoteStr);
env.put("SPARK_CONNECT_MODE_ENABLED", "1");
} else if (conf.getOrDefault(
SparkLauncher.SPARK_API_MODE, "classic").toLowerCase(Locale.ROOT).equals("connect") &&
masterStr != null) {
env.put("SPARK_REMOTE", masterStr);
env.put("SPARK_CONNECT_MODE_ENABLED", "1");
} else {
String defaultApiMode = "1".equals(System.getenv("SPARK_CONNECT_MODE")) ? "connect" : "classic";
String apiMode = conf.getOrDefault(SparkLauncher.SPARK_API_MODE, defaultApiMode).toLowerCase(Locale.ROOT);
if (apiMode.equals("connect")) {
env.put("SPARK_CONNECT_MODE_ENABLED", "1");
}
}

if (!isEmpty(pyOpts)) {
Expand Down
6 changes: 5 additions & 1 deletion python/pyspark/sql/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,11 @@ def getOrCreate(self) -> "SparkSession":
from pyspark.core.context import SparkContext

with self._lock:
is_api_mode_connect = opts.get("spark.api.mode", "classic").lower() == "connect"
default_api_mode = "classic"
if os.environ["SPARK_CONNECT_MODE"] == "1":
default_api_mode = "connect"

is_api_mode_connect = opts.get("spark.api.mode", default_api_mode).lower() == "connect"

if (
"SPARK_CONNECT_MODE_ENABLED" in os.environ
Expand Down

0 comments on commit dee71fc

Please sign in to comment.