# Using User defined function from snowflake in dbt model

**URL:** <https://discourse.getdbt.com/t/using-user-defined-function-from-snowflake-in-dbt-model/8734>\
**Category:** Help\
**Created:** [June 16, 2023, 2:03am UTC](https://discourse.getdbt.com/t/using-user-defined-function-from-snowflake-in-dbt-model/8734 "2023-06-16T02:03:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayasfps](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/jayasfps/32/2555_2.png) [@jayasfps](https://discourse.getdbt.com/u/jayasfps)\
**Post date:** [June 16, 2023, 2:03am UTC](https://discourse.getdbt.com/t/using-user-defined-function-from-snowflake-in-dbt-model/8734/1 "2023-06-16T02:03:46Z")

</div>

I am working on transforming the queries from snowflake in to a dbt model.  
The query uses a user defined function from the snowflake schema which takes parameters.

Is there a possibility to use the UDF in the dbt model by referring it as {{database}}.{{schema}}.{{num\_working\_days(parameter1,parameter2,parameter3)}}?

---

<div class="post-metadata">

**Author:** ![Surya](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/surya/32/3763_2.png) [@Surya](https://discourse.getdbt.com/u/Surya)\
**Post date:** [June 16, 2023, 2:42am UTC](https://discourse.getdbt.com/t/using-user-defined-function-from-snowflake-in-dbt-model/8734/2 "2023-06-16T02:42:37Z")

</div>

@jayasfps  
Plz refer this

> [@Call a dataset persistent function with a ref](https://discourse.getdbt.com/t/call-a-dataset-persistent-function-with-a-ref/7422):
>
> I’m migrating a view from bigquery and it uses a couple persistent functions written in javascript. Since they aren’t written in sql, I cannot use a macro to reproduce them, so I probably have to call them in my dbt model. Since I have to write my project\_id and dataset\_id in order to call the function, is there a way to add these as source and call the function using a ref, so the model respects modularity of sources? Thank you!

---

<div class="post-metadata">

**Author:** ![jayasfps](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/jayasfps/32/2555_2.png) [@jayasfps](https://discourse.getdbt.com/u/jayasfps)\
**Post date:** [June 19, 2023, 4:41am UTC](https://discourse.getdbt.com/t/using-user-defined-function-from-snowflake-in-dbt-model/8734/3 "2023-06-19T04:41:04Z")

</div>

Thank you @Surya , It worked out.

---

<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:** [June 26, 2023, 4:42am UTC](https://discourse.getdbt.com/t/using-user-defined-function-from-snowflake-in-dbt-model/8734/4 "2023-06-26T04:42:01Z")

</div>

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