Changeset: 3049fd52fb80 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3049fd52fb80
Modified Files:
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures.stable.out.int128
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql.h
        sql/backends/monet5/sql_rank.mal
        sql/common/sql_types.c
        sql/server/rel_select.c
        sql/test/Tests/systemfunctions.stable.out
        sql/test/Tests/systemfunctions.stable.out.int128
Branch: Jul2017
Log Message:

Merge with Dec2016 branch.


diffs (162 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -94,6 +94,8 @@ Ready.
 [ "aggr",      "covar",        "function aggr.covar(e1:bat[:lng], 
e2:bat[:lng]):lng;", "",     ""      ]
 [ "aggr",      "covar",        "function aggr.covar(e1:bat[:sht], 
e2:bat[:sht]):sht;", "",     ""      ]
 [ "aggr",      "exist",        "command aggr.exist(b:bat[:any_2], h:any_1):bit 
",      "ALGexist;",    ""      ]
+[ "aggr",      "exist",        "command aggr.exist(b:bat[:any_2]):bit ",       
"SQLexist;",    ""      ]
+[ "aggr",      "exist",        "command aggr.exist(v:any_2):bit ",     
"SQLexist_val;",        ""      ]
 [ "aggr",      "jsonaggr",     "command aggr.jsonaggr(val:bat[:dbl]):str ",    
"JSONgroupStr;",        "Aggregate the double values to array." ]
 [ "aggr",      "jsonaggr",     "command aggr.jsonaggr(val:bat[:str]):str ",    
"JSONgroupStr;",        "Aggregate the string values to array." ]
 [ "aggr",      "max",  "command aggr.max(b:bat[:any_1], g:bat[:oid], 
e:bat[:any_2]):bat[:any_1] ",     "AGGRmax3;",    ""      ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128 
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -102,6 +102,8 @@ Ready.
 [ "aggr",      "covar",        "function aggr.covar(e1:bat[:lng], 
e2:bat[:lng]):lng;", "",     ""      ]
 [ "aggr",      "covar",        "function aggr.covar(e1:bat[:sht], 
e2:bat[:sht]):sht;", "",     ""      ]
 [ "aggr",      "exist",        "command aggr.exist(b:bat[:any_2], h:any_1):bit 
",      "ALGexist;",    ""      ]
+[ "aggr",      "exist",        "command aggr.exist(b:bat[:any_2]):bit ",       
"SQLexist;",    ""      ]
+[ "aggr",      "exist",        "command aggr.exist(v:any_2):bit ",     
"SQLexist_val;",        ""      ]
 [ "aggr",      "jsonaggr",     "command aggr.jsonaggr(val:bat[:dbl]):str ",    
"JSONgroupStr;",        "Aggregate the double values to array." ]
 [ "aggr",      "jsonaggr",     "command aggr.jsonaggr(val:bat[:str]):str ",    
"JSONgroupStr;",        "Aggregate the string values to array." ]
 [ "aggr",      "max",  "command aggr.max(b:bat[:any_1], g:bat[:oid], 
e:bat[:any_2]):bat[:any_1] ",     "AGGRmax3;",    ""      ]
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -4600,3 +4600,25 @@ SQLflush_log(void *ret)
        store_flush_log();
        return MAL_SUCCEED;
 }
+
+str
+SQLexist_val(bit *res, void *v)
+{
+       if (v) 
+               *res = TRUE;
+       else
+               *res = FALSE;
+       return MAL_SUCCEED;
+}
+
+str
+SQLexist(bit *res, bat *id)
+{
+       BAT *b;
+
+       if ((b = BATdescriptor(*id)) == NULL)
+               throw(SQL, "aggr.exist", "Cannot access descriptor");
+       *res = BATcount(b);
+       BBPunfix(b->batCacheid);
+       return MAL_SUCCEED;
+}
diff --git a/sql/backends/monet5/sql.h b/sql/backends/monet5/sql.h
--- a/sql/backends/monet5/sql.h
+++ b/sql/backends/monet5/sql.h
@@ -315,4 +315,7 @@ sql5_export str BATSTRstrings(bat *res, 
 
 sql5_export str SQLflush_log(void *ret);
 
+sql5_export str SQLexist(bit *res, bat *id);
+sql5_export str SQLexist_val(bit *res, void *val);
+
 #endif /* _SQL_H */
diff --git a/sql/backends/monet5/sql_rank.mal b/sql/backends/monet5/sql_rank.mal
--- a/sql/backends/monet5/sql_rank.mal
+++ b/sql/backends/monet5/sql_rank.mal
@@ -50,3 +50,8 @@ comment "return the densely ranked group
 command aggr.exist(b:bat[:any_2], h:any_1):bit 
 address ALGexist;
 
+command aggr.exist(b:bat[:any_2]):bit
+address SQLexist;
+
+command aggr.exist(v:any_2):bit
+address SQLexist_val;
diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c
--- a/sql/common/sql_types.c
+++ b/sql/common/sql_types.c
@@ -1411,6 +1411,8 @@ sqltypeinit( sql_allocator *sa)
        sql_create_aggr(sa, "all", "sql", "all", ANY, ANY);
        sql_create_aggr(sa, "exist", "aggr", "exist", ANY, BIT);
        sql_create_aggr(sa, "not_exist", "aggr", "not_exist", ANY, BIT);
+       sql_create_func(sa, "sql_exists", "aggr", "exist", ANY, NULL, BIT, 
SCALE_NONE);
+       sql_create_func(sa, "sql_not_exists", "aggr", "not_exist", ANY, NULL, 
BIT, SCALE_NONE);
        /* needed for relational version */
        sql_create_func(sa, "in", "calc", "in", ANY, ANY, BIT, SCALE_NONE);
        sql_create_func(sa, "identity", "calc", "identity", ANY, NULL, OID, 
SCALE_NONE);
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -4916,11 +4916,17 @@ rel_query(mvc *sql, sql_rel *rel, symbol
                for (n = fl->h; n ; n = n->next) {
                        int lateral = check_is_lateral(n->data.sym), 
lateral_used = 0;
 
+                       /* just used current expression */
                        fnd = table_ref(sql, NULL, n->data.sym, 0);
                        if (!fnd && (rel || lateral) && sql->session->status != 
-ERR_AMBIGUOUS) {
                                /* reset error */
                                sql->session->status = 0;
                                sql->errstr[0] = 0;
+                               /* here we have 2 cases; the query could be 
+                                * using the outer relation (correlated query)
+                                * or we could have a lateral query.
+                                * Also we could have both.
+                                */ 
                                if (used && rel)
                                        rel = rel_dup(rel);
                                if (!used && (!sn->lateral && !lateral) && rel) 
{
@@ -4933,6 +4939,10 @@ rel_query(mvc *sql, sql_rel *rel, symbol
                                        /* create dummy single row project */
                                        rel = rel_project(sql->sa, NULL, 
applyexps = rel_projections(sql, o, NULL, 1, 1)); 
                                }
+                               if (lateral && rel) {
+                                       res = rel_crossproduct(sql->sa, res, 
rel, op_join);
+                                       rel = NULL;
+                               }
                                if (lateral) {
                                        list *pre_exps = rel_projections(sql, 
res, NULL, 1, 1);
                                        fnd = table_ref(sql, res, n->data.sym, 
lateral);
diff --git a/sql/test/Tests/systemfunctions.stable.out 
b/sql/test/Tests/systemfunctions.stable.out
--- a/sql/test/Tests/systemfunctions.stable.out
+++ b/sql/test/Tests/systemfunctions.stable.out
@@ -3381,6 +3381,8 @@ Ready.
 [ "sys",       "sql_div",      0,      "sec_interval", "/"     ]
 [ "sys",       "sql_div",      1,      "sec_interval", ""      ]
 [ "sys",       "sql_div",      2,      "sec_interval", ""      ]
+[ "sys",       "sql_exists",   0,      "boolean",      "exist" ]
+[ "sys",       "sql_exists",   1,      "any",  ""      ]
 [ "sys",       "sql_max",      0,      "any",  "max"   ]
 [ "sys",       "sql_max",      1,      "any",  ""      ]
 [ "sys",       "sql_max",      2,      "any",  ""      ]
@@ -3608,6 +3610,8 @@ Ready.
 [ "sys",       "sql_neg",      1,      "month_interval",       ""      ]
 [ "sys",       "sql_neg",      0,      "sec_interval", "-"     ]
 [ "sys",       "sql_neg",      1,      "sec_interval", ""      ]
+[ "sys",       "sql_not_exists",       0,      "boolean",      "not_exist"     
]
+[ "sys",       "sql_not_exists",       1,      "any",  ""      ]
 [ "sys",       "sql_sub",      0,      "oid",  "-"     ]
 [ "sys",       "sql_sub",      1,      "oid",  ""      ]
 [ "sys",       "sql_sub",      2,      "oid",  ""      ]
diff --git a/sql/test/Tests/systemfunctions.stable.out.int128 
b/sql/test/Tests/systemfunctions.stable.out.int128
--- a/sql/test/Tests/systemfunctions.stable.out.int128
+++ b/sql/test/Tests/systemfunctions.stable.out.int128
@@ -3795,6 +3795,8 @@ Ready.
 [ "sys",       "sql_div",      0,      "sec_interval", "/"     ]
 [ "sys",       "sql_div",      1,      "sec_interval", ""      ]
 [ "sys",       "sql_div",      2,      "sec_interval", ""      ]
+[ "sys",       "sql_exists",   0,      "boolean",      "exist" ]
+[ "sys",       "sql_exists",   1,      "any",  ""      ]
 [ "sys",       "sql_max",      0,      "any",  "max"   ]
 [ "sys",       "sql_max",      1,      "any",  ""      ]
 [ "sys",       "sql_max",      2,      "any",  ""      ]
@@ -4104,6 +4106,8 @@ Ready.
 [ "sys",       "sql_neg",      1,      "month_interval",       ""      ]
 [ "sys",       "sql_neg",      0,      "sec_interval", "-"     ]
 [ "sys",       "sql_neg",      1,      "sec_interval", ""      ]
+[ "sys",       "sql_not_exists",       0,      "boolean",      "not_exist"     
]
+[ "sys",       "sql_not_exists",       1,      "any",  ""      ]
 [ "sys",       "sql_sub",      0,      "oid",  "-"     ]
 [ "sys",       "sql_sub",      1,      "oid",  ""      ]
 [ "sys",       "sql_sub",      2,      "oid",  ""      ]
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to