Skip to content

Commit 6750a33

Browse files
committed
SNOW-848033: backend prerelease version compatibility (#1641)
1 parent 5387b1b commit 6750a33

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ author_email = [email protected]
99
license = Apache-2.0
1010
license_files = LICENSE.txt, NOTICE
1111
classifiers =
12-
Development Status :: 5 - Production/Stable
12+
Development Status :: 4 - Beta
1313
Environment :: Console
1414
Environment :: Other Environment
1515
Intended Audience :: Developers

src/snowflake/connector/connection.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
from .telemetry_oob import TelemetryService
9999
from .time_util import HeartBeatTimer, get_time_millis
100100
from .util_text import construct_hostname, parse_account, split_statements
101+
from .version import VERSION
101102

102103
DEFAULT_CLIENT_PREFETCH_THREADS = 4
103104
MAX_CLIENT_PREFETCH_THREADS = 10
@@ -350,9 +351,19 @@ def __init__(
350351
self.__set_error_attributes()
351352
self.connect(**kwargs)
352353
self._telemetry = TelemetryClient(self._rest)
353-
354354
# get the imported modules from sys.modules
355355
self._log_telemetry_imported_packages()
356+
# in the future we won't need this if the backend supports prerelease versions
357+
self._log_telemetry(
358+
TelemetryData.from_telemetry_data_dict(
359+
from_dict={
360+
TelemetryField.KEY_IS_PRERELEASE.value: TelemetryData.FALSE
361+
if str(VERSION[2]).isdigit()
362+
else TelemetryData.TRUE
363+
},
364+
timestamp=get_time_millis(),
365+
)
366+
)
356367

357368
def __del__(self) -> None: # pragma: no cover
358369
try:

src/snowflake/connector/description.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from __future__ import annotations
99

1010
import platform
11+
import re
1112
import sys
1213

1314
from .version import VERSION
@@ -20,4 +21,10 @@
2021
COMPILER = platform.python_compiler()
2122

2223
CLIENT_NAME = "PythonConnector" # don't change!
23-
CLIENT_VERSION = ".".join([str(v) for v in VERSION[:3]])
24+
25+
# This is a short-term workaround for the backend to enable client side features for preview version, e.g. 3.1.0a1
26+
CLIENT_VERSION = (
27+
".".join([str(v) for v in VERSION[:3]])
28+
if str(VERSION[2]).isdigit()
29+
else f"{str(VERSION[0])}.{str(VERSION[1])}.{re.split('[ab]', str(VERSION[2]))[0]}"
30+
)

src/snowflake/connector/telemetry.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class TelemetryField(Enum):
5050
KEY_SQLSTATE = "sql_state"
5151
KEY_DRIVER_TYPE = "driver_type"
5252
KEY_DRIVER_VERSION = "driver_version"
53+
KEY_IS_PRERELEASE = "is_prerelease"
5354
KEY_REASON = "reason"
5455
KEY_VALUE = "value"
5556
KEY_EXCEPTION = "exception"

0 commit comments

Comments
 (0)