2010YOUY01 commented on PR #13028:
URL: https://github.com/apache/datafusion/pull/13028#issuecomment-2428913421

   Thank you. I have some suggestions for `LIMIT`'s behavior:
   
   Before this PR, only int literals are accepted
   ```sh
   DataFusion CLI v42.0.0
   > create table t1(v1 int);
   0 row(s) fetched.
   Elapsed 0.052 seconds.
   
   > insert into t1 values (1),(2),(3);
   +-------+
   | count |
   +-------+
   | 3     |
   +-------+
   1 row(s) fetched.
   Elapsed 0.086 seconds.
   
   > select * from t1 limit 1.5;
   Error during planning: Unexpected expression in LIMIT clause
   > select * from t1 limit true;
   Error during planning: Unexpected expression in LIMIT clause
   ```
   
   This PR:
   ```sh
   > select * from t1 limit 1.5;
   +----+
   | v1 |
   +----+
   | 1  |
   +----+
   1 row(s) fetched.
   Elapsed 0.006 seconds.
   
   > select * from t1 offset 0.5 limit 10;
   +----+
   | v1 |
   +----+
   | 1  |
   | 2  |
   | 3  |
   +----+
   3 row(s) fetched.
   Elapsed 0.004 seconds.
   
   > select * from t1 limit false;
   +----+
   | v1 |
   +----+
   +----+
   0 row(s) fetched.
   Elapsed 0.009 seconds.
   ```
   
   Postgres's behavior is: if `OFFSET` is not integer for example 0.5, 0th row 
won't be included, if `LIMIT` is 0.5, then 0th row would be included:
   ```sh
   postgres=# select * from t1 limit 1.5;
    v1 
   ----
     1
     2
   (2 rows)
   
   postgres=# select * from t1 offset 0.5 limit 10;
    v1 
   ----
     2
     3
   (2 rows)
   
   postgres=# select * from t1 limit false;
   ERROR:  argument of LIMIT must be type bigint, not type boolean
   LINE 1: select * from t1 limit false;
   ```
   
   1. I think it's good to follow Postgres' behavior for non-integer arguments
   2. Don't support non-numeric arguments like bool, I think they are allowed 
to cast to integer, but not meaningful in SQL query (maybe there are other 
types that have a similar issue I'm not aware of)


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to