@@ -223,10 +223,55 @@ export class PrestoDriver extends BaseDriver implements DriverInterface {
223223 }
224224
225225 public informationSchemaQuery ( ) {
226- if ( this . config . schema ) {
227- return `${ super . informationSchemaQuery ( ) } AND columns.table_schema = '${ this . config . schema } '` ;
228- }
229- return super . informationSchemaQuery ( ) ;
226+ const catalogPrefix = this . catalog ? `${ this . catalog } .` : '' ;
227+ const schemaFilter = this . config . schema ? ` AND columns.table_schema = '${ this . config . schema } '` : '' ;
228+
229+ return `
230+ SELECT columns.column_name as ${ this . quoteIdentifier ( 'column_name' ) } ,
231+ columns.table_name as ${ this . quoteIdentifier ( 'table_name' ) } ,
232+ columns.table_schema as ${ this . quoteIdentifier ( 'table_schema' ) } ,
233+ columns.data_type as ${ this . quoteIdentifier ( 'data_type' ) }
234+ FROM ${ catalogPrefix } information_schema.columns
235+ WHERE columns.table_schema NOT IN ('pg_catalog', 'information_schema', 'mysql', 'performance_schema', 'sys', 'INFORMATION_SCHEMA')${ schemaFilter }
236+ ` ;
237+ }
238+
239+ protected override getSchemasQuery ( ) {
240+ const catalogPrefix = this . catalog ? `${ this . catalog } .` : '' ;
241+
242+ return `
243+ SELECT table_schema as ${ this . quoteIdentifier ( 'schema_name' ) }
244+ FROM ${ catalogPrefix } information_schema.tables
245+ WHERE table_schema NOT IN ('pg_catalog', 'information_schema', 'mysql', 'performance_schema', 'sys', 'INFORMATION_SCHEMA')
246+ GROUP BY table_schema
247+ ` ;
248+ }
249+
250+ protected override getTablesForSpecificSchemasQuery ( schemasPlaceholders : string ) {
251+ const catalogPrefix = this . catalog ? `${ this . catalog } .` : '' ;
252+
253+ const query = `
254+ SELECT table_schema as ${ this . quoteIdentifier ( 'schema_name' ) } ,
255+ table_name as ${ this . quoteIdentifier ( 'table_name' ) }
256+ FROM ${ catalogPrefix } information_schema.tables as columns
257+ WHERE table_schema IN (${ schemasPlaceholders } )
258+ ` ;
259+ return query ;
260+ }
261+
262+ protected override getColumnsForSpecificTablesQuery ( conditionString : string ) {
263+ const catalogPrefix = this . catalog ? `${ this . catalog } .` : '' ;
264+
265+ const query = `
266+ SELECT columns.column_name as ${ this . quoteIdentifier ( 'column_name' ) } ,
267+ columns.table_name as ${ this . quoteIdentifier ( 'table_name' ) } ,
268+ columns.table_schema as ${ this . quoteIdentifier ( 'schema_name' ) } ,
269+ columns.data_type as ${ this . quoteIdentifier ( 'data_type' ) }
270+ FROM ${ catalogPrefix } information_schema.columns as columns
271+ WHERE ${ conditionString }
272+ ` ;
273+
274+ return query ;
230275 }
231276
232277 public normalizeResultOverColumns ( data : any [ ] , columns : TableStructure ) {
0 commit comments