Parsing JSON file in Snowflake Database












1















enter image description hereDatabase :SNOWFLAKE



My table contains JSON data for example:



{
"bucket":"IN_Apps",
"bySeqno":56,
"cas":1527639206906626048,
"content":"eyJoaWdoQmluIjoiNTQ4NTA4MDkiLCJkb2N1bWVudFR5cGUiOiJJSU5ETyIsImNhcmRUeXBlIyayI6Ik1BU1RFUkNBUkQifQ==",
"event":"mutation",
"expiration":0,
"flags":33554432,
"key":"iin54850809",
"lockTime":0,
"partition":948,
"revSeqno":1,
"vBucketUuid":137987627737694
}


when i tried to parse it.



select 
parse_json:bucket::string as bucket ,
parse_json:bySeqno::string as bySeqno ,
parse_json:cas::INT as cas ,
parse_json:content::string as content ,
parse_json:event::string as event
,parse_json:expiration::string as expiration
,parse_json:flags::string as flags
,parse_json:key::string as key
,parse_json:lockTime::string as lockTime
,parse_json:partition::string as partition
,parse_json:revSeqno::string as revSeqno
,parse_json:vBucketUuid::string as vBucketUuid
from STG_YS_APPS v


but it is throwing error like.




SQL compilation error: error line 2 at position 0 invalid identifier > >'PARSE_JSON'




may someone please help me.










share|improve this question

























  • any clue techie please

    – OMG
    Nov 13 '18 at 15:42











  • What is the exact schema of your table? Do you have there a column name called "parse_json" ? That's what your SQL suggests, but that would be weird. Maybe do "DESC TABLE v" and add the output to the question

    – Marcin Zukowski
    Nov 13 '18 at 22:59











  • @MarcinZukowski: No i don't have column named as parse_json. it is inbuilt in snowflake for parsing JSON.

    – OMG
    Nov 14 '18 at 5:05











  • Well, your query is written like you did. Please run "DESC TABLE v" and provide output

    – Marcin Zukowski
    Nov 14 '18 at 5:06
















1















enter image description hereDatabase :SNOWFLAKE



My table contains JSON data for example:



{
"bucket":"IN_Apps",
"bySeqno":56,
"cas":1527639206906626048,
"content":"eyJoaWdoQmluIjoiNTQ4NTA4MDkiLCJkb2N1bWVudFR5cGUiOiJJSU5ETyIsImNhcmRUeXBlIyayI6Ik1BU1RFUkNBUkQifQ==",
"event":"mutation",
"expiration":0,
"flags":33554432,
"key":"iin54850809",
"lockTime":0,
"partition":948,
"revSeqno":1,
"vBucketUuid":137987627737694
}


when i tried to parse it.



select 
parse_json:bucket::string as bucket ,
parse_json:bySeqno::string as bySeqno ,
parse_json:cas::INT as cas ,
parse_json:content::string as content ,
parse_json:event::string as event
,parse_json:expiration::string as expiration
,parse_json:flags::string as flags
,parse_json:key::string as key
,parse_json:lockTime::string as lockTime
,parse_json:partition::string as partition
,parse_json:revSeqno::string as revSeqno
,parse_json:vBucketUuid::string as vBucketUuid
from STG_YS_APPS v


but it is throwing error like.




SQL compilation error: error line 2 at position 0 invalid identifier > >'PARSE_JSON'




may someone please help me.










share|improve this question

























  • any clue techie please

    – OMG
    Nov 13 '18 at 15:42











  • What is the exact schema of your table? Do you have there a column name called "parse_json" ? That's what your SQL suggests, but that would be weird. Maybe do "DESC TABLE v" and add the output to the question

    – Marcin Zukowski
    Nov 13 '18 at 22:59











  • @MarcinZukowski: No i don't have column named as parse_json. it is inbuilt in snowflake for parsing JSON.

    – OMG
    Nov 14 '18 at 5:05











  • Well, your query is written like you did. Please run "DESC TABLE v" and provide output

    – Marcin Zukowski
    Nov 14 '18 at 5:06














1












1








1








enter image description hereDatabase :SNOWFLAKE



My table contains JSON data for example:



{
"bucket":"IN_Apps",
"bySeqno":56,
"cas":1527639206906626048,
"content":"eyJoaWdoQmluIjoiNTQ4NTA4MDkiLCJkb2N1bWVudFR5cGUiOiJJSU5ETyIsImNhcmRUeXBlIyayI6Ik1BU1RFUkNBUkQifQ==",
"event":"mutation",
"expiration":0,
"flags":33554432,
"key":"iin54850809",
"lockTime":0,
"partition":948,
"revSeqno":1,
"vBucketUuid":137987627737694
}


when i tried to parse it.



select 
parse_json:bucket::string as bucket ,
parse_json:bySeqno::string as bySeqno ,
parse_json:cas::INT as cas ,
parse_json:content::string as content ,
parse_json:event::string as event
,parse_json:expiration::string as expiration
,parse_json:flags::string as flags
,parse_json:key::string as key
,parse_json:lockTime::string as lockTime
,parse_json:partition::string as partition
,parse_json:revSeqno::string as revSeqno
,parse_json:vBucketUuid::string as vBucketUuid
from STG_YS_APPS v


but it is throwing error like.




SQL compilation error: error line 2 at position 0 invalid identifier > >'PARSE_JSON'




may someone please help me.










share|improve this question
















enter image description hereDatabase :SNOWFLAKE



My table contains JSON data for example:



{
"bucket":"IN_Apps",
"bySeqno":56,
"cas":1527639206906626048,
"content":"eyJoaWdoQmluIjoiNTQ4NTA4MDkiLCJkb2N1bWVudFR5cGUiOiJJSU5ETyIsImNhcmRUeXBlIyayI6Ik1BU1RFUkNBUkQifQ==",
"event":"mutation",
"expiration":0,
"flags":33554432,
"key":"iin54850809",
"lockTime":0,
"partition":948,
"revSeqno":1,
"vBucketUuid":137987627737694
}


when i tried to parse it.



select 
parse_json:bucket::string as bucket ,
parse_json:bySeqno::string as bySeqno ,
parse_json:cas::INT as cas ,
parse_json:content::string as content ,
parse_json:event::string as event
,parse_json:expiration::string as expiration
,parse_json:flags::string as flags
,parse_json:key::string as key
,parse_json:lockTime::string as lockTime
,parse_json:partition::string as partition
,parse_json:revSeqno::string as revSeqno
,parse_json:vBucketUuid::string as vBucketUuid
from STG_YS_APPS v


but it is throwing error like.




SQL compilation error: error line 2 at position 0 invalid identifier > >'PARSE_JSON'




may someone please help me.







sql json snowflake-datawarehouse






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 6:31







OMG

















asked Nov 13 '18 at 14:55









OMGOMG

464




464













  • any clue techie please

    – OMG
    Nov 13 '18 at 15:42











  • What is the exact schema of your table? Do you have there a column name called "parse_json" ? That's what your SQL suggests, but that would be weird. Maybe do "DESC TABLE v" and add the output to the question

    – Marcin Zukowski
    Nov 13 '18 at 22:59











  • @MarcinZukowski: No i don't have column named as parse_json. it is inbuilt in snowflake for parsing JSON.

    – OMG
    Nov 14 '18 at 5:05











  • Well, your query is written like you did. Please run "DESC TABLE v" and provide output

    – Marcin Zukowski
    Nov 14 '18 at 5:06



















  • any clue techie please

    – OMG
    Nov 13 '18 at 15:42











  • What is the exact schema of your table? Do you have there a column name called "parse_json" ? That's what your SQL suggests, but that would be weird. Maybe do "DESC TABLE v" and add the output to the question

    – Marcin Zukowski
    Nov 13 '18 at 22:59











  • @MarcinZukowski: No i don't have column named as parse_json. it is inbuilt in snowflake for parsing JSON.

    – OMG
    Nov 14 '18 at 5:05











  • Well, your query is written like you did. Please run "DESC TABLE v" and provide output

    – Marcin Zukowski
    Nov 14 '18 at 5:06

















any clue techie please

– OMG
Nov 13 '18 at 15:42





any clue techie please

– OMG
Nov 13 '18 at 15:42













What is the exact schema of your table? Do you have there a column name called "parse_json" ? That's what your SQL suggests, but that would be weird. Maybe do "DESC TABLE v" and add the output to the question

– Marcin Zukowski
Nov 13 '18 at 22:59





What is the exact schema of your table? Do you have there a column name called "parse_json" ? That's what your SQL suggests, but that would be weird. Maybe do "DESC TABLE v" and add the output to the question

– Marcin Zukowski
Nov 13 '18 at 22:59













@MarcinZukowski: No i don't have column named as parse_json. it is inbuilt in snowflake for parsing JSON.

– OMG
Nov 14 '18 at 5:05





@MarcinZukowski: No i don't have column named as parse_json. it is inbuilt in snowflake for parsing JSON.

– OMG
Nov 14 '18 at 5:05













Well, your query is written like you did. Please run "DESC TABLE v" and provide output

– Marcin Zukowski
Nov 14 '18 at 5:06





Well, your query is written like you did. Please run "DESC TABLE v" and provide output

– Marcin Zukowski
Nov 14 '18 at 5:06












1 Answer
1






active

oldest

votes


















1














Answer with a known schema



Update: Since you provided schema, which shows a VAR column of VARIANT type, here's what you need, couldn't be simpler:



select
var:bucket::string as bucket,
var:bySeqno::string as bySeqno,
var:cas::int as cas
...
from STG_YS_APPS v


Below the answer before the schema was known



I'll assume you have a VARCHAR (or similar) column in your table that is called json, and stores the values you presented. You didn't provide the schema, so please adjust the column name as necessary.



You're not using PARSE_JSON as a function in your SQL. You should write something like



select
parse_json(json):bucket::string as bucket,
parse_json(json):bySeqno::string as bySeqno,
parse_json(json):cas::int as cas
...
from STG_YS_APPS v





share|improve this answer


























  • i have attached the snapshot of schema above. when i tried select parse_json(json):bucket::string as bucket from STG_YS_APPS, i got error: invalid identifier 'JSON . please help if i am missing something

    – OMG
    Nov 14 '18 at 6:35











  • may someone please help me if possible, Snowflake datawarehouse is little new to me.

    – OMG
    Nov 14 '18 at 14:38











  • am i need to add lateral flatten

    – OMG
    Nov 14 '18 at 14:42











  • I'm sorry, but you clearly should do some reading and read/watch some tutorials about SQL in general and Snowflake VARIANT processing... Your questions suggest lack of very basic SQL knowledge.

    – Marcin Zukowski
    Nov 15 '18 at 0:25











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53283738%2fparsing-json-file-in-snowflake-database%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Answer with a known schema



Update: Since you provided schema, which shows a VAR column of VARIANT type, here's what you need, couldn't be simpler:



select
var:bucket::string as bucket,
var:bySeqno::string as bySeqno,
var:cas::int as cas
...
from STG_YS_APPS v


Below the answer before the schema was known



I'll assume you have a VARCHAR (or similar) column in your table that is called json, and stores the values you presented. You didn't provide the schema, so please adjust the column name as necessary.



You're not using PARSE_JSON as a function in your SQL. You should write something like



select
parse_json(json):bucket::string as bucket,
parse_json(json):bySeqno::string as bySeqno,
parse_json(json):cas::int as cas
...
from STG_YS_APPS v





share|improve this answer


























  • i have attached the snapshot of schema above. when i tried select parse_json(json):bucket::string as bucket from STG_YS_APPS, i got error: invalid identifier 'JSON . please help if i am missing something

    – OMG
    Nov 14 '18 at 6:35











  • may someone please help me if possible, Snowflake datawarehouse is little new to me.

    – OMG
    Nov 14 '18 at 14:38











  • am i need to add lateral flatten

    – OMG
    Nov 14 '18 at 14:42











  • I'm sorry, but you clearly should do some reading and read/watch some tutorials about SQL in general and Snowflake VARIANT processing... Your questions suggest lack of very basic SQL knowledge.

    – Marcin Zukowski
    Nov 15 '18 at 0:25
















1














Answer with a known schema



Update: Since you provided schema, which shows a VAR column of VARIANT type, here's what you need, couldn't be simpler:



select
var:bucket::string as bucket,
var:bySeqno::string as bySeqno,
var:cas::int as cas
...
from STG_YS_APPS v


Below the answer before the schema was known



I'll assume you have a VARCHAR (or similar) column in your table that is called json, and stores the values you presented. You didn't provide the schema, so please adjust the column name as necessary.



You're not using PARSE_JSON as a function in your SQL. You should write something like



select
parse_json(json):bucket::string as bucket,
parse_json(json):bySeqno::string as bySeqno,
parse_json(json):cas::int as cas
...
from STG_YS_APPS v





share|improve this answer


























  • i have attached the snapshot of schema above. when i tried select parse_json(json):bucket::string as bucket from STG_YS_APPS, i got error: invalid identifier 'JSON . please help if i am missing something

    – OMG
    Nov 14 '18 at 6:35











  • may someone please help me if possible, Snowflake datawarehouse is little new to me.

    – OMG
    Nov 14 '18 at 14:38











  • am i need to add lateral flatten

    – OMG
    Nov 14 '18 at 14:42











  • I'm sorry, but you clearly should do some reading and read/watch some tutorials about SQL in general and Snowflake VARIANT processing... Your questions suggest lack of very basic SQL knowledge.

    – Marcin Zukowski
    Nov 15 '18 at 0:25














1












1








1







Answer with a known schema



Update: Since you provided schema, which shows a VAR column of VARIANT type, here's what you need, couldn't be simpler:



select
var:bucket::string as bucket,
var:bySeqno::string as bySeqno,
var:cas::int as cas
...
from STG_YS_APPS v


Below the answer before the schema was known



I'll assume you have a VARCHAR (or similar) column in your table that is called json, and stores the values you presented. You didn't provide the schema, so please adjust the column name as necessary.



You're not using PARSE_JSON as a function in your SQL. You should write something like



select
parse_json(json):bucket::string as bucket,
parse_json(json):bySeqno::string as bySeqno,
parse_json(json):cas::int as cas
...
from STG_YS_APPS v





share|improve this answer















Answer with a known schema



Update: Since you provided schema, which shows a VAR column of VARIANT type, here's what you need, couldn't be simpler:



select
var:bucket::string as bucket,
var:bySeqno::string as bySeqno,
var:cas::int as cas
...
from STG_YS_APPS v


Below the answer before the schema was known



I'll assume you have a VARCHAR (or similar) column in your table that is called json, and stores the values you presented. You didn't provide the schema, so please adjust the column name as necessary.



You're not using PARSE_JSON as a function in your SQL. You should write something like



select
parse_json(json):bucket::string as bucket,
parse_json(json):bySeqno::string as bySeqno,
parse_json(json):cas::int as cas
...
from STG_YS_APPS v






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 15 '18 at 0:24

























answered Nov 14 '18 at 5:12









Marcin ZukowskiMarcin Zukowski

1,9351820




1,9351820













  • i have attached the snapshot of schema above. when i tried select parse_json(json):bucket::string as bucket from STG_YS_APPS, i got error: invalid identifier 'JSON . please help if i am missing something

    – OMG
    Nov 14 '18 at 6:35











  • may someone please help me if possible, Snowflake datawarehouse is little new to me.

    – OMG
    Nov 14 '18 at 14:38











  • am i need to add lateral flatten

    – OMG
    Nov 14 '18 at 14:42











  • I'm sorry, but you clearly should do some reading and read/watch some tutorials about SQL in general and Snowflake VARIANT processing... Your questions suggest lack of very basic SQL knowledge.

    – Marcin Zukowski
    Nov 15 '18 at 0:25



















  • i have attached the snapshot of schema above. when i tried select parse_json(json):bucket::string as bucket from STG_YS_APPS, i got error: invalid identifier 'JSON . please help if i am missing something

    – OMG
    Nov 14 '18 at 6:35











  • may someone please help me if possible, Snowflake datawarehouse is little new to me.

    – OMG
    Nov 14 '18 at 14:38











  • am i need to add lateral flatten

    – OMG
    Nov 14 '18 at 14:42











  • I'm sorry, but you clearly should do some reading and read/watch some tutorials about SQL in general and Snowflake VARIANT processing... Your questions suggest lack of very basic SQL knowledge.

    – Marcin Zukowski
    Nov 15 '18 at 0:25

















i have attached the snapshot of schema above. when i tried select parse_json(json):bucket::string as bucket from STG_YS_APPS, i got error: invalid identifier 'JSON . please help if i am missing something

– OMG
Nov 14 '18 at 6:35





i have attached the snapshot of schema above. when i tried select parse_json(json):bucket::string as bucket from STG_YS_APPS, i got error: invalid identifier 'JSON . please help if i am missing something

– OMG
Nov 14 '18 at 6:35













may someone please help me if possible, Snowflake datawarehouse is little new to me.

– OMG
Nov 14 '18 at 14:38





may someone please help me if possible, Snowflake datawarehouse is little new to me.

– OMG
Nov 14 '18 at 14:38













am i need to add lateral flatten

– OMG
Nov 14 '18 at 14:42





am i need to add lateral flatten

– OMG
Nov 14 '18 at 14:42













I'm sorry, but you clearly should do some reading and read/watch some tutorials about SQL in general and Snowflake VARIANT processing... Your questions suggest lack of very basic SQL knowledge.

– Marcin Zukowski
Nov 15 '18 at 0:25





I'm sorry, but you clearly should do some reading and read/watch some tutorials about SQL in general and Snowflake VARIANT processing... Your questions suggest lack of very basic SQL knowledge.

– Marcin Zukowski
Nov 15 '18 at 0:25


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53283738%2fparsing-json-file-in-snowflake-database%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Full-time equivalent

さくらももこ

13 indicted, 8 arrested in Calif. drug cartel investigation