Why does the Spark user differ if using sparklyr from Spark SQL?

J15S
New Contributor III

My team uses a shared cluster. We've been having issues with spark_connect failing to work at times (can't easily reproduce). One thing I've recently noticed is that the Spark user through sparklyr seems to be set to the first person who connects to Spark on the (shared) cluster.

```

library(sparklyr)

sc <- spark_connect(method = "databricks")

DBI::dbGetQuery(sc, 'select current_user() as user')

```

which is not necessarily the same as user identified with Spark SQL in a notebook.

```

%sql

select current_user() as user

```

Is this a bug? Could this be causing Spark connection issues?