Changeset: 58bf720e8e67 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=58bf720e8e67
Modified Files:
sql/rel.txt
sql/server/rel_select.c
sql/server/sql_parser.y
Branch: SciQL-2
Log Message:
Fixed 'head of offset BAT ... is not aligned with head of offset BAT ...' error
given for tiles with pattern like 'GROUP BY a[x][y:y+1]' (i.e., one of the
dimension ranges has a single value)
With the implementation of non-rectangular tiles, the offset of the 'x'
dimension is generated using 'offsets()' producing a single offset, while the
offsets of the 'y' dimension is generated using 'array_series1()' producing a
list of offsets. Thus, the two BATs are not aligned.
The currently solution is to detect if there is only one range spec., then use
'array_series1()' to generate a list of offsets for dimension 'x'.
rel.txt: document the extended use of e_column->f
sql_parser.y: removed the syntax for DISTINCT tiles (since we have decided to
use HAVING instead), so that we can rely on the length of the data.lval of a
GROUPBY symbol to detect the number of tile-range specs.
diffs (122 lines):
diff --git a/sql/rel.txt b/sql/rel.txt
--- a/sql/rel.txt
+++ b/sql/rel.txt
@@ -142,12 +142,17 @@ e_column
-> l optional relation name
-> r expression name
-> f only used by the dimensional columns of the arrays
- a list of four lists, with each of them containing
three expressions denoting the [start:step:stop] values
+ a list of four lists, with each of them containing
three or more
+ expressions denoting the [start:step:stop] values
->h->data: the initial range of the array
- ->h->next->data: for unbounded arrays, the range of the
_current_ bounding box.
- The same as ->h->data in case of fixed
arrays.
- ->h->next->next->data: the slicing range, is empty if
there has been no slicing
- ->h->next->next->next->data: the tiling ranges, is
empty if there has been no tiling
+ ->h->next->data: the slicing range, is empty if there
has been no slicing
+ ->h->next->next->data: the tiling ranges, is empty if
there has been no tiling
+ for rectangular tiles, this is a list of three
nodes, and there is no next
+ for non-rectangular tiles, this is a list of
one node
+ (i.e., the single dimention value);
+ more point-ranges are appended after
this one
+ (i.e.,
->h->next->next->...->data),
+ and they are all lists of one
node.
-> type
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
@@ -2254,7 +2254,7 @@ static int
#define ARRAY_TILING_MAX_DIMS 3
static list *
-rel_arraytiling(mvc *sql, sql_rel **rel, symbol *tile_def, int f, str *aname)
+rel_arraytiling(mvc *sql, sql_rel **rel, symbol *tile_def, int f, str *aname,
int oneRange)
{
list *exps = new_exp_list(sql->sa), *offsets = NULL;
node *n = NULL;
@@ -2386,10 +2386,21 @@ rel_arraytiling(mvc *sql, sql_rel **rel,
st = exp_subtype(d_rng->h->data);
/* If a step is specified, we don't care what it exactly is,
just treat
- * it as an expression; otherwise get the step value from the
dimension range */
- exp_os_ste = (dlist_length(dn->data.lval) == 3) ?
- rel_check_type(sql, exp_subtype(d_rng->h->next->data),
rel_value_exp(sql, rel, dn->data.lval->h->next->data.sym, sql_where, ek),
type_cast) :
- (dlist_length(dn->data.lval) == 2)? exp_copy(sql->sa,
d_rng->h->next->data) : NULL;
+ * it as an expression;
+ * otherwise get the step value from the dimension range for
tiling
+ * spec. with only one range definition.
+ * That is, for tiling group by such as:
+ * SELECT x, y, SUM(v) FROM a GROUP BY a[x][y:y+2];
+ * We want to use 'array_series1' to generate a list of offsets
for 'x',
+ * instead of using 'offsets' to generate a single value.
+ * This is because the impl. of tiled AGGR requires that the
offsets
+ * lists of all columns to be aligned (i.e., have the same
length).
+ */
+ if (dlist_length(dn->data.lval) == 3) {
+ exp_os_ste = rel_check_type(sql,
exp_subtype(d_rng->h->next->data), rel_value_exp(sql, rel,
dn->data.lval->h->next->data.sym, sql_where, ek), type_cast);
+ } else if (dlist_length(dn->data.lval) == 2 || oneRange) {
+ exp_os_ste = exp_copy(sql->sa, d_rng->h->next->data);
+ }
/* array tiling range stop, which, in case of a single
<index_term>, is
* just 'start+step' to make the range only include '0'.
@@ -2401,7 +2412,10 @@ rel_arraytiling(mvc *sql, sql_rel **rel,
* an exp_atom with "0" if not specified (case SQL_COLUMN),
and
* append it to 'offsets'.
*/
- if (dlist_length(dn->data.lval) > 1) {
+ if (dlist_length(dn->data.lval) == 1 && oneRange) {
+ exp_os_sto = exp_binop(sql->sa, exp_copy(sql->sa,
exp_os_sta), exp_copy(sql->sa, exp_os_ste),
+ sql_bind_func(sql->sa,
sql->session->schema, "sql_add", st, st, F_FUNC));
+ } else if (dlist_length(dn->data.lval) > 1) {
sym_tsto = (dlist_length(dn->data.lval) == 2) ?
dn->data.lval->h->next->data.sym : dn->data.lval->h->next->next->data.sym;
switch (sym_tsto->token) {
case SQL_COLUMN: /* '<column>' */
@@ -4930,7 +4944,8 @@ add_tiling_ranges(mvc *sql, list *l, lis
for (nl = l->h, nr = r->h; nl && nr; nl = nl->next, nr = nr->next) {
sql_exp *cl = nl->data, *cr = nr->data;
- assert(cl->type == e_column && cl->f && cr->type == e_column &&
cr->f);
+ assert(cl->type == e_column && cl->f && cr->type == e_column &&
cr->f && strcmp(cl->name, cr->name) ==0);
+
if (list_length(((list*)cr->f)->h->next->next->data) > 1) {
return sql_error(sql, 02, "SELECT: array tiles with
mixed point range and interval range not supported yet\n");
}
@@ -4958,7 +4973,7 @@ rel_group_by(mvc *sql, sql_rel *rel, sym
list *es = NULL;
if (grp->token == SQL_ARRAY_DIM_SLICE) {
- if (!(es = rel_arraytiling(sql, &rel, grp, f, &aname)))
+ if (!(es = rel_arraytiling(sql, &rel, grp, f, &aname,
dlist_length(groupby->data.lval) ==1)))
return NULL;
/* FIXME: shouldn't we do the same error checks as the
case of normal GROUP BY below? */
if (list_length(exps) == 0) {
@@ -4967,13 +4982,6 @@ rel_group_by(mvc *sql, sql_rel *rel, sym
exps = add_tiling_ranges(sql, exps, es);
}
found_sgb += 1;
- if (o->next->type == type_int) {
- if (o->next->data.i_val) {
- /* TODO: how do we pass this
information? */
- return sql_error(sql, 02, "SELECT:
DISTINCT array tiles not supported yet\n");
- }
- o = o->next; /* skip the node containing the
DISTINCT information */
- }
} else {
e = rel_column_ref(sql, &rel, grp, f);
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -3152,8 +3152,7 @@ table_name:
opt_group_by_clause:
/* empty */ { $$ = NULL; }
| sqlGROUP BY column_ref_commalist { $$ = _symbol_create_list( SQL_GROUPBY,
$3 );}
- | sqlGROUP BY tiling_commalist { $$ = _symbol_create_list( SQL_GROUPBY,
append_int($3,0) );}
- | sqlGROUP BY DISTINCT tiling_commalist { $$ = _symbol_create_list(
SQL_GROUPBY, append_int($4,1) );}
+ | sqlGROUP BY tiling_commalist { $$ = _symbol_create_list( SQL_GROUPBY, $3
);}
;
tiling_commalist:
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list