Skip to content

Conversation

@mike-taylor-nomihealth
Copy link
Contributor

@mike-taylor-nomihealth mike-taylor-nomihealth commented Nov 1, 2024

Check List

  • Tests has been run in packages where changes made if available
  • Linter has been run for changed code
  • Tests for the changes have been added if not covered yet
  • Docs have been added / updated if required

Closes #7440
Supersedes #8765

@mike-taylor-nomihealth mike-taylor-nomihealth requested a review from a team as a code owner November 1, 2024 17:40
@vercel
Copy link

vercel bot commented Nov 1, 2024

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 Nov 1, 2024 5:44pm
examples-react-d3 ⬜️ Ignored (Inspect) Visit Preview Nov 1, 2024 5:44pm
examples-react-dashboard ⬜️ Ignored (Inspect) Visit Preview Nov 1, 2024 5:44pm
examples-react-data-table ⬜️ Ignored (Inspect) Visit Preview Nov 1, 2024 5:44pm
examples-react-highcharts ⬜️ Ignored (Inspect) Visit Preview Nov 1, 2024 5:44pm
examples-react-material-ui ⬜️ Ignored (Inspect) Visit Preview Nov 1, 2024 5:44pm
examples-react-pivot-table ⬜️ Ignored (Inspect) Visit Preview Nov 1, 2024 5:44pm
examples-vue-query-builder ⬜️ Ignored (Inspect) Visit Preview Nov 1, 2024 5:44pm

@github-actions github-actions bot added the pr:community Contribution from Cube.js community members. label Nov 1, 2024
@paveltiunov
Copy link
Member

@mike-taylor-nomihealth Thanks for contributing! Could we please put it under the flag enabled by default? Thanks!

@mike-taylor-nomihealth
Copy link
Contributor Author

mike-taylor-nomihealth commented Dec 11, 2024

@mike-taylor-nomihealth Thanks for contributing! Could we please put it under the flag enabled by default? Thanks!

I believe I got this all set up properly - let me know if this is not what you meant

Also - just realized #8665 was the same fix, so I implemented it in the suggested format from that bug ticket.

Adds env var for the snowflake driver to enable or disable the
case sensitivity and if not set will default to case insensitive
Copy link
Member

@KSDaemon KSDaemon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mike-taylor-nomihealth!
Thank you for taking this up! Left some comments! WDYT?

await this.execute(connection, 'ALTER SESSION SET TIMEZONE = \'UTC\'', [], false);
await this.execute(connection, `ALTER SESSION SET STATEMENT_TIMEOUT_IN_SECONDS = ${this.config.executionTimeout}`, [], false);

if (this.ignoreCase) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized that we mess the value of our env CUBEJS_DB_SNOWFLAKE_QUOTED_IDENTIFIERS_IGNORE_CASE / this.ignoreCase and the value we pass to the Snowflake.

I mean — if we have true — we pass false and vice versa.
Maybe it would be better to align them. Possible options imho are:

  1. Rename our var to smth like CUBEJS_DB_SNOWFLAKE_QUOTED_IDENTIFIERS_RESPECT_CASE. Then having it set to true — means exactly what we set by this statement — not ignoring the case.
  2. Or.... Use CUBEJS_DB_SNOWFLAKE_QUOTED_IDENTIFIERS_IGNORE_CASE as is: if it is true — then — we should pass true to Snowflake. In this case, don't forget to update the default value if var is not set, as we want respect case by default.

Copy link
Contributor Author

@mike-taylor-nomihealth mike-taylor-nomihealth Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought about this and even though it makes it a little bit janky to keep the CUBEJS_DB_SNOWFLAKE_QUOTED_IDENTIFIERS_IGNORE_CASE that matches the values passed so it matches the env var with the key/value that we're passing in the session - I think that's more straightforward even though it does mean we have the default behavior always hitting that logic path for a !this.ignoreCase

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we absolutely we sure we want to respect case by default for the snowflake driver given that they made the change to ignore it and upper() everthing? It seems non-intuitive that their driver doesn't default to case insensitive when that's the behavior of their UI and everything in between, so if we set the default behavior to be case sensitive it feels like there are a lot of folks using this driver that are going to have to set a value explicitly when the default behavior probably should reflect how snowflake is using it (even if they didn't update their driver settings to reflect that by default.).

I made the change in the PR but am just playing devils advocate here, because it seems like we got here because this ISN'T the default behavior but probably should be because of how SNOWFLAKE decided to update their behaviors.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I agree with you in general. The idea is first to put this behind the flag and later enable it by default.

@KSDaemon KSDaemon changed the title Fixing case statements in snowflake driver feat(snowflake-driver): add ignore case statements flag Dec 13, 2024
@KSDaemon
Copy link
Member

KSDaemon commented Jan 6, 2025

Gentle ping @mike-taylor-nomihealth!

exportBucket: this.getExportBucket(dataSource),
resultPrefetch: 1,
executionTimeout: getEnv('dbQueryTimeout', { dataSource }),
ignoreCase: getEnv('snowflakeQuotedIdentIgnoreCase', { dataSource }),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here you set ignoreCase, while SnowflakeDriverOptions type has caseSensitiveIdentifiers?: boolean

resultPrefetch?: number,
exportBucket?: SnowflakeDriverExportBucket,
executionTimeout?: number,
caseSensitiveIdentifiers?: boolean,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
caseSensitiveIdentifiers?: boolean,
identIgnoreCase?: boolean,

exportBucket: this.getExportBucket(dataSource),
resultPrefetch: 1,
executionTimeout: getEnv('dbQueryTimeout', { dataSource }),
ignoreCase: getEnv('snowflakeQuotedIdentIgnoreCase', { dataSource }),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ignoreCase: getEnv('snowflakeQuotedIdentIgnoreCase', { dataSource }),
identIgnoreCase: getEnv('snowflakeQuotedIdentIgnoreCase', { dataSource }),


// We only want to ignore the case if someone sets the value to false explicitly since the default assumption
// is that casing matters
if (!this.ignoreCase) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!this.ignoreCase) {
if (!this.identIgnoreCase) {

@KSDaemon
Copy link
Member

Okay... I took it into my own hands.: #9131.

@KSDaemon KSDaemon closed this Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:community Contribution from Cube.js community members.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Loading database schema from Snowflake fails in some cases

3 participants