Recently I wanted to create Spaces and Folders through SQL commands in Dremio, but found that it was not possible. I spent some time digging into the innards of how custom SQL commands and parsing work in Dremio, and implemented this functionality myself.
For those of you comfortable with working with custom Dremio-OSS builds, I have included a link below to the commit, which shows an example of how to create a recursive space/folder SQL command. This could also be used as the basis for building any sort of custom SQL command Parser (which is very different from a UDF, which you would include in a SELECT statement).