From 0f2cac126deb1b8c1666e207e75f9786863fcfdc Mon Sep 17 00:00:00 2001 From: Matt Topol Date: Wed, 7 Feb 2024 12:16:12 -0500 Subject: [PATCH 1/6] chore(snowflake): add '[ADBC]' to snowflake application name --- go/adbc/driver/snowflake/snowflake_database.go | 3 +++ python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py | 1 + 2 files changed, 4 insertions(+) diff --git a/go/adbc/driver/snowflake/snowflake_database.go b/go/adbc/driver/snowflake/snowflake_database.go index 7b76fa5a5a..fb04d201c8 100644 --- a/go/adbc/driver/snowflake/snowflake_database.go +++ b/go/adbc/driver/snowflake/snowflake_database.go @@ -265,6 +265,9 @@ func (d *databaseImpl) SetOptions(cnOptions map[string]string) error { } d.cfg.ClientTimeout = dur case OptionApplicationName: + if !strings.HasPrefix(v, "[ADBC]") { + v = "[ADBC][Go]" + v + } d.cfg.Application = v case OptionSSLSkipVerify: switch v { diff --git a/python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py b/python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py index 701de23e3b..ce586d9d7a 100644 --- a/python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py +++ b/python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py @@ -131,6 +131,7 @@ def connect( kwargs = (db_kwargs or {}).copy() if uri is not None: kwargs["uri"] = uri + kwargs[DatabaseOptions.APPLICATION_NAME] = "[ADBC][Python]" + kwargs.get(DatabaseOptions.APPLICATION_NAME, "") return adbc_driver_manager.AdbcDatabase(driver=_driver_path(), **kwargs) From 6aad000511f4c103196c709c3336ed284575b0eb Mon Sep 17 00:00:00 2001 From: Matt Topol Date: Wed, 7 Feb 2024 12:26:22 -0500 Subject: [PATCH 2/6] don't override modify user's choice --- python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py b/python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py index ce586d9d7a..53d1f6bc4f 100644 --- a/python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py +++ b/python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py @@ -131,7 +131,7 @@ def connect( kwargs = (db_kwargs or {}).copy() if uri is not None: kwargs["uri"] = uri - kwargs[DatabaseOptions.APPLICATION_NAME] = "[ADBC][Python]" + kwargs.get(DatabaseOptions.APPLICATION_NAME, "") + kwargs.setdefault(DatabaseOptions.APPLICATION_NAME, "[ADBC][Python]") return adbc_driver_manager.AdbcDatabase(driver=_driver_path(), **kwargs) From fcdbf1e69fc1428921800293f471246685cc697d Mon Sep 17 00:00:00 2001 From: Matt Topol Date: Wed, 7 Feb 2024 12:31:44 -0500 Subject: [PATCH 3/6] add default application name --- go/adbc/driver/snowflake/snowflake_database.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/go/adbc/driver/snowflake/snowflake_database.go b/go/adbc/driver/snowflake/snowflake_database.go index fb04d201c8..979f0d2111 100644 --- a/go/adbc/driver/snowflake/snowflake_database.go +++ b/go/adbc/driver/snowflake/snowflake_database.go @@ -176,6 +176,10 @@ func (d *databaseImpl) SetOptions(cnOptions map[string]string) error { } } + // set default application name to track + // unless user overrides it + d.cfg.Application = "[ADBC][Go]" + var err error for k, v := range cnOptions { v := v // copy into loop scope From e97faff8ed6f57b242cd4d0d22f03a78e6882dd9 Mon Sep 17 00:00:00 2001 From: Matt Topol Date: Wed, 7 Feb 2024 12:47:44 -0500 Subject: [PATCH 4/6] fix prefix add version --- go/adbc/driver/snowflake/snowflake_database.go | 5 +++-- .../adbc_driver_snowflake/adbc_driver_snowflake/__init__.py | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/go/adbc/driver/snowflake/snowflake_database.go b/go/adbc/driver/snowflake/snowflake_database.go index 979f0d2111..76ab4684bf 100644 --- a/go/adbc/driver/snowflake/snowflake_database.go +++ b/go/adbc/driver/snowflake/snowflake_database.go @@ -176,9 +176,10 @@ func (d *databaseImpl) SetOptions(cnOptions map[string]string) error { } } + defaultAppName := "[ADBC][Go-" + infoDriverVersion + "]" // set default application name to track // unless user overrides it - d.cfg.Application = "[ADBC][Go]" + d.cfg.Application = defaultAppName var err error for k, v := range cnOptions { @@ -270,7 +271,7 @@ func (d *databaseImpl) SetOptions(cnOptions map[string]string) error { d.cfg.ClientTimeout = dur case OptionApplicationName: if !strings.HasPrefix(v, "[ADBC]") { - v = "[ADBC][Go]" + v + v = defaultAppName + v } d.cfg.Application = v case OptionSSLSkipVerify: diff --git a/python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py b/python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py index 53d1f6bc4f..8dfdaead31 100644 --- a/python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py +++ b/python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py @@ -131,7 +131,10 @@ def connect( kwargs = (db_kwargs or {}).copy() if uri is not None: kwargs["uri"] = uri - kwargs.setdefault(DatabaseOptions.APPLICATION_NAME, "[ADBC][Python]") + appname = kwargs.get(DatabaseOptions.APPLICATION_NAME.value, "") + kwargs[DatabaseOptions.APPLICATION_NAME.value] = ( + f"[ADBC][Python-{__version__}]" + appname + ) return adbc_driver_manager.AdbcDatabase(driver=_driver_path(), **kwargs) From 7d82a5785a3d5bd8a41ca382ffae301e641234f9 Mon Sep 17 00:00:00 2001 From: Matt Topol Date: Wed, 7 Feb 2024 12:50:58 -0500 Subject: [PATCH 5/6] Update python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py Co-authored-by: David Li --- python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py b/python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py index 8dfdaead31..e1bdb6ebd4 100644 --- a/python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py +++ b/python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py @@ -133,7 +133,7 @@ def connect( kwargs["uri"] = uri appname = kwargs.get(DatabaseOptions.APPLICATION_NAME.value, "") kwargs[DatabaseOptions.APPLICATION_NAME.value] = ( - f"[ADBC][Python-{__version__}]" + appname + f"[ADBC][Python-{__version__}]{appname}" ) return adbc_driver_manager.AdbcDatabase(driver=_driver_path(), **kwargs) From 8c9cc0f72437eac8c80dcc3c08f3d9bdcf280ab3 Mon Sep 17 00:00:00 2001 From: Matt Topol Date: Wed, 7 Feb 2024 12:55:10 -0500 Subject: [PATCH 6/6] lint --- .../adbc_driver_snowflake/adbc_driver_snowflake/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py b/python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py index e1bdb6ebd4..19b3bbc18e 100644 --- a/python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py +++ b/python/adbc_driver_snowflake/adbc_driver_snowflake/__init__.py @@ -132,9 +132,9 @@ def connect( if uri is not None: kwargs["uri"] = uri appname = kwargs.get(DatabaseOptions.APPLICATION_NAME.value, "") - kwargs[DatabaseOptions.APPLICATION_NAME.value] = ( - f"[ADBC][Python-{__version__}]{appname}" - ) + kwargs[ + DatabaseOptions.APPLICATION_NAME.value + ] = f"[ADBC][Python-{__version__}]{appname}" return adbc_driver_manager.AdbcDatabase(driver=_driver_path(), **kwargs)