@@ -166,8 +166,11 @@ async function executeDataQueryWithTiming(
166166 connLabel : string ,
167167 type : ExecutionTypes ,
168168 target ?: string ,
169+ query ?: string ,
169170) : Promise < ExecutionResult > {
170- return withExecutionTiming ( ( ) => executeDataQuery ( connLabel , type , target ) ) ;
171+ return withExecutionTiming ( ( ) =>
172+ executeDataQuery ( connLabel , type , target , undefined , query ) ,
173+ ) ;
171174}
172175
173176async function executeQueryWithTiming (
@@ -575,27 +578,48 @@ export async function executeActiveEditorQuery(type?: ExecutionTypes) {
575578 const isDataQuery = context . target && context . target !== "scratchpad" ;
576579 const query = retrieveQueryData ( ) ;
577580
578- if ( isDataQuery && context . isInsights ) {
579- const { result : res , duration } = await executeDataQueryWithTiming (
580- context . conn . connLabel ,
581- executionType ,
581+ if ( type === ExecutionTypes . PopulateScratchpad ) {
582+ type = context . isPython
583+ ? ExecutionTypes . PopulateScratchpadPython
584+ : ExecutionTypes . PopulateScratchpad ;
585+
586+ const dsFile = getPartialDatasourceFileForNotebooks (
587+ query ?? "" ,
582588 context . target ,
589+ context . isSql ,
583590 ) ;
584-
585- const dataType = getDataTypeForEditor ( context . executorName ) ;
586- const querySample = getQuerySample ( query ?? "" , dataType ) ;
587-
588- handleExecuteDataQueryResults (
591+ prepareToPopulateScratchpad (
589592 context . conn . connLabel ,
590- res ,
591- context . executorName ,
592- dataType ,
593- querySample ,
594- context . documentType ,
595- context . isPython ,
596- duration ,
593+ type ,
594+ context . target ,
595+ undefined ,
596+ dsFile ,
597597 ) ;
598598 return ;
599+ } else {
600+ if ( isDataQuery && context . isInsights ) {
601+ const { result : res , duration } = await executeDataQueryWithTiming (
602+ context . conn . connLabel ,
603+ executionType ,
604+ context . target ,
605+ query ,
606+ ) ;
607+
608+ const dataType = getDataTypeForEditor ( context . executorName ) ;
609+ const querySample = getQuerySample ( query ?? "" , dataType ) ;
610+
611+ handleExecuteDataQueryResults (
612+ context . conn . connLabel ,
613+ res ,
614+ context . executorName ,
615+ dataType ,
616+ querySample ,
617+ context . documentType ,
618+ context . isPython ,
619+ duration ,
620+ ) ;
621+ return ;
622+ }
599623 }
600624
601625 const { result : res , duration } = await executeQueryWithTiming (
@@ -715,9 +739,10 @@ export async function executeDataQuery(
715739 type : ExecutionTypes ,
716740 target ?: string ,
717741 datasourceFile ?: DataSourceFiles ,
742+ queryParsed ?: string ,
718743) : Promise < any > {
719744 const isPython = isExecutionPython ( type ) ;
720- const query = getQuery ( datasourceFile , type ) ;
745+ const query = queryParsed ? queryParsed : getQuery ( datasourceFile , type ) ;
721746 const dsExecutionType = getDSExecutionType ( datasourceFile ) ;
722747 const udaName = datasourceFile ?. dataSource ?. uda ?. name ?? "" ;
723748 const isNotebook = isExecutionNotebook ( type ) ;
0 commit comments