cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

Presto hive table to delta table conversion

SQL
New Contributor II

Hi Everyone,

I am using the below sql query to generate the days in order in hive & it is working fine. The table got migrated to delta and my query is failing. It would be appreciated if someone helps me to figure out the issue.

SQL Query :

with  

explode_dates as (

    with list_of_dates as (

    SELECT CAST(date_column AS DATE) AS DAY

    FROM (

       VALUES (SEQUENCE(cast('2021-01-01' AS date), date_add('day',-1,current_date), INTERVAL '1' DAY) ) 

      ) AS t1(date_array)

    CROSS JOIN UNNEST(date_array) AS t2(date_column)

    )

     select a.day as KPI_DATE, month(b.day) as dates_month, b.day as dates from list_of_dates a

     join list_of_dates b on b.day between date_trunc('quarter', date_add('day',0,a.day)) and a.day )

5 REPLIES 5

jose_gonzalez
Moderator
Moderator

Hi @Arumugam Perumal​ ,

Please provide more details. What is the error you are getting? can you share the error stack trace?

SQL
New Contributor II

Hi @Jose Gonzalez​ ,

I am getting below error message .I have changed the date_add function in order to compatible with Delta (date_add('day',-1,current_date), INTERVAL '1' DAY) )  --> date_add(current_date,-1))

Error Message:

ERROR processing query/statement. Error Code: 0, SQL state: org.apache.hive.service.cli.HiveSQLException: Error running query: org.apache.spark.sql.AnalysisException: cannot resolve '`date_array`' given input columns: [];

jose_gonzalez
Moderator
Moderator

Hi @Arumugam Perumal​ ,

I was checking the list of build in functions and it seems like we do not have "date_array". You can check the docs

SQL
New Contributor II

could you please help me with the alternative function for date_array

Does any other date() function help you to solve this issue?

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.