โ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