MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / checkValid

Method checkValid

src/Interpreters/WindowDescription.cpp:91–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91void WindowFrame::checkValid() const
92{
93 // Check the validity of offsets.
94 if (begin_type == BoundaryType::Offset
95 && !((begin_offset.getType() == Field::Types::UInt64
96 || begin_offset.getType() == Field::Types::Int64)
97 && begin_offset.safeGet<Int64>() >= 0
98 && begin_offset.safeGet<Int64>() < INT_MAX))
99 {
100 throw Exception(ErrorCodes::BAD_ARGUMENTS,
101 "Frame start offset for '{}' frame must be a nonnegative 32-bit integer, '{}' of type '{}' given",
102 type,
103 applyVisitor(FieldVisitorToString(), begin_offset),
104 begin_offset.getType());
105 }
106
107 if (end_type == BoundaryType::Offset
108 && !((end_offset.getType() == Field::Types::UInt64
109 || end_offset.getType() == Field::Types::Int64)
110 && end_offset.safeGet<Int64>() >= 0
111 && end_offset.safeGet<Int64>() < INT_MAX))
112 {
113 throw Exception(ErrorCodes::BAD_ARGUMENTS,
114 "Frame end offset for '{}' frame must be a nonnegative 32-bit integer, '{}' of type '{}' given",
115 type,
116 applyVisitor(FieldVisitorToString(), end_offset),
117 end_offset.getType());
118 }
119
120 // Check relative positioning of offsets.
121 // UNBOUNDED PRECEDING end and UNBOUNDED FOLLOWING start should have been
122 // forbidden at the parsing level.
123 chassert(!(begin_type == BoundaryType::Unbounded && !begin_preceding));
124 chassert(!(end_type == BoundaryType::Unbounded && end_preceding));
125
126 if (begin_type == BoundaryType::Unbounded
127 || end_type == BoundaryType::Unbounded)
128 {
129 return;
130 }
131
132 if (begin_type == BoundaryType::Current
133 && end_type == BoundaryType::Offset
134 && !end_preceding)
135 {
136 return;
137 }
138
139 if (end_type == BoundaryType::Current
140 && begin_type == BoundaryType::Offset
141 && begin_preceding)
142 {
143 return;
144 }
145
146 if (end_type == BoundaryType::Current
147 && begin_type == BoundaryType::Current)
148 {

Callers 3

WindowStepMethod · 0.80
updateOutputHeaderMethod · 0.80
resolveWindowMethod · 0.80

Calls 7

applyVisitorFunction · 0.85
accurateLessOrEqualFunction · 0.85
ExceptionClass · 0.70
toStringFunction · 0.70
getTypeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected