Error order query results

DS1:

SELECT AString, CAST(Adate as DATE) AS Adate, ANumber, CONVERT_TO_INTEGER(“atable”.“dir0”, 1, 1, 0) AS Revision FROM “Adataset”.“abucket”.atable AS atable

DS2:

SELECT Astring, YEAR(Adate) AS “Year”, MONTH(Adate) AS “Month”, SUM(Anumber) AS Anumber
FROM DS1
WHERE Revision = (SELECT MAX(Revision) FROM DS1)
GROUP BY Astring, YEAR(Adate), MONTH(Adate)

DS3:

SELECT *
FROM DS2 where “Year” = YEAR(CURRENT_DATE) and “Month” >= MONTH(CURRENT_DATE)

Executing DS3 works fine. However the following:

SELECT *
FROM DS2 where “Year” = YEAR(CURRENT_DATE) and “Month” >= MONTH(CURRENT_DATE) ORDER BY “Month”

Produces an error, a bit of which looks like this:

Caused by: java.lang.AssertionError: rel [rel#25577:AggregateRel.LOGICAL.ANY([]).[](input=rel#25506:Subset#18.LOGICAL.ANY([]).[],group={0, 1, 2},Anumber=SUM($3))] has lower cost {75448.7422890625 rows, 877817.40625 cpu, 168203.0 io, 168203.0 network, 17.6 memory} than best cost {76951.5547890625 rows, 889832.90625 cpu, 168203.0 io, 168203.0 network, 17.6 memory} of subset [rel#25454:Subset#19.LOGICAL.ANY([]).[]]

This is on 2.0.1

I suspect this might have to do with using alpine as my base image. I rebuilt using ubuntu and have not had the issue again.

1 Like