-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SNOW-375565: How to fetchAsString
but keep null values?
#176
Comments
fetchAsString
but keep null values?fetchAsString
but keep null values?
Is there a resolution here? This seems to still be an issue. |
hi, thank you for submitting this issue. using latest (
per the Snowflake documentation for Fetching Data Types as Strings
as i see it, this is what is happening, forcing the number to be returned as string. ( what happens in your case when you leave |
Hi @sfc-gh-dszmolka, thank you for the response.
CREATE TABLE a (x float);
INSERT INTO a VALUES (null);
SELECT x FROM a;
|
i see, thank you for the clarification @datbth . looking around a bit I found (maybe a bit late) that this item has already been submitted in 2021 to the team to pick up and prioritize, to implement the necessary capability into the driver. hopefully it can happen sometimes in the coming months. until then, we'll need to resort to some kind of workaround i'm afraid. (server side or client side) |
I hit this today and was surprised by the behavior, where we were doing Our workaround was to use patch-package to modify this line: diff --git a/node_modules/snowflake-sdk/lib/connection/result/column.js b/node_modules/snowflake-sdk/lib/connection/result/column.js
index 58da09f..6d1045f 100644
--- a/node_modules/snowflake-sdk/lib/connection/result/column.js
+++ b/node_modules/snowflake-sdk/lib/connection/result/column.js
@@ -9,7 +9,7 @@ var SfTimestamp = require('./sf_timestamp');
var SqlTypes = require('./data_types').SqlTypes;
var bigInt = require('big-integer');
-var NULL_UPPERCASE = 'NULL';
+var NULL_UPPERCASE = null;
/**
* Creates a new Column. I'd be kind of curious to know what the use case is for getting the string |
thank you for sharing your approach of how to work around this issue ! sadly I cannot answer the question why |
PR in review at #831 |
PR merged and fix will be part of the next release cycle, probably end of May 2024 |
released with May 2024 release cycle, version 1.11.0 thank you for your patience here ! |
Please answer these questions before submitting your issue. Thanks!
What version of NodeJS are you using (
node --version
andnpm --version
)?Node: v14.17.0
Npm: 6.14.14
What operating system and processor architecture are you using?
What are the component versions in the environment (
npm list
)?I'm using [email protected]
What did you do?
Run a SQL with fetchAsString option:
What did you expect to see?
Console logging
true
andnull
What did you see instead?
Console logging
false
and"null"
Add this to get standard output.
I would like to fetch all values as raw Strings, so that I don't have to worry about any lossy/distorted values due to Javascript processing. But currently, with
fetchAsString
option,null
values are being turned into'NULL'
(NULL_UPPERCASE string). I could process through the non-text columns and revert'NULL'
values intonull
s, but that would be very inefficient as the values have to be processed unnecessarily multiple times.Thus, may I ask for the reasons behind the decision of this behavior of turning
null
into'NULL'
? And whether there are any better setup or workaround for my case?Thank you.
The text was updated successfully, but these errors were encountered: