SQLExecutor2 through Webapp usage

tamvap
Level 2
SQLExecutor2 through Webapp usage

Hello,

Currently I am trying to use SQLExecutor2 to a DSS Webapp. The reason why is that I have a large dataset and i want to get the data filtered.

First I was trying to use an existing Dataset  that has been created in DSS Flow from SQL table like below.

 

mydataset = dataiku.Dataset("VALUE_TAB")
executor = SQLExecutor2(dataset=mydataset)

test_query = """SELECT * FROM VALUE_TAB WHERE VERSION = 'V3'"""
result = executor.query_to_df(test_query)

 

  I had an error message that says that: 

"Could not find table/view VALUE_TAB in schema SCHEMA".

Is there a way to use in a Webapp a dataset from DSS flow with SQLExecutor2 library , or i have to make the connection directly with the SQL?

Thanks,

Tamvap 

 

 

0 Kudos
1 Reply
fchataigner2
Dataiker
Dataiker

Hi,

the SQLExecutor2 only issue statements on a jdbc connection corresponding to the dataset you pass, here the VALUE_TAB dataset. But that doesn't mean that you can put the dataset name in a SQL query and have DSS adjust the query automatically to replace VALUE_TAB by the actual schema/table name that the dataset points to.

It's likely that here you need to get the schema and table name from the dataset and put them in the SELECT * FROM ...  , with proper quoting.

0 Kudos
A banner prompting to get Dataiku DSS
Public