From b5679e8004707b7ca328807983466e8660baab51 Mon Sep 17 00:00:00 2001 From: Jeremy Cohen Date: Mon, 30 May 2022 13:38:26 +0200 Subject: [PATCH 1/4] Add invocation env to user agent string --- dbt/adapters/spark/connections.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dbt/adapters/spark/connections.py b/dbt/adapters/spark/connections.py index 59ceb9dd8..10c566dea 100644 --- a/dbt/adapters/spark/connections.py +++ b/dbt/adapters/spark/connections.py @@ -1,3 +1,5 @@ +import os + from contextlib import contextmanager import dbt.exceptions @@ -7,6 +9,7 @@ from dbt.events import AdapterLogger from dbt.utils import DECIMALS from dbt.adapters.spark import __version__ +from dbt.tracking import DBT_INVOCATION_ENV try: from TCLIService.ttypes import TOperationState as ThriftState @@ -409,9 +412,11 @@ def open(cls, connection): cls.validate_creds(creds, required_fields) dbt_spark_version = __version__.version + dbt_invocation_env = os.getenv(DBT_INVOCATION_ENV) or "manual" user_agent_entry = ( - f"dbt-labs-dbt-spark/{dbt_spark_version} (Databricks)" # noqa + f"dbt-labs-dbt-spark/{dbt_spark_version} (Databricks) {dbt_invocation_env}" # noqa ) + import ipdb; ipdb.set_trace() # http://simba.wpengine.com/products/Spark/doc/ODBC_InstallGuide/unix/content/odbc/hi/configuring/serverside.htm ssp = {f"SSP_{k}": f"{{{v}}}" for k, v in creds.server_side_parameters.items()} From 5737f8bd8d8eab9567fe169f0124ccc8349e9dc8 Mon Sep 17 00:00:00 2001 From: Jeremy Cohen Date: Fri, 3 Jun 2022 14:10:06 +0200 Subject: [PATCH 2/4] Consistency + fixups --- CHANGELOG.md | 3 +++ dbt/adapters/spark/connections.py | 5 +---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 961fe01a3..92e1c3195 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ ### Fixes - `adapter.get_columns_in_relation` (method) and `get_columns_in_relation` (macro) now return identical responses. The previous behavior of `get_columns_in_relation` (macro) is now represented by a new macro, `get_columns_in_relation_raw` ([#354](https://github.com/dbt-labs/dbt-spark/issues/354), [#355](https://github.com/dbt-labs/dbt-spark/pull/355)) +### Under the hood +- Add `DBT_INVOCATION_ENV` environment variable to ODBC user agent string + ## dbt-spark 1.1.0 (April 28, 2022) ### Features diff --git a/dbt/adapters/spark/connections.py b/dbt/adapters/spark/connections.py index 10c566dea..1d9ab2418 100644 --- a/dbt/adapters/spark/connections.py +++ b/dbt/adapters/spark/connections.py @@ -413,10 +413,7 @@ def open(cls, connection): dbt_spark_version = __version__.version dbt_invocation_env = os.getenv(DBT_INVOCATION_ENV) or "manual" - user_agent_entry = ( - f"dbt-labs-dbt-spark/{dbt_spark_version} (Databricks) {dbt_invocation_env}" # noqa - ) - import ipdb; ipdb.set_trace() + user_agent_entry = f"dbt-labs-dbt-spark/{dbt_spark_version} (Databricks) ({dbt_invocation_env})" # noqa # http://simba.wpengine.com/products/Spark/doc/ODBC_InstallGuide/unix/content/odbc/hi/configuring/serverside.htm ssp = {f"SSP_{k}": f"{{{v}}}" for k, v in creds.server_side_parameters.items()} From d3d9e1b8fb124ba47f4dddc858997957d9dd694a Mon Sep 17 00:00:00 2001 From: Jeremy Cohen Date: Fri, 3 Jun 2022 14:10:39 +0200 Subject: [PATCH 3/4] Changelog entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92e1c3195..49e030aba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ - `adapter.get_columns_in_relation` (method) and `get_columns_in_relation` (macro) now return identical responses. The previous behavior of `get_columns_in_relation` (macro) is now represented by a new macro, `get_columns_in_relation_raw` ([#354](https://github.com/dbt-labs/dbt-spark/issues/354), [#355](https://github.com/dbt-labs/dbt-spark/pull/355)) ### Under the hood -- Add `DBT_INVOCATION_ENV` environment variable to ODBC user agent string +- Add `DBT_INVOCATION_ENV` environment variable to ODBC user agent string ([#366](https://github.com/dbt-labs/dbt-spark/pull/366)) ## dbt-spark 1.1.0 (April 28, 2022) From 9ff32c6275a32b80b1a3eb00739a3a7f712aa3ac Mon Sep 17 00:00:00 2001 From: Jeremy Cohen Date: Tue, 7 Jun 2022 12:13:33 +0200 Subject: [PATCH 4/4] Try diff pattern --- dbt/adapters/spark/connections.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt/adapters/spark/connections.py b/dbt/adapters/spark/connections.py index 1d9ab2418..135463eb3 100644 --- a/dbt/adapters/spark/connections.py +++ b/dbt/adapters/spark/connections.py @@ -413,7 +413,7 @@ def open(cls, connection): dbt_spark_version = __version__.version dbt_invocation_env = os.getenv(DBT_INVOCATION_ENV) or "manual" - user_agent_entry = f"dbt-labs-dbt-spark/{dbt_spark_version} (Databricks) ({dbt_invocation_env})" # noqa + user_agent_entry = f"dbt-labs-dbt-spark/{dbt_spark_version} (Databricks, {dbt_invocation_env})" # noqa # http://simba.wpengine.com/products/Spark/doc/ODBC_InstallGuide/unix/content/odbc/hi/configuring/serverside.htm ssp = {f"SSP_{k}": f"{{{v}}}" for k, v in creds.server_side_parameters.items()}