@@ -560,3 +560,80 @@ describe('DBSQLClient.createAuthProvider', () => {
560560 expect ( provider ) . to . be . equal ( customProvider ) ;
561561 } ) ;
562562} ) ;
563+
564+ describe ( 'DBSQLClient.enableMetricViewMetadata' , ( ) => {
565+ it ( 'should store enableMetricViewMetadata config when enabled' , async ( ) => {
566+ const client = new DBSQLClient ( ) ;
567+
568+ expect ( client . getConfig ( ) . enableMetricViewMetadata ) . to . be . undefined ;
569+
570+ await client . connect ( { ...connectOptions , enableMetricViewMetadata : true } ) ;
571+
572+ expect ( client . getConfig ( ) . enableMetricViewMetadata ) . to . be . true ;
573+ } ) ;
574+
575+ it ( 'should not store enableMetricViewMetadata config when disabled' , async ( ) => {
576+ const client = new DBSQLClient ( ) ;
577+
578+ expect ( client . getConfig ( ) . enableMetricViewMetadata ) . to . be . undefined ;
579+
580+ await client . connect ( { ...connectOptions , enableMetricViewMetadata : false } ) ;
581+
582+ expect ( client . getConfig ( ) . enableMetricViewMetadata ) . to . be . false ;
583+ } ) ;
584+
585+ it ( 'should inject session parameter when enableMetricViewMetadata is true' , async ( ) => {
586+ const client = new DBSQLClient ( ) ;
587+ const thriftClient = new ThriftClientStub ( ) ;
588+ sinon . stub ( client , 'getClient' ) . returns ( Promise . resolve ( thriftClient ) ) ;
589+
590+ await client . connect ( { ...connectOptions , enableMetricViewMetadata : true } ) ;
591+ await client . openSession ( ) ;
592+
593+ expect ( thriftClient . openSessionReq ?. configuration ) . to . have . property (
594+ 'spark.sql.thriftserver.metadata.metricview.enabled' ,
595+ 'true' ,
596+ ) ;
597+ } ) ;
598+
599+ it ( 'should not inject session parameter when enableMetricViewMetadata is false' , async ( ) => {
600+ const client = new DBSQLClient ( ) ;
601+ const thriftClient = new ThriftClientStub ( ) ;
602+ sinon . stub ( client , 'getClient' ) . returns ( Promise . resolve ( thriftClient ) ) ;
603+
604+ await client . connect ( { ...connectOptions , enableMetricViewMetadata : false } ) ;
605+ await client . openSession ( ) ;
606+
607+ expect ( thriftClient . openSessionReq ?. configuration ) . to . not . have . property (
608+ 'spark.sql.thriftserver.metadata.metricview.enabled' ,
609+ ) ;
610+ } ) ;
611+
612+ it ( 'should not inject session parameter when enableMetricViewMetadata is not set' , async ( ) => {
613+ const client = new DBSQLClient ( ) ;
614+ const thriftClient = new ThriftClientStub ( ) ;
615+ sinon . stub ( client , 'getClient' ) . returns ( Promise . resolve ( thriftClient ) ) ;
616+
617+ await client . connect ( connectOptions ) ;
618+ await client . openSession ( ) ;
619+
620+ expect ( thriftClient . openSessionReq ?. configuration ) . to . not . have . property (
621+ 'spark.sql.thriftserver.metadata.metricview.enabled' ,
622+ ) ;
623+ } ) ;
624+
625+ it ( 'should preserve user-provided session configuration' , async ( ) => {
626+ const client = new DBSQLClient ( ) ;
627+ const thriftClient = new ThriftClientStub ( ) ;
628+ sinon . stub ( client , 'getClient' ) . returns ( Promise . resolve ( thriftClient ) ) ;
629+
630+ await client . connect ( { ...connectOptions , enableMetricViewMetadata : true } ) ;
631+ const userConfig = { QUERY_TAGS : 'team:engineering' , ansi_mode : 'true' } ;
632+ await client . openSession ( { configuration : userConfig } ) ;
633+
634+ expect ( thriftClient . openSessionReq ?. configuration ) . to . deep . equal ( {
635+ ...userConfig ,
636+ 'spark.sql.thriftserver.metadata.metricview.enabled' : 'true' ,
637+ } ) ;
638+ } ) ;
639+ } ) ;
0 commit comments