Changeset: 607ad8cd56d2 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=607ad8cd56d2
Modified Files:
monetdb5/extras/jaql/Tests/json02.mal
monetdb5/extras/jaql/Tests/json02.stable.out
monetdb5/extras/jaql/json.c
Branch: jacqueline
Log Message:
JSONextract: translate nils to null entries
If elems refers to an explicit nil, translate that to a null entry in
the output array. This way, outer joins (preserve) can still rely on
the order from extract being correct (following the input from elems).
diffs (55 lines):
diff --git a/monetdb5/extras/jaql/Tests/json02.mal
b/monetdb5/extras/jaql/Tests/json02.mal
--- a/monetdb5/extras/jaql/Tests/json02.mal
+++ b/monetdb5/extras/jaql/Tests/json02.mal
@@ -29,3 +29,10 @@ elem3 := bat.insert(elem3, 0@0, 3@0);
(k1,k2,k3,k4,k5,k6,k7) := json.extract(j1,j2,j3,j4,j5,j6,j7,elem3,0@0);
json.print(s, k1,k2,k3,k4,k5,k6,k7);
+
+elem4 := bat.new(:oid, :oid);
+elem4 := bat.insert(elem4, 0@0, 1@0);
+elem4 := bat.insert(elem4, 0@0, nil:oid);
+
+(k1,k2,k3,k4,k5,k6,k7) := json.extract(j1,j2,j3,j4,j5,j6,j7,elem4,0@0);
+json.print(s, k1,k2,k3,k4,k5,k6,k7);
diff --git a/monetdb5/extras/jaql/Tests/json02.stable.out
b/monetdb5/extras/jaql/Tests/json02.stable.out
--- a/monetdb5/extras/jaql/Tests/json02.stable.out
+++ b/monetdb5/extras/jaql/Tests/json02.stable.out
@@ -38,12 +38,18 @@ function user.main():void;
elem3 := bat.insert(elem3,0@0,3@0);
(k1,k2,k3,k4,k5,k6,k7) := json.extract(j1,j2,j3,j4,j5,j6,j7,elem3,0@0);
json.print(s,k1,k2,k3,k4,k5,k6,k7);
+ elem4 := bat.new(:oid,:oid);
+ elem4 := bat.insert(elem4,0@0,1@0);
+ elem4 := bat.insert(elem4,0@0,nil:oid);
+ (k1,k2,k3,k4,k5,k6,k7) := json.extract(j1,j2,j3,j4,j5,j6,j7,elem4,0@0);
+ json.print(s,k1,k2,k3,k4,k5,k6,k7);
end main;
[ "hello", { "world": [ 0, 2, true, null ] } ]
[ [ "hello", { "world": [ 0, 2, true, null ] } ] ]
[ "hello" ]
[ { "world": [ 0, 2, true, null ] } ]
[ "hello", [ 0, 2, true, null ] ]
+[ "hello", null ]
# 22:47:10 >
# 22:47:10 > "Done."
diff --git a/monetdb5/extras/jaql/json.c b/monetdb5/extras/jaql/json.c
--- a/monetdb5/extras/jaql/json.c
+++ b/monetdb5/extras/jaql/json.c
@@ -834,8 +834,13 @@ JSONextract(int *rkind, int *rstring, in
w = BUNlast(jbr.kind) - 1 + *startoid;
BATloop(e, p, q) {
v = *(oid *)BUNtail(bie, p);
- z = json_copy_entry(bik, bis, bii, bid, bia, bio, bin,
- *startoid, v, &jb, &jbr);
+ if (v != oid_nil) {
+ z = json_copy_entry(bik, bis, bii, bid, bia, bio, bin,
+ *startoid, v, &jb, &jbr);
+ } else {
+ BUNappend(jbr.kind, "n", FALSE);
+ z = BUNlast(jbr.kind) - 1 + *startoid;
+ }
BUNins(jbr.array, &w, &z, FALSE);
}
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list