You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/10/13 04:04:02 UTC
[GitHub] [superset] liumengkai edited a comment on issue #17073: The results returned by the superset and clickhouse clients are different, and the client is correct
liumengkai edited a comment on issue #17073:
URL: https://github.com/apache/superset/issues/17073#issuecomment-941896915
@zhaoyongjie
@junlincc
Hi!
I have eid == 303 records,the client's result is true, When pid = 6909, there should be three records, corresponding to eid=302, eid=304, and eid=306, But from the page query I can only get one record。
Before add the 'pid = 6909' filter,the sql generated is:
"""
SELECT toStartOfDay(toDateTime(create_date)) AS __timestamp,
pid AS pid,
eid AS eid,
SUM(cnt) AS "SUM(cnt) "
FROM XXX.XXX
WHERE create_date >= toDateTime('2021-10-11 11:43:30')
AND create_date < toDateTime('2021-10-13 11:43:30')
AND eid IN (302,
303,
304)
GROUP BY pid,
eid,
toStartOfDay(toDateTime(create_date))
ORDER BY "SUM(cnt) " DESC
LIMIT 10000;
"""
After add 'pid = 6909' filter,the sql generated is:
"""
SELECT toStartOfDay(toDateTime(create_date)) AS __timestamp,
pid AS pid,
eid AS eid,
SUM(cnt) AS "SUM(cnt) "
FROM XXX.XXX
WHERE create_date >= toDateTime('2021-10-11 11:44:52')
AND create_date < toDateTime('2021-10-13 11:44:52')
AND eid IN (302,
303,
304)
AND pid = 6909
GROUP BY pid,
eid,
toStartOfDay(toDateTime(create_date))
ORDER BY "SUM(cnt) " DESC
LIMIT 10000;
"""
another strange thing is: same query , when I run it on the page,he returns one record like mentioned above ,but when I run it in SQL Lab, I can get two records ,but superset will take one as title,so it shows returned 1 row

Then I tried to use python script & clickhouse-driver (clickhouse-driver I am using in superset) to execute the same SQL program,I got three records returned。
python script:
from clickhouse_driver import Client
if __name__ == '__main__':
client = Client('xxx.internal')
client.execute('use XXX')
result = client.execute(
'SELECT toStartOfDay(toDateTime(create_date)) AS __TIMESTAMP,pid AS pid,eid AS eid,SUM(cnt) AS \"SUM(cnt)\" FROM XXX.XXX WHERE create_date >= toDateTime(\'2021-10-11 11:01:57\') AND create_date < toDateTime(\'2021-10-13 11:01:57\') AND eid IN (302,303,304) AND pid = 6909 GROUP BY pid,eid,toStartOfDay(toDateTime(create_date)) ORDER BY \"SUM(cnt)\" DESC LIMIT 10000;')
print(result)

Basically I think it's something wrong after superset got the data.
Not sure if there is any problem above,Anyone have ideas, please bring them up:-)
thx! Looking forward to your reply :-)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org