File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ if [ " $# " -ne 2 ]; then
5+ echo " Usage: $0 <left.jsonl|jsonl.gz> <right.jsonl|jsonl.gz>" >&2
6+ exit 2
7+ fi
8+
9+ read_jsonl () {
10+ case " $1 " in
11+ * .gz) gzip -dc -- " $1 " ;;
12+ * ) cat -- " $1 " ;;
13+ esac
14+ }
15+
16+ normalize () {
17+ jq -S -c '
18+ if .recordType == "node" then
19+ {
20+ recordType: "node",
21+ labels: (.labels | sort),
22+ properties: .properties
23+ }
24+ elif .recordType == "relationship" then
25+ {
26+ recordType: "relationship",
27+ type: .type,
28+ properties: .properties
29+ }
30+ else
31+ error("Unsupported recordType: \(.recordType)")
32+ end
33+ '
34+ }
35+
36+ if diff -u \
37+ <( read_jsonl " $1 " | sed " /^[[:space:]]*$/d" | normalize | LC_ALL=C sort) \
38+ <( read_jsonl " $2 " | sed " /^[[:space:]]*$/d" | normalize | LC_ALL=C sort) ; then
39+ echo " JSONL content matches."
40+ else
41+ echo " JSONL content differs." >&2
42+ exit 1
43+ fi
You can’t perform that action at this time.
0 commit comments