Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion csharp/src/DatabricksParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ public class DatabricksParameters : SparkParameters
/// <summary>
/// Whether to enable the feature flag cache for fetching remote configuration from the server.
/// When enabled, the driver fetches feature flags from the Databricks server and merges them with local properties.
/// Default value is true if not specified.
/// Default value is false if not specified.
/// </summary>
public const string FeatureFlagCacheEnabled = "adbc.databricks.feature_flag_cache_enabled";

Expand Down
6 changes: 3 additions & 3 deletions csharp/src/FeatureFlagCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ public async Task<IReadOnlyDictionary<string, string>> MergePropertiesWithFeatur

try
{
// Check if feature flag cache is enabled (default: true)
if (localProperties.TryGetValue(DatabricksParameters.FeatureFlagCacheEnabled, out string? enabledStr) &&
bool.TryParse(enabledStr, out bool enabled) &&
// Check if feature flag cache is enabled (default: false)
if (!localProperties.TryGetValue(DatabricksParameters.FeatureFlagCacheEnabled, out string? enabledStr) ||
!bool.TryParse(enabledStr, out bool enabled) ||
!enabled)
{
activity?.AddEvent(new ActivityEvent("feature_flags.skipped",
Expand Down
58 changes: 58 additions & 0 deletions csharp/test/Unit/FeatureFlagCacheTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,64 @@ public async Task FeatureFlagContext_BackgroundRefreshError_ContinuesRefreshLoop

#endregion

#region MergePropertiesWithFeatureFlagsAsync Default Behavior Tests

[Fact]
public async Task MergePropertiesWithFeatureFlagsAsync_PropertyNotSet_ReturnsLocalProperties()
{
// Arrange - No FeatureFlagCacheEnabled property set (default: false)
var localProperties = new Dictionary<string, string>
{
["host"] = TestHost,
["some_property"] = "some_value"
};
var cache = FeatureFlagCache.GetInstance();

// Act
var result = await cache.MergePropertiesWithFeatureFlagsAsync(localProperties, DriverVersion);

// Assert - Should return local properties unchanged (feature flags skipped)
Assert.Same(localProperties, result);
}

[Fact]
public async Task MergePropertiesWithFeatureFlagsAsync_PropertySetToFalse_ReturnsLocalProperties()
{
// Arrange - FeatureFlagCacheEnabled explicitly set to false
var localProperties = new Dictionary<string, string>
{
["host"] = TestHost,
[DatabricksParameters.FeatureFlagCacheEnabled] = "false"
};
var cache = FeatureFlagCache.GetInstance();

// Act
var result = await cache.MergePropertiesWithFeatureFlagsAsync(localProperties, DriverVersion);

// Assert - Should return local properties unchanged (feature flags skipped)
Assert.Same(localProperties, result);
}

[Fact]
public async Task MergePropertiesWithFeatureFlagsAsync_PropertySetToInvalidValue_ReturnsLocalProperties()
{
// Arrange - FeatureFlagCacheEnabled set to a non-boolean value
var localProperties = new Dictionary<string, string>
{
["host"] = TestHost,
[DatabricksParameters.FeatureFlagCacheEnabled] = "notabool"
};
var cache = FeatureFlagCache.GetInstance();

// Act
var result = await cache.MergePropertiesWithFeatureFlagsAsync(localProperties, DriverVersion);

// Assert - Should return local properties unchanged (can't parse as bool)
Assert.Same(localProperties, result);
}

#endregion

#region Helper Methods

/// <summary>
Expand Down
Loading