Closed mhkeller closed 2 weeks ago
Thanks for the thorough reproduction! This allowed me to quickly track down the problem. I have a fix in #491, along with additional changes that should make your example work as it should.
Thanks a bunch for writing a fix so quickly! I'm glad the repro was helpful – it's been on my list for a while to make an issue for this and I finally had some time last night to get it all documented.
I'm trying to make a regression chart where the x and y columns are assigned dynamically via a menu. I had this working circa version 0.7.1 but after updating to 0.10.0 I am getting an error about invalid aggregations. I tried downgrading but, mysteriously, the error remains.
I made a reproduction repo here using the athletes example: https://github.com/mhkeller/mosaic-aggr-error
Here's the error, which occurs when you hover or brush on the chart area:
If I hard-code the x and y column names, everything works fine when I brush.
Here is the query that is executed when the column names are hard-coded:
Here's a diff of the two queries: https://www.diffchecker.com/nF0AQG1R/
It seems the only thing that's different is that the query from the dynamically generated scenario renames the columns to
"x"
and"y"
. The part of the query it's failing on is:SELECT AVG("x") FROM "athletes")
which makes sense to me since the alias"x"
doesn't exist on theathletes
table, only in theFROM
clause at the end(SELECT "height" AS "x", "weight" AS "y", "sex", "height", "weight" FROM "athletes" AS "source")
.I did a small tweak where I do this at the beginning
and then change the references in the subqueries to be
FROM t
. That fixes the error although the numbers are slightly different from the query with hard-coded column names. That's as far as I got. I'm not sure why the numbers would be slightly off but maybe I messed up something in the syntax. It seems that avoiding references to the original table, though, when column names are being aliased could be a good fix, but my knowledge of Mosaic internals is low.