@@ -287,6 +287,12 @@ module.exports = {
287287 const tableForeignKeys = await db . queryTolerant ( queryConstants . GET_TABLE_FOREIGN_KEYS , [ tableOid ] ) ;
288288 const triggers = await this . _getTriggers ( schemaName , tableName , schemaOid , tableOid , ignoreUdfUdpTriggers ) ;
289289
290+ logger . info ( 'Table data retrieved' , {
291+ schemaName,
292+ tableName,
293+ columnTypes : tableColumns . map ( column => column . data_type ) ,
294+ } ) ;
295+
290296 const partitioning = prepareTablePartition ( partitionResult , tableColumns ) ;
291297 const tableLevelProperties = prepareTableLevelData ( tableLevelData , tableToastOptions ) ;
292298 const description = getDescriptionFromResult ( descriptionResult ) ;
@@ -352,7 +358,7 @@ module.exports = {
352358 tableOid ,
353359 ] ) ;
354360
355- return _ . map ( tableColumns , ( columnData , index ) => {
361+ return _ . map ( tableColumns , columnData => {
356362 return {
357363 ...columnData ,
358364 ...( _ . find ( tableColumnsAdditionalData , { name : columnData . column_name } ) || { } ) ,
@@ -368,13 +374,23 @@ module.exports = {
368374 ( await db . queryTolerant ( queryConstants . GET_ROWS_COUNT ( fullTableName ) , [ ] , true ) ) ?. quantity || 0 ;
369375 const limit = getLimit ( quantity , recordSamplingSettings ) ;
370376
371- const jsonColumns = _ . chain ( attributes )
372- . filter ( ( { type } ) => _ . includes ( [ 'json' , 'jsonb' ] , type ) )
373- . map ( 'name' )
374- . join ( ', ' )
375- . value ( ) ;
377+ const jsonColumns = attributes . filter ( ( { type } ) => _ . includes ( [ 'json' , 'jsonb' ] , type ) ) ;
378+
379+ const jsonColumnsString = _ . map ( jsonColumns , 'name' ) . join ( ', ' ) ;
380+
381+ const samplingDataSize = await db . queryTolerant (
382+ queryConstants . GET_SAMPLED_DATA_SIZE ( fullTableName , jsonColumnsString ) ,
383+ [ limit ] ,
384+ true ,
385+ ) ;
386+
387+ logger . info ( 'Sampling table' , {
388+ tableName,
389+ jsonColumnsNumber : jsonColumns . length ,
390+ samplingDataSize : samplingDataSize ?. _hackolade_tmp_sampling_tbl_size ,
391+ } ) ;
376392
377- return await db . queryTolerant ( queryConstants . GET_SAMPLED_DATA ( fullTableName , jsonColumns ) , [ limit ] ) ;
393+ return await db . queryTolerant ( queryConstants . GET_SAMPLED_DATA ( fullTableName , jsonColumnsString ) , [ limit ] ) ;
378394 } ,
379395
380396 async _retrieveSingleViewData ( schemaOid , schemaName , ignoreUdfUdpTriggers , viewName ) {
0 commit comments