MCPcopy Create free account
hub / github.com/apache/arrow / GetIntervalDayFromCompletePeriod

Method GetIntervalDayFromCompletePeriod

cpp/src/gandiva/interval_holder.cc:128–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128int64_t IntervalDaysHolder::GetIntervalDayFromCompletePeriod(
129 ExecutionContext* context, std::string& days_in_period, std::string& hours_in_period,
130 std::string& minutes_in_period, std::string& seconds_in_period,
131 int32_t suppress_errors, bool* out_valid) {
132 double qty_days = 0;
133 double qty_hours = 0;
134 double qty_minutes = 0;
135 double qty_seconds = 0;
136
137 if (!days_in_period.empty()) {
138 try {
139 std::replace(days_in_period.begin(), days_in_period.end(), ',', '.');
140 qty_days = std::stod(days_in_period);
141 } catch (...) {
142 std::string cause("Invalid number of days");
143 return_error_with_cause(context, cause, suppress_errors);
144 *out_valid = false;
145 return 0;
146 }
147 }
148
149 if (!hours_in_period.empty()) {
150 try {
151 std::replace(hours_in_period.begin(), hours_in_period.end(), ',', '.');
152 qty_hours = std::stod(hours_in_period);
153 } catch (...) {
154 std::string cause("Invalid number of hours");
155 return_error_with_cause(context, cause, suppress_errors);
156 *out_valid = false;
157 return 0;
158 }
159 }
160
161 if (!minutes_in_period.empty()) {
162 try {
163 std::replace(minutes_in_period.begin(), minutes_in_period.end(), ',', '.');
164 qty_minutes = std::stod(minutes_in_period);
165 } catch (...) {
166 std::string cause("Invalid number of minutes");
167 return_error_with_cause(context, cause, suppress_errors);
168 *out_valid = false;
169 return 0;
170 }
171 }
172
173 if (!seconds_in_period.empty()) {
174 try {
175 std::replace(seconds_in_period.begin(), seconds_in_period.end(), ',', '.');
176 qty_seconds = std::stod(seconds_in_period);
177 } catch (...) {
178 std::string cause("Invalid number of seconds");
179 return_error_with_cause(context, cause, suppress_errors);
180 *out_valid = false;
181 return 0;
182 }
183 }
184
185 auto millis_in_the_period =

Callers

nothing calls this directly

Calls 4

return_error_with_causeFunction · 0.85
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected