https://dagster.io/ logo
#ask-community
Title
# ask-community
t

Tom Reilly

05/18/2023, 6:31 PM
When using a graph with branch logic, i.e
Copy code
@graph
def snowflake_table():
    method_1_load, method_2_load = branching_op()
    method_1_op(method_1_load)
    method_2_op(method_2_load)
is there a way to resolve this to a single output? We frequently create table assets using
AssetsDefinition.from_graph()
and would like to use conditional branching to determine which load method to use. Regardless of which method is used the output is a materialized table. We name the asset by specifying a value for
'result'
in
keys_by_output_name
Copy code
snowflake_table_asset = AssetsDefinition.from_graph(
    snowflake_table,
    keys_by_output_name={
        "result": AssetKey("specific_table_name"),
    }
)
but when branching is involved this leads to errors like
Copy code
The set of output names keys specified in the keys_by_output_name argument must equal the set of asset keys outputted
Is this an anti-pattern? Would moving the conditional logic within resource methods (in this case our internal snowflake client) preferred?
2 Views