Skip to content

Commit 3edd436

Browse files
committed
Simplify session params handling
Address PR review comments by simplifying the session configuration logic. Always create a new map and copy existing params regardless of whether metric view metadata is enabled. This makes the code cleaner and more consistent: - No nil check needed (ranging over nil map is safe in Go) - Consistent behavior in all cases - More readable code Resolves reviewer comments from @vikrantpuppala, @copilot-pull-request-reviewer, and @gopalldb Signed-off-by: Shivam Raj <[email protected]>
1 parent 5a113cb commit 3edd436

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

connector.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,12 @@ func (c *connector) Connect(ctx context.Context) (driver.Conn, error) {
4343
}
4444

4545
// Prepare session configuration
46-
sessionParams := c.cfg.SessionParams
46+
sessionParams := make(map[string]string)
47+
for k, v := range c.cfg.SessionParams {
48+
sessionParams[k] = v
49+
}
50+
4751
if c.cfg.EnableMetricViewMetadata {
48-
// Make a copy of session params and add metric view metadata config
49-
if sessionParams == nil {
50-
sessionParams = make(map[string]string)
51-
} else {
52-
// Create a copy to avoid modifying the original
53-
paramsCopy := make(map[string]string, len(sessionParams)+1)
54-
for k, v := range sessionParams {
55-
paramsCopy[k] = v
56-
}
57-
sessionParams = paramsCopy
58-
}
5952
sessionParams["spark.sql.thriftserver.metadata.metricview.enabled"] = "true"
6053
}
6154

0 commit comments

Comments
 (0)