0 votes

You can create a "SQL query" recipe with the public API using the `SQLQueryRecipeCreator` object. However, there isn't an equivalent object for a "SQL script" recipe. How can I create a SQL script recipe using the public API?

asked by

1 Answer

0 votes
Best answer

There is no specific API to create an SQL Script recipe, but you can use the generic SingleOutputRecipeCreator to do it.
Here is an example to create such a recipe:

from dataikuapi.dss.recipe import SingleOutputRecipeCreator

# Create an SQL script recipe
builder = SingleOutputRecipeCreator('sql_script', "my_sql_script_recipe_name", project)
builder = builder.with_input("my_input_ds")
builder = builder.with_output("my_output_ds")
recipe = builder.build()        

# Update the SQL script recipe to set its script
recipe_def = recipe.get_definition_and_payload()
recipe_def.set_payload('CREATE TABLE ...')
recipe.set_definition_and_payload(recipe_def)
answered by
selected by
Hi apichery, thanks for the above. The above Python executes fine but the node and dataset doesn't appear in the Dataiku flow. Not sure why not. No error from Python or Dataiku. Im running Version 4.3.1
Have you tried to refresh your browser? Your browser might not be notified that the Flow has been updated.
Yep - it doesn't help. What's interesting is that if I then try to create a node with SQLQueryRecipeCreator with the same output, the first recipe created with SingleOutputRecipeCreator suddenly appears.
972 questions
1,000 answers
1,047 comments
2,392 users

┬ęDataiku 2012-2018 - Privacy Policy