Danger
err:user:bad_request:invalid_analytics_functionExample
What Happened?#
Your query tried to use a function that's blocked for security reasons!
For security, only safe functions are allowed in analytics queries. Functions that could:
- Read files from the server (
file,executable) - Make network requests (
url,remote) - Access external systems (
mysql,postgresql,s3,hdfs) - Modify data or system state
...are all blocked.
How to Fix It#
1. Use Allowed Functions#
Stick to standard analytics functions:
2. Common Safe Functions#
These are examples of allowed functions:
Aggregate functions:
COUNT(),SUM(),AVG(),MIN(),MAX()uniq(),groupArray()
Date/time functions:
now(),today(),yesterday()toStartOfHour(),toStartOfDay(),toStartOfWeek()toDate(),toDateTime()
String functions:
concat(),substring(),lower(),upper()length(),position()
Mathematical functions:
round(),floor(),ceil()abs(),sqrt(),pow()
Conditional functions:
if(),multiIf()CASE WHEN ... THEN ... END
3. Remove Dangerous Functions#
Commonly Blocked Functions#
These functions are blocked for security:
| Function | Why Blocked |
|---|---|
file(), executable() | File system access |
url(), remote() | Network requests |
mysql(), postgresql(), mongodb() | External database access |
s3(), hdfs(), azureBlobStorage() | External storage access |
dictGet(), dictGetOrDefault() | Dictionary access |
Note
Need a specific function that's blocked? Contact support to discuss your use case - we may be able to safely enable it!