clickhouse

How to throw manually exception in Clickhouse?


I want to write some tests for my data using just SQL clickhouse dialect. For that purpose I need to throw exception when my data is broken, how can I do this ?

For example - if value in my column more then 3 - I want to fail query.


Solution

  • I found solution it's function throwIf

    example from docs:

    SELECT throwIf(number = 3, 'Too many') FROM numbers(10);
    

    link on documentation: https://clickhouse.com/docs/sql-reference/functions/other-functions#throwif