fix(snowflake): fixing the snowflake schema fetcher logic (#7440)
Check List
- [x] Tests has been run in packages where changes made if available
- [x] Linter has been run for changed code
- [x] Tests for the changes have been added if not covered yet
- [x] Docs have been added / updated if required
Issue Reference this PR resolves
[For example #12]
Description of Changes Made (if issue reference is not provided)
[Description goes here]
The latest updates on your projects. Learn more about Vercel for Git ↗︎
8 Skipped Deployments
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| examples-angular-dashboard | ⬜️ Ignored (Inspect) | Visit Preview | Sep 3, 2024 6:35pm | |
| examples-react-d3 | ⬜️ Ignored (Inspect) | Visit Preview | Sep 3, 2024 6:35pm | |
| examples-react-dashboard | ⬜️ Ignored (Inspect) | Visit Preview | Sep 3, 2024 6:35pm | |
| examples-react-data-table | ⬜️ Ignored (Inspect) | Visit Preview | Sep 3, 2024 6:35pm | |
| examples-react-highcharts | ⬜️ Ignored (Inspect) | Visit Preview | Sep 3, 2024 6:35pm | |
| examples-react-material-ui | ⬜️ Ignored (Inspect) | Visit Preview | Sep 3, 2024 6:35pm | |
| examples-react-pivot-table | ⬜️ Ignored (Inspect) | Visit Preview | Sep 3, 2024 6:35pm | |
| examples-vue-query-builder | ⬜️ Ignored (Inspect) | Visit Preview | Sep 3, 2024 6:35pm |
Hi @christianallred-nomi đź‘‹
Thanks for your contribution! Do you think this is a breaking change?
It should not be no.
A while ago snowflake made a decision to always cap case their responses. This caused an Outage for us. And is what causes the bug this or is aiming to fix with cube.
The fact that this is working for some snowflake users means they have this setting set globally instead of by session.
I liked this solution because it fixes the problem for affected users but should leave the existing users the same.
I have not had time to test this 100% however so if someone with a working snowflake instance can test it, that would be great:
An alternate decision that would not require a session update would be to update the snowflake driver to overwrite the result parser function
@christianallred Thanks for contributing it! I think it's definitely great feature however as of now it should go under the flag which we'd enable by default going forward.
@christianallred Thanks for contributing it! I think it's definitely great feature however as of now it should go under the flag which we'd enable by default going forward.
Whatever y'all decide is fine. It’s just broken for our use case until a fix is decided on. FWIW I don’t really have skin in the game anymore as I am leaving the org that was looking at cube as a solution. Cheers :)
@paveltiunov any info about this? I'm having issue with the undefined in snowflake https://github.com/cube-js/cube/issues/7440
@mattssll We're open for this change if it'd land under the flag. If you have capacity to fix PR we'd be happy to merge it.
@christianallred-nomi if you don't know, here are a few tips on how to add flag. It's pretty easy!
Add a new env in env.ts, something like:
/**
* Snowflake flag controlling QUOTED_IDENTIFIERS_IGNORE_CASE.
* Defaults to FALSE if not set
*/
snowflakeQuotedIdentIgnoreCase: ({
dataSource
}: {
dataSource: string,
}) => (
const val = process.env[
keyByDataSource(
'CUBEJS_DB_SNOWFLAKE_QUOTED_IDENTIFIERS_IGNORE_CASE',
dataSource,
)
];
if (val) {
if (val.toLocaleLowerCase() === 'true') {
return true;
} else if (val.toLowerCase() === 'false') {
return false;
} else {
throw new TypeError(
`The ${
keyByDataSource(
'CUBEJS_DB_SNOWFLAKE_QUOTED_IDENTIFIERS_IGNORE_CASE',
dataSource,
)
} must be either 'true' or 'false'.`
);
}
} else {
return false;
}
),
Then read and store the flag value in driver's [constructor](https://github.com/cube-js/cube/blob/master/packages/cubejs-snowflake-driver/src/SnowflakeDriver.ts#L253, smth like:
this.ignoreCase = getEnv('snowflakeQuotedIdentIgnoreCase', { dataSource })
And check it in the initConnection(), or simply pass as arg to execute.
if (this.ignoreCase) {
await this.execute(connection, 'ALTER SESSION SET QUOTED_IDENTIFIERS_IGNORE_CASE = FALSE', [], false);
}