Comment
New Contributor II

Serge:

Great and very helpful article.  I am trying to come up for a work around that there is no SET SESSION TIMESTAMP function in databricks by using either a session variable or a Hive Variable, but I am getting stumped.   Here is the rough pseudocode of what I am trying to do:   

SET test_date = '2024-02-01';                                                        

CREATE OR REPLACE VIEW race_today AS
SELECT *
FROM raceresults
WHERE CAST(RaceDate AS DATE) = COALESCE(CAST('${test_date}' AS DATE), CURRENT_DATE());

What I want to accomplish -- If there is a test_date set then use that within the views, if there is no test_date then use the CURRENT_DATE() as the filter. 

I have tried a few variants of creating this, but keep getting syntax errors about using DEFINE instead of SET.  Any suggestions on how to resolve the syntax and proper usage would be appreciated.