-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TL;DR * Change all our left expressions from plain strings to `model.SelectColumn` (`FromClause` and a couple of complex SQLs). We're currently thinking what this `FromClause` should ultimately be, so that'll probably change, but still it's a step forward. * Add pretty print for errors in all tests with `sqlmock` --------------------------------------------- Some older story: So I basically wanted to improve my last `GROUP BY` change just a little bit, by making just a few expressions like that ``` Select := fmt.Sprintf("count(if(%s<=%f, 1, NULL))/count(*)*100", strconv.Quote(getFirstFieldName()), cutValue) query.Columns = append(query.Columns, model.SelectColumn{Expression: aexp.SQL{Query: Select}}) ``` properly typed, instead of using `aexp.SQL{}`. But the scope of this PR kind of spiraled out of control, as those small changes made some other part of code not compile, and that repeated a lot of times. But it's not that bad, all these changes change code from untyped `string` field representation to our typed system. One most notable change is `Query.FromClause` also becomes of `model.SelectColumn` type instead of `string`. I didn't expect that, but that makes sense. This string often looked like this: ``` query.FromClause = fmt.Sprintf( "(SELECT %s, ROW_NUMBER() OVER (PARTITION BY %s ORDER BY %s %s) AS %s FROM %s WHERE %s)", fieldsAsString, partitionBy, strconv.Quote(metricsAggr.SortBy), metricsAggr.Order, model.RowNumberColumnName, query.FromClause, b.whereBuilder.WhereClauseAsString(), ) ``` so it's probably a good idea to make it typed as well. I think that maybe using `aexp.AExp` as its type might be a bit more natural, than `model.SelectColumn`, but even if you agree, that's a small not very important change that can be done in another PR. --------- Co-authored-by: Jacek Migdal <[email protected]>
- Loading branch information
Showing
31 changed files
with
668 additions
and
609 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.