Skip to content
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

Passing Hive configuration properties #85

Closed
cylldby opened this issue Nov 30, 2022 · 11 comments
Closed

Passing Hive configuration properties #85

cylldby opened this issue Nov 30, 2022 · 11 comments
Assignees
Labels
enhancement New feature or request

Comments

@cylldby
Copy link

cylldby commented Nov 30, 2022

While experimenting with this adapter, I'm trying to find a way to pass configuration properties to Hive.
For example, I would like to be able to run:

set hive.auto.convert.join=true;
set hive.stats.fetch.partition.stats=true;
set hive.vectorized.execution.enabled=true;

SELECT * FROM mytable

Apparently with Impyla we need to pass these properties in a configuration dictionary when execute-ing a query.

Is it possible to attach such a dictionary in a model's config ?

@cylldby
Copy link
Author

cylldby commented Nov 30, 2022

About passing configuration with Impyla, I'm referring to this

@tovganesh
Copy link
Contributor

tovganesh commented Nov 30, 2022

Can you try using pre-hooks for settings the properties?
https://docs.getdbt.com/reference/resource-configs/pre-hook-post-hook

@cylldby
Copy link
Author

cylldby commented Nov 30, 2022

Thank you for the fast reply !

Unfortunately using pre-hooks fails.
I have a query that runs fine on its own. But as soon as I tried to add for instance

{{
    config(
        materialized='table',
        pre_hook="set hive.exec.dynamic.partition=true;"
    )
}}

I get the following error:

Unable to establish connection to Hive server: Error while compiling statement: FAILED: ParseException line 3:12 cannot recognize input near 'set' 'hive' '.' in statement

@tovganesh
Copy link
Contributor

Ok. Let me explore this at our end and get back to you.

@tovganesh tovganesh self-assigned this Dec 1, 2022
@tovganesh tovganesh added the enhancement New feature or request label Dec 1, 2022
@cylldby
Copy link
Author

cylldby commented Dec 1, 2022

Thank you very much ! 🙏
I will look on my end too. It looks tricky 😓

@cylldby
Copy link
Author

cylldby commented Dec 1, 2022

For reference, there is this issue in the dbt-spark repository, with similar target.
In there they suggest the addition of a field in the profiles.yml file to contain the desired configuration, which would then be passed to the connection object.

It is quite interesting.. An ideal situation would be to be able to pass configuration at model level but I'm not sure we have such possibility.

@tovganesh
Copy link
Contributor

tovganesh commented Dec 1, 2022

The parse error for pre_hook seems strange. Apparently dbt adds a comment for query when it is executing, and Hive doesn't seem to honour comment when using set.

So:

/*dbt some comment */
set hive.exec.dynamic.partition=true;

flags an error, while:

set hive.exec.dynamic.partition=true;

works!
Verified this in Hue. Let me check how I can handle this in adapter.

@tovganesh
Copy link
Contributor

Are you ok to try out this draft PR: #89 ?

@cylldby
Copy link
Author

cylldby commented Dec 5, 2022

Sorry for the delay !

I could test the PR against a test table and it seems it solves the issue !
I could include a list of SET <parameter>=<value>; in a pre-hook in my model config, and confirmed they were executed with dbt --debug run.

Thank you very much for the fast fixing !

Let me know if I can do anything else.

@wuguozhu
Copy link

In what version is this issue fixed? We need a solution urgently

@tovganesh
Copy link
Contributor

@wuguozhu you can install from the source for the fix. There is no updated pip package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants