Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Join return wrong result! #54483

Open
ImTangYun opened this issue Dec 30, 2024 · 0 comments
Open

Join return wrong result! #54483

ImTangYun opened this issue Dec 30, 2024 · 0 comments
Labels
type/bug Something isn't working

Comments

@ImTangYun
Copy link

ImTangYun commented Dec 30, 2024

Steps to reproduce the behavior (Required)

createtab_stmt
CREATE TABLE tmp.tangyun_test4(
day string,
agency_uid varchar(65535),
_col0 bigint)
ROW FORMAT SERDE
'org.apache.hadoop.hive.ql.io.orc.OrcSerde'
STORED AS INPUTFORMAT
'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat'

data for tmp.tangyun_test4:
test4_data_orc.log

CREATE TABLE tmp.tangyun_test6(
day string,
uid bigint,
vm_postcount int,
time bigint)
ROW FORMAT SERDE
'org.apache.hadoop.hive.ql.io.orc.OrcSerde'
STORED AS INPUTFORMAT
'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat'
data for tmp.tangyun_test6:
test6_data_orc.log

set sql_dialect='trino';

SELECT "t3"."day" AS "DAY", "t3"."agency_uid" AS "agency_uid", "t10"."post_credit" AS "post_credit"
FROM (SELECT "day", "agency_uid"
FROM (SELECT "day", "agency_uid"
FROM "tmp"."tangyun_test4") AS "t0"
GROUP BY "day", "agency_uid") AS "t3"
LEFT JOIN (SELECT "day", CASE WHEN "uid" IS NOT NULL THEN CAST("uid" AS VARCHAR(65535)) ELSE CAST('all' AS VARCHAR(65535)) END AS "uid", SUM("$f2") AS "post_credit"
FROM (SELECT "day", "uid", CASE WHEN (ROW_NUMBER() OVER (PARTITION BY "uid", "day" ORDER BY "time" DESC)) = 1 THEN "vm_postcount" ELSE 0 END AS "$f2"
FROM "tmp"."tangyun_test6") AS "t5"
GROUP BY GROUPING SETS(("day", "uid"), "day")) AS "t10" ON "t3"."day" = "t10"."day" AND "t3"."agency_uid" = "t10"."uid"

Expected behavior (Required)

DAY     | agency_uid | post_credit 

------------+------------+-------------
2024-11-25 | 3834442359 | 1749945
2024-11-25 | 3848292872 | 90655
2024-11-25 | all | 1840600

Real behavior (Required)

DAY     | agency_uid | post_credit 

------------+------------+-------------
2024-11-25 | 3848292872 | 90655
2024-11-25 | 3834442359 | 1749945
2024-11-25 | all | 1749945
2024-11-25 | all | 90655

StarRocks version (Required)

3.3.7

@ImTangYun ImTangYun added the type/bug Something isn't working label Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant