# Is it possible to set hive config variables in macro?

**URL:** <https://discourse.getdbt.com/t/is-it-possible-to-set-hive-config-variables-in-macro/5173>\
**Category:** Help\
**Created:** [October 25, 2022, 4:29am UTC](https://discourse.getdbt.com/t/is-it-possible-to-set-hive-config-variables-in-macro/5173 "2022-10-25T04:29:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hurcy](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/hurcy/32/4168_2.png) [@hurcy](https://discourse.getdbt.com/u/hurcy)\
**Post date:** [October 25, 2022, 4:29am UTC](https://discourse.getdbt.com/t/is-it-possible-to-set-hive-config-variables-in-macro/5173/1 "2022-10-25T04:29:55Z")

</div>

I’m using dbt core with dbt-hive adapter.  
I used to set variables in hive as follows.

```auto
set hive.server2.enable.doAs=false;
set hive.server2.tez.default.queues=default;
set hive.server2.tez.initialize.default.sessions=false;
set hive.server2.tez.sessions.per.default.queue=1;

```

I would like to apply different configurations using macros.  
But I got ParseException. (FAILED: ParseException line 19:0 cannot recognize input near ‘set’ ‘hive.server2.enable.doAs’ ‘=’ in create table statement)

```auto
{% macro tpch_settings(engine='mr') %}
{% if engine == 'mr' %}
set hive.server2.enable.doAs=false;
set hive.server2.tez.default.queues=default;
set hive.server2.tez.initialize.default.sessions=false;
set hive.server2.tez.sessions.per.default.queue=1;
....
{% endif %}
{% endmacro %}

```

---

<div class="post-metadata">

**Author:** ![joellabes](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/joellabes/32/3980_2.png) [@joellabes](https://discourse.getdbt.com/u/joellabes)\
**Post date:** [October 27, 2022, 9:31am UTC](https://discourse.getdbt.com/t/is-it-possible-to-set-hive-config-variables-in-macro/5173/2 "2022-10-27T09:31:45Z")

</div>

You won’t be able to configure your database connection from inside of a dbt macro in a model definition - by the time that code is being hit, you already have a database connection and as you’ve seen, you’re inside of a `create table as select` block.

I’m not familiar with hive but recommend you open an issue on their adapter’s repository to describe your use case as it will need to be enabled at the adapter level, not in userspace

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/1X/a7a7ca1fe379aaf90952b0e13118a817babcd14f.png) [@system](https://discourse.getdbt.com/u/system)\
**Post date:** [December 5, 2022, 12:32pm UTC](https://discourse.getdbt.com/t/is-it-possible-to-set-hive-config-variables-in-macro/5173/3 "2022-12-05T12:32:13Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
