@@ -636,4 +636,49 @@ describe('DBSQLClient.enableMetricViewMetadata', () => {
636636 'spark.sql.thriftserver.metadata.metricview.enabled' : 'true' ,
637637 } ) ;
638638 } ) ;
639+
640+ it ( 'should serialize queryTags dict and set in session configuration' , async ( ) => {
641+ const client = new DBSQLClient ( ) ;
642+ const thriftClient = new ThriftClientStub ( ) ;
643+ sinon . stub ( client , 'getClient' ) . returns ( Promise . resolve ( thriftClient ) ) ;
644+
645+ await client . openSession ( {
646+ queryTags : { team : 'data-eng' , project : 'etl' } ,
647+ } ) ;
648+
649+ expect ( thriftClient . openSessionReq ?. configuration ) . to . deep . equal ( {
650+ QUERY_TAGS : 'team:data-eng,project:etl' ,
651+ } ) ;
652+ } ) ;
653+
654+ it ( 'should let queryTags take precedence over configuration.QUERY_TAGS' , async ( ) => {
655+ const client = new DBSQLClient ( ) ;
656+ const thriftClient = new ThriftClientStub ( ) ;
657+ sinon . stub ( client , 'getClient' ) . returns ( Promise . resolve ( thriftClient ) ) ;
658+
659+ await client . openSession ( {
660+ queryTags : { team : 'new-team' } ,
661+ configuration : { QUERY_TAGS : 'team:old-team,other:value' , ansi_mode : 'true' } ,
662+ } ) ;
663+
664+ expect ( thriftClient . openSessionReq ?. configuration ) . to . deep . equal ( {
665+ QUERY_TAGS : 'team:new-team' ,
666+ ansi_mode : 'true' ,
667+ } ) ;
668+ } ) ;
669+
670+ it ( 'should remove QUERY_TAGS from configuration when queryTags is empty' , async ( ) => {
671+ const client = new DBSQLClient ( ) ;
672+ const thriftClient = new ThriftClientStub ( ) ;
673+ sinon . stub ( client , 'getClient' ) . returns ( Promise . resolve ( thriftClient ) ) ;
674+
675+ await client . openSession ( {
676+ queryTags : { } ,
677+ configuration : { QUERY_TAGS : 'team:old-team' , ansi_mode : 'true' } ,
678+ } ) ;
679+
680+ expect ( thriftClient . openSessionReq ?. configuration ) . to . deep . equal ( {
681+ ansi_mode : 'true' ,
682+ } ) ;
683+ } ) ;
639684} ) ;
0 commit comments