Skip to content

Commit 2efbfaf

Browse files
committed
🧠 playground schema derive-schema: handle non-minified json #6394
1 parent 2e405da commit 2efbfaf

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

scripts/cli/playground

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18832,6 +18832,19 @@ playground_schema_derive_schema_command() {
1883218832
fi
1883318833
fi
1883418834

18835+
if jq -e . >/dev/null 2>&1 <<< "$(head -1 "$payload_file")"
18836+
then
18837+
log "💫 payload is one json per line, one json record per line will be used"
18838+
elif jq -e . >/dev/null 2>&1 <<< "$(cat "$payload_file")"
18839+
then
18840+
log "💫 payload is single json, it will be used as one record"
18841+
jq -c . "$payload_file" > $tmp_dir/minified.json
18842+
cp $tmp_dir/minified.json $payload_file
18843+
else
18844+
logerror "❌ payload is not a valid json"
18845+
exit 1
18846+
fi
18847+
1883518848
LATEST_TAG=$(grep "export TAG" $root_folder/scripts/utils.sh | head -1 | cut -d "=" -f 2 | cut -d " " -f 1)
1883618849
if [ -z "$LATEST_TAG" ]
1883718850
then

scripts/cli/src/commands/schema/derive-schema.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ else
3838
fi
3939
fi
4040

41+
if jq -e . >/dev/null 2>&1 <<< "$(head -1 "$payload_file")"
42+
then
43+
log "💫 payload is one json per line, one json record per line will be used"
44+
elif jq -e . >/dev/null 2>&1 <<< "$(cat "$payload_file")"
45+
then
46+
log "💫 payload is single json, it will be used as one record"
47+
jq -c . "$payload_file" > $tmp_dir/minified.json
48+
cp $tmp_dir/minified.json $payload_file
49+
else
50+
logerror "❌ payload is not a valid json"
51+
exit 1
52+
fi
53+
4154
LATEST_TAG=$(grep "export TAG" $root_folder/scripts/utils.sh | head -1 | cut -d "=" -f 2 | cut -d " " -f 1)
4255
if [ -z "$LATEST_TAG" ]
4356
then

0 commit comments

Comments
 (0)