jayzhan211 commented on PR #15281:
URL: https://github.com/apache/datafusion/pull/15281#issuecomment-2764473375

   ```
   D create table t1(a int, b int);
   D insert values (11, 2), (3, 0);
   Parser Error: syntax error at or near "values"
   LINE 1: insert values (11, 2), (3, 0);
                  ^
   D insert into t1 values (11, 2), (3, 0);
   D create table t2(a int, b int);
   D insert into t2 values (11, 3), (3, 0);
   D select e.b ,(select case when max(e2.a) > 10 then 'a' else 'b' end from t2 
e2 where e2.b = e.b+1 ) from t e;
   Catalog Error: Table with name t does not exist!
   Did you mean "t1"?
   LINE 1: ...d from t2 e2 where e2.b = e.b+1 ) from t e;
                                                     ^
   D select e.b ,(select case when max(e2.a) > 10 then 'a' else 'b' end from t2 
e2 where e2.b = e.b+1 ) from t1 e;
   
┌───────┬───────────────────────────────────────────────────────────────────────────────────────────────────────┐
   │   b   │ (SELECT CASE  WHEN ((max(e2.a) > 10)) THEN ('a') ELSE 'b' END FROM 
t2 AS e2 WHERE (e2.b = (e.b + 1))) │
   │ int32 │                                                varchar             
                                   │
   
├───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────┤
   │     2 │ a                                                                  
                                   │
   │     0 │                                                                    
                                   │
   
└───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────┘
   D select e.b ,(select case when max(e2.a) > 10 then 'a' else 'b' end from t2 
e2 where e2.b = e.b+2 ) from t1 e;
   
┌───────┬───────────────────────────────────────────────────────────────────────────────────────────────────────┐
   │   b   │ (SELECT CASE  WHEN ((max(e2.a) > 10)) THEN ('a') ELSE 'b' END FROM 
t2 AS e2 WHERE (e2.b = (e.b + 2))) │
   │ int32 │                                                varchar             
                                   │
   
├───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────┤
   │     0 │                                                                    
                                   │
   │     2 │                                                                    
                                   │
   
└───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────┘
   ```
   
   ```
   postgres=# select e.b ,(select case when max(e2.a) > 10 then 'a' else 'b' 
end from t2 e2 where e2.b = e.b+1 ) from t1 e;
    b | case 
   ---+------
    2 | a
    0 | b
   (2 rows)
   
   postgres=# select e.b ,(select case when max(e2.a) > 10 then 'a' else 'b' 
end from t2 e2 where e2.b = e.b+2 ) from t1 e;
    b | case 
   ---+------
    2 | b
    0 | b
   (2 rows)
   ```
   
   it seems the result is consistent with postgres


-- 
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

Reply via email to