Skip to content

Commit

Permalink
feat(databricks-jdbc-driver): Support Java higher then 11
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr committed Sep 12, 2024
1 parent e7347db commit 03c278d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/cubejs-jdbc-driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
],
"dependencies": {
"@cubejs-backend/base-driver": "^0.35.81",
"@cubejs-backend/shared": "^0.35.67",
"generic-pool": "^3.1.7",
"node-java-maven": "^0.1.2",
"sqlstring": "^2.3.0"
Expand Down
17 changes: 8 additions & 9 deletions packages/cubejs-jdbc-driver/src/JDBCDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* @fileoverview The `JDBCDriver` and related types declaration.
*/

/* eslint-disable no-restricted-syntax,import/no-extraneous-dependencies */
import { Readable } from 'stream';
import {
getEnv,
assertDataSource,
Expand All @@ -27,6 +25,7 @@ import { DriverOptionsInterface, SupportedDrivers } from './supported-drivers';
import { JDBCDriverConfiguration } from './types';
import { QueryStream, nextFn, Row, transformRow } from './QueryStream';

/* eslint-disable no-restricted-syntax,import/no-extraneous-dependencies */
const DriverManager = require('@cubejs-backend/jdbc/lib/drivermanager');
const Connection = require('@cubejs-backend/jdbc/lib/connection');
const DatabaseMetaData = require('@cubejs-backend/jdbc/lib/databasemetadata');
Expand All @@ -35,11 +34,6 @@ const mvn = require('node-java-maven');

let mvnPromise: Promise<void> | null = null;

type JdbcStatement = {
setQueryTimeout: (t: number) => any,
execute: (q: string) => any,
};

const initMvn = (customClassPath: any) => {
if (!mvnPromise) {
mvnPromise = new Promise((resolve, reject) => {
Expand All @@ -53,6 +47,11 @@ const initMvn = (customClassPath: any) => {
if (!jinst.isJvmCreated()) {
jinst.addOption('-Xrs');
jinst.addOption('-Dfile.encoding=UTF8');

// Workaround for Databricks JDBC driver
// Issue when deserializing Apache Arrow data with Java JVMs version 11 or higher, due to compatibility issues.
jinst.addOption('--add-opens=java.base/java.nio=ALL-UNNAMED');

const classPath = (mvnResults && mvnResults.classpath || []).concat(customClassPath || []);
jinst.setupClasspath(classPath);
}
Expand All @@ -78,7 +77,7 @@ interface ExtendedPool extends Pool<any> {

export class JDBCDriver extends BaseDriver {
protected readonly config: JDBCDriverConfiguration;

protected pool: ExtendedPool;

protected jdbcProps: any;
Expand Down Expand Up @@ -360,7 +359,7 @@ export class JDBCDriver extends BaseDriver {
public static getSupportedDrivers(): string[] {
return Object.keys(SupportedDrivers);
}

public static dbTypeDescription(dbType: string): DriverOptionsInterface {
return SupportedDrivers[dbType];
}
Expand Down

0 comments on commit 03c278d

Please sign in to comment.