File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,18 @@ export const parseFromFluxResults = (
2929 const groupSet = new Set ( fluxGroupKeyUnion )
3030 let max = 0
3131
32+ // checks whether the string is valid JSON object or not
33+ const isJsonObject = jsonString => {
34+ try {
35+ const object = JSON . parse ( jsonString )
36+ if ( object && typeof object === 'object' ) {
37+ return true
38+ }
39+ } catch { }
40+
41+ return false
42+ }
43+
3244 for ( let i = 0 ; i < tables . length ; i ++ ) {
3345 if ( values [ i ] !== currVal || tables [ i ] !== currTable ) {
3446 // sets the boundaries for the chunk based on different yields or tables
@@ -72,7 +84,16 @@ export const parseFromFluxResults = (
7284 ) {
7385 columnData = new Date ( columnData ) . toISOString ( )
7486 }
75- if ( typeof columnData === 'string' ) {
87+
88+ // (Sahas):
89+ // the columnData can have a comma (,) in two cases
90+ // 1. it's a JSON Object
91+ // 2. It's a string of CSV
92+ if ( isJsonObject ( columnData ) ) {
93+ // 1. replace Double quotes \" with Single quotes \' in a json object
94+ // 2. then wrap the JSON object in double quotes
95+ columnData = `"${ columnData . replace ( / [ ' " ] + / g, "'" ) } "`
96+ } else if ( typeof columnData === 'string' && columnData . includes ( ',' ) ) {
7697 columnData = `"${ columnData } "`
7798 }
7899 if ( column === 'result' ) {
You can’t perform that action at this time.
0 commit comments