(Cross-posting from Stack Exchange)
I'm trying to load data into Stata from a SQL database hosted in Databricks, via the odbc load command. For part of the query I need to declare and run a small Python function (Databricks SQL, or at least our version, allows for User-Defined Functions written in SQL or Python, but not Stata, R etc.). This seems to yield an error independent of the content of the function.
Consider this MWE:
Yields the error
While just taking the bit in quotes from the exec() option runs successfully on Databricks.
Any way around this? Users on my system aren't allowed to add permanent functions (though I could see if my IT group would add it for me), so that isn't an option.
I'm trying to load data into Stata from a SQL database hosted in Databricks, via the odbc load command. For part of the query I need to declare and run a small Python function (Databricks SQL, or at least our version, allows for User-Defined Functions written in SQL or Python, but not Stata, R etc.). This seems to yield an error independent of the content of the function.
Consider this MWE:
Code:
odbc load, dsn("DBname") exec(`"CREATE TEMPORARY FUNCTION findrate(name STRING) RETURNS STRING LANGUAGE PYTHON as $$ return "Hello " + name $$; select findrate("World") as num;"') user("token") password("`dbpat'") clear
Code:
Error running query: [PARSE_SYNTAX_ERROR] org.apache.spark.sql.catalyst.parser.ParseException: [PARSE_SYNTAX_ERROR] Syntax error at or near 'select': extra input 'select'. SQLSTATE: 42601 (line 1, pos 112) = SQLSTATE=42601
Any way around this? Users on my system aren't allowed to add permanent functions (though I could see if my IT group would add it for me), so that isn't an option.
Comment