-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CT-3112] [Feature] Pass model configuration to execute() #226
Comments
Thanks for opening @SoumayaMauthoorMOJ! We've gotten this ask before, in order to support things like:
I don't think this is something we'd be able to prioritize immediately, but I want to leave some notes below, in case it's helpful in thinking through what a better pattern here might look like. There are a few things that make this tricky. I think it's slightly trickier if the relevant config needs to be supplied when creating the connection, versus configs that can be supplied as additional keyword arguments to an existing connection/cursor. Support for the latter pattern seems to vary quite a bit, and those keyword arguments are not standardized. If the config is relevant to connection creation:
If the config can be passed to the
|
Hello @jtcohen6 thanks for getting back to me. To clarify the requirement is about "configs that can be supplied as additional keyword arguments to the execute method of an existing connection/cursor." This is because we can already pass the config during connection creation by adding to the I should also clarify that it is somewhat possible to pass in configs by creating additional functions in However this requires modifying all macros to explicitly refer to this function, which means a lot of additional code to modify/maintain. |
Okay. My sense is that, for some data warehouse clients, there are configs which can only be set at initial connection creation, and cannot be subsequently overridden when submitting/executing a specific query. To support those warehouses/configs, we'd need the trickier pattern of (a) fetching that config when the connection is being created; (b) not reusing connections, but always closing & reopening. I understand that this is different from the config of interest that prompted you to open this issue.
In theory, something like this might be possible: {%- macro statement(name=None, fetch_result=False, auto_begin=True, language='sql') -%}
...
{%- if language == 'sql'-%}
{%- set work_group = config.get("work_group") -%}
{%- set res, table = adapter.execute(compiled_code, auto_begin=auto_begin, fetch=fetch_result, work_group=work_group) -%}
... I haven't thought enough about whether that's the right thread to pull on — but I think it would have coverage for almost all queries submitted from the Jinja context, which tend to pass through {%- set adapter_specific_kwargs = get_adapter_execute_kwargs_from_context() -%}
{%- set res, table = adapter.execute(compiled_code, auto_begin=auto_begin, fetch=fetch_result, **kwargs) -%}
-- or
{%- set res, table = adapter.execute(compiled_code, auto_begin=auto_begin, fetch=fetch_result, adapter_kwargs=adapter_specific_kwargs) -%} |
So just to clarify, you understand that in the case of Athena passing in additional configs such as work_group does not require closing and reopening the connection since I can pass that to
Why not limit to configs that don't need you to close and reopen the connection? Closing and reopening the connection seems a bit drastic and could impact performance. |
Transferring to
|
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days. |
Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers. |
Is this your first time submitting a feature request?
Describe the feature
Have the ability to pass in model, snapshot, seed and other configuration to the cursor() method, in addition to credentials saved to
profiles.yml
.Describe alternatives you've considered
No response
Who will this benefit?
This has been raised by at least two adapters:
Are you interested in contributing this feature?
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: