Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Align drivers methods signatures (add overrides to public/protected driver methods) #9094

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/cubejs-base-driver/src/BaseDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,20 +470,20 @@ export abstract class BaseDriver implements DriverInterface {
}
}

public getSchemas() {
public getSchemas(): Promise<QuerySchemasResult[]> {
const query = this.getSchemasQuery();
return this.query<QuerySchemasResult>(query);
}

public getTablesForSpecificSchemas(schemas: QuerySchemasResult[]) {
public getTablesForSpecificSchemas(schemas: QuerySchemasResult[]): Promise<QueryTablesResult[]> {
const schemasPlaceholders = schemas.map((_, idx) => this.param(idx)).join(', ');
const schemaNames = schemas.map(s => s.schema_name);

const query = this.getTablesForSpecificSchemasQuery(schemasPlaceholders);
return this.query<QueryTablesResult>(query, schemaNames);
}

public async getColumnsForSpecificTables(tables: QueryTablesResult[]) {
public async getColumnsForSpecificTables(tables: QueryTablesResult[]): Promise<QueryColumnsResult[]> {
const groupedBySchema: Record<string, string[]> = {};
tables.forEach((t) => {
if (!groupedBySchema[t.schema_name]) {
Expand Down
6 changes: 3 additions & 3 deletions packages/cubejs-bigquery-driver/src/BigQueryDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,14 @@ export class BigQueryDriver extends BaseDriver implements DriverInterface {
return dataSetsColumns.reduce((prev, current) => Object.assign(prev, current), {});
}

public async getSchemas(): Promise<QuerySchemasResult[]> {
public override async getSchemas(): Promise<QuerySchemasResult[]> {
const dataSets = await this.bigquery.getDatasets();
return dataSets[0].filter((dataSet) => dataSet.id).map((dataSet) => ({
schema_name: dataSet.id!,
}));
}

public async getTablesForSpecificSchemas(schemas: QuerySchemasResult[]): Promise<QueryTablesResult[]> {
public override async getTablesForSpecificSchemas(schemas: QuerySchemasResult[]): Promise<QueryTablesResult[]> {
try {
const allTablePromises = schemas.map(async schema => {
const tables = await this.getTablesQuery(schema.schema_name);
Expand All @@ -247,7 +247,7 @@ export class BigQueryDriver extends BaseDriver implements DriverInterface {
}
}

public async getColumnsForSpecificTables(tables: QueryTablesResult[]): Promise<QueryColumnsResult[]> {
public override async getColumnsForSpecificTables(tables: QueryTablesResult[]): Promise<QueryColumnsResult[]> {
try {
const allColumnPromises = tables.map(async table => {
const tableName = `${table.schema_name}.${table.table_name}`;
Expand Down
14 changes: 7 additions & 7 deletions packages/cubejs-redshift-driver/src/RedshiftDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class RedshiftDriver extends PostgresDriver<RedshiftDriverConfiguration>
/**
* @override
*/
protected informationSchemaQuery() {
protected override informationSchemaQuery() {
return `
SELECT columns.column_name as ${this.quoteIdentifier('column_name')},
columns.table_name as ${this.quoteIdentifier('table_name')},
Expand All @@ -119,7 +119,7 @@ export class RedshiftDriver extends PostgresDriver<RedshiftDriverConfiguration>
* so it needs to be queried separately.
* @override
*/
public async tablesSchema(): Promise<DatabaseStructure> {
public override async tablesSchema(): Promise<DatabaseStructure> {
const query = this.informationSchemaQuery();
const tablesSchema = await this.query(query, []).then(data => data.reduce<DatabaseStructure>(this.informationColumnsSchemaReducer, {}));

Expand Down Expand Up @@ -155,7 +155,7 @@ export class RedshiftDriver extends PostgresDriver<RedshiftDriverConfiguration>
/**
* @override
*/
protected getSchemasQuery() {
protected override getSchemasQuery() {
return `
SELECT table_schema as ${this.quoteIdentifier('schema_name')}
FROM information_schema.tables
Expand All @@ -170,15 +170,15 @@ export class RedshiftDriver extends PostgresDriver<RedshiftDriverConfiguration>
* It returns regular schemas (queryable from information_schema) and external ones.
* @override
*/
public async getSchemas(): Promise<QuerySchemasResult[]> {
public override async getSchemas(): Promise<QuerySchemasResult[]> {
const schemas = await this.query<QuerySchemasResult>(`SHOW SCHEMAS FROM DATABASE ${this.dbName}`, []);

return schemas
.filter(s => !IGNORED_SCHEMAS.includes(s.schema_name))
.map(s => ({ schema_name: s.schema_name }));
}

public async getTablesForSpecificSchemas(schemas: QuerySchemasResult[]): Promise<QueryTablesResult[]> {
public override async getTablesForSpecificSchemas(schemas: QuerySchemasResult[]): Promise<QueryTablesResult[]> {
const tables = await super.getTablesForSpecificSchemas(schemas);

// We might request the external schemas and tables, their descriptions won't be returned
Expand All @@ -195,7 +195,7 @@ export class RedshiftDriver extends PostgresDriver<RedshiftDriverConfiguration>
return tables;
}

public async getColumnsForSpecificTables(tables: QueryTablesResult[]): Promise<QueryColumnsResult[]> {
public override async getColumnsForSpecificTables(tables: QueryTablesResult[]): Promise<QueryColumnsResult[]> {
const columns = await super.getColumnsForSpecificTables(tables);

// We might request the external tables, their descriptions won't be returned
Expand Down Expand Up @@ -245,7 +245,7 @@ export class RedshiftDriver extends PostgresDriver<RedshiftDriverConfiguration>
* And querying even system tables is billed.
* @override
*/
public async testConnection() {
public override async testConnection() {
const conn = await this.pool.connect();
conn.release();
}
Expand Down
Loading