Skip to content

Commit 4d9452a

Browse files
sergisulcaKSDaemonron-damon
authored
feat(pinot-driver): Add enableNullHandling to query options using env var (#9213)
* Add enableNullHandling=true to query options using env var CUBEJS_DB_NULL_HANDLING * Add 'The Startree/Pinot null value support' to docs * fix reference env var * Update docs/pages/product/configuration/data-sources/pinot.mdx Co-authored-by: Konstantin Burkalev <[email protected]> * Update docs/pages/reference/configuration/environment-variables.mdx Co-authored-by: ron-damon <[email protected]> * Update docs/pages/reference/configuration/environment-variables.mdx Co-authored-by: ron-damon <[email protected]> * Update packages/cubejs-backend-shared/src/env.ts Co-authored-by: Konstantin Burkalev <[email protected]> * fix env var name --------- Co-authored-by: Konstantin Burkalev <[email protected]> Co-authored-by: ron-damon <[email protected]>
1 parent d934f61 commit 4d9452a

File tree

4 files changed

+50
-9
lines changed

4 files changed

+50
-9
lines changed

docs/pages/product/configuration/data-sources/pinot.mdx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,15 @@ CUBEJS_DB_PASS=**********
4242

4343
## Environment Variables
4444

45-
| Environment Variable | Description | Possible Values | Required |
46-
|----------------------|--------------------------------------------|---------------------|:--------:|
47-
| `CUBEJS_DB_HOST` | The host URL for your Pinot broker | A valid host URL ||
48-
| `CUBEJS_DB_PORT` | The port for the database connection | A valid port number ||
49-
| `CUBEJS_DB_USER` | The username used to connect to the broker | A valid username ||
50-
| `CUBEJS_DB_PASS` | The password used to connect to the broker | A valid password ||
51-
| `CUBEJS_DB_NAME` | The database name for StarTree | A valid name ||
52-
| `CUBEJS_DB_PINOT_AUTH_TOKEN` | The authentication token for StarTree | A valid token ||
45+
| Environment Variable | Description | Possible Values | Required |
46+
|---------------------------------|-------------------------------------------------------|---------------------|:--------:|
47+
| `CUBEJS_DB_HOST` | The host URL for your Pinot broker | A valid host URL ||
48+
| `CUBEJS_DB_PORT` | The port for the database connection | A valid port number ||
49+
| `CUBEJS_DB_USER` | The username used to connect to the broker | A valid username ||
50+
| `CUBEJS_DB_PASS` | The password used to connect to the broker | A valid password ||
51+
| `CUBEJS_DB_NAME` | The database name for StarTree | A valid name ||
52+
| `CUBEJS_DB_PINOT_NULL_HANDLING` | If `true`, enables null handling. Default is `false` | `true`, `false` ||
53+
| `CUBEJS_DB_PINOT_AUTH_TOKEN` | The authentication token for StarTree | A valid token ||
5354

5455
## Pre-Aggregation Feature Support
5556

docs/pages/reference/configuration/environment-variables.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,15 @@ The Snowflake warehouse to use when connecting to the database.
740740
| ---------------------------------------------------------------------- | ---------------------- | --------------------- |
741741
| [A valid Snowflake warehouse][snowflake-docs-warehouse] in the account | N/A | N/A |
742742

743+
## `CUBEJS_DB_PINOT_NULL_HANDLING`
744+
745+
The Startree/Pinot null value support. If `true`, enables null handling.
746+
747+
| Possible Values | Default in Development | Default in Production |
748+
| --------------- | ---------------------- | --------------------- |
749+
| `true`, `false` | `false` | `false` |
750+
751+
743752
## `CUBEJS_DB_SSL`
744753

745754
If `true`, enables SSL encryption for database connections from Cube.

packages/cubejs-backend-shared/src/env.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,6 +1780,35 @@ const variables: Record<string, (...args: any) => any> = {
17801780
]
17811781
),
17821782

1783+
/**
1784+
* Pinot / Startree Null value support
1785+
*/
1786+
1787+
pinotNullHandling: ({ dataSource }: { dataSource: string }) => {
1788+
const val = process.env[
1789+
keyByDataSource('CUBEJS_DB_PINOT_NULL_HANDLING', dataSource)
1790+
];
1791+
1792+
if (val) {
1793+
if (val.toLocaleLowerCase() === 'true') {
1794+
return true;
1795+
} else if (val.toLowerCase() === 'false') {
1796+
return false;
1797+
} else {
1798+
throw new TypeError(
1799+
`The ${
1800+
keyByDataSource(
1801+
'CUBEJS_DB_PINOT_NULL_HANDLING',
1802+
dataSource,
1803+
)
1804+
} must be either 'true' or 'false'.`
1805+
);
1806+
}
1807+
} else {
1808+
return false;
1809+
}
1810+
},
1811+
17831812
/** ****************************************************************
17841813
* Dremio Driver *
17851814
***************************************************************** */

packages/cubejs-pinot-driver/src/PinotDriver.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export type PinotDriverConfiguration = {
3333
ssl?: string | TLSConnectionOptions;
3434
dataSource?: string;
3535
queryTimeout?: number;
36+
nullHandling?: boolean;
3637
};
3738

3839
type AuthorizationHeaders = {
@@ -108,6 +109,7 @@ export class PinotDriver extends BaseDriver implements DriverInterface {
108109
: undefined,
109110
authToken: getEnv('pinotAuthToken', { dataSource }),
110111
ssl: this.getSslOptions(dataSource),
112+
nullHandling: getEnv('pinotNullHandling', { dataSource }),
111113
queryTimeout: getEnv('dbQueryTimeout', { dataSource }),
112114
...config
113115
};
@@ -167,7 +169,7 @@ export class PinotDriver extends BaseDriver implements DriverInterface {
167169
}),
168170
body: JSON.stringify({
169171
sql: query,
170-
queryOptions: `useMultistageEngine=true;enableNullHandling=true;timeoutMs=${this.config.queryTimeout}`
172+
queryOptions: `useMultistageEngine=true;enableNullHandling=${this.config.nullHandling};timeoutMs=${this.config.queryTimeout}`
171173
})
172174
});
173175

0 commit comments

Comments
 (0)