Define SQL table name using Python

alm
Databricks Partner

I want to control which schema a notebook writes. I want it to depend on the user that runs the notebook.

For now, the scope is to suport languages Python and SQL. I have written a Python function, `get_path`, that returns the full path of the destination. 

My idea was to create a SQL function that wraps the Python function.

```

create or replace function GETPATH(catalog_name string, schema_name string, table_name string)
returns string
language python
as $$
from path import get_path
return get_path(catalog_name, schema_name, table_name)
$$
```
Surprisingly, or not so much so, this doesn't work.
 
Any idea how to implement something like this? It might be, that it should handled completely different.
 
If I can set the catalog and schema of notebooks in a folder somewhere else so that the notebook only defines the table name, it would also solve the problem.   

  

alm
Databricks Partner

What is unclear to you? I need to create a table that depend on the username of the current user