suibianwanwank commented on issue #15032: URL: https://github.com/apache/datafusion/issues/15032#issuecomment-2771512245
Additionally, I tried this query in several other databases—here are some execution plans. SQL server execution plan: ``` |--Compute Scalar(DEFINE:([Expr1006]=CASE WHEN [Expr1004]=(1) THEN 'A' ELSE 'B' END)) |--Hash Match(Right Outer Join, HASH:([B].[b])=([A].[b]), RESIDUAL:([test].[test].[B].[b] as [A].[b]=[test].[test].[B].[b] as [B].[b])) |--Stream Aggregate(GROUP BY:([B].[b]) DEFINE:([Expr1004]=MAX([test].[test].[B].[a] as [B].[a]))) | |--Sort(ORDER BY:([B].[b] ASC)) | |--Table Scan(OBJECT:([test].[test].[B] AS [B])) |--Table Scan(OBJECT:([test].[test].[B] AS [A])) ``` Presto execution plan: ``` Presto Plan: - Output[PlanNodeId 50][b, _col1] => [field_0:integer, expr_35:varchar(1)] Estimates: {source: CostBasedSourceInfo, rows: 3 (180B), cpu: 558.00, memory: 91.00, network: 0.00} b := field_0 (9:5) _col1 := expr_35 (10:5) - Project[PlanNodeId 406][projectLocality = LOCAL] => [field_0:integer, expr_35:varchar(1)] Estimates: {source: CostBasedSourceInfo, rows: 3 (180B), cpu: 558.00, memory: 91.00, network: 0.00} expr_35 := SWITCH(BOOLEAN'true', WHEN((max) > (INTEGER'10'), VARCHAR'a'), VARCHAR'b') (12:22) - Aggregate(STREAMING)[field_0, unique][PlanNodeId 405] => [field_0:integer, unique:bigint, max:integer] Estimates: {source: CostBasedSourceInfo, rows: 3 (180B), cpu: 378.00, memory: 91.00, network: 0.00} max := "presto.default.max"((field_16)) (11:22) - LeftJoin[PlanNodeId 404][("add" = "field_17")][$hashvalue, $hashvalue_47] => [field_0:integer, unique:bigint, field_16:integer] Estimates: {source: CostBasedSourceInfo, rows: 3 (180B), cpu: 329.00, memory: 34.00, network: 0.00} Distribution: REPLICATED - Project[PlanNodeId 816][projectLocality = LOCAL] => [field_0:integer, unique:bigint, add:integer, $hashvalue:bigint] Estimates: {source: CostBasedSourceInfo, rows: 2 (120B), cpu: 122.00, memory: 0.00, network: 0.00} $hashvalue := combine_hash(BIGINT'0', COALESCE($operator$hash_code(add), BIGINT'0')) (2:6) - Project[PlanNodeId 489][projectLocality = LOCAL] => [field_0:integer, unique:bigint, add:integer] Estimates: {source: CostBasedSourceInfo, rows: 2 (120B), cpu: 66.00, memory: 0.00, network: 0.00} add := (field_0) + (INTEGER'1') (2:6) - AssignUniqueId[PlanNodeId 403] => [field_0:integer, unique:bigint] Estimates: {source: CostBasedSourceInfo, rows: 2 (120B), cpu: 28.00, memory: 0.00, network: 0.00} - LocalExchange[PlanNodeId 778][ROUND_ROBIN] () => [field_0:integer] Estimates: {source: CostBasedSourceInfo, rows: 2 (120B), cpu: 10.00, memory: 0.00, network: 0.00} - Values[PlanNodeId 0] => [field_0:integer] Estimates: {source: CostBasedSourceInfo, rows: 2 (120B), cpu: 0.00, memory: 0.00, network: 0.00} (INTEGER'2') (INTEGER'0') - LocalExchange[PlanNodeId 779][HASH][$hashvalue_47] (field_17) => [field_16:integer, field_17:integer, $hashvalue_47:bigint] Estimates: {source: CostBasedSourceInfo, rows: 2 (120B), cpu: 68.00, memory: 0.00, network: 0.00} - Project[PlanNodeId 817][projectLocality = LOCAL] => [field_16:integer, field_17:integer, $hashvalue_48:bigint] Estimates: {source: CostBasedSourceInfo, rows: 2 (120B), cpu: 34.00, memory: 0.00, network: 0.00} $hashvalue_48 := combine_hash(BIGINT'0', COALESCE($operator$hash_code(field_17), BIGINT'0')) (3:9) - Values[PlanNodeId 28] => [field_16:integer, field_17:integer] Estimates: {source: CostBasedSourceInfo, rows: 2 (120B), cpu: 0.00, memory: 0.00, network: 0.00} (INTEGER'1', INTEGER'2') (null, INTEGER'0') ``` BTW, I ran this query in DuckDB and found that DuckDB also has this issue. FYI, @xudong963 @jayzhan211 -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org