Custom sql for dataset

HI

for a dataset i have to modify a data in custom sql.
at the moment it is written as YYYYMMDD and I have to write it as YYYY/MM/DD

I have to do it in sql because then I need it for a join and I can’t do it with calculated fields

I wrote like this (in bold the part that does not work)

SELECT CONCAT(hostname,pagepath) as link_sito, concat(partition_0,‘/’,partition_1,‘/’,partition_2) as data_partition, CONCAT(LEFT(date, 4),‘/’,LEFT(RIGHT(date, 4),2),‘/’,RIGHT(date, 2)) as data_ga4, eventname, eventcount, date, hostname as sito, eventcountperuser
FROM ga4_db.bigdata_ga4
WHERE eventname=‘page_view’
GROUP BY 1,2,3, eventname, eventcount, date, hostname, eventcountperuser

for the part in bold it gives me this message. I don’t understand what I’m doing wrong

region: eu-west-1
timestamp: 1693299443775
requestId: f04cd909-f327-4226-8a5b-21102bb25ef6
sourceErrorCode: 100071
sourceErrorMessage: [Simba]AthenaJDBC An error has been thrown from the AWS Athena client. Queries of this type are not supported [Execution ID not available]
sourceErrorState: HY000
sourceException: java.sql.SQLException
sourceType: ATHENA

Hello @andreab,

I am not sure LEFT and RIGHT work with Athena. can you try using substr?

From the top of my head should be something like:

concat(substr(date, 1,4),'/',substr(date,5,2),'/',substr(date,7,2))

Hope this works!

Kind regards,
Andres.

Hi @andres007
Yes, it works
thanks

1 Like