Error 135: ZERO_ARRAY_OR_TUPLE_INDEX
подсказка
This error occurs when you attempt to access a tuple element using index 0. ClickHouse tuples use 1-based indexing, meaning the first element is at index 1, not 0.
Most common causes
-
Using 0-based indexing from other languages
- Developers coming from Python, JavaScript, C++, Java, etc. where arrays start at 0
- Forgetting ClickHouse uses 1-based indexing for tuples and arrays (with arrays
0will work but return the default value of the array type, not the first element) - Copy-pasting code from other systems without adjusting indices
- Mental model mismatch between ClickHouse and application code
-
Incorrect tuple element access
- Using
.0to access first element instead of.1 - Using
tupleElement(tuple, 0)instead oftupleElement(tuple, 1) - Bracket notation with 0 index:
tuple[0]instead oftuple[1] - Off-by-one errors in loop indices or calculations
- Using
-
Dynamic index calculations
- Loop counters starting at 0 instead of 1
- Range functions generating 0-based sequences
- Mathematical calculations resulting in 0 index
- Converting from 0-based system without adjustment
Common solutions
1. Use 1-based indexing for tuple access
2. Use dot notation with correct indices
Related error codes
- INDEX_OF_POSITIONAL_ARGUMENT_IS_OUT_OF_RANGE (69) - Tuple/array index exceeds bounds
- ILLEGAL_TYPE_OF_ARGUMENT (43) - Wrong type used for index
- SIZES_OF_ARRAYS_DONT_MATCH (190) - Array size mismatches
- ILLEGAL_INDEX (127) - Invalid index usage