Changeset: 7e72e1e6ff30 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/7e72e1e6ff30
Modified Files:
        clients/Tests/MAL-signatures-hge.test
        clients/Tests/MAL-signatures.test
        monetdb5/modules/kernel/algebra.c
Branch: Dec2025
Log Message:

Allow offset with return_skipped==true in two result firstn.


diffs (62 lines):

diff --git a/clients/Tests/MAL-signatures-hge.test 
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -3465,6 +3465,11 @@ ALGfirstn
 Calculate first N values of B with candidate list S
 algebra
 firstn
+pattern algebra.firstn(X_0:bat[:any], X_1:bat[:oid], X_2:bat[:oid], X_3:lng, 
X_4:lng, X_5:bit, X_6:bit, X_7:bit, X_8:bit) (X_9:bat[:oid], X_10:bat[:oid])
+ALGfirstn
+Calculate first N values of B with candidate list S
+algebra
+firstn
 pattern algebra.firstn(X_0:bat[:any], X_1:bat[:oid], X_2:bat[:oid], X_3:lng, 
X_4:lng, X_5:bit, X_6:bit, X_7:bit, X_8:bit):bat[:oid]
 ALGfirstn
 Calculate first N values of B with candidate list S
diff --git a/clients/Tests/MAL-signatures.test 
b/clients/Tests/MAL-signatures.test
--- a/clients/Tests/MAL-signatures.test
+++ b/clients/Tests/MAL-signatures.test
@@ -2900,6 +2900,11 @@ ALGfirstn
 Calculate first N values of B with candidate list S
 algebra
 firstn
+pattern algebra.firstn(X_0:bat[:any], X_1:bat[:oid], X_2:bat[:oid], X_3:lng, 
X_4:lng, X_5:bit, X_6:bit, X_7:bit, X_8:bit) (X_9:bat[:oid], X_10:bat[:oid])
+ALGfirstn
+Calculate first N values of B with candidate list S
+algebra
+firstn
 pattern algebra.firstn(X_0:bat[:any], X_1:bat[:oid], X_2:bat[:oid], X_3:lng, 
X_4:lng, X_5:bit, X_6:bit, X_7:bit, X_8:bit):bat[:oid]
 ALGfirstn
 Calculate first N values of B with candidate list S
diff --git a/monetdb5/modules/kernel/algebra.c 
b/monetdb5/modules/kernel/algebra.c
--- a/monetdb5/modules/kernel/algebra.c
+++ b/monetdb5/modules/kernel/algebra.c
@@ -1007,7 +1007,6 @@ ALGfirstn(Client cntxt, MalBlkPtr mb, Ma
        if (n > (lng) BUN_MAX)
                n = BUN_MAX;
        if (getArgType(mb, pci, pci->retc + 4) == TYPE_lng) {
-               assert(ret2 == NULL);
                o = *getArgReference_lng(stk, pci, pci->retc + 4);
                if (o < 0 || o > (lng) BUN_MAX) {
                        BBPreclaim(b);
@@ -1019,6 +1018,12 @@ ALGfirstn(Client cntxt, MalBlkPtr mb, Ma
                        n += o;
                        o = 0;
                }
+               if (ret2 && o != 0) {
+                       BBPreclaim(b);
+                       BBPreclaim(s);
+                       BBPreclaim(g);
+                       throw(MAL, "algebra.firstn", ILLEGAL_ARGUMENT);
+               }
        }
        asc = *getArgReference_bit(stk, pci, pci->argc - 3);
        nilslast = *getArgReference_bit(stk, pci, pci->argc - 2);
@@ -1971,6 +1976,7 @@ static mel_func algebra_init_funcs[] = {
  pattern("algebra", "firstn", ALGfirstn, false, "Calculate first N values of B 
with candidate list S", args(1,8, 
batarg("",oid),batargany("b",0),batarg("s",oid),batarg("g",oid),arg("n",lng),arg("asc",bit),arg("nilslast",bit),arg("distinct",bit))),
  pattern("algebra", "firstn", ALGfirstn, false, "Calculate first N values of B 
with candidate list S", args(2,9, 
batarg("",oid),batarg("",oid),batargany("b",0),batarg("s",oid),batarg("g",oid),arg("n",lng),arg("asc",bit),arg("nilslast",bit),arg("distinct",bit))),
  pattern("algebra", "firstn", ALGfirstn, false, "Calculate first N values of B 
with candidate list S", args(1,10, 
batarg("",oid),batargany("b",0),batarg("s",oid),batarg("g",oid),arg("n",lng),arg("o",lng),arg("return_skipped",bit),arg("asc",bit),arg("nilslast",bit),arg("distinct",bit))),
+ pattern("algebra", "firstn", ALGfirstn, false, "Calculate first N values of B 
with candidate list S", args(2,11, 
batarg("",oid),batarg("",oid),batargany("b",0),batarg("s",oid),batarg("g",oid),arg("n",lng),arg("o",lng),arg("return_skipped",bit),arg("asc",bit),arg("nilslast",bit),arg("distinct",bit))),
  pattern("algebra", "groupedfirstn", ALGgroupedfirstn, false, "Grouped 
firstn", args(1,5, 
batarg("",oid),arg("n",lng),batarg("s",oid),batarg("g",oid),varargany("arg",0))),
  pattern("algebra", "groupedfirstn", ALGgroupedfirstn, false, "Grouped 
firstn", args(1,7, 
batarg("",oid),arg("n",lng),arg("o",lng),arg("return_skipped",bit),batarg("s",oid),batarg("g",oid),varargany("arg",0))),
  command("algebra", "reuse", ALGreuse, false, "Reuse a temporary BAT if you 
can. Otherwise,\nallocate enough storage to accept result of an\noperation (not 
involving the heap)", args(1,2, batargany("",1),batargany("b",1))),
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to