Changeset: f389a425dd85 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f389a425dd85 Modified Files: sql/server/rel_optimizer.c sql/test/BugTracker-2019/Tests/count-distinct.Bug-6790.stable.out Branch: Nov2019 Log Message:
Fix for bug 6790. At rel_distinct_aggregate_on_unique_values optimizer, ignore constants because on a column projection they won't be distinct anymore diffs (51 lines): diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c --- a/sql/server/rel_optimizer.c +++ b/sql/server/rel_optimizer.c @@ -2492,9 +2492,7 @@ rel_distinct_aggregate_on_unique_values( for (node *m = ((list*)exp->l)->h; m && all_unique; m = m->next) { sql_exp *arg = (sql_exp*) m->data; - if (arg->card == CARD_ATOM) /* constants are always unique */ - continue; - else if (arg->type == e_column) { + if (arg->type == e_column) { fcmp cmp = (fcmp)&kc_column_cmp; sql_column *c = exp_find_column(rel, arg, -2); diff --git a/sql/test/BugTracker-2019/Tests/count-distinct.Bug-6790.stable.out b/sql/test/BugTracker-2019/Tests/count-distinct.Bug-6790.stable.out --- a/sql/test/BugTracker-2019/Tests/count-distinct.Bug-6790.stable.out +++ b/sql/test/BugTracker-2019/Tests/count-distinct.Bug-6790.stable.out @@ -78,13 +78,13 @@ stdout of test 'count-distinct.Bug-6790` % 1 # length [ 1 ] #SELECT DISTINCT CAST( - SUM ( DISTINCT 10 ) AS BIGINT) AS col1 FROM tab2; -% .L3 # table_name +% .L4 # table_name % col1 # name % bigint # type % 3 # length [ -10 ] #SELECT DISTINCT CAST(49 * + 78 + + COUNT ( DISTINCT + 5 ) AS BIGINT) AS col0 FROM tab1 AS cor0; -% .L3 # table_name +% .L4 # table_name % col0 # name % bigint # type % 4 # length @@ -93,7 +93,7 @@ stdout of test 'count-distinct.Bug-6790` % .L4 # table_name % L4 # name % bigint # type -% 4 # length +% 2 # length [ 12 ] #SELECT DISTINCT - 37, - COUNT ( DISTINCT - + 96 ) col1 FROM tab2; % .L1, .L4 # table_name @@ -110,7 +110,7 @@ stdout of test 'count-distinct.Bug-6790` [ NULL, 15 ] [ NULL, 87 ] #SELECT DISTINCT CAST ( NULL AS INTEGER ) - - 95 AS col1, CAST(col2 * + + col1 AS BIGINT) AS col1 FROM tab2 AS cor0; -% .L2, sys.L3 # table_name +% .L2, sys.L4 # table_name % col1, col1 # name % bigint, bigint # type % 1, 4 # length _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list