Query failed: Connection name not specified

gblack686
gblack686 Partner, Registered Posts: 62 Partner
Job failed: Error in Python process: At line 144: <type 'exceptions.Exception'>: Query failed: Connection name not specified

line 144: SQLExecutor2.exec_recipe_fragment(output_dataset, final_query)

My code was working just fine and then I changed the output dataset and I'm getting this error. (I don't have any inputs) Do I need to write something in the pre-script for the SQLExecutor2 to tell it to look for a specific connection?

Best Answers

  • ATsao
    ATsao Dataiker Alumni, Registered Posts: 139 ✭✭✭✭✭✭✭✭
    edited July 17 Answer ✓

    Hi,

    In your python code, did you make sure to first set up your SQL executor accordingly? Something like:

    executor = SQLExecutor2(connection="db-connection") # or dataset="dataset_name"
    executor.exec_recipe_fragment(output_dataset, final_query)

    You can also find more information about SQLExecutor2 in our python API documentation here:

    https://doc.dataiku.com/dss/latest/python-api/sql.html#retrieving-results

    I hope that this helps!

    Best,

    Andrew

  • Clément_Stenac
    Clément_Stenac Dataiker, Dataiku DSS Core Designer, Registered Posts: 753 Dataiker
    Answer ✓

    Ah, right. Just like "normal" SQL recipes, "delegated" SQL recipes via "exec_recipe_fragment" only compute the connection name from the input, so you'll need to add an input dataset indeed.

    It does not need to represent actual "input" data of your plugin, it just needs to be a SQL table dataset pointing to any table of the output connection, so that DSS can fetch the connection name from there.

    We'll add your interest in having input-less SQL recipes (and hence, input-less "delegated" SQL recipes)

Answers

  • gblack686
    gblack686 Partner, Registered Posts: 62 Partner
    edited July 17
    executor = SQLExecutor2(connection="cde_adhoc")
    output_dataset = executor.exec_recipe_fragment(output_dataset, final_query)

    Hi Andrew,

    I've added the code just like in the documentation and am still getting the same error "Connection name not specified". The output connection name matches the SQLexecutor connection name. It's weird this was working before without specifying connection. Also, when I try to declare dataset I get the same error.

    [2020/04/07-00:31:31.769] [qtp839552703-48] [INFO] [dku.jobs]  - Executing a partial SQL query recipe for compute_test_plugin_output2_NP (write to PROJECT_NAME.testout)
    [2020/04/07-00:31:31.769] [qtp839552703-48] [INFO] [dku.jobs]  - Starting runner
    [2020/04/07-00:31:31.775] [qtp839552703-48] [ERROR] [dku.jobs]  - Call failed
    java.lang.IllegalArgumentException: Connection name not specified

    =/

  • Clément_Stenac
    Clément_Stenac Dataiker, Dataiku DSS Core Designer, Registered Posts: 753 Dataiker

    Hi,

    What was the output before you changed it and what is it after you changed it ?

  • gblack686
    gblack686 Partner, Registered Posts: 62 Partner

    So it seems to have to do with my not supplying an input role. When I deleted it, it still worked, but it must have been cached or something. Eventually, it stopped working without an input dataset and could not find the connection, even when specified in the code itself.

    I don't want an input dataset in the plugin if I can avoid it. Is there a way I can supply the connection to the configuration elsewhere? It doesn't seem to be working in the python recipe.py.

  • Rickh008
    Rickh008 Dataiku DSS Core Designer, Registered Posts: 15 ✭✭✭✭

    I am having a similar issue. I get this error when running both R and Python code recipes. What should I try?

    Capture.PNG

Setup Info
    Tags
      Help me…