Skip to content

Commit cbc6d03

Browse files
committed
Fix Group by issue when using JSONata
1 parent c66af71 commit cbc6d03

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/components/ExperimentalEditor.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,21 @@ export const ExperimentalEditor = ({ query, onChange, onRunQuery, editorContext
4343
onRunQuery();
4444
};
4545

46+
// TODO: Extract field names from the actual result.
4647
const fieldNames = query.fields
4748
.map((field) => {
48-
if (field.name) {
49-
return field.name;
49+
if (field.language === 'jsonpath') {
50+
if (field.name) {
51+
return field.name;
52+
}
53+
54+
const pathArray = (JSONPath as any).toPathArray(field.jsonPath);
55+
return pathArray[pathArray.length - 1];
5056
}
5157

52-
const pathArray = (JSONPath as any).toPathArray(field.jsonPath);
53-
return pathArray[pathArray.length - 1];
58+
return field.name;
5459
})
60+
.filter((name) => name)
5561
.map((path) => ({ label: path, value: path }));
5662

5763
return (

0 commit comments

Comments
 (0)