# Dynamic Partition Handling for Event-Date Queries in Dremio

**URL:** <https://community.dremio.com/t/dynamic-partition-handling-for-event-date-queries-in-dremio/12330>\
**Category:** Uncategorized\
**Created:** [September 23, 2024, 4:33pm UTC](https://community.dremio.com/t/dynamic-partition-handling-for-event-date-queries-in-dremio/12330 "2024-09-23T16:33:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![JoiceJacob](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/joicejacob/32/5715_2.png) [@JoiceJacob](https://community.dremio.com/u/JoiceJacob)\
**Post date:** [September 23, 2024, 4:33pm UTC](https://community.dremio.com/t/dynamic-partition-handling-for-event-date-queries-in-dremio/12330/1 "2024-09-23T16:33:12Z")

</div>

Hi team,

I have a table called cust\_rec\_data that contains columns like customer\_number, event\_date, recharge\_amount, recharge\_channel, and part\_idx (which represents the month extracted from event\_date in MM format). The event\_date column is indexed. Since the table holds a large amount of data for the last 12 months, we use part\_idx for partitioning. When integrating Dremio with BI tools like Superset, the user wants to view the sum of recharge amounts by recharge\_channel for a specific range between different event\_date values. They don’t expect to manually select part\_idx because they’ve already selected the date range based on event\_date. Can we manipulate the query in Dremio to automatically add the relevant part\_idx values based on the selected date range, without user input, so that the query runs much faster?

Thanks in Advance

---

<div class="post-metadata">

**Author:** ![AjayBabuM](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/ajaybabum/32/6736_2.png) [@AjayBabuM](https://community.dremio.com/u/AjayBabuM)\
**Post date:** [September 24, 2024, 3:49pm UTC](https://community.dremio.com/t/dynamic-partition-handling-for-event-date-queries-in-dremio/12330/2 "2024-09-24T15:49:16Z")

</div>

Hello Dremio Team,

Any update on this query?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![balaji.ramaswamy](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/balaji.ramaswamy/32/843_2.png) [@balaji.ramaswamy](https://community.dremio.com/u/balaji.ramaswamy)\
**Post date:** [September 25, 2024, 3:12am UTC](https://community.dremio.com/t/dynamic-partition-handling-for-event-date-queries-in-dremio/12330/3 "2024-09-25T03:12:39Z")

</div>

@JoiceJacob What is the source? If RDBMS, Dremio will just push down query written. You can create a view and add column you need in the filter. I am not entirey following your question.

If the backend is Iceberg table format there is a concept called partition transform which can help

Kindly let me know the source and if you have a job profile and we can start there

---

<div class="post-metadata">

**Author:** ![AjayBabuM](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/ajaybabum/32/6736_2.png) [@AjayBabuM](https://community.dremio.com/u/AjayBabuM)\
**Post date:** [September 25, 2024, 7:31am UTC](https://community.dremio.com/t/dynamic-partition-handling-for-event-date-queries-in-dremio/12330/4 "2024-09-25T07:31:45Z")

</div>

Hi @balaji.ramaswamy,

It’s MySQL 8.x, and column in VDS can show an example? In my case event\_date will be change based on user input from BI tool.

Thanks.

---

<div class="post-metadata">

**Author:** ![balaji.ramaswamy](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/balaji.ramaswamy/32/843_2.png) [@balaji.ramaswamy](https://community.dremio.com/u/balaji.ramaswamy)\
**Post date:** [September 25, 2024, 8:42pm UTC](https://community.dremio.com/t/dynamic-partition-handling-for-event-date-queries-in-dremio/12330/5 "2024-09-25T20:42:56Z")

</div>

@AjayBabuM For RDBMS, Dremio does a push down of the query written, can you provide a job profile of the query you are running on Dremio so we can see what is getting pushed down?

---

<div class="post-metadata">

**Author:** ![AjayBabuM](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/ajaybabum/32/6736_2.png) [@AjayBabuM](https://community.dremio.com/u/AjayBabuM)\
**Post date:** [September 30, 2024, 7:58pm UTC](https://community.dremio.com/t/dynamic-partition-handling-for-event-date-queries-in-dremio/12330/6 "2024-09-30T19:58:47Z")

</div>

Hi @balaji.ramaswamy

Please find the query profile. Here, when the BI tool executes the query towards Dremio,

 ![image](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/2X/0/08924f5bdaca0241a4a608084f81070c4b4803c1.png)

expecting dremio should convert it to,

 ![image](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/2X/4/45de690034aed82b72522421072bfc724a2d4686.png)

So that BI tool no need to select part\_idx(dervied from event\_date) again since already selected event\_date. Actually here the table size was huge if we use part\_idx it will execute more fast.

[12926816-d159-47cc-99a3-61a46db068f3.zip](https://community.dremio.com/uploads/short-url/14CeV8A3eTcMw48tT3806u9PFuD.zip) (15.4 KB)

Thanks,  
Ajay Babu Maguluri

---

<div class="post-metadata">

**Author:** ![balaji.ramaswamy](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/balaji.ramaswamy/32/843_2.png) [@balaji.ramaswamy](https://community.dremio.com/u/balaji.ramaswamy)\
**Post date:** [October 2, 2024, 7:05am UTC](https://community.dremio.com/t/dynamic-partition-handling-for-event-date-queries-in-dremio/12330/7 "2024-10-02T07:05:46Z")

</div>

@AjayBabuM Dremio is unaware of the indexes created in MySQL. It simply pushes down all the work to the server side (MySQL) and does not change the filter condition to add columns that have indexes. The optimization it can do is if you join two MySQL tables with a filter condition, it can push the entire join with the filter into MySQL
