Changeset: 3b698cddf94f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3b698cddf94f
Modified Files:
sql/server/rel_unnest.c
sql/test/mergetables/Tests/sqlsmith-exists.stable.out
Branch: default
Log Message:
convert semijoin's into leftjoin on unnesting aka push up of (leftjoin through
a semijoin)
diffs (80 lines):
diff --git a/sql/server/rel_unnest.c b/sql/server/rel_unnest.c
--- a/sql/server/rel_unnest.c
+++ b/sql/server/rel_unnest.c
@@ -1076,8 +1076,8 @@ push_up_join(mvc *sql, sql_rel *rel, lis
return rel; /* ie try again */
}
crossproduct = list_empty(j->exps);
- rd = (j->op != op_full)?rel_dependent_var(sql, d,
jr):(list*)1;
- ld = (((j->op == op_join && rd) || j->op ==
op_right))?rel_dependent_var(sql, d, jl):(list*)1;
+ rd = (j->op != op_full && j->op !=
op_right)?rel_dependent_var(sql, d, jr):(list*)1;
+ ld = ((j->op == op_join || j->op ==
op_right))?rel_dependent_var(sql, d, jl):(list*)1;
if (ld && rd) {
node *m;
@@ -1091,6 +1091,11 @@ push_up_join(mvc *sql, sql_rel *rel, lis
set_dependent(j);
n = rel_crossproduct(sql->sa, rel, j, j->op);
j->op = rel->op;
+ if (is_semi(rel->op)) {
+ //assert(!is_semi(rel->op));
+ j->op = op_left;
+ rel->op = op_left;
+ }
n->l = rel_project(sql->sa, n->l,
rel_projections(sql, n->l, NULL, 1, 1));
nr = n->r;
nr = n->r = rel_project(sql->sa, n->r,
is_semi(nr->op)?sa_list(sql->sa):rel_projections(sql, nr->r, NULL, 1, 1));
@@ -1119,6 +1124,10 @@ push_up_join(mvc *sql, sql_rel *rel, lis
nj->exps = exps_copy(sql, j->exps);
rel_destroy(j);
j = nj;
+ if (is_semi(rel->op)) {
+ //assert(!is_semi(rel->op));
+ rel->op = op_left;
+ }
move_join_exps(sql, j, rel);
return j;
}
diff --git a/sql/test/mergetables/Tests/sqlsmith-exists.stable.out
b/sql/test/mergetables/Tests/sqlsmith-exists.stable.out
--- a/sql/test/mergetables/Tests/sqlsmith-exists.stable.out
+++ b/sql/test/mergetables/Tests/sqlsmith-exists.stable.out
@@ -377,6 +377,39 @@ stdout of test 'sqlsmith-exists` in dire
% c0, c1 # name
% int, int # type
% 1, 1 # length
+#select
+# subq_1.c0 as c0
+#from
+# (select
+# subq_0.c9 as c0
+# from
+# (select
+# ref_3.aa as c0,
+# ref_3.cc as c1,
+# ref_2.col2 as c2,
+# ref_2.col2 as c3,
+# ref_0.col1 as c4,
+# ref_1.col3 as c5,
+# ref_3.aa as c6,
+# ref_1.col2 as c7,
+# ref_2.col2 as c8,
+# ref_1.col8 as c9,
+# ref_2.col1 as c10,
+# ref_0.col2 as c11,
+# ref_2.col0 as c12,
+# ref_0.col1 as c13,
+# ref_2.col1 as c14
+# from
+# tab1 as ref_0
+# left join another_t as ref_1
+# on (ref_0.col2 is null)
+# inner join tab0 as ref_2
+# left join analytics as ref_3
+# on (ref_2.col1 is not null)
+% . # table_name
+% c0 # name
+% int # type
+% 1 # length
#ROLLBACK;
# 19:56:32 >
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list