This message was deleted.
# general
s
This message was deleted.
e
Yes! There are a few. Quick q — is this a single function (query), or a bunch of functions?
d
Currently it is one function/database query
e
OK, so it should be pretty easy:
Copy code
@parameterize(
    query_1={'query_param' : source('query_param_source_1'),
    query_2={'query_param' : source('query_param_source_2')
)
def query(query_param: ...) -> ...::
    return do_something_with(query_param)
This would be equivalent to defining the same one twice with the same logic but different params. E.G.
Copy code
def query_1(query_param_source_1: ...) -> ...:
    return do_something_with(query_param)

def query_2(query_param_source_2: ...) -> ...:
    return do_something_with(query_param)
Note if you have
n
of these its a different story but we have a way to support that too
d
I see, that's intuitive if you know pytest
s
@Elijah Ben Izzy I think you have typos - the arguments/sources need to be different between them.
e
@Stefan Krawczyk yep you’re correct, fixed it. And @David Wesolowski yeah! Turns out Hamilton + pytest have some very similar approaches (this is very much like the parametrized decorator). Funny that I didn’t actually learn pytest.mark.parametrized until after we built Hamilton…
👍 1
d
except that you spell it correctly 🙂
e
lmao @Stefan Krawczyk and I had quite a back and forth about the spelling 😆 We used to spell it wrong then we deprecated them