395 FUNCTION_THROW_IF_VALUE_IS_NON_ZERO
Error Code 395: FUNCTION_THROW_IF_VALUE_IS_NON_ZERO
This error occurs when the throwIf function evaluates to a non-zero (true) value.
The throwIf function is designed to intentionally throw an exception when its condition is met, and error code 395 is the standard error code for this behavior.
When you'll see it
You'll encounter this error in the following situations:
-
Explicit use of
throwIffunction:- When you deliberately use
throwIf()in your query to validate data or enforce business rules - Example:
SELECT throwIf(number = 2) FROM numbers(5)
- When you deliberately use
-
HTTP streaming queries:
- When an exception occurs mid-stream while data is being sent over HTTP
- The error appears in the response body even after HTTP 200 status has been sent
-
Testing and validation:
- When using
throwIfto test error handling in applications - During data quality checks that use assertions
- When using
-
Custom error codes (optional):
- With the setting
allow_custom_error_code_in_throwif = 1, you can specify custom error codes - Example:
throwIf(1, 'test', toInt32(49))- but this is generally not recommended
- With the setting
Potential causes
-
Intentional validation failure - The most common cause, where
throwIfis working as designed to catch invalid data -
Business rule violation - Data doesn't meet expected criteria (e.g., checking for null values, out-of-range numbers, duplicate records)
-
Test queries - Using
throwIffor debugging or testing error handling -
HTTP response timing - In HTTP queries, error code 395 can appear mid-response when processing rows incrementally
Quick fixes
1. For legitimate validation failures:
Fix: Adjust your data or query logic to avoid the triggering condition.
2. For HTTP streaming issues:
3. For unexpected errors in production:
4. For testing/debugging:
Important notes
- The
throwIffunction is intentional - it's meant to throw exceptions when the condition is true - Error code 395 itself is not a bug; it indicates the function is working as designed
- When using custom error codes (with
allow_custom_error_code_in_throwif = 1), thrown exceptions may have unexpected error codes, making debugging harder