Skip to content

Commit 64dfa23

Browse files
committed
[FIXUP] add separate createTableRaw, fix override for createTable
1 parent 9ccefe2 commit 64dfa23

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

packages/cubejs-base-driver/src/BaseDriver.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,9 +614,14 @@ export abstract class BaseDriver implements DriverInterface {
614614
return [];
615615
}
616616

617-
public createTable(quotedTableName: string, columns: TableColumn[]) {
617+
// This is only for use in tests
618+
public async createTableRaw(query: string): Promise<void> {
619+
await this.query(query);
620+
}
621+
622+
public async createTable(quotedTableName: string, columns: TableColumn[]): Promise<void> {
618623
const createTableSql = this.createTableSql(quotedTableName, columns);
619-
return this.query(createTableSql, []).catch(e => {
624+
await this.query(createTableSql, []).catch(e => {
620625
e.message = `Error during create table: ${createTableSql}: ${e.message}`;
621626
throw e;
622627
});

packages/cubejs-clickhouse-driver/src/ClickHouseDriver.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
QuerySchemasResult,
2020
StreamOptions,
2121
StreamTableDataWithTypes,
22+
TableColumn,
2223
TableQueryResult,
2324
TableStructure,
2425
UnloadOptions,
@@ -650,6 +651,20 @@ export class ClickHouseDriver extends BaseDriver implements DriverInterface {
650651
}));
651652
}
652653

654+
// This is only for use in tests
655+
public override async createTableRaw(query: string): Promise<void> {
656+
await this.command(query);
657+
}
658+
659+
public override async createTable(quotedTableName: string, columns: TableColumn[]) {
660+
const createTableSql = this.createTableSql(quotedTableName, columns);
661+
try {
662+
await this.command(createTableSql);
663+
} catch (e) {
664+
throw new Error(`Error during create table: ${createTableSql}`, {cause: e});
665+
}
666+
}
667+
653668
/**
654669
* We use unloadWithoutTempTable strategy
655670
*/
@@ -712,7 +727,7 @@ export class ClickHouseDriver extends BaseDriver implements DriverInterface {
712727
};
713728
}
714729

715-
// This is not part of a driver interface, and should be used only for testing
730+
// This is not part of a driver interface, and marked public only for testing
716731
public async command(query: string): Promise<void> {
717732
await this.withConnection(async (connection) => {
718733
await connection.command({
@@ -721,7 +736,7 @@ export class ClickHouseDriver extends BaseDriver implements DriverInterface {
721736
});
722737
}
723738

724-
// This is not part of a driver interface, and should be used only for testing
739+
// This is not part of a driver interface, and marked public only for testing
725740
public async insert(table: string, values: Array<Array<unknown>>): Promise<void> {
726741
await this.withConnection(async (connection) => {
727742
await connection.insert({

packages/cubejs-testing-drivers/src/tests/testQueries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export function testQueries(type: string, { includeIncrementalSchemaSuite, exten
117117
console.log(`Creating ${queries.length} fixture tables`);
118118
try {
119119
for (const q of queries) {
120-
await driver.query(q);
120+
await driver.createTableRaw(q);
121121
}
122122
console.log(`Creating ${queries.length} fixture tables completed`);
123123
} catch (e: any) {

0 commit comments

Comments
 (0)