-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for column tests not rendering on quoted columns (#425)
* (#201) Fix for column tests not rendering on quoted columns * Add support for bigquery quotes * use backticks for databricks and spark; add compat module and test
- Loading branch information
Showing
4 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Docs | ||
body: Fix for column tests not rendering on quoted columns | ||
time: 2023-05-31T11:54:19.687363-04:00 | ||
custom: | ||
Author: drewbanin | ||
Issue: "201" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
function getQuoteChar(project_metadata) { | ||
var backtickDatabases = ['bigquery', 'spark', 'databricks']; | ||
var adapter_type = (project_metadata || {}).adapter_type; | ||
|
||
if (backtickDatabases.indexOf(adapter_type) >= 0) { | ||
return '`'; | ||
} else { | ||
return '"'; | ||
} | ||
} | ||
|
||
|
||
module.exports = { | ||
getQuoteChar, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
const compat = require("./compat"); | ||
|
||
const BACKTICK = '`'; | ||
const QUOTE = '"'; | ||
|
||
|
||
test("column quoting", () => { | ||
expect(compat.getQuoteChar({adapter_type: 'bigquery'})).toStrictEqual(BACKTICK); | ||
expect(compat.getQuoteChar({adapter_type: 'spark'})).toStrictEqual(BACKTICK); | ||
expect(compat.getQuoteChar({adapter_type: 'databricks'})).toStrictEqual(BACKTICK); | ||
expect(compat.getQuoteChar({adapter_type: 'postgres'})).toStrictEqual(QUOTE); | ||
expect(compat.getQuoteChar({adapter_type: 'snowflake'})).toStrictEqual(QUOTE); | ||
expect(compat.getQuoteChar({adapter_type: 'redshift'})).toStrictEqual(QUOTE); | ||
expect(compat.getQuoteChar({adapter_type: 'unknown_db'})).toStrictEqual(QUOTE); | ||
}); | ||
|
||
test("column quoting with invalid adapter", () => { | ||
expect(compat.getQuoteChar({adapter_type: null})).toStrictEqual(QUOTE); | ||
expect(compat.getQuoteChar({})).toStrictEqual(QUOTE); | ||
expect(compat.getQuoteChar(null)).toStrictEqual(QUOTE); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters