Raw SQL to Ecto query

Greetings! I want to make applications for solving problems in SQL language, in addition, I want to execute a query in a sandboxed database to get the query result. For the initial validation of the user’s query, I want to try to translate the raw SQL query from the user into an Ecto query and if it is incorrect, then don`t execute it. The question is: how convert raw SQL into Ecto query? Or is there another way to validate queries from users? Thanks for answers!

You cannot, at least without implementing full parser and compiler for SQL. But if you are able to do so, then you do not need to translate it to Ecto at all.