Hi, i’m using a `volume_anomalies` test on source ...
# community-support
f
Hi, i’m using a
volume_anomalies
test on source data where the date column i want to use for the
timestamp_column
parameter is a string with format like
20240105
. So i need to parse it to an actual timestamp with
parse_timestamp('%Y%m%d', event_date)
. It worked with
timestamp_column: "parse_timestamp('%Y%m%d', event_date)"
until upgrading to the latest elementary version, now this workaround is throwing an error (because the timestamp_column is also used as an alias in the query that tests creates and aliases can’t contain functions). Is there another way to parse the timestamp? Since it’s source data i’m testing there’s no way to transform the timestamp in the table itself. Thanks in advance!
o
Hi @Flora Schneider, care to share the error you encounter. a quick solution from the top of my head might be to create a
view
model on top of the source (which parses the timestamp and names it) and running the
volume_anomalies
test on it instead
f
Hi @Ofek Weiss, thanks for getting back to me. The issue seems to come from this line in the macro where
timestamp_column
is used as an alias in the SQL which was just added recently. In my case it results in this line in the by the macro generated query:
Copy code
cast(parse_timestamp('%Y%m%d', event_date) as TIMESTAMP) as parse_timestamp('%Y%m%d', event_date)
… which ofc fails due to having a function in the alias. I moved the tests from source to base tables as a workaround and it’s fine. But it was a nice hack to be able to cast a string to an actual timestamp in the test configs.
o
@Flora Schneider Good news! this will be fixed in our next release 🎉 , stay tuned 👀
f
Hey @Ofek Weiss, that’s great 🙂 And thanks for letting me know!
m
just ran into this. any news on using casting functions in the config?