ignore query json parse errors
UI fix: ignore query json parse errors in query console
@@ -209,8 +209,12 @@ const getTableSchemaData = (tableName) => {
const getAsObject = (str: SQLResult) => {
if (typeof str === 'string' || str instanceof String) {
+ try {
+ return JSONbig.parse(str);
+ } catch(e) {
return JSON.parse(JSON.stringify(str));
}
+ }
return str;
};
@@ -219,9 +223,7 @@ const getAsObject = (str: SQLResult) => {
// Expected Output: {columns: [], records: []}
const getQueryResults = (params, url, checkedOptions) => {
return getQueryResult(params, url).then(({ data }) => {
- data = JSONbig.parse(data);
let queryResponse = null;
-
queryResponse = getAsObject(data);
// if sql api throws error, handle here
@@ -301,13 +303,13 @@ const getQueryResults = (params, url, checkedOptions) => {
},
queryStats: {
columns: columnStats,
- records: [[data.timeUsedMs, data.numDocsScanned, data.totalDocs, data.numServersQueried, data.numServersResponded,
- data.numSegmentsQueried, data.numSegmentsProcessed, data.numSegmentsMatched, data.numConsumingSegmentsQueried,
- data.numEntriesScannedInFilter, data.numEntriesScannedPostFilter, data.numGroupsLimitReached,
- data.partialResponse ? data.partialResponse : '-', data.minConsumingFreshnessTimeMs,
- data.offlineThreadCpuTimeNs, data.realtimeThreadCpuTimeNs]]
+ records: [[queryResponse.timeUsedMs, queryResponse.numDocsScanned, queryResponse.totalDocs, queryResponse.numServersQueried, queryResponse.numServersResponded,
+ queryResponse.numSegmentsQueried, queryResponse.numSegmentsProcessed, queryResponse.numSegmentsMatched, queryResponse.numConsumingSegmentsQueried,
+ queryResponse.numEntriesScannedInFilter, queryResponse.numEntriesScannedPostFilter, queryResponse.numGroupsLimitReached,
+ queryResponse.partialResponse ? queryResponse.partialResponse : '-', queryResponse.minConsumingFreshnessTimeMs,
+ queryResponse.offlineThreadCpuTimeNs, queryResponse.realtimeThreadCpuTimeNs]]
},
- data,
+ data: queryResponse,
};
});
};
