question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Selecting same aggregation multiple times leads to incorrect results (regression in master?)

See original GitHub issue

I created a table

CREATE TABLE IF NOT EXISTS  fruit (
   "orderdate" TEXT,
   "name" TEXT,
   "country" TEXT,
   "count" int 
)
CLUSTERED BY ("orderdate")  INTO 2 SHARDS;

And then I inserted some data

insert into fruit(orderdate,name,country,count) values('2020-06-01','apple','usa',1);
	insert into fruit(orderdate,name,country,count) values('2020-06-02','apple','zh',2);
	insert into fruit(orderdate,name,country,count) values('2020-06-03','apple','ca',3);
	insert into fruit(orderdate,name,country,count) values('2020-06-04','apple','tx',4);
	insert into fruit(orderdate,name,country,count) values('2020-06-05','apple','yy',5);
	insert into fruit(orderdate,name,country,count) values('2020-06-06','apple','cw',6);

execute sql:

SELECT
    name,
    count(country) AS counts
FROM
    fruit
WHERE
    orderdate >= '2020-06-02'
    AND orderdate <= '2020-06-05'
GROUP BY
    name

the result is count=4.

but I joined case when

SELECT
    name,
    count(country) AS counts,
    CASE WHEN 1 = 0 THEN
        0
    ELSE
        cast(count(country) AS double)
    END AS usacount
FROM
    fruit
WHERE
    orderdate >= '2020-06-02'
    AND orderdate <= '2020-06-05'
GROUP BY
    name

the result is counts=6. what happened?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mfusseneggercommented, Jun 17, 2020

This should be fixed now with https://github.com/crate/crate/pull/10094

0reactions
makebestcommented, Jun 18, 2020

That’s great. Thank you very much.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Steps to Take When Your Regression (or Other Statistical ...
Misspecifying the model​​ The results look strange because they're not very accurate. There may exist effects you didn't include, like interactions, non-linear ...
Read more >
Incorrect output is returned when you use the Linear ...
Discusses a problem in which the incorrect output is returned when you use Linear Regression (LINEST) function in Excel.
Read more >
Practical Regression and Anova using R
The objective is to learn what methods are available and more importantly, when they should be applied.
Read more >
What is Bagging? | IBM
Bagging, also known as bootstrap aggregation, is the ensemble learning method that is commonly used to reduce variance within a noisy dataset.
Read more >
Multicollinearity in Regression Analysis: Problems, Detection ...
Multicollinearity is when independent variables in a regression model are correlated. I explore its problems, testing your model for it, and solutions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found