Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Cannot set session variables #57

Open
friendofasquid opened this issue Jul 23, 2021 · 1 comment
Open

Cannot set session variables #57

friendofasquid opened this issue Jul 23, 2021 · 1 comment

Comments

@friendofasquid
Copy link

friendofasquid commented Jul 23, 2021

Hi—I have a requirement to do this following

SET SESSION hive.insert_existing_partitions_behavior = 'OVERWRITE'"

prior to running a query. I am trying to do this in a custom materialisation, so tried this:

{% call statement() %}
SET SESSION hive.insert_existing_partitions_behavior = 'OVERWRITE'";

INSERT INTO … SELECT … -- my long query here
{% endcall %}

This fails as I believe statement doesn't support multiple statements.

I also tried:

{% do run_query("SET SESSION hive.insert_existing_partitions_behavior = 'OVERWRITE'";) %}
{% set results = run_query("SHOW SESSION") %}
{% do results.print_table(max_rows=none,max_column_width=100) %}

But can see in the results variable that insert_existing_partitions_behavior hasn't changed from APPEND, its default value.

@friendofasquid
Copy link
Author

I looked into this a bit more closely. add_query splits the SQL it receives by ;, then sends each one to be executed. However, with prestodb library, the only way I can see to session session variables is passing session_properties to its connect method.

But to do something sensible, you'd want access to the node's configurations so you might set appropriate session variables, but AFAIK, this is not available from within SQLConnectionManager.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant