malloy icon indicating copy to clipboard operation
malloy copied to clipboard

Exclude columns from selection or group_by

Open carlineng opened this issue 1 year ago • 0 comments

Interesting feature request from Slack. It's often the case where someone wants to use a group_by clause to deduplicate a table based on a set of columns. A query like this looks something like:

run: source -> {
  group_by: col_1, col_2, ..., col_n
}

where the user has to enumerate all the columns.

We could enable syntax like:

run: source -> {
  group_by: *
}

to do a distinct operation on all columns. Then further extend this syntax with something like:

run: source -> {
  group_by: * { exclude: col_j }
}

to group on all columns except col_j.

exclude: could also be used in a select: clause, such as:

run: source -> {
   select: * { exclude: col_j }
}

carlineng avatar Jan 05 '24 21:01 carlineng