Skip to content
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
21 changes: 21 additions & 0 deletions packages/cubejs-backend-shared/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1613,6 +1613,10 @@ const variables: Record<string, (...args: any) => any> = {
]
),

/** ***************************************************************
* Presto Driver *
**************************************************************** */

/**
* Presto catalog.
*/
Expand All @@ -1626,6 +1630,23 @@ const variables: Record<string, (...args: any) => any> = {
]
),

/** ***************************************************************
* Pinot Driver *
**************************************************************** */

/**
* Pinot / Startree Auth Token
*/
pinotAuthToken: ({
dataSource,
}: {
dataSource: string,
}) => (
process.env[
keyByDataSource('CUBEJS_DB_PINOT_AUTH_TOKEN', dataSource)
]
),

/** ****************************************************************
* Cube Store Driver *
***************************************************************** */
Expand Down
21 changes: 20 additions & 1 deletion packages/cubejs-pinot-driver/src/PinotDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ export type PinotDriverConfiguration = {
host?: string;
port?: string;
user?: string;
database?: string;
basicAuth?: { user: string, password: string };
authToken?: string;
ssl?: string | TLSConnectionOptions;
dataSource?: string;
queryTimeout?: number;
};

type AuthorizationHeaders = {
Authorization: string;
database?: string;
};

type PinotResponse = {
exceptions: any[],
minConsumingFreshnessTimeMs: number,
Expand Down Expand Up @@ -92,12 +99,14 @@ export class PinotDriver extends BaseDriver implements DriverInterface {
host: getEnv('dbHost', { dataSource }),
port: getEnv('dbPort', { dataSource }),
user: getEnv('dbUser', { dataSource }),
database: getEnv('dbName', { dataSource }),
basicAuth: getEnv('dbPass', { dataSource })
? {
user: getEnv('dbUser', { dataSource }),
password: getEnv('dbPass', { dataSource }),
}
: undefined,
authToken: getEnv('pinotAuthToken', { dataSource }),
ssl: this.getSslOptions(dataSource),
queryTimeout: getEnv('dbQueryTimeout', { dataSource }),
...config
Expand Down Expand Up @@ -127,7 +136,17 @@ export class PinotDriver extends BaseDriver implements DriverInterface {
} : value)));
}

public authorizationHeaders(): { Authorization?: string } {
public authorizationHeaders(): AuthorizationHeaders | {} {
if (this.config.authToken) {
const res: AuthorizationHeaders = { Authorization: `Bearer ${this.config.authToken}` };

if (this.config.database) {
res.database = this.config.database;
}

return res;
}

if (!this.config.basicAuth) {
return {};
}
Expand Down
Loading