Skip to content

Commit 6f47cbf

Browse files
committed
changed flag value to be of any type
Signed-off-by: Sai Shree Pradhan <saishree.pradhan@databricks.com>
1 parent 4735329 commit 6f47cbf

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/databricks/sql/common/feature_flag.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def _is_refresh_needed(self) -> bool:
7676
)
7777
return time.monotonic() > refresh_threshold
7878

79-
def is_feature_enabled(self, name: str, default_value: bool) -> bool:
79+
def get_flag_value(self, name: str, default_value: Any) -> Any:
8080
"""
8181
Checks if a feature is enabled.
8282
- BLOCKS on the first call until flags are fetched.
@@ -95,10 +95,7 @@ def is_feature_enabled(self, name: str, default_value: bool) -> bool:
9595
assert self._flags is not None
9696

9797
# Now, return the value from the populated cache.
98-
flag_value = self._flags.get(name)
99-
if flag_value is None:
100-
return default_value
101-
return flag_value.lower() == "true"
98+
return self._flags.get(name, default_value)
10299

103100
def _refresh_flags(self):
104101
"""Performs a synchronous network request to fetch and update flags."""

src/databricks/sql/telemetry/telemetry_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,10 @@ def is_telemetry_enabled(connection: "Connection") -> bool:
110110

111111
if connection.enable_telemetry:
112112
context = FeatureFlagsContextFactory.get_instance(connection)
113-
return context.is_feature_enabled(
113+
flag_value = context.get_flag_value(
114114
TelemetryHelper.TELEMETRY_FEATURE_FLAG_NAME, default_value=False
115115
)
116+
return str(flag_value).lower() == "true"
116117
else:
117118
return False
118119

0 commit comments

Comments
 (0)