Is there a way to set up an if/else statement within a flow depending on if a SQL query errors out? For example,
if(select * from table) = error then (alter table add column) else somethingelse
?
k
Kevin Kho
12/07/2021, 9:44 PM
Use the case task on this page this checks for a condition. If is evaluated during build time. You need something to evaluate during runtime
j
Jason Motley
12/07/2021, 9:45 PM
Just what I need, thank you
Jason Motley
12/07/2021, 10:08 PM
One other quick q @Kevin Kho - is there a way to quickly detect if there is a column already present in a destination table? Without querying information schema. I want to add a timestamp to ALL data in a SQL table but I'm only uploading 1 days worth at a time, and some tables might not already have the timestamp column in place
Jason Motley
12/07/2021, 10:08 PM
ex.
if (column last refresh exists) then (add refresh time) else (add column last refresh then add refresh time)
. I tried some IF EXISTS SQL but that didn't quite work
k
Kevin Kho
12/07/2021, 10:12 PM
I dont think this is a simple operation in SQL. I think you need to query information tables but I can be wrong
j
Jason Motley
12/07/2021, 10:13 PM
so provided the information schema is BLANK/null (i.e. no column), what would I want in that "if" statement within Prefect itself?
Jason Motley
12/07/2021, 10:13 PM
if length(results)=0 (null?), then "do stuff"?
k
Kevin Kho
12/07/2021, 10:14 PM
If there are no columns, I think so, but of course do this inside a task and use the
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.