Skip to content

Commit df763cc

Browse files
marianore-muttdataigorlukaninsergisulcaKSDaemonron-damon
authored
feat(pinot-driver): Add enableNullHandling to query options using env var (#9310)
* feat(pinot-driver): Add enableNullHandling=true to query options * 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 * Add docs for auth token config --------- Co-authored-by: Igor Lukanin <[email protected]> Co-authored-by: sergisulca <[email protected]> Co-authored-by: Sergio Sulca <[email protected]> Co-authored-by: Konstantin Burkalev <[email protected]> Co-authored-by: ron-damon <[email protected]>
1 parent 894cfd8 commit df763cc

File tree

4 files changed

+61
-11
lines changed

4 files changed

+61
-11
lines changed

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ workloads. [StarTree][link-startree] is a fully-managed platform for Pinot.
1414
- The hostname for the [Pinot][pinot] broker
1515
- The port for the [Pinot][pinot] broker
1616

17-
With the current implementation of the Pinot driver, you have to enable the
18-
[multi-stage query engine][link-pinot-msqe] in your Pinot cluster.
17+
Note that the following features should be enabled in your Pinot cluster:
18+
- [Multi-stage query engine][link-pinot-msqe].
19+
- [Advanced null value support][link-pinot-nvs].
1920

2021
## Setup
2122

@@ -41,14 +42,15 @@ CUBEJS_DB_PASS=**********
4142

4243
## Environment Variables
4344

44-
| Environment Variable | Description | Possible Values | Required |
45-
|----------------------|--------------------------------------------|---------------------|:--------:|
46-
| `CUBEJS_DB_HOST` | The host URL for your Pinot broker | A valid host URL ||
47-
| `CUBEJS_DB_PORT` | The port for the database connection | A valid port number ||
48-
| `CUBEJS_DB_USER` | The username used to connect to the broker | A valid username ||
49-
| `CUBEJS_DB_PASS` | The password used to connect to the broker | A valid password ||
50-
| `CUBEJS_DB_NAME` | The database name for StarTree | A valid name ||
51-
| `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 ||
5254

5355
## Pre-Aggregation Feature Support
5456

@@ -97,6 +99,7 @@ Cube does not require any additional configuration to enable SSL as Pinot connec
9799
[link-pinot]: https://pinot.apache.org/
98100
[pinot]: https://docs.pinot.apache.org/
99101
[link-pinot-msqe]: https://docs.pinot.apache.org/reference/multi-stage-engine
102+
[link-pinot-nvs]: https://docs.pinot.apache.org/developers/advanced/null-value-support#advanced-null-handling-support
100103
[pinot-docs-approx-agg-fns]:
101104
https://docs.pinot.apache.org/users/user-guide-query/query-syntax/how-to-handle-unique-counting
102105
[ref-recipe-enable-ssl]:

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,22 @@ 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+
## `CUBEJS_DB_PINOT_AUTH_TOKEN`
752+
753+
The authentication token for StarTree to be passed as HTTP headers.
754+
755+
| Possible Values | Default in Development | Default in Production |
756+
| ----------------------------------- | ---------------------- | --------------------- |
757+
| A valid string containing the token | N/A | N/A |
758+
743759
## `CUBEJS_DB_SSL`
744760

745761
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
@@ -1784,6 +1784,35 @@ const variables: Record<string, (...args: any) => any> = {
17841784
]
17851785
),
17861786

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

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;timeoutMs=${this.config.queryTimeout}`
172+
queryOptions: `useMultistageEngine=true;enableNullHandling=${this.config.nullHandling};timeoutMs=${this.config.queryTimeout}`
171173
})
172174
});
173175

0 commit comments

Comments
 (0)