在试图获取高并发集群上的用户数据时,我面临着这个问题。我使用下面的命令获取用户详细信息
dbutils.notebook.entry_point.getDbutils().notebook().getContext().tags().apply('user')
下面是运行的错误日志。任何帮助都会很感激的。
Py4JError: An error occurred while calling o475.tags. Trace:
py4j.security.Py4JSecurityException: Method public scala.collection.immutable.Map com.databricks.backend.common.rpc.CommandContext.tags() is not whitelisted on class class com.databricks.backend.common.rpc.CommandContext
at py4j.security.WhitelistingPy4JSecurityManager.checkCall(WhitelistingPy4JSecurityManager.java:409)
at py4j.Gateway.invoke(Gateway.java:294)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.GatewayConnection.run(GatewayConnection.java:251)
at java.lang.Thread.run(Thread.java:748)发布于 2021-11-12 17:36:40
可以使用dbutils命令检索信息:
dbutils.notebook.entry_point.getDbutils().notebook().getContext().userName().get()发布于 2021-11-12 18:09:07
您可以使用以下代码:
import json
# parse x:
y = dbutils.notebook.entry_point.getDbutils().notebook().getContext().toJson()
res = json.loads(y)
print(res['tags']['user'])注:测试代码

发布于 2022-05-30 15:35:46
我一直在用这个:
user_id = spark.sql('select current_user() as user').collect()[0]['user']current_user()是数据库中的文档化SQL函数
https://stackoverflow.com/questions/63440056
复制相似问题