How to get the min date of a date that is stored as an int in dbt + snowflake?

I am working with dbt + SNOWFLAKE.

I have a column called “Event_Name”, which is a date that comes as an int.

20230101

I’ve made the following model and I’ve tested it with hardcoded dates to make sure I got the function right.
However, when I want to point the start_date to the min Event_Date, I get the following error:


17:18:04  252005: Failed to convert current row, cause: Python int too large to convert to C int

This is the model:


{{ config(
      alias='DIM_DATE',
      materialized = "table"
) }}

{% set get_min_date_query %}
    select min(event_date::varchar) 
    from  {{ ref('raw_events_pivot') }}
{% endset %}
{% set min_query_result = run_query(get_min_date_query) %}

{% if execute %}
 {% set min_year_result = min_query_result.columns[0].values()[0] %}
{% else %}
    set min_year_result = 0
{% endif %}  
{% set start_date =  get_start_date(min_year_result ) %}
 

with date_create as (
{{ dbt_date.get_date_dimension( start_date ,  '2023-12-31' )}}
) 

SELECT
    DATE_DAY AS date,
    YEAR_NUMBER as year,
    DAY_OF_WEEK_NAME_SHORT as day_name,
    WEEK_OF_YEAR,
    'WK' || WEEK_OF_YEAR || '-' || YEAR_NUMBER as week_year, --WK52-2022
    MONTH_OF_YEAR as month_nr,
    MONTH_NAME,
    MONTH_NAME_SHORT,
    QUARTER_OF_YEAR as quarter,
    'Q'|| QUARTER_OF_YEAR  || '-' || YEAR_NUMBER AS quarter_year, --Q1-2023
    current_user() as INT_LoadBy,
    sysdate()  as INT_UPDATETIMESTAMPUTC,
    'DBT' as COD_IntSourceSystem
FROM Date


What am I supposed to do to fix this?
I even tried to convert the start date to char but I didn’t get it…