Changeset: 6b93010956a8 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6b93010956a8
Modified Files:
monetdb5/extras/jaql/Tests/transform00.mal
monetdb5/extras/jaql/Tests/transform00.stable.out
monetdb5/extras/jaql/jaqlgencode.c
Branch: jacqueline
Log Message:
transform: handle variable with double constant
skip the integer case when the constant is double (answer must be dbl)
cast all int values to dbl in that case as well
add break not to fall in assert case
add tests that triggered these failures
diffs (177 lines):
diff --git a/monetdb5/extras/jaql/Tests/transform00.mal
b/monetdb5/extras/jaql/Tests/transform00.mal
--- a/monetdb5/extras/jaql/Tests/transform00.mal
+++ b/monetdb5/extras/jaql/Tests/transform00.mal
@@ -3,3 +3,6 @@ jaql.x("[{\"a\": 1}, {\"a\": 2.6}] -> tr
jaql.x("[1,2.2,3] -> transform 2 * $;");
jaql.x("[{\"a\": 1}, {\"a\": 2.5}] -> transform $.a + $.a;");
jaql.x("[{\"a\": 1, \"b\": 3.4}, {\"a\": 2.5, \"b\": 4}] -> transform $.a +
$.b;");
+jaql.x("[1,2,3] -> transform 2 * ($ * 2);");
+jaql.x("[1,2,3] -> transform 2 * 2.0 * $;");
+jaql.x("[1,2,3] -> transform ($ * 2.0) / 4;");
diff --git a/monetdb5/extras/jaql/Tests/transform00.stable.out
b/monetdb5/extras/jaql/Tests/transform00.stable.out
--- a/monetdb5/extras/jaql/Tests/transform00.stable.out
+++ b/monetdb5/extras/jaql/Tests/transform00.stable.out
@@ -22,12 +22,18 @@ function user.main():void;
jaql.x("[1,2.2,3] -> transform 2 * $;");
jaql.x("[{\"a\": 1}, {\"a\": 2.5}] -> transform $.a + $.a;");
jaql.x("[{\"a\": 1, \"b\": 3.4}, {\"a\": 2.5, \"b\": 4}] -> transform $.a
+ $.b;");
+ jaql.x("[1,2,3] -> transform 2 * ($ * 2);");
+ jaql.x("[1,2,3] -> transform 2 * 2.0 * $;");
+ jaql.x("[1,2,3] -> transform ($ * 2.0) / 4;");
end main;
[ 4, 4, 4 ]
[ 1, 2.600000 ]
[ 2, 4.400000, 6 ]
[ 2, 5.000000 ]
[ 4.400000, 6.500000 ]
+[ 4, 8, 12 ]
+[ 4.000000, 8.000000, 12.000000 ]
+[ 0.500000, 1.000000, 1.500000 ]
# 21:27:13 >
# 21:27:13 > "Done."
diff --git a/monetdb5/extras/jaql/jaqlgencode.c
b/monetdb5/extras/jaql/jaqlgencode.c
--- a/monetdb5/extras/jaql/jaqlgencode.c
+++ b/monetdb5/extras/jaql/jaqlgencode.c
@@ -748,6 +748,7 @@ dumpvariabletransformation(MalBlkPtr mb,
q = pushDbl(mb, q, t->tval3->dval);
g = getArg(q, 0);
pushInstruction(mb, q);
+ break;
default:
assert(0);
}
@@ -876,26 +877,32 @@ dumpvariabletransformation(MalBlkPtr mb,
q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any));
q = pushArgument(mb, q, s);
q = pushArgument(mb, q, v);
- h = getArg(q, 0);
- pushInstruction(mb, q);
+ if (v != -1) {
+ h = getArg(q, 0);
+ pushInstruction(mb, q);
+ } else {
+ h = -1;
+ }
p = copyInstruction(q); /* reuse for dbl case below */
- q = newInstruction(mb, ASSIGNsymbol);
- setModuleId(q, algebraRef);
- setFunctionId(q, joinRef);
- q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any));
- q = pushArgument(mb, q, j);
- q = pushArgument(mb, q, h);
- h = getArg(q, 0);
- pushInstruction(mb, q);
- q = newInstruction(mb, ASSIGNsymbol);
- setModuleId(q, algebraRef);
- setFunctionId(q, putName("kunion", 6));
- q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any));
- q = pushArgument(mb, q, *j3);
- q = pushArgument(mb, q, h);
- *j3 = getArg(q, 0);
- pushInstruction(mb, q);
+ if (h != -1) {
+ q = newInstruction(mb, ASSIGNsymbol);
+ setModuleId(q, algebraRef);
+ setFunctionId(q, joinRef);
+ q = pushReturn(mb, q, newTmpVariable(mb,
TYPE_any));
+ q = pushArgument(mb, q, j);
+ q = pushArgument(mb, q, h);
+ h = getArg(q, 0);
+ pushInstruction(mb, q);
+ q = newInstruction(mb, ASSIGNsymbol);
+ setModuleId(q, algebraRef);
+ setFunctionId(q, putName("kunion", 6));
+ q = pushReturn(mb, q, newTmpVariable(mb,
TYPE_any));
+ q = pushArgument(mb, q, *j3);
+ q = pushArgument(mb, q, h);
+ *j3 = getArg(q, 0);
+ pushInstruction(mb, q);
+ }
if (c != -1) {
q = newInstruction(mb, ASSIGNsymbol);
@@ -1107,8 +1114,29 @@ dumpvariabletransformation(MalBlkPtr mb,
q = pushReturn(mb, q, newTmpVariable(mb,
TYPE_any));
q = pushArgument(mb, q, e);
q = pushArgument(mb, q, r);
- s = getArg(q, 0);
+ v = getArg(q, 0);
pushInstruction(mb, q);
+
+ if (f == -1) {
+ q = newInstruction(mb, ASSIGNsymbol);
+ setModuleId(q, batcalcRef);
+ setFunctionId(q, putName("dbl", 3));
+ q = pushReturn(mb, q,
newTmpVariable(mb, TYPE_any));
+ q = pushArgument(mb, q, s);
+ s = getArg(q, 0);
+ pushInstruction(mb, q);
+ q = newInstruction(mb, ASSIGNsymbol);
+ setModuleId(q, algebraRef);
+ setFunctionId(q, putName("kunion", 6));
+ q = pushReturn(mb, q,
newTmpVariable(mb, TYPE_any));
+ q = pushArgument(mb, q, v);
+ q = pushArgument(mb, q, s);
+ s = getArg(q, 0);
+ pushInstruction(mb, q);
+ } else {
+ s = v;
+ }
+
v = g;
}
@@ -1143,14 +1171,16 @@ dumpvariabletransformation(MalBlkPtr mb,
q = pushChr(mb, q, 'n');
r = getArg(q, 0);
pushInstruction(mb, q);
- q = newInstruction(mb, ASSIGNsymbol);
- setModuleId(q, algebraRef);
- setFunctionId(q, projectRef);
- q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any));
- q = pushArgument(mb, q, h);
- q = pushChr(mb, q, 'i');
- h = getArg(q, 0);
- pushInstruction(mb, q);
+ if (h != -1) {
+ q = newInstruction(mb, ASSIGNsymbol);
+ setModuleId(q, algebraRef);
+ setFunctionId(q, projectRef);
+ q = pushReturn(mb, q, newTmpVariable(mb,
TYPE_any));
+ q = pushArgument(mb, q, h);
+ q = pushChr(mb, q, 'i');
+ h = getArg(q, 0);
+ pushInstruction(mb, q);
+ }
q = newInstruction(mb, ASSIGNsymbol);
setModuleId(q, algebraRef);
setFunctionId(q, projectRef);
@@ -1160,14 +1190,18 @@ dumpvariabletransformation(MalBlkPtr mb,
i = getArg(q, 0);
pushInstruction(mb, q);
- q = newInstruction(mb, ASSIGNsymbol);
- setModuleId(q, algebraRef);
- setFunctionId(q, putName("kunion", 6));
- q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any));
- q = pushArgument(mb, q, h);
- q = pushArgument(mb, q, i);
- h = getArg(q, 0);
- pushInstruction(mb, q);
+ if (h != -1) {
+ q = newInstruction(mb, ASSIGNsymbol);
+ setModuleId(q, algebraRef);
+ setFunctionId(q, putName("kunion", 6));
+ q = pushReturn(mb, q, newTmpVariable(mb,
TYPE_any));
+ q = pushArgument(mb, q, h);
+ q = pushArgument(mb, q, i);
+ h = getArg(q, 0);
+ pushInstruction(mb, q);
+ } else {
+ h = i;
+ }
q = newInstruction(mb, ASSIGNsymbol);
setModuleId(q, algebraRef);
setFunctionId(q, putName("kdifference", 11));
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list