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 <lmorosdb>
This commit is contained in:
Luis Moros 2024-06-20 15:34:15 -04:00 committed by GitHub
parent cd6812342e
commit d5be160af0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -201,10 +201,10 @@ class SQLDatabase:
from dbruntime.databricks_repl_context import get_context from dbruntime.databricks_repl_context import get_context
context = get_context() context = get_context()
default_host = context.browserHostName
except ImportError: except ImportError:
pass default_host = None
default_host = context.browserHostName if context else None
if host is None: if host is None:
host = get_from_env("host", "DATABRICKS_HOST", default_host) host = get_from_env("host", "DATABRICKS_HOST", default_host)