Closed DavidGregory084 closed 10 years ago
So I think we decided that we need: case class Group[A] implicit conversions between Column[A] and subtypes to Group[A] and subtypes. TupleGroup
If I'm right about point 2), this means defining implicit functions to create Group objects from Columns? e.g.
implicit def scalarFunctionColumn2ScalarFunctionGroup(col: ScalarFunctionColumn[A]) =
ScalarFunctionGroup[A](<params>)
Then groupBy can be a List[Group[A]]?
We certainly are - thanks!
When a grouping functions is used outside of a group by clause It would be better to fail to compile time instead of throwing an exception at run time
The way to do this is to introduce a new type Group
and change the groupBy function signature to take Group
s instead of Column
s
Have a look a Order and OrderSyntax for an example of how to implement the implicit conversion for a Column
.
You will also need to create TupleGroup
as a subclass of Group
trait Group
case class ColumnGroup(column: Column[_]) extends Group
case class TupleGroup(columns: List[Column[_]]) extends Group
with implicit conversions from all sizes of tuples of columns to TupleGroup
I don't think you need different conversions for each Column subclass. You only need to know which columns are being grouped by, not their types
I didn't do quite as you suggested as I couldn't get nested grouping operators to work unless Groups could contain other Groups...I hope that is okay.
Very pleased to see this!
[error] found : sqlest.ast.FunctionGroup
[error] required: sqlest.ast.AliasedColumn[_]
[error] select(sum(MyTable.col1).as("sum"), rollUp(MyTable.col1))
[error]
This is really good. I've added a few comments to your commit but only very minor changes
Good work on making it not compile when you use a FunctionGroup inside a select clause
Don't worry about the nested group operators, it's possible but tricky to get this to work. I'll come back and have a look at it later
Thanks David - great work!
Accepting contributions?