WeCodingNow opened a new issue, #12294:
URL: https://github.com/apache/datafusion/issues/12294

   ### Is your feature request related to a problem or challenge?
   
   DataFusion: v41.0.0
   
   I want to be able to write the following query as a prepared statement:
   
   ```sql
   PREPARE get_N_rand_ints_from_last_run(INT) AS
   SELECT id
   FROM
       "test"
   WHERE run_id = 'foo'
   ORDER BY random()
   LIMIT $1
   ```
   
   I get the following error message:
   ```
   Error during planning: Unexpected expression in LIMIT clause
   ```
   
   It is impossible, as as it seems that the LIMIT clause supports only 
constants in it 
(https://github.com/apache/datafusion/blob/ac74cd3163e43563807a8c6e8e72bb058cb6f459/datafusion/sql/src/query.rs#L101-L114).
   
   
   <details><summary>Postgres does support using prepared statement's arguments 
in the LIMIT clause:</summary>
   <p>
   
   
![image](https://github.com/user-attachments/assets/b937e41d-f352-45f9-85c9-a6799ee46754)
   
   </p>
   </details> 
   
   
   
   ### Describe the solution you'd like
   
   Support using prepared statement arguments in the LIMIT clause
   
   
   ### Describe alternatives you've considered
   
   inapplicable
   
   ### Additional context
   
   _No response_


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