
Answer-first summary for fast verification
Answer: The connection will be successful, and the `print` statement will output `[REDACTED]`.
The correct answer is **D**. Databricks provides built-in secret redaction. When `dbutils.secrets.get` is used, the actual secret value is retrieved and available for programmatic use (such as passing it into the JDBC driver options), which allows the connection to succeed. However, to prevent accidental exposure of sensitive data, Databricks automatically identifies secret values and redacts them from any notebook output, replacing them with `[REDACTED]`. * **Why A is incorrect:** The redirection is for display purposes only; it does not interfere with the functionality of the variable in the JDBC connection. * **Why B and D are incorrect:** Secrets are never printed in plain text in notebook results once retrieved via the secrets utility. * **Why C and E are incorrect:** `dbutils.secrets.get` does not trigger an interactive prompt; it fetches the value programmatically from the configured Secret Scope.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
A security team is migrating from hardcoded credentials to the Databricks Secrets utility for external database connections. They have already successfully uploaded the database password to a secret scope named db_creds with the key jdbc_password and granted the necessary permissions.
They update their notebook code as follows:
password = dbutils.secrets.get(scope="db_creds", key="jdbc_password")
print(password)
df = (spark.read
.format("jdbc")
.option("url", connection)
.option("dbtable", tablename)
.option("user", username)
.option("password", password)
.load())
password = dbutils.secrets.get(scope="db_creds", key="jdbc_password")
print(password)
df = (spark.read
.format("jdbc")
.option("url", connection)
.option("dbtable", tablename)
.option("user", username)
.option("password", password)
.load())
What is the outcome when this code block is executed?
A
The connection to the external table will fail, and the notebook output will display [REDACTED].
B
The connection will be successful, and the print statement will output the password as a plain text string.
C
An interactive input prompt will appear in the notebook requesting the password; if entered correctly, the password is then stored in DBFS.
D
The connection will be successful, and the print statement will output [REDACTED].
E
The notebook will trigger a prompt for the secret; upon entry, the connection succeeds and the password is shown in plain text.