Help Center/
Data Lake Insight/
FAQs/
Spark Jobs/
Spark Job O&M/
How Do I Resolve the "Input argument to rand must be a constant" Error in Spark 3.3.1 SQL Statements?
Updated on 2025-07-10 GMT+08:00
How Do I Resolve the "Input argument to rand must be a constant" Error in Spark 3.3.1 SQL Statements?
Symptom
When the rand function is used in SQL statements of Spark 3.3.1, the error message "Input argument to rand must be a constant" is displayed.
Figure 1 rand function error

Solution
In Spark 3.3.1, the rand function requires constant parameters.
To fix this error, update the parameters in the rand function within the SQL statements to constant parameters and rerun the SQL statements.
Parent topic: Spark Job O&M
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot