10-19-2022 04:30 AM
Hello. What would be the equivalent of the below in databricks?
DECLARE @LastChangeDate as date
SET @LastChangeDate = GetDate()
I already tried the below and worked. However I need to know how set a sql variable dynamically
SET da.dbname = test;
SELECT "${da.dbname}" AS db_name
Thank you in advance.
11-04-2022 09:46 PM
Hi @ELENI GEORGOUSI
In databricks sql it will works in the following manner
SET LastChangeDate =current_date()
Select ${hiveconf:LastChangeDate}
10-31-2022 01:11 AM
Hello. Is the above something that can be done in databricks sql?
10-31-2022 08:09 PM
@ELENI GEORGOUSI
set LastChangeDate =current_date();
or
in your sql query
select current_date() as date
11-01-2022 12:38 AM
11-01-2022 01:16 AM
11-01-2022 01:19 AM
Hello @somanath Sankaran. I need an equivalent to Declare variable. In the above example you attached, I cannot refer to this variable as for example ${dt} throughout the notebook.
11-01-2022 01:42 AM
11-04-2022 09:46 PM
Hi @ELENI GEORGOUSI
In databricks sql it will works in the following manner
SET LastChangeDate =current_date()
Select ${hiveconf:LastChangeDate}
08-21-2023 12:53 PM
Hello - thanks for this suggestion. However, I am getting this error in databricks:
"Error running query: [_LEGACY_ERROR_TEMP_DBR_0222] org.apache.spark.sql.AnalysisException: Configuration LastChangeDate is not available."
I've tried many different suggestions for this and can't seem to find a way to do this simple thing.
05-20-2023 04:05 AM
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