From d5be160af0ebcf0a63ba31a7eaa04d44b26401c3 Mon Sep 17 00:00:00 2001 From: Luis Moros <68286057+lmoros-DB@users.noreply.github.com> Date: Thu, 20 Jun 2024 15:34:15 -0400 Subject: [PATCH] community[patch]: Fix sql_databse.from_databricks issue when ran from Job (#23224) **Desscription**: When the ``sql_database.from_databricks`` is executed from a Workflow Job, the ``context`` object does not have a "browserHostName" property, resulting in an error. This change manages the error so the "DATABRICKS_HOST" env variable value is used instead of stoping the flow Co-authored-by: lmorosdb --- libs/community/langchain_community/utilities/sql_database.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/community/langchain_community/utilities/sql_database.py b/libs/community/langchain_community/utilities/sql_database.py index fa57ea60ff..dfc24ed626 100644 --- a/libs/community/langchain_community/utilities/sql_database.py +++ b/libs/community/langchain_community/utilities/sql_database.py @@ -201,10 +201,10 @@ class SQLDatabase: from dbruntime.databricks_repl_context import get_context context = get_context() + default_host = context.browserHostName except ImportError: - pass + default_host = None - default_host = context.browserHostName if context else None if host is None: host = get_from_env("host", "DATABRICKS_HOST", default_host)