@@ -44,7 +44,7 @@ func (c *connector) Connect(ctx context.Context) (driver.Conn, error) {
4444 protocolVersion := int64 (c .cfg .ThriftProtocolVersion )
4545 session , err := tclient .OpenSession (ctx , & cli_service.TOpenSessionReq {
4646 ClientProtocolI64 : & protocolVersion ,
47- Configuration : make ( map [ string ] string ) ,
47+ Configuration : c . cfg . SessionParams ,
4848 InitialNamespace : & cli_service.TNamespace {
4949 CatalogName : catalogName ,
5050 SchemaName : schemaName ,
@@ -65,14 +65,6 @@ func (c *connector) Connect(ctx context.Context) (driver.Conn, error) {
6565
6666 log .Info ().Msgf ("connect: host=%s port=%d httpPath=%s serverProtocolVersion=0x%X" , c .cfg .Host , c .cfg .Port , c .cfg .HTTPPath , session .ServerProtocolVersion )
6767
68- for k , v := range c .cfg .SessionParams {
69- setStmt := fmt .Sprintf ("SET `%s` = `%s`;" , k , v )
70- _ , err := conn .ExecContext (ctx , setStmt , []driver.NamedValue {})
71- if err != nil {
72- return nil , dbsqlerrint .NewExecutionError (ctx , fmt .Sprintf ("error setting session param: %s" , setStmt ), err , nil )
73- }
74- log .Info ().Msgf ("set session parameter: param=%s value=%s" , k , v )
75- }
7668 return conn , nil
7769}
7870
@@ -215,8 +207,7 @@ func WithUserAgentEntry(entry string) ConnOption {
215207 }
216208}
217209
218- // Sessions params will be set upon opening the session by calling SET function.
219- // If using connection pool, session params can avoid successive calls of "SET ..."
210+ // Session parameters are passed directly in TOpenSessionReq.Configuration during session creation.
220211func WithSessionParams (params map [string ]string ) ConnOption {
221212 return func (c * config.Config ) {
222213 for k , v := range params {
0 commit comments