Skip to content

Commit 24aac51

Browse files
authored
Merge branch 'main' into fix/ES-1804970-cloudfetch-stale-column-names
2 parents c8b7f1b + 3f115aa commit 24aac51

5 files changed

Lines changed: 81 additions & 12 deletions

File tree

connection.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,8 @@ func (c *conn) executeStatement(ctx context.Context, query string, args []driver
515515
req.Parameters = parameters
516516
}
517517

518+
req.EnforceEmbeddedSchemaCorrectness = c.cfg.EnforceEmbeddedSchemaCorrectness
519+
518520
// Add per-statement query tags if provided via context
519521
if queryTags := driverctx.QueryTagsFromContext(ctx); len(queryTags) > 0 {
520522
serialized := SerializeQueryTags(queryTags)

connector.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,15 @@ func WithEnableMetricViewMetadata(enable bool) ConnOption {
329329
}
330330
}
331331

332+
// WithEnforceEmbeddedSchemaCorrectness enables enforcement of embedded schema correctness
333+
// in query execution. When set to true, the server will enforce embedded schema correctness.
334+
// Default is false.
335+
func WithEnforceEmbeddedSchemaCorrectness(enforce bool) ConnOption {
336+
return func(c *config.Config) {
337+
c.EnforceEmbeddedSchemaCorrectness = enforce
338+
}
339+
}
340+
332341
// Setup of Oauth M2m authentication
333342
func WithClientCredentials(clientID, clientSecret string) ConnOption {
334343
return func(c *config.Config) {

internal/cli_service/cli_service.go

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/cli_service/thrift_field_id_test.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ import (
2020
func TestThriftFieldIdsAreWithinAllowedRange(t *testing.T) {
2121
const maxAllowedFieldID = 3329
2222

23+
allowedExceptions := map[int]bool{
24+
3353: true,
25+
}
26+
2327
// Get the directory of this test file
2428
_, filename, _, ok := runtime.Caller(0)
2529
if !ok {
@@ -30,7 +34,7 @@ func TestThriftFieldIdsAreWithinAllowedRange(t *testing.T) {
3034
testDir := filepath.Dir(filename)
3135
cliServicePath := filepath.Join(testDir, "cli_service.go")
3236

33-
violations, err := validateThriftFieldIDs(cliServicePath, maxAllowedFieldID)
37+
violations, err := validateThriftFieldIDs(cliServicePath, maxAllowedFieldID, allowedExceptions)
3438
if err != nil {
3539
t.Fatalf("Failed to validate thrift field IDs: %v", err)
3640
}
@@ -51,8 +55,9 @@ func TestThriftFieldIdsAreWithinAllowedRange(t *testing.T) {
5155
}
5256

5357
// validateThriftFieldIDs parses the cli_service.go file and extracts all thrift field IDs
54-
// to validate they are within the allowed range.
55-
func validateThriftFieldIDs(filePath string, maxAllowedFieldID int) ([]string, error) {
58+
// to validate they are within the allowed range. Field IDs listed in allowedExceptions
59+
// are permitted even if they exceed the maximum.
60+
func validateThriftFieldIDs(filePath string, maxAllowedFieldID int, allowedExceptions map[int]bool) ([]string, error) {
5661
file, err := os.Open(filePath) //nolint:gosec // G304: path is a test fixture, not user-controlled
5762
if err != nil {
5863
return nil, fmt.Errorf("failed to open file %s: %w", filePath, err)
@@ -84,7 +89,7 @@ func validateThriftFieldIDs(filePath string, maxAllowedFieldID int) ([]string, e
8489
continue
8590
}
8691

87-
if fieldID >= maxAllowedFieldID {
92+
if fieldID >= maxAllowedFieldID && !allowedExceptions[fieldID] {
8893
// Extract struct/field context from the line
8994
context := extractFieldContext(line)
9095
violation := fmt.Sprintf(

internal/config/config.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,15 @@ type UserConfig struct {
101101
// Telemetry configuration
102102
// Uses config overlay pattern: client > server > default.
103103
// Unset = check server feature flag; explicitly true/false overrides the server.
104-
EnableTelemetry ConfigValue[bool]
105-
TelemetryBatchSize int // 0 = use default (100)
106-
TelemetryFlushInterval time.Duration // 0 = use default (5s)
107-
TelemetryRetryCount int // -1 = use default (3); 0 = disable retries; set via telemetry_retry_count
108-
TelemetryRetryDelay time.Duration // 0 = use default (100ms); set via telemetry_retry_delay
109-
Transport http.RoundTripper
110-
UseLz4Compression bool
111-
EnableMetricViewMetadata bool
104+
EnableTelemetry ConfigValue[bool]
105+
TelemetryBatchSize int // 0 = use default (100)
106+
TelemetryFlushInterval time.Duration // 0 = use default (5s)
107+
TelemetryRetryCount int // -1 = use default (3); 0 = disable retries; set via telemetry_retry_count
108+
TelemetryRetryDelay time.Duration // 0 = use default (100ms); set via telemetry_retry_delay
109+
Transport http.RoundTripper
110+
UseLz4Compression bool
111+
EnableMetricViewMetadata bool
112+
EnforceEmbeddedSchemaCorrectness bool
112113
CloudFetchConfig
113114
}
114115

@@ -302,6 +303,13 @@ func ParseDSN(dsn string) (UserConfig, error) {
302303
ucfg.EnableMetricViewMetadata = enableMetricViewMetadata
303304
}
304305

306+
if enforceEmbeddedSchemaCorrectness, ok, err := params.extractAsBool("enforceEmbeddedSchemaCorrectness"); ok {
307+
if err != nil {
308+
return UserConfig{}, err
309+
}
310+
ucfg.EnforceEmbeddedSchemaCorrectness = enforceEmbeddedSchemaCorrectness
311+
}
312+
305313
// Telemetry parameters
306314
if enableTelemetry, ok, err := params.extractAsBool("enableTelemetry"); ok {
307315
if err != nil {

0 commit comments

Comments
 (0)