This article is related to the following error message:
- TypeError:
(Comparison Operator)
not supported between instances of(data type)
and(data type)
- Where a
Comparison Operator
is typically: <, >, <= ,>=, =. and a data type is typically: 'int', 'str', 'float', 'none', etc. - Example message: TypeError: '<' not supported between instances of 'str' and 'int'
This error message is the result of comparing two different data types within conditional logic in your Matik dynamic content. Usually, this is the result of a data quality issue.
The most common occurrence of this error in Matik is when a null value is passed into conditional logic. Matik interprets null values as strings, resulting in the mismatch in comparison types. This behavior is by design since a null value cannot be compared to a numerical value, and Matik does not know the significance of a null value in your data set.
To resolve this issue, you can set up your Dynamic Content queries to handle null values appropriately. For example, let's say you have a "number of active users" metric that displays null when active users are 0. Your Dynamic Content query might look something like:
SELECT
active_users_num
FROM matik_metrics_table
WHERE company_id = &:company_id
To prevent the error above from occurring when there are no active users, we can add a COALESCE() function to replace nulls with 0's:
SELECT
COALESCE(active_users_num,0)
FROM matik_metrics_table
WHERE company_id = &:company_id
The COALESCE() function will replace all null values returned by active_users_num and replace them with zeros.
Comments
0 comments
Please sign in to leave a comment.