02-22-2023 12:14 AM
Hi,
I have a table as below:
create table default.test_user(
ID bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1 INCREMENT BY 1),
usr1 varchar(255) NOT NULL,
ts1 timestamp NOT NULL,
usr2 varchar(255) NOT NULL,
ts2 timestamp NOT NULL) USING Delta;
I tried to insert data as below:
insert into table default.test_user
(usr1,ts1,usr2,ts2)
values
(current_user,current_timestamp,current_user,current_Timestamp)
I am getting error as below:
cannot evaluate expression current_user() AS `current_user()` in inline table definition; line 4 pos 1
Please suggest.
02-22-2023 01:03 AM
The current_user function in Databricks SQL is not evaluated as a valid expression, as it is not supported by the platform. Instead, you can use the current_user_name function to retrieve the current user's name.
Thanks,
02-22-2023 03:32 AM
select current_user is working for me... it is the combination with current_timestamp which is not working. Please try this:
insert into table default.test_user
(usr1,ts1,usr2,ts2)
values
(current_user,current_timestamp,current_user,current_Timestamp)
02-22-2023 02:13 AM
Hi @Himanshu Agrawal ,
It's working for me, please refer below snapshot for the same-
02-22-2023 03:27 AM
select current_user works for me as well... but it does not work for the specific scenario which i have pasted... with the current_timestamp
Try this:
insert into table default.test_user
(usr1,ts1,usr2,ts2)
values
(current_user,current_timestamp,current_user,current_Timestamp)
02-22-2023 06:13 AM
02-23-2023 01:43 AM
03-01-2023 12:32 PM
It appears current_user() is blocked from VALUES because it is considered non-detereministic.
I've taken the liberty of opening:
https://issues.apache.org/jira/browse/SPARK-42638
feel free to open a support ticket to add some **ompf**.....
04-24-2023 03:01 AM
Hi @Himanshu Agrawal
Hope everything is going great.
Just wanted to check in if you were able to resolve your issue. If yes, would you be happy to mark an answer as best so that other members can find the solution more quickly? If not, please tell us so we can help you.
Cheers!
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