Is there a way to get the column data types from SQL in v1.4.4?

Hello, I’m working on a materialization macro that inserts data into a target table, from the columns from a source view in the model.

For e.g. this model will insert col_a, col_b, col_c into a table, with columns col_a, col_b, col_c.


{{
  config(
    materialized = 'insert_into_table',
    schedule = 'USING CRON 0 * * * * UTC',
  )
}}

SELECT 
    col_a, col_b, col_c 
FROM 
    {{ref('model'}};

For when there are DDL changes in the source view, I’m trying to compare what the columns in the target table currently are, with their names and data types, to the columns selected in the SQL from the source view.

I’m able to get the column names and their data types of the target table with: adapter.get_columns_in_relation(table_relation)

But I’m not sure how to get the data types of columns for the SQL. I’m able to get the column names with: get_columns_in_query (sql).

I realize that there is a macro just for this called: get_column_schema_from_query but it’s only released on a later version.

Is there something I could do to match this in dbt v1.4.4.?