Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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: 2 additions & 0 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,8 @@ func (c *conn) executeStatement(ctx context.Context, query string, args []driver
req.Parameters = parameters
}

req.EnforceEmbeddedSchemaCorrectness = c.cfg.EnforceEmbeddedSchemaCorrectness

// Add per-statement query tags if provided via context
if queryTags := driverctx.QueryTagsFromContext(ctx); len(queryTags) > 0 {
serialized := SerializeQueryTags(queryTags)
Expand Down
9 changes: 9 additions & 0 deletions connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,15 @@ func WithEnableMetricViewMetadata(enable bool) ConnOption {
}
}

// WithEnforceEmbeddedSchemaCorrectness enables enforcement of embedded schema correctness
// in query execution. When set to true, the server will enforce embedded schema correctness.
// Default is false.
func WithEnforceEmbeddedSchemaCorrectness(enforce bool) ConnOption {
return func(c *config.Config) {
c.EnforceEmbeddedSchemaCorrectness = enforce
}
}

// Setup of Oauth M2m authentication
func WithClientCredentials(clientID, clientSecret string) ConnOption {
return func(c *config.Config) {
Expand Down
45 changes: 45 additions & 0 deletions internal/cli_service/cli_service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions internal/cli_service/thrift_field_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import (
func TestThriftFieldIdsAreWithinAllowedRange(t *testing.T) {
const maxAllowedFieldID = 3329

allowedExceptions := map[int]bool{
3353: true,
}

// Get the directory of this test file
_, filename, _, ok := runtime.Caller(0)
if !ok {
Expand All @@ -30,7 +34,7 @@ func TestThriftFieldIdsAreWithinAllowedRange(t *testing.T) {
testDir := filepath.Dir(filename)
cliServicePath := filepath.Join(testDir, "cli_service.go")

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

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

if fieldID >= maxAllowedFieldID {
if fieldID >= maxAllowedFieldID && !allowedExceptions[fieldID] {
// Extract struct/field context from the line
context := extractFieldContext(line)
violation := fmt.Sprintf(
Expand Down
24 changes: 16 additions & 8 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,15 @@ type UserConfig struct {
// Telemetry configuration
// Uses config overlay pattern: client > server > default.
// Unset = check server feature flag; explicitly true/false overrides the server.
EnableTelemetry ConfigValue[bool]
TelemetryBatchSize int // 0 = use default (100)
TelemetryFlushInterval time.Duration // 0 = use default (5s)
TelemetryRetryCount int // -1 = use default (3); 0 = disable retries; set via telemetry_retry_count
TelemetryRetryDelay time.Duration // 0 = use default (100ms); set via telemetry_retry_delay
Transport http.RoundTripper
UseLz4Compression bool
EnableMetricViewMetadata bool
EnableTelemetry ConfigValue[bool]
TelemetryBatchSize int // 0 = use default (100)
TelemetryFlushInterval time.Duration // 0 = use default (5s)
TelemetryRetryCount int // -1 = use default (3); 0 = disable retries; set via telemetry_retry_count
TelemetryRetryDelay time.Duration // 0 = use default (100ms); set via telemetry_retry_delay
Transport http.RoundTripper
UseLz4Compression bool
EnableMetricViewMetadata bool
EnforceEmbeddedSchemaCorrectness bool
CloudFetchConfig
}

Expand Down Expand Up @@ -302,6 +303,13 @@ func ParseDSN(dsn string) (UserConfig, error) {
ucfg.EnableMetricViewMetadata = enableMetricViewMetadata
}

if enforceEmbeddedSchemaCorrectness, ok, err := params.extractAsBool("enforceEmbeddedSchemaCorrectness"); ok {
if err != nil {
return UserConfig{}, err
}
ucfg.EnforceEmbeddedSchemaCorrectness = enforceEmbeddedSchemaCorrectness
}

// Telemetry parameters
if enableTelemetry, ok, err := params.extractAsBool("enableTelemetry"); ok {
if err != nil {
Expand Down
Loading