Skip to content

Commit c2c7118

Browse files
authored
fix(jdbc-driver, databricks-jdbc-driver): clearTimeout on validate catch, temp table name (#6220)
1 parent cfa4b47 commit c2c7118

File tree

2 files changed

+5
-35
lines changed

2 files changed

+5
-35
lines changed

packages/cubejs-databricks-jdbc-driver/src/DatabricksDriver.ts

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -754,15 +754,15 @@ export class DatabricksDriver extends JDBCDriver {
754754
try {
755755
await this.query(
756756
`
757-
CREATE TABLE ${this.getUnloadExportTableName(tableFullName)}
757+
CREATE TABLE ${tableFullName}
758758
USING CSV LOCATION '${this.config.exportBucketMountDir || this.config.exportBucket}/${tableFullName}.csv'
759759
OPTIONS (escape = '"')
760760
AS (${sql});
761761
`,
762762
params,
763763
);
764764
} finally {
765-
await this.query(`DROP TABLE IF EXISTS ${this.getUnloadExportTableName(tableFullName)};`, []);
765+
await this.query(`DROP TABLE IF EXISTS ${tableFullName};`, []);
766766
}
767767
}
768768

@@ -787,46 +787,15 @@ export class DatabricksDriver extends JDBCDriver {
787787
try {
788788
await this.query(
789789
`
790-
CREATE TABLE ${this.getUnloadExportTableName(tableFullName)}
790+
CREATE TABLE _${tableFullName}
791791
USING CSV LOCATION '${this.config.exportBucketMountDir || this.config.exportBucket}/${tableFullName}.csv'
792792
OPTIONS (escape = '"')
793793
AS SELECT ${columns} FROM ${tableFullName}
794794
`,
795795
[],
796796
);
797797
} finally {
798-
await this.query(`DROP TABLE IF EXISTS ${this.getUnloadExportTableName(tableFullName)};`, []);
798+
await this.query(`DROP TABLE IF EXISTS _${tableFullName};`, []);
799799
}
800800
}
801-
802-
/**
803-
* Returns export table name (hash) by table full name.
804-
*/
805-
private getUnloadExportTableName(tableFullName: string): string {
806-
const table: string[] = tableFullName.split('.');
807-
const hashCharset = 'abcdefghijklmnopqrstuvwxyz012345';
808-
const digestBuffer = crypto.createHash('md5').update(tableFullName).digest();
809-
810-
let result = '';
811-
let residue = 0;
812-
let shiftCounter = 0;
813-
814-
for (let i = 0; i < 5; i++) {
815-
const byte = digestBuffer.readUInt8(i);
816-
shiftCounter += 16;
817-
// eslint-disable-next-line operator-assignment,no-bitwise
818-
residue = (byte << (shiftCounter - 8)) | residue;
819-
// eslint-disable-next-line no-bitwise
820-
while (residue >> 5) {
821-
result += hashCharset.charAt(residue % 32);
822-
shiftCounter -= 5;
823-
// eslint-disable-next-line operator-assignment,no-bitwise
824-
residue = residue >> 5;
825-
}
826-
}
827-
result += hashCharset.charAt(residue % 32);
828-
829-
table[table.length - 1] = result;
830-
return table.join('.');
831-
}
832801
}

packages/cubejs-jdbc-driver/src/JDBCDriver.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ export class JDBCDriver extends BaseDriver {
136136
clearTimeout(timeout);
137137
resolve(valid);
138138
}).catch(() => {
139+
clearTimeout(timeout);
139140
resolve(false);
140141
});
141142
})

0 commit comments

Comments
 (0)