featurebase/sql3/planner
seebs b35c240da7
handle count(*) in having correctly (#2274)
* correct reference for `having count(*)`

It turns out that `having count(*) ...` was always treating
the count(*) as exactly 1. After studying this a lot, I noticed
that in fact, we correctly handle other counts. The reason is
that there's already code to recognize aggregates in `having`
clauses as matching aggregates that are being computed -- but
it only covers the other aggregate clause types, not the newly
added `countStarPlanExpression` from making `count(*)` work even
if there's no `_id` field.

We add several corresponding test cases.

* fix sum(a_decimal) type conversion

Added a test case for this, and also added a fix for it.
Underlying issue: qualifiedRefPlanExpression could end up
producing an int64 instead of a pql.Decimal, even though it
had expected type Decimal.

Originally this worked by politely converting an int64 to
a pql.Decimal in the Evaluate phase, but this was not ideal;
the real question is why it was coming out as an int64 at
that step. Showed this to Pat, who spent a while studying it
and produced a better fix.

* temporarily comment out test which fails in DAX
2023-03-01 23:49:45 -06:00
..
types Aggregation Nation (fb-1955, fb-1887) (#2252) 2023-02-16 10:56:27 -06:00
compilealterdatabase.go A bug fix roundup (#2242) 2023-02-13 12:28:34 -06:00
compilealtertable.go make count(*) not depend on _id (#2258) 2023-02-17 08:46:25 -06:00
compilebulkinsert.go make count(*) not depend on _id (#2258) 2023-02-17 08:46:25 -06:00
compilecreatedatabase.go A bug fix roundup (#2242) 2023-02-13 12:28:34 -06:00
compilecreatetable.go make count(*) not depend on _id (#2258) 2023-02-17 08:46:25 -06:00
compilecreateview.go A bug fix roundup (#2242) 2023-02-13 12:28:34 -06:00
compiledelete.go A bug fix roundup (#2242) 2023-02-13 12:28:34 -06:00
compiledropdatabase.go A bug fix roundup (#2242) 2023-02-13 12:28:34 -06:00
compiledroptable.go A bug fix roundup (#2242) 2023-02-13 12:28:34 -06:00
compiledropview.go A bug fix roundup (#2242) 2023-02-13 12:28:34 -06:00
compileinsert.go make count(*) not depend on _id (#2258) 2023-02-17 08:46:25 -06:00
compileselect.go ORDER BY ....what now!? (fb-1954) (#2257) 2023-02-17 13:35:36 -06:00
compileshow.go make count(*) not depend on _id (#2258) 2023-02-17 08:46:25 -06:00
executionplanner.go SQL tests now that CodedErrors are across HTTP (#2284) 2023-03-01 13:51:14 -05:00
executionplannersystemtables.go set default epoch for timestamps in system tables 2023-02-15 14:34:51 -06:00
expression.go handle count(*) in having correctly (#2274) 2023-03-01 23:49:45 -06:00
expression_it_test.go Sync from private repo to commit 12d608c80d 2022-12-12 09:01:20 -08:00
expressionagg.go handle count(*) in having correctly (#2274) 2023-03-01 23:49:45 -06:00
expressionanalyzer.go ORDER BY ....what now!? (fb-1954) (#2257) 2023-02-17 13:35:36 -06:00
expressionanalyzercall.go FB-1968 timestamp data type related fixes and enhancements (#2256) 2023-02-24 14:57:17 -05:00
expressionpql.go make count(*) not depend on _id (#2258) 2023-02-17 08:46:25 -06:00
expressiontypes.go FB-1968 timestamp data type related fixes and enhancements (#2256) 2023-02-24 14:57:17 -05:00
inbuiltfunctionsdate.go FB-1968 timestamp data type related fixes and enhancements (#2256) 2023-02-24 14:57:17 -05:00
inbuiltfunctionsset.go cleaned up sync from private repo 2022-09-30 11:20:58 -07:00
inbuiltfunctionsstring.go FB-1862: Implement Str() scalar string function (#2215) 2023-02-14 15:58:36 -05:00
inbuiltfunctionstable.go ORDER BY ....what now!? (fb-1954) (#2257) 2023-02-17 13:35:36 -06:00
main_test.go added testify dependency 2022-09-30 11:31:37 -07:00
opalterdatabase.go CLI: make it more like psql (#2235) 2023-02-14 09:23:51 -06:00
opaltertable.go Sync from private repo to commit 12d608c80d 2022-12-12 09:01:20 -08:00
opalterview.go Get rid of *most* of the context.Background() references in sql3 package (#2238) 2023-02-10 13:40:46 -06:00
opbulkinsert.go FB-1968 timestamp data type related fixes and enhancements (#2256) 2023-02-24 14:57:17 -05:00
opcreatedatabase.go Support for setting individual DatabaseOptions (#2231) 2023-02-06 08:50:28 -06:00
opcreatetable.go make count(*) not depend on _id (#2258) 2023-02-17 08:46:25 -06:00
opcreateview.go Get rid of *most* of the context.Background() references in sql3 package (#2238) 2023-02-10 13:40:46 -06:00
opdistinct.go Sup 294 pre sort command (#2209) 2023-01-23 12:26:38 -06:00
opdropdatabase.go Support for setting individual DatabaseOptions (#2231) 2023-02-06 08:50:28 -06:00
opdroptable.go implemented DISTINCT (fb-1562) (#2388) 2023-01-10 23:28:00 +00:00
opdropview.go Get rid of *most* of the context.Background() references in sql3 package (#2238) 2023-02-10 13:40:46 -06:00
opfanout.go introduce performance counters and system table fanout, plus refactor metrics (#2363) 2023-01-19 21:35:02 +00:00
opfeaturebasecolumns.go forward-port tests from SQL1 tree (#2261) 2023-03-01 13:40:50 -06:00
opfeaturebasedatabases.go make count(*) not depend on _id (#2258) 2023-02-17 08:46:25 -06:00
opfeaturebasetables.go make count(*) not depend on _id (#2258) 2023-02-17 08:46:25 -06:00
opfilter.go implemented DISTINCT (fb-1562) (#2388) 2023-01-10 23:28:00 +00:00
opgroupby.go fix import paths and import cycles 2023-01-12 00:31:14 +00:00
ophaving.go fix import paths 2023-01-11 18:59:24 +00:00
opinsert.go FB-1968 timestamp data type related fixes and enhancements (#2256) 2023-02-24 14:57:17 -05:00
opnestedloops.go hand comma version of inner join (#2221) 2023-01-25 13:37:05 -06:00
opnulltable.go implemented DISTINCT (fb-1562) (#2388) 2023-01-10 23:28:00 +00:00
oporderby.go ORDER BY ....what now!? (fb-1954) (#2257) 2023-02-17 13:35:36 -06:00
oppqlaggregate.go make count(*) not depend on _id (#2258) 2023-02-17 08:46:25 -06:00
oppqldelete.go make count(*) not depend on _id (#2258) 2023-02-17 08:46:25 -06:00
oppqldistinctscan.go make count(*) not depend on _id (#2258) 2023-02-17 08:46:25 -06:00
oppqlfiltereddelete.go fix import paths 2023-01-11 18:59:24 +00:00
oppqlgroupby.go handle count(*) in having correctly (#2274) 2023-03-01 23:49:45 -06:00
oppqlmultiaggregate.go implemented DISTINCT (fb-1562) (#2388) 2023-01-10 23:28:00 +00:00
oppqlmultigroupby.go Aggregation Nation (fb-1955, fb-1887) (#2252) 2023-02-16 10:56:27 -06:00
oppqltablescan.go make count(*) not depend on _id (#2258) 2023-02-17 08:46:25 -06:00
oppqltruncate.go fix typo in file name 2023-02-15 14:34:51 -06:00
opprojection.go implemented DISTINCT (fb-1562) (#2388) 2023-01-10 23:28:00 +00:00
opquery.go implemented DISTINCT (fb-1562) (#2388) 2023-01-10 23:28:00 +00:00
oprelalias.go implemented DISTINCT (fb-1562) (#2388) 2023-01-10 23:28:00 +00:00
opsubquery.go fix import paths and import cycles 2023-01-12 00:31:14 +00:00
opsystemtable.go Aggregation Nation (fb-1955, fb-1887) (#2252) 2023-02-16 10:56:27 -06:00
optablevaluedfunction.go implemented DISTINCT (fb-1562) (#2388) 2023-01-10 23:28:00 +00:00
optop.go implemented DISTINCT (fb-1562) (#2388) 2023-01-10 23:28:00 +00:00
planoptimizer.go handle count(*) in having correctly (#2274) 2023-03-01 23:49:45 -06:00
planwalker.go Implement DELETE (fb 1557) (#2382) 2023-01-10 23:25:08 +00:00
systemobjects.go make count(*) not depend on _id (#2258) 2023-02-17 08:46:25 -06:00
wireprotocol.go introduce performance counters and system table fanout, plus refactor metrics (#2363) 2023-01-19 21:35:02 +00:00