cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
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
Databricks Employee
Databricks Employee

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
Databricks Employee
Databricks Employee

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

jose_gonzalez
Databricks Employee
Databricks Employee

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

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group