OmniSciDB  085a039ca4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TableFunctionsTesting.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2021 OmniSci, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include "../../QueryEngine/TableFunctions/SystemFunctions/os/Shared/TableFunctionsCommon.h"
20 #include "../../QueryEngine/heavydbTypes.h"
21 
22 /*
23  This file contains tesing compile-time UDTFs. The unit-tests are
24  implemented within the RBC package.
25  */
26 
27 #define CPU_DEVICE_CODE 0x637075; // 'cpu' in hex
28 #define GPU_DEVICE_CODE 0x677075; // 'gpu' in hex
29 
30 // clang-format off
31 /*
32  UDTF: ct_device_selection_udtf_any(Cursor<int32_t>, Constant<1>) -> Column<int32_t>
33  UDTF: ct_device_selection_udtf_cpu__cpu_(Cursor<int32_t>, Constant<1>) -> Column<int32_t>
34  UDTF: ct_device_selection_udtf_gpu__gpu_(Cursor<int32_t>, Constant<1>) -> Column<int32_t>
35  UDTF: ct_device_selection_udtf_both__cpu_(Cursor<int32_t>, Constant<1>) -> Column<int32_t>
36  UDTF: ct_device_selection_udtf_both__gpu_(Cursor<int32_t>, Constant<1>) -> Column<int32_t>
37 */
38 // clang-format on
39 
42 #ifdef __CUDACC__
43  out[0] = GPU_DEVICE_CODE;
44 #else
45  out[0] = CPU_DEVICE_CODE;
46 #endif
47  return 1;
48 }
49 
50 #ifndef __CUDACC__
51 
54  Column<int64_t>& out) {
55  out[0] = CPU_DEVICE_CODE;
56  return 1;
57 }
58 
59 #endif // #ifndef __CUDACC__
60 
63  Column<int64_t>& out) {
64  out[0] = GPU_DEVICE_CODE;
65  return 1;
66 }
67 
68 #ifndef __CUDACC__
69 
72  Column<int64_t>& out) {
73  out[0] = CPU_DEVICE_CODE;
74  return 1;
75 }
76 
77 #endif // #ifndef __CUDACC__
78 
81  Column<int64_t>& out) {
82  out[0] = GPU_DEVICE_CODE;
83  return 1;
84 }
85 
86 #undef CPU_DEVICE_CODE
87 #undef GPU_DEVICE_CODE
88 
89 // clang-format off
90 /*
91  Test functions for constant sizer parameter:
92 
93  UDTF: ct_binding_udtf_constant__cpu_1(Cursor<int32_t>, Constant<1>) -> Column<int32_t>
94  UDTF: ct_binding_udtf_constant__cpu_2(Cursor<int32_t, int32_t>, Constant<1>) -> Column<int32_t>
95  UDTF: ct_binding_udtf_constant__cpu_3(Cursor<int32_t, int32_t, int32_t>, Constant<1>) -> Column<int32_t>
96  UDTF: ct_binding_udtf_constant__cpu_4(Cursor<int64_t, int32_t, int32_t>, Constant<1>) -> Column<int32_t>
97  UDTF: ct_binding_udtf_constant__cpu_5(Cursor<int64_t, int64_t, int32_t>, Constant<1>) -> Column<int32_t>
98  UDTF: ct_binding_udtf_constant__cpu_6(Cursor<int64_t, int32_t, int64_t>, Constant<1>) -> Column<int32_t>
99  UDTF: ct_binding_udtf_constant__cpu_7(Cursor<int32_t, ColumnList<int32_t>>, Constant<1>) -> Column<int32_t>
100  UDTF: ct_binding_udtf_constant__cpu_8(Cursor<ColumnList<int32_t>, int64_t>, Constant<1>) -> Column<int32_t>
101  UDTF: ct_binding_udtf_constant__cpu_9(Cursor<ColumnList<int32_t>, ColumnList<int64_t>>, Constant<1>) -> Column<int32_t>
102  UDTF: ct_binding_udtf_constant__cpu_10(Cursor<int64_t, ColumnList<int64_t>, int64_t>, Constant<1>) -> Column<int32_t>
103 
104 
105  Test functions for row multiplier sizer parameter:
106 
107  UDTF: ct_binding_udtf__cpu_11(Cursor<int32_t>, RowMultiplier) -> Column<int32_t>
108  UDTF: ct_binding_udtf__cpu_12(Cursor<int32_t, int32_t>, RowMultiplier) -> Column<int32_t>
109  UDTF: ct_binding_udtf__cpu_13(Cursor<int32_t, int32_t, int32_t>, RowMultiplier) -> Column<int32_t>
110  UDTF: ct_binding_udtf__cpu_14(Cursor<int64_t, int32_t, int32_t>, RowMultiplier) -> Column<int32_t>
111  UDTF: ct_binding_udtf__cpu_15(Cursor<int64_t, int64_t, int32_t>, RowMultiplier) -> Column<int32_t>
112  UDTF: ct_binding_udtf__cpu_16(Cursor<int64_t, int32_t, int64_t>, RowMultiplier) -> Column<int32_t>
113  UDTF: ct_binding_udtf__cpu_17(Cursor<int32_t, ColumnList<int32_t>>, RowMultiplier) -> Column<int32_t>
114  UDTF: ct_binding_udtf__cpu_18(Cursor<ColumnList<int32_t>, int64_t>, RowMultiplier) -> Column<int32_t>
115  UDTF: ct_binding_udtf__cpu_19(Cursor<ColumnList<int32_t>, ColumnList<int64_t>>, RowMultiplier) -> Column<int32_t>
116  UDTF: ct_binding_udtf__cpu_20(Cursor<int64_t, ColumnList<int64_t>, int64_t>, RowMultiplier) -> Column<int32_t>
117 
118  UDTF: ct_binding_udtf2__cpu_21(RowMultiplier, Cursor<int32_t>) -> Column<int32_t>
119  UDTF: ct_binding_udtf6__cpu_22(Cursor<int32_t>, RowMultiplier, int32_t) -> Column<int32_t>
120  UDTF: ct_binding_udtf4__cpu_23(Cursor<ColumnList<int32_t>>, RowMultiplier, int32_t) -> Column<int32_t>
121  UDTF: ct_binding_udtf5__cpu_24(Cursor<ColumnList<int32_t>>, int32_t, RowMultiplier) -> Column<int32_t>
122  UDTF: ct_binding_udtf3__cpu_25(Cursor<Column<int32_t>>, int32_t, RowMultiplier) -> Column<int32_t>
123 */
124 // clang-format on
125 
126 #ifndef __CUDACC__
127 
130  out[0] = 1;
131  return 1;
132 }
135  const Column<int32_t>& input2,
136  Column<int32_t>& out) {
137  out[0] = 11;
138  return 1;
139 }
142  const Column<int32_t>& input2,
143  const Column<int32_t>& input3,
144  Column<int32_t>& out) {
145  out[0] = 111;
146  return 1;
147 }
150  const Column<int32_t>& input2,
151  const Column<int32_t>& input3,
152  Column<int32_t>& out) {
153  out[0] = 211;
154  return 1;
155 }
158  const Column<int64_t>& input2,
159  const Column<int32_t>& input3,
160  Column<int32_t>& out) {
161  out[0] = 221;
162  return 1;
163 }
166  const Column<int32_t>& input2,
167  const Column<int64_t>& input3,
168  Column<int32_t>& out) {
169  out[0] = 212;
170  return 1;
171 }
174  const ColumnList<int32_t>& input2,
175  Column<int32_t>& out) {
176  out[0] = 13;
177  return 1;
178 }
181  const Column<int64_t>& input2,
182  Column<int32_t>& out) {
183  out[0] = 32;
184  return 1;
185 }
188  const ColumnList<int64_t>& input2,
189  Column<int32_t>& out) {
190  out[0] = 34;
191  return 1;
192 }
195  const ColumnList<int64_t>& input2,
196  const Column<int64_t>& input3,
197  Column<int64_t>& out) {
198  out[0] = 242;
199  return 1;
200 }
201 
203  const int32_t multiplier,
204  Column<int32_t>& out) {
205  out[0] = 1000 + 19 + multiplier;
206  return 1;
207 }
209  const Column<int32_t>& input2,
210  const int32_t multiplier,
211  Column<int32_t>& out) {
212  out[0] = 1000 + 119 + multiplier;
213  return 1;
214 }
216  const Column<int32_t>& input2,
217  const Column<int32_t>& input3,
218  const int32_t multiplier,
219  Column<int32_t>& out) {
220  out[0] = 1000 + 1119 + multiplier;
221  return 1;
222 }
224  const Column<int32_t>& input2,
225  const Column<int32_t>& input3,
226  const int32_t multiplier,
227  Column<int32_t>& out) {
228  out[0] = 1000 + 2119 + multiplier;
229  return 1;
230 }
232  const Column<int64_t>& input2,
233  const Column<int32_t>& input3,
234  const int32_t multiplier,
235  Column<int32_t>& out) {
236  out[0] = 1000 + 2219 + multiplier;
237  return 1;
238 }
240  const Column<int32_t>& input2,
241  const Column<int64_t>& input3,
242  const int32_t multiplier,
243  Column<int32_t>& out) {
244  out[0] = 1000 + 2129 + multiplier;
245  return 1;
246 }
248  const ColumnList<int32_t>& input2,
249  const int32_t multiplier,
250  Column<int32_t>& out) {
251  out[0] = 1000 + 139 + multiplier;
252  return 1;
253 }
255  const Column<int64_t>& input2,
256  const int32_t multiplier,
257  Column<int32_t>& out) {
258  out[0] = 1000 + 329 + multiplier;
259  return 1;
260 }
262  const ColumnList<int64_t>& input2,
263  const int32_t multiplier,
264  Column<int32_t>& out) {
265  out[0] = 1000 + 349 + multiplier;
266  return 1;
267 }
269  const ColumnList<int64_t>& input2,
270  const Column<int64_t>& input3,
271  const int32_t multiplier,
272  Column<int64_t>& out) {
273  out[0] = 1000 + 2429 + multiplier;
274  return 1;
275 }
276 
277 EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf2__cpu_21(const int32_t multiplier,
278  const Column<int32_t>& input1,
279  Column<int32_t>& out) {
280  out[0] = 1000 + 91 + multiplier;
281  return 1;
282 }
284  const int32_t multiplier,
285  const int32_t input2,
286  Column<int32_t>& out) {
287  out[0] = 1000 + 196 + multiplier + 10 * input2;
288  return 1;
289 }
292  const int32_t multiplier,
293  const int32_t input2,
294  Column<int32_t>& out) {
295  out[0] = 1000 + 396 + multiplier + 10 * input2;
296  return 1;
297 }
300  const int32_t input2,
301  const int32_t multiplier,
302  Column<int32_t>& out) {
303  out[0] = 1000 + 369 + multiplier + 10 * input2;
304  return 1;
305 }
307  const int32_t input2,
308  const int32_t multiplier,
309  Column<int32_t>& out) {
310  out[0] = 1000 + 169 + multiplier + 10 * input2;
311  return 1;
312 }
313 
314 #endif // #ifndef __CUDACC__
315 
316 /*
317  Test functions for default sizer parameter:
318 */
319 
320 // clang-format off
321 /*
322  UDTF: ct_udtf_default_sizer1a__cpu_1(Cursor<int32_t>, RowMultiplier) -> Column<int32_t>
323  UDTF: ct_udtf_default_sizer1b__cpu_2(Cursor<int32_t>, Cursor<int32_t>, RowMultiplier) -> Column<int32_t>
324  UDTF: ct_udtf_default_sizer1c__cpu_3(Cursor<int32_t, int32_t, int32_t>, RowMultiplier, Cursor<int32_t>, int32_t) -> Column<int32_t>
325  UDTF: ct_udtf_default_sizer1d__cpu_4(RowMultiplier, int32_t, Cursor<int32_t>) -> Column<int32_t>
326  UDTF: ct_udtf_default_sizer2a__cpu_1(Cursor<int32_t>, int32_t, RowMultiplier) -> Column<int32_t>
327  UDTF: ct_udtf_default_sizer2b__cpu_2(Cursor<int32_t>, RowMultiplier, Cursor<int32_t>) -> Column<int32_t>
328  UDTF: ct_udtf_default_sizer2c__cpu_3(int32_t, RowMultiplier, Cursor<int32_t>) -> Column<int32_t>
329  UDTF: ct_udtf_default_sizer3a__cpu_1(Cursor<int32_t>, RowMultiplier, int32_t) -> Column<int32_t>
330  UDTF: ct_udtf_default_sizer3b__cpu_2(Cursor<int32_t>, int32_t, Cursor<int32_t>, RowMultiplier) -> Column<int32_t>
331  UDTF: ct_udtf_default_sizer4a__cpu_1(Cursor<int32_t>, RowMultiplier, Cursor<int32_t>, int32_t) -> Column<int32_t>
332  UDTF: ct_udtf_default_sizer4b__cpu_2(RowMultiplier, Cursor<int32_t>, int32_t) -> Column<int32_t>
333 */
334 // clang-format on
335 
336 #ifndef __CUDACC__
337 
340  const int32_t multiplier,
341  Column<int32_t>& out) {
342  out[0] = 1000 + 1 + 10 * multiplier;
343  return 1;
344 }
347  const Column<int32_t>& input2,
348  const int32_t multiplier,
349  Column<int32_t>& out) {
350  out[0] = 1000 + 2 + 11 * multiplier;
351  return 1;
352 }
355  const Column<int32_t>& input2,
356  const Column<int32_t>& input3,
357  const int32_t multiplier,
358  const Column<int32_t>& input4,
359  const int32_t x,
360  Column<int32_t>& out) {
361  out[0] = 1000 + 101 + 10 * multiplier + x;
362  return 1;
363 }
365 ct_udtf_default_sizer1d__cpu_4(const int32_t multiplier,
366  const int32_t x,
367  const Column<int32_t>& input1,
368  Column<int32_t>& out) {
369  out[0] = 1000 + 99 + 10 * multiplier + x;
370  return 1;
371 }
374  const int32_t x,
375  const int32_t multiplier,
376  Column<int32_t>& out) {
377  out[0] = 1000 + 98 + multiplier + 10 * x;
378  return 1;
379 }
382  const int32_t multiplier,
383  const Column<int32_t>& input2,
384  Column<int32_t>& out) {
385  out[0] = 1000 + 2 + multiplier;
386  return 1;
387 }
390  const int32_t multiplier,
391  const Column<int32_t>& input1,
392  Column<int32_t>& out) {
393  out[0] = 1000 + 99 + multiplier + 11 * x;
394  return 1;
395 }
398  const int32_t multiplier,
399  const int32_t x,
400  Column<int32_t>& out) {
401  out[0] = 1000 + 98 + 100 * multiplier + x;
402  return 1;
403 }
406  const int32_t x,
407  const Column<int32_t>& input2,
408  const int32_t multiplier,
409  Column<int32_t>& out) {
410  out[0] = 1000 + 99 + 100 * multiplier + x;
411  return 1;
412 }
415  const int32_t multiplier,
416  const Column<int32_t>& input2,
417  const int32_t x,
418  Column<int32_t>& out) {
419  out[0] = 1000 + 99 + 10 * multiplier + x;
420  return 1;
421 }
423 ct_udtf_default_sizer4b__cpu_2(const int32_t multiplier,
424  const Column<int32_t>& input,
425  const int32_t x,
426  Column<int32_t>& out) {
427  out[0] = 1000 + 99 + 9 * multiplier + x;
428  return 1;
429 }
430 
431 #endif // #ifndef __CUDACC__
432 
433 // clang-format off
434 /*
435  UDTF: ct_binding_dict_encoded1__cpu_1(Cursor<TextEncodingDict>, RowMultiplier) -> Column<TextEncodingDict> | input_id=args<0>
436  UDTF: ct_binding_dict_encoded2__cpu_1(Cursor<TextEncodingDict, TextEncodingDict>) -> Column<TextEncodingDict> | input_id=args<0, 0>, Column<TextEncodingDict> | input_id=args<0, 1>
437  UDTF: ct_binding_dict_encoded3__cpu_1(Cursor<TextEncodingDict, TextEncodingDict>) -> Column<TextEncodingDict> | input_id=args<0, 1>, Column<TextEncodingDict> | input_id=args<0, 0>
438  UDTF: ct_binding_dict_encoded4__cpu_1(Cursor<ColumnList<TextEncodingDict>>) -> Column<TextEncodingDict> | input_id=args<0,0>
439  UDTF: ct_binding_dict_encoded5__cpu_1(Cursor<ColumnList<TextEncodingDict>>) -> Column<TextEncodingDict> | input_id=args<0,1>
440  UDTF: ct_binding_dict_encoded6__cpu_1(Cursor<ColumnList<TextEncodingDict>>) -> Column<TextEncodingDict> | input_id=args<0,0>, Column<TextEncodingDict> | input_id=args<0,1>
441 */
442 // clang-format on
443 
444 #ifndef __CUDACC__
445 
448  const int32_t multiplier,
450  for (int64_t i = 0; i < input.size(); i++) {
451  out[i] = input[i]; // assign string id
452  }
453  return multiplier * input.size();
454 }
455 
458  const Column<TextEncodingDict>& input2,
460  Column<TextEncodingDict>& out2) {
461  set_output_row_size(input1.size());
462  for (int64_t i = 0; i < input1.size(); i++) {
463  out1[i] = input1[i];
464  out2[i] = input2[i];
465  }
466  return input1.size();
467 }
468 
471  const Column<TextEncodingDict>& input2,
473  Column<TextEncodingDict>& out2) {
474  set_output_row_size(input1.size());
475  for (int64_t i = 0; i < input1.size(); i++) {
476  out1[i] = input2[i];
477  out2[i] = input1[i];
478  }
479  return input1.size();
480 }
481 
485  int64_t sz = input[0].size();
487  for (int64_t i = 0; i < sz; i++) {
488  out[i] = input[0][i];
489  }
490  return sz;
491 }
492 
496  int64_t sz = input[1].size();
498  for (int64_t i = 0; i < sz; i++) {
499  out[i] = input[1][i];
500  }
501  return sz;
502 }
503 
507  Column<TextEncodingDict>& out1) {
508  int64_t sz = input[0].size();
510  for (int64_t i = 0; i < sz; i++) {
511  out0[i] = input[0][i];
512  out1[i] = input[1][i];
513  }
514  return sz;
515 }
516 
517 #endif // #ifndef __CUDACC__
518 
519 // clang-format off
520 /*
521  UDTF: ct_binding_template__cpu_template(Cursor<TextEncodingDict>) -> Column<TextEncodingDict> | input_id=args<0>
522  UDTF: ct_binding_template__cpu_template(Cursor<int>) -> Column<int>
523  UDTF: ct_binding_template__cpu_template(Cursor<float>) -> Column<float>
524 */
525 // clang-format on
526 
527 #ifndef __CUDACC__
528 
529 template <typename T>
531  Column<T>& out) {
532  set_output_row_size(input.size());
533  for (int64_t i = 0; i < input.size(); i++) {
534  out[i] = input[i];
535  }
536  return input.size();
537 }
538 
539 #endif // #ifndef __CUDACC__
540 
541 // clang-format off
542 /*
543  UDTF: ct_binding_columnlist__cpu_template(Cursor<int32_t, ColumnList<int32_t>>) -> Column<int32_t>
544  UDTF: ct_binding_columnlist__cpu_template(Cursor<float, ColumnList<float>>) -> Column<int32_t>
545  UDTF: ct_binding_columnlist__cpu_template(Cursor<TextEncodingDict, ColumnList<TextEncodingDict>>) -> Column<int32_t>
546  UDTF: ct_binding_columnlist__cpu_template(Cursor<int16_t, ColumnList<int16_t>>) -> Column<int32_t>
547 */
548 // clang-format on
549 
550 #ifndef __CUDACC__
551 
552 template <typename T>
554  const ColumnList<T>& input2,
555  Column<int32_t>& out) {
557  if constexpr (std::is_same<T, int32_t>::value) {
558  out[0] = 1;
559  } else if constexpr (std::is_same<T, float>::value) {
560  out[0] = 2;
561  } else if constexpr (std::is_same<T, TextEncodingDict>::value) {
562  out[0] = 3;
563  } else {
564  out[0] = 4;
565  }
566  return 1;
567 }
568 
569 #endif // #ifndef __CUDACC__
570 
571 // clang-format off
572 /*
573  UDTF: ct_binding_column__cpu_template(Column<int32_t>) -> Column<int32_t>
574  UDTF: ct_binding_column__cpu_template(Column<float>) -> Column<int32_t>
575 */
576 // clang-format on
577 
578 #ifndef __CUDACC__
579 
580 template <typename T>
582  Column<int32_t>& out) {
584  if constexpr (std::is_same<T, int32_t>::value) {
585  out[0] = 10;
586  } else {
587  out[0] = 20;
588  }
589  return 1;
590 }
591 
592 #endif // #ifndef __CUDACC__
593 
594 // clang-format off
595 /*
596  UDTF: ct_binding_scalar_multiply__cpu_template(Cursor<Column<float>>, float) -> Column<float>
597  UDTF: ct_binding_scalar_multiply__cpu_template(Cursor<Column<double>>, double) -> Column<double>
598  UDTF: ct_binding_scalar_multiply__cpu_template(Cursor<Column<int32_t>>, int32_t) -> Column<int32_t>
599  UDTF: ct_binding_scalar_multiply__cpu_template(Cursor<Column<int64_t>>, int64_t) -> Column<int64_t>
600 */
601 // clang-format on
602 
603 #ifndef __CUDACC__
604 
605 template <typename T>
607  const T multiplier,
608  Column<T>& out) {
609  const int64_t num_rows = input.size();
610  set_output_row_size(num_rows);
611  for (int64_t r = 0; r < num_rows; ++r) {
612  if (!input.isNull(r)) {
613  out[r] = input[r] * multiplier;
614  } else {
615  out.setNull(r);
616  }
617  }
618  return num_rows;
619 }
620 
621 // clang-format off
622 /*
623  UDTF: ct_binding_str_length__cpu_(Cursor<TextEncodingDict>) -> Column<TextEncodingDict> string | input_id=args<0>, Column<int64_t> string_length
624 */
625 // clang-format on
628  Column<TextEncodingDict>& out_str,
629  Column<int64_t>& out_size) {
630  const int64_t num_rows = input_str.size();
631  set_output_row_size(num_rows);
632  for (int64_t i = 0; i < num_rows; i++) {
633  out_str[i] = input_str[i];
634  const std::string str = input_str.getString(i);
635  out_size[i] = str.size();
636  }
637  return num_rows;
638 }
639 
640 // clang-format off
641 /*
642  UDTF: ct_binding_str_equals__cpu_(Cursor<ColumnList<TextEncodingDict>>) -> Column<TextEncodingDict> string_if_equal | input_id=args<0, 0>, Column<bool> strings_are_equal
643 */
644 // clang-format on
647  Column<TextEncodingDict>& string_if_equal,
648  Column<bool>& strings_are_equal) {
649  const int64_t num_rows = input_strings.size();
650  const int64_t num_cols = input_strings.numCols();
651  set_output_row_size(num_rows);
652  for (int64_t r = 0; r < num_rows; r++) {
653  bool are_equal = true;
654  if (num_cols > 0) {
655  std::string first_str = input_strings[0].getString(r);
656  for (int64_t c = 1; c != num_cols; ++c) {
657  if (input_strings[c].getString(r) != first_str) {
658  are_equal = false;
659  break;
660  }
661  }
662  strings_are_equal[r] = are_equal;
663  if (are_equal && num_cols > 0) {
664  string_if_equal[r] = input_strings[0][r];
665  } else {
666  string_if_equal.setNull(r);
667  }
668  }
669  }
670  return num_rows;
671 }
672 
673 // clang-format off
674 /*
675  UDTF: ct_substr__cpu_(TableFunctionManager, Cursor<Column<TextEncodingDict> str, Column<int> pos, Column<int> len>) -> Column<TextEncodingDict> substr | input_id=args<0>
676 */
677 // clang-format on
678 
681  const Column<TextEncodingDict>& input_str,
682  const Column<int>& pos,
683  const Column<int>& len,
684  Column<TextEncodingDict>& output_substr) {
685  const int64_t num_rows = input_str.size();
686  mgr.set_output_row_size(num_rows);
687  for (int64_t row_idx = 0; row_idx < num_rows; row_idx++) {
688  const std::string input_string{input_str.getString(row_idx)};
689  const std::string substring = input_string.substr(pos[row_idx], len[row_idx]);
690  const TextEncodingDict substr_id = output_substr.getStringId(substring);
691  output_substr[row_idx] = substr_id;
692  }
693  return num_rows;
694 }
695 
696 // clang-format off
697 /*
698  UDTF: ct_string_concat__cpu_(TableFunctionManager, Cursor<ColumnList<TextEncodingDict>>, TextEncodingNone separator) -> Column<TextEncodingDict> concatted_str | input_id=args<0, 0>
699 */
700 // clang-format on
703  const ColumnList<TextEncodingDict>& input_strings,
705  Column<TextEncodingDict>& concatted_string) {
706  const int64_t num_rows = input_strings.size();
707  const int64_t num_cols = input_strings.numCols();
708  const std::string separator_str{separator.getString()};
709  mgr.set_output_row_size(num_rows);
710  for (int64_t row_idx = 0; row_idx < num_rows; row_idx++) {
711  if (num_cols > 0) {
712  std::string concatted_output{input_strings[0].getString(row_idx)};
713  for (int64_t col_idx = 1; col_idx < num_cols; ++col_idx) {
714  concatted_output += separator_str;
715  concatted_output += input_strings[col_idx].getString(row_idx);
716  }
717  const TextEncodingDict concatted_str_id =
718  concatted_string.getStringId(concatted_output);
719  concatted_string[row_idx] = concatted_str_id;
720  } else {
721  concatted_string.setNull(row_idx);
722  }
723  }
724  return num_rows;
725 }
726 
727 // clang-format off
728 /*
729  UDTF: ct_synthesize_new_dict__cpu_(TableFunctionManager, int32_t num_strings) -> Column<TextEncodingDict> new_dict_col | input_id=args<0>
730 */
731 // clang-format on
734  const int64_t num_strings,
735  Column<TextEncodingDict>& new_dict_col) {
736  mgr.set_output_row_size(num_strings);
737  for (int32_t s = 0; s < num_strings; ++s) {
738  const std::string new_string = "String_" + std::to_string(s);
739  const int32_t string_id = new_dict_col.getStringId(new_string);
740  new_dict_col[s] = string_id;
741  }
742  return num_strings;
743 }
744 
745 #endif // #ifndef __CUDACC__
746 
747 #ifndef __CUDACC__
748 
749 #include <algorithm>
750 
751 template <typename T>
752 struct SortAsc {
753  SortAsc(const bool nulls_last)
754  : null_value_(std::numeric_limits<T>::lowest())
755  , null_value_mapped_(map_null_value(nulls_last)) {}
756  static T map_null_value(const bool nulls_last) {
757  return nulls_last ? std::numeric_limits<T>::max() : std::numeric_limits<T>::lowest();
758  }
759  inline T mapValue(const T& val) {
760  return val == null_value_ ? null_value_mapped_ : val;
761  }
762  bool operator()(const T& a, const T& b) { return mapValue(a) < mapValue(b); }
763  const T null_value_;
765 };
766 
767 template <typename T>
768 struct SortDesc {
769  SortDesc(const bool nulls_last)
770  : null_value_(std::numeric_limits<T>::lowest())
771  , null_value_mapped_(map_null_value(nulls_last)) {}
772  static T map_null_value(const bool nulls_last) {
773  return nulls_last ? std::numeric_limits<T>::lowest() : std::numeric_limits<T>::max();
774  }
775 
776  inline T mapValue(const T& val) {
777  return val == null_value_ ? null_value_mapped_ : val;
778  }
779 
780  bool operator()(const T& a, const T& b) { return mapValue(a) > mapValue(b); }
781  const T null_value_;
783 };
784 
785 // clang-format off
786 /*
787  UDTF: sort_column_limit__cpu_template(Cursor<Column<int8_t>>, int32_t, bool, bool) -> Column<int8_t>
788  UDTF: sort_column_limit__cpu_template(Cursor<Column<int16_t>>, int32_t, bool, bool) -> Column<int16_t>
789  UDTF: sort_column_limit__cpu_template(Cursor<Column<int32_t>>, int32_t, bool, bool) -> Column<int32_t>
790  UDTF: sort_column_limit__cpu_template(Cursor<Column<int64_t>>, int32_t, bool, bool) -> Column<int64_t>
791  UDTF: sort_column_limit__cpu_template(Cursor<Column<float>>, int32_t, bool, bool) -> Column<float>
792  UDTF: sort_column_limit__cpu_template(Cursor<Column<double>>, int32_t, bool, bool) -> Column<double>
793 */
794 // clang-format on
795 
796 template <typename T>
798  const int32_t limit,
799  const bool sort_ascending,
800  const bool nulls_last,
801  Column<T>& output) {
802  const int64_t num_rows = input.size();
803  set_output_row_size(num_rows);
804  output = input;
805  if (sort_ascending) {
806  std::sort(output.ptr_, output.ptr_ + num_rows, SortAsc<T>(nulls_last));
807  } else {
808  std::sort(output.ptr_, output.ptr_ + num_rows, SortDesc<T>(nulls_last));
809  }
810  if (limit < 0 || limit > num_rows) {
811  return num_rows;
812  }
813  return limit;
814 }
815 
816 #endif
817 
818 // clang-format off
819 /*
820  UDTF: ct_binding_column2__cpu_template(Column<T>, Column<U>) -> Column<K>, T=[int32_t, double], U=[int32_t, double], K=[int32_t]
821  UDTF: ct_binding_column2__cpu_template(Column<T>, Column<T>) -> Column<T> | input_id=args<0>, T=[TextEncodingDict]
822 */
823 // clang-format on
824 
825 #ifndef __CUDACC__
826 
827 template <typename T, typename U, typename K>
829  const Column<U>& input2,
830  Column<K>& out) {
831  if constexpr (std::is_same<T, TextEncodingDict>::value &&
832  std::is_same<U, TextEncodingDict>::value) {
833  set_output_row_size(input1.size());
834  for (int64_t i = 0; i < input1.size(); i++) {
835  out[i] = input1[i];
836  }
837  return input1.size();
838  }
839 
841  if constexpr (std::is_same<T, int32_t>::value && std::is_same<U, double>::value) {
842  out[0] = 10;
843  } else if constexpr (std::is_same<T, double>::value && std::is_same<U, double>::value) {
844  out[0] = 20;
845  } else if constexpr (std::is_same<T, int32_t>::value &&
846  std::is_same<U, int32_t>::value) {
847  out[0] = 30;
848  } else if constexpr (std::is_same<T, double>::value &&
849  std::is_same<U, int32_t>::value) {
850  out[0] = 40;
851  }
852  return 1;
853 }
854 
855 #endif // #ifndef __CUDACC__
856 
857 // clang-format off
858 /*
859  UDTF: ct_named_output__cpu_template(Column<T> input) -> Column<T> total, T=[int32_t, double]
860  UDTF: ct_named_const_output__cpu_template(Column<T> input, Constant<2>) -> Column<T> total, T=[int32_t, double]
861  UDTF: ct_named_user_const_output__cpu_template(Column<T> input, ConstantParameter c) -> Column<T> total, T=[int32_t, double]
862  UDTF: ct_named_rowmul_output__cpu_template(Column<T> input, RowMultiplier m) -> Column<T> total, T=[int32_t, double]
863 */
864 // clang-format on
865 
866 #ifndef __CUDACC__
867 
868 template <typename T>
870  Column<T>& out) {
872  T acc = 0;
873  for (int64_t i = 0; i < input.size(); i++) {
874  acc += input[i];
875  }
876  out[0] = acc;
877  return 1;
878 }
879 
880 template <typename T>
882  Column<T>& out) {
883  T acc1 = 0, acc2 = 0;
884  for (int64_t i = 0; i < input.size(); i++) {
885  if (i % 2 == 0) {
886  acc1 += input[i];
887  } else {
888  acc2 += input[i];
889  }
890  }
891  out[0] = acc1;
892  out[1] = acc2;
893  return 2;
894 }
895 
896 template <typename T>
898  int32_t c,
899  Column<T>& out) {
900  for (int64_t i = 0; i < c; i++) {
901  out[i] = 0;
902  }
903  for (int64_t i = 0; i < input.size(); i++) {
904  out[i % c] += input[i];
905  }
906  return c;
907 }
908 
909 template <typename T>
911  int32_t m,
912  Column<T>& out) {
913  for (int64_t j = 0; j < m; j++) {
914  for (int64_t i = 0; i < input.size(); i++) {
915  out[j * input.size() + i] += input[i];
916  }
917  }
918  return m * input.size();
919 }
920 
921 #endif // #ifndef __CUDACC__
922 
923 // clang-format off
924 /*
925  UDTF: ct_no_arg_runtime_sizing__cpu_template() -> Column<T> answer, T=[int32_t]
926 */
927 // clang-format on
928 
929 #ifndef __CUDACC__
930 
931 template <typename T>
934  answer[0] = 42;
935  return 1;
936 }
937 
938 #endif // #ifndef __CUDACC__
939 
940 // clang-format off
941 /*
942  UDTF: ct_no_arg_constant_sizing(Constant<42>) -> Column<int32_t> answer
943 */
944 // clang-format on
945 
947 #ifdef __CUDACC__
948  int32_t start = threadIdx.x + blockDim.x * blockIdx.x;
949  int32_t stop = static_cast<int32_t>(42);
950  int32_t step = blockDim.x * gridDim.x;
951 #else
952  auto start = 0;
953  auto stop = 42;
954  auto step = 1;
955 #endif
956  for (auto i = start; i < stop; i += step) {
957  answer[i] = 42 * i;
958  }
959  return 42;
960 }
961 
962 // clang-format off
963 /*
964  UDTF: ct_scalar_1_arg_runtime_sizing__cpu_template(T num) -> Column<T> answer, T=[float, double, int32_t, int64_t]
965 */
966 // clang-format on
967 
968 #ifndef __CUDACC__
969 
970 template <typename T>
971 NEVER_INLINE HOST int32_t
973  T quotient = num;
975  int32_t counter{0};
976  while (quotient >= 1) {
977  answer[counter++] = quotient;
978  quotient /= 10;
979  }
980  return counter;
981 }
982 
983 #endif // #ifndef __CUDACC__
984 
985 // clang-format off
986 /*
987  UDTF: ct_scalar_2_args_constant_sizing(int64_t, int64_t, Constant<5>) -> Column<int64_t> answer1, Column<int64_t> answer2
988 */
989 // clang-format on
990 
992  const int64_t num2,
993  Column<int64_t>& answer1,
994  Column<int64_t>& answer2) {
995 #ifdef __CUDACC__
996  int32_t start = threadIdx.x + blockDim.x * blockIdx.x;
997  int32_t stop = static_cast<int32_t>(5);
998  int32_t step = blockDim.x * gridDim.x;
999 #else
1000  auto start = 0;
1001  auto stop = 5;
1002  auto step = 1;
1003 #endif
1004  for (auto i = start; i < stop; i += step) {
1005  answer1[i] = num1 + i * num2;
1006  answer2[i] = num1 - i * num2;
1007  }
1008  return 5;
1009 }
1010 
1011 // clang-format off
1012 /*
1013  UDTF: ct_no_cursor_user_constant_sizer__cpu_(int32_t, ConstantParameter c) -> Column<int32_t> output
1014 */
1015 // clang-format on
1016 
1017 #ifndef __CUDACC__
1018 
1021  int32_t c,
1022  Column<int32_t>& output) {
1023  for (int32_t i = 0; i < c; i++) {
1024  output[i] = input_num;
1025  }
1026  return c;
1027 }
1028 
1029 #endif // #ifndef __CUDACC__
1030 
1031 // clang-format off
1032 /*
1033  UDTF: ct_templated_no_cursor_user_constant_sizer__cpu_template(T, ConstantParameter c) -> Column<T> output, T=[int32_t, float]
1034 */
1035 // clang-format on
1036 
1037 #ifndef __CUDACC__
1038 
1039 template <typename T>
1040 NEVER_INLINE HOST int32_t
1042  int32_t c,
1043  Column<T>& output) {
1044  for (int32_t i = 0; i < c; i++) {
1045  output[i] = input_num;
1046  }
1047  return c;
1048 }
1049 
1050 #endif // #ifndef __CUDACC__
1051 
1052 #ifdef __CUDACC__
1053 
1054 // clang-format off
1055 /*
1056  UDTF: ct_no_cursor_user_constant_sizer__gpu_(int32_t, ConstantParameter c) -> Column<int32_t> output
1057 */
1058 // clang-format on
1059 
1060 EXTENSION_NOINLINE int32_t
1061 ct_no_cursor_user_constant_sizer__gpu_(const int32_t input_num,
1062  int32_t c,
1063  Column<int32_t>& output) {
1064  int32_t start = threadIdx.x + blockDim.x * blockIdx.x;
1065  int32_t step = blockDim.x * gridDim.x;
1066 
1067  for (int32_t i = start; i < c; i += step) {
1068  output[i] = input_num;
1069  }
1070  return c;
1071 }
1072 
1073 // clang-format off
1074 /*
1075  UDTF: ct_templated_no_cursor_user_constant_sizer__gpu_template(T, ConstantParameter c) -> Column<T> output, T=[int32_t, float]
1076 */
1077 // clang-format on
1078 
1079 template <typename T>
1080 TEMPLATE_NOINLINE int32_t
1081 ct_templated_no_cursor_user_constant_sizer__gpu_template(const T input_num,
1082  int32_t c,
1083  Column<T>& output) {
1084  int32_t start = threadIdx.x + blockDim.x * blockIdx.x;
1085  int32_t step = blockDim.x * gridDim.x;
1086 
1087  for (int32_t i = start; i < c; i += step) {
1088  output[i] = input_num;
1089  }
1090  return c;
1091 }
1092 
1093 #endif //__CUDACC__
1094 
1095 template <typename T>
1097  if (x >= 0) {
1098  if (y > (std::numeric_limits<T>::max() - x)) {
1099  throw std::overflow_error("Addition overflow detected");
1100  }
1101  } else {
1102  if (y < (std::numeric_limits<T>::min() - x)) {
1103  throw std::underflow_error("Addition underflow detected");
1104  }
1105  }
1106  return x + y;
1107 }
1108 
1109 // clang-format off
1110 /*
1111  UDTF: column_list_safe_row_sum__cpu_template(Cursor<ColumnList<T>>) -> Column<T>, T=[int32_t, int64_t, float, double]
1112 */
1113 // clang-format on
1114 
1115 #ifndef __CUDACC__
1116 
1117 template <typename T>
1118 NEVER_INLINE HOST int32_t
1120  int32_t output_num_rows = input.numCols();
1121  set_output_row_size(output_num_rows);
1122  for (int i = 0; i < output_num_rows; i++) {
1123  auto col = input[i];
1124  T s = 0;
1125  for (int j = 0; j < col.size(); j++) {
1126  try {
1127  s = safe_addition(s, col[j]);
1128  } catch (const std::exception& e) {
1129  return TABLE_FUNCTION_ERROR(e.what());
1130  } catch (...) {
1131  return TABLE_FUNCTION_ERROR("Unknown error");
1132  }
1133  }
1134  out[i] = s;
1135  }
1136  return output_num_rows;
1137 }
1138 
1139 #endif // #ifndef __CUDACC__
1140 
1141 // clang-format off
1142 /*
1143  UDTF: ct_gpu_default_init__gpu_(Constant<1>) -> Column<int32_t> output_buffer
1144 */
1145 // clang-format on
1146 
1148  // output_buffer[0] should always be 0 due to default initialization for GPU
1149  return 1;
1150 }
1151 
1152 // clang-format off
1153 /*
1154  UDTF: ct_hamming_distance(TextEncodingNone, TextEncodingNone, Constant<1>) -> Column<int32_t> hamming_distance
1155 */
1156 // clang-format on
1157 
1159  const TextEncodingNone& str2,
1160  Column<int32_t>& hamming_distance) {
1161  const int32_t str_len = str1.size() <= str2.size() ? str1.size() : str2.size();
1162 
1163 #ifdef __CUDACC__
1164  const int32_t start = threadIdx.x + blockDim.x * blockIdx.x;
1165  const int32_t step = blockDim.x * gridDim.x;
1166  int32_t* output_ptr = hamming_distance.ptr_;
1167 #else
1168  const int32_t start = 0;
1169  const int32_t step = 1;
1170 #endif
1171 
1172  int32_t num_chars_unequal = 0;
1173  for (int32_t i = start; i < str_len; i += step) {
1174  num_chars_unequal += (str1[i] != str2[i]) ? 1 : 0;
1175  }
1176 #ifdef __CUDACC__
1177  atomicAdd(output_ptr, num_chars_unequal);
1178 #else
1179  hamming_distance[0] = num_chars_unequal;
1180 #endif
1181  return 1;
1182 }
1183 
1184 // clang-format off
1185 /*
1186  UDTF: ct_get_string_chars__template(Column<T>, TextEncodingNone, RowMultiplier) -> Column<int32_t> idx, Column<int8_t> char_bytes, T=[int16_t, int32_t]
1187 */
1188 // clang-format on
1189 template <typename T>
1191  const TextEncodingNone& str,
1192  const int32_t multiplier,
1193  Column<int32_t>& idx,
1194  Column<int8_t>& char_bytes) {
1195  const int32_t str_len = str.size();
1196  // Note: we assume RowMultiplier is 1 for this test, was to make running on
1197  // GPU easy Todo: Provide Constant RowMultiplier interface
1198  if (multiplier != 1) {
1199  return 0;
1200  }
1201  const int32_t num_input_rows = indices.size();
1202  const int32_t num_output_rows = num_input_rows * multiplier;
1203 
1204 #ifdef __CUDACC__
1205  const int32_t start = threadIdx.x + blockDim.x * blockIdx.x;
1206  const int32_t step = blockDim.x * gridDim.x;
1207 #else
1208  const int32_t start = 0;
1209  const int32_t step = 1;
1210 #endif
1211 
1212  for (int32_t i = start; i < num_output_rows; i += step) {
1213  idx[i] = indices[i % num_output_rows];
1214  char_bytes[i] = str[i % str_len]; // index < str_len ? str[i] : 0;
1215  }
1216  return num_output_rows;
1217 }
1218 
1219 #ifndef __CUDACC__
1220 
1221 #include <iostream>
1222 #include <string>
1223 
1224 // clang-format off
1225 /*
1226  UDTF: ct_string_to_chars__cpu_(TextEncodingNone) -> Column<int32_t> char_idx, Column<int8_t> char_bytes
1227 */
1228 // clang-format on
1229 
1231  Column<int32_t>& char_idx,
1232  Column<int8_t>& char_bytes) {
1233  const std::string str{input.getString()};
1234  const int64_t str_size(str.size());
1235  set_output_row_size(str_size);
1236  for (int32_t i = 0; i < str_size; ++i) {
1237  char_idx[i] = i;
1238  char_bytes[i] = str[i];
1239  }
1240  return str_size;
1241 }
1242 
1243 // clang-format off
1244 /*
1245  The purpose of ct_sleep1 and ct_sleep2 is to test parallel execution
1246  of UDTFs (use --num-executors=..). For instance, ct_sleep1 output
1247  column buffers are managed by a global manager, hence, ct_sleep1 can
1248  be run only sequentially. However, ct_sleep2 output column buffers
1249  are managed with a thread-safe manager instance, hence, ct_sleep2
1250  can be run in parallel.
1251 
1252  UDTF: ct_sleep1__cpu_(int32_t seconds, int32_t mode) -> Column<int32_t> output
1253  UDTF: ct_sleep2(TableFunctionManager, int32_t seconds, int32_t mode) -> Column<int32_t> output
1254 
1255  Here mode argument is used to test various approaches of accessing
1256  the table function manager:
1257 
1258  - mode == 0
1259  ct_sleep1 uses global set_output_row_size function
1260  ct_sleep2 uses thread-safe set_output_row_size method
1261 
1262  - mode == 1
1263  ct_sleep1 retrieves global singleton manager and uses its set_output_row_size method
1264  ct_sleep2 same as in mode == 1
1265 
1266  - mode == 2
1267  ct_sleep1 does not call set_output_row_size function, expect error return
1268  ct_sleep2 does not call set_output_row_size method, expect error return
1269 
1270  - mode == 3
1271  ct_sleep1 same as mode == 2
1272  ct_sleep2 calls global set_output_row_size function, expect error return
1273 */
1274 // clang-format on
1275 EXTENSION_NOINLINE int32_t ct_sleep_worker(int32_t seconds, Column<int32_t>& output) {
1276  // save entering time
1277  output[0] = std::chrono::duration_cast<std::chrono::milliseconds>(
1278  std::chrono::system_clock::now().time_since_epoch())
1279  .count() &
1280  0xffffff;
1281  // store thread id info
1282  output[2] = std::hash<std::thread::id>()(std::this_thread::get_id()) & 0xffff;
1283  // do "computations" for given seconds
1284  std::this_thread::sleep_for(std::chrono::seconds(seconds));
1285  // save leaving time
1286  output[1] = std::chrono::duration_cast<std::chrono::milliseconds>(
1287  std::chrono::system_clock::now().time_since_epoch())
1288  .count() &
1289  0xffffff;
1290  return 3;
1291 }
1292 
1294  int32_t mode,
1295  Column<int32_t>& output) {
1296  switch (mode) {
1297  case 0: {
1298  set_output_row_size(3); // uses global singleton of TableFunctionManager
1299  break;
1300  }
1301  case 1: {
1303  mgr->set_output_row_size(3);
1304  break;
1305  }
1306  case 2:
1307  case 3: {
1308  break;
1309  }
1310  default:
1311  return TABLE_FUNCTION_ERROR("unexpected mode");
1312  }
1313  if (output.size() == 0) {
1314  return TABLE_FUNCTION_ERROR("unspecified output columns row size");
1315  }
1316  return ct_sleep_worker(seconds, output);
1317 }
1318 
1320  int32_t seconds,
1321  int32_t mode,
1322  Column<int32_t>& output) {
1323  switch (mode) {
1324  case 0:
1325  case 1: {
1326  mgr.set_output_row_size(3); // uses thread-safe TableFunctionManager instance
1327  break;
1328  }
1329  case 2: {
1330  break;
1331  }
1332  case 3: {
1333  try {
1334  auto* mgr0 = TableFunctionManager::get_singleton(); // it may throw "singleton is
1335  // not initialized"
1336  mgr0->set_output_row_size(3);
1337  } catch (std::exception& e) {
1338  return mgr.ERROR_MESSAGE(e.what());
1339  }
1340  break;
1341  }
1342  default:
1343  return mgr.ERROR_MESSAGE("unexpected mode");
1344  }
1345  if (output.size() == 0) {
1346  return mgr.ERROR_MESSAGE("unspecified output columns row size");
1347  }
1348  return ct_sleep_worker(seconds, output);
1349 }
1350 
1351 // clang-format off
1352 /*
1353  UDTF: ct_throw_if_gt_100__cpu_template(TableFunctionManager, Column<T>) -> Column<T> val, T=[float, double]
1354 */
1355 // clang-format on
1356 
1357 template <typename T>
1359  const Column<T>& input,
1360  Column<T>& output) {
1361  int64_t num_rows = input.size();
1362  mgr.set_output_row_size(num_rows);
1363  for (int64_t r = 0; r < num_rows; ++r) {
1364  if (input[r] > 100) {
1365  return mgr.ERROR_MESSAGE("Values greater than 100 not allowed");
1366  }
1367  output[r] = input[r];
1368  }
1369  return num_rows;
1370 }
1371 
1372 // clang-format off
1373 /*
1374  The following UDTFs are used to test an optimization rule that moves
1375  filters on UDTF outputs to the inputs when the names of outputs and
1376  input arguments match in the UDTF signatures. This optimization
1377  makes sense only if filters and table functions are commutative with
1378  respect to the corresponding input and output arguments:
1379 
1380  filter(udtf(..., input[j], ...)[i]) == udtf(..., filter(input[j]), ...)[i]
1381 
1382  The UDTFs below invalidate this requirement for the purpose of
1383  testing the feature: the result will depend on whether the
1384  optimization is enabled or not.
1385 
1386  UDTF: ct_copy_and_add_size(TableFunctionManager, Cursor<Column<int32_t> x>) | filter_table_function_transpose=on -> Column<int32_t> x
1387  UDTF: ct_add_size_and_mul_alpha(TableFunctionManager, Cursor<Column<int32_t>, Column<int32_t>> | fields=[x, x2], int32_t alpha) | filter_table_function_transpose=on -> Column<int32_t> x, Column<int32_t> x2
1388 
1389  UDTF: ct_sparse_add(TableFunctionManager, Cursor<Column<int32_t> x, Column<int32_t> d1>, int32_t f1, Cursor<Column<int32_t> x, Column<int32_t> d2>, int32_t f2) | filter_table_function_transpose=on -> Column<int32_t> x, Column<int32_t> d
1390 */
1391 // clang-format on
1392 
1394  const Column<int32_t>& input,
1395  Column<int32_t>& output) {
1396  mgr.set_output_row_size(input.size());
1397  for (int32_t i = 0; i < input.size(); i++) {
1398  output[i] = input[i] + input.size();
1399  }
1400  return output.size();
1401 }
1402 
1404  const Column<int32_t>& input1,
1405  const Column<int32_t>& input2,
1406  int32_t alpha,
1407  Column<int32_t>& output1,
1408  Column<int32_t>& output2) {
1409  auto size = input1.size();
1410  mgr.set_output_row_size(size);
1411  for (int32_t i = 0; i < size; i++) {
1412  output1[i] = input1[i] + size;
1413  output2[i] = input2[i] * alpha;
1414  }
1415  return size;
1416 }
1417 
1418 /*
1419  Add two sparse graphs given by pairs of coordinates and the
1420  corresponding values and multiply with the size of output
1421  columns. Unspecified points are assumed to have the specified fill
1422  value.
1423 */
1424 
1426  const Column<int32_t>& x1,
1427  const Column<int32_t>& d1,
1428  int32_t f1,
1429  const Column<int32_t>& x2,
1430  const Column<int32_t>& d2,
1431  int32_t f2,
1432  Column<int32_t>& x,
1433  Column<int32_t>& d) {
1434  // sorted set of common coordinates:
1435  std::set<int32_t, std::less<int32_t>> x12;
1436  // inverse map of coordinates and indices, keys are sorted:
1437  std::map<int32_t, int32_t, std::less<int32_t>> i1, i2;
1438 
1439  for (int32_t i = 0; i < x1.size(); i++) {
1440  i1[x1[i]] = i;
1441  x12.insert(x1[i]);
1442  }
1443  for (int32_t i = 0; i < x2.size(); i++) {
1444  i2[x2[i]] = i;
1445  x12.insert(x2[i]);
1446  }
1447  auto size = x12.size();
1448 
1449  mgr.set_output_row_size(size);
1450  int32_t k = 0;
1451  for (auto x_ : x12) {
1452  x[k] = x_;
1453  auto i1_ = i1.find(x_);
1454  auto i2_ = i2.find(x_);
1455  if (i1_ != i1.end()) {
1456  if (i2_ != i2.end()) {
1457  d[k] = d1[i1_->second] + d2[i2_->second];
1458  } else {
1459  d[k] = d1[i1_->second] + f2;
1460  }
1461  } else if (i2_ != i2.end()) {
1462  d[k] = f1 + d2[i2_->second];
1463  } else {
1464  d[k] = f1 + f2;
1465  }
1466  d[k] *= size;
1467  k++;
1468  }
1469  return size;
1470 }
1471 
1472 #endif // #ifndef __CUDACC__
1473 
1474 enum TFAggType { MIN, MAX };
1475 
1476 template <typename T>
1477 TEMPLATE_INLINE T get_min_or_max(const Column<T>& col, const TFAggType min_or_max) {
1478  const auto input_min_max = get_column_min_max(col);
1479  if (min_or_max == TFAggType::MIN) {
1480  return input_min_max.first;
1481  }
1482  return input_min_max.second;
1483 }
1484 
1485 template <typename T>
1487  const Column<T>& col2,
1488  const TFAggType min_or_max) {
1489  const auto input1_min_max = get_column_min_max(col1);
1490  const auto input2_min_max = get_column_min_max(col2);
1491  if (min_or_max == TFAggType::MIN) {
1492  return input1_min_max.first < input2_min_max.first ? input1_min_max.first
1493  : input2_min_max.first;
1494  }
1495  return input1_min_max.second > input2_min_max.second ? input1_min_max.second
1496  : input2_min_max.second;
1497 }
1498 
1499 // clang-format off
1500 /*
1501  UDTF: ct_pushdown_stats__cpu_template(TableFunctionManager, TextEncodingNone agg_type, Cursor<Column<K> id, Column<T> x, Column<T> y, Column<Z> z>) | filter_table_function_transpose=on -> Column<int32_t> row_count, Column<K> id | input_id=args<0>, Column<T> x, Column<T> y, Column<Z> z, K=[int32_t, int64_t, TextEncodingDict], T=[int32_t, int64_t, float, double], Z=[int32_t, int64_t, float, double]
1502 */
1503 // clang-format on
1504 
1505 #ifndef __CUDACC__
1506 
1507 template <typename K, typename T, typename Z>
1508 NEVER_INLINE HOST int32_t
1510  const TextEncodingNone& agg_type,
1511  const Column<K>& input_id,
1512  const Column<T>& input_x,
1513  const Column<T>& input_y,
1514  const Column<Z>& input_z,
1515  Column<int32_t>& output_row_count,
1516  Column<K>& output_id,
1517  Column<T>& output_x,
1518  Column<T>& output_y,
1519  Column<Z>& output_z) {
1520  const std::string agg_type_str = agg_type.getString();
1521  const TFAggType min_or_max = agg_type_str == "MIN" ? TFAggType::MIN : TFAggType::MAX;
1522  mgr.set_output_row_size(1);
1523  output_row_count[0] = input_id.size();
1524  output_id[0] = get_min_or_max(input_id, min_or_max);
1525  output_x[0] = get_min_or_max(input_x, min_or_max);
1526  output_y[0] = get_min_or_max(input_y, min_or_max);
1527  output_z[0] = get_min_or_max(input_z, min_or_max);
1528  return 1;
1529 }
1530 
1531 #endif // #ifndef __CUDACC__
1532 
1533 // clang-format off
1534 /*
1535  UDTF: ct_pushdown_projection__cpu_template(TableFunctionManager, Cursor<Column<K> id, Column<T> x, Column<T> y, Column<Z> z>) | filter_table_function_transpose=on -> Column<K> id | input_id=args<0>, Column<T> x, Column<T> y, Column<Z> z, K=[int32_t, int64_t, TextEncodingDict], T=[int32_t, int64_t, float, double], Z=[int32_t, int64_t, float, double]
1536 */
1537 // clang-format on
1538 
1539 #ifndef __CUDACC__
1540 
1541 template <typename K, typename T, typename Z>
1543  const Column<K>& input_id,
1544  const Column<T>& input_x,
1545  const Column<T>& input_y,
1546  const Column<Z>& input_z,
1547  Column<K>& output_id,
1548  Column<T>& output_x,
1549  Column<T>& output_y,
1550  Column<Z>& output_z) {
1551  const int64_t input_size = input_id.size();
1552  mgr.set_output_row_size(input_size);
1553  for (int64_t input_idx = 0; input_idx < input_size; ++input_idx) {
1554  output_id[input_idx] = input_id[input_idx];
1555  output_x[input_idx] = input_x[input_idx];
1556  output_y[input_idx] = input_y[input_idx];
1557  output_z[input_idx] = input_z[input_idx];
1558  }
1559  return input_size;
1560 }
1561 
1562 #endif // #ifndef __CUDACC__
1563 
1564 // clang-format off
1565 /*
1566  UDTF: ct_union_pushdown_stats__cpu_template(TableFunctionManager, TextEncodingNone agg_type, Cursor<Column<K> id, Column<T> x, Column<T> y, Column<Z> z>, Cursor<Column<K> id, Column<T> x, Column<T> y, Column<Z> z, Column<T> w>) | filter_table_function_transpose=on -> Column<int32_t> row_count, Column<K> id | input_id=args<0, 0>, Column<T> x, Column<T> y, Column<Z> z, Column<T> w, K=[int32_t, int64_t, TextEncodingDict], T=[int32_t, int64_t, float, double], Z=[int32_t, int64_t, float, double]
1567 */
1568 // clang-format on
1569 
1570 #ifndef __CUDACC__
1571 
1572 template <typename K, typename T, typename Z>
1573 NEVER_INLINE HOST int32_t
1575  const TextEncodingNone& agg_type,
1576  const Column<K>& input1_id,
1577  const Column<T>& input1_x,
1578  const Column<T>& input1_y,
1579  const Column<Z>& input1_z,
1580  const Column<K>& input2_id,
1581  const Column<T>& input2_x,
1582  const Column<T>& input2_y,
1583  const Column<Z>& input2_z,
1584  const Column<T>& input2_w,
1585  Column<int32_t>& output_row_count,
1586  Column<K>& output_id,
1587  Column<T>& output_x,
1588  Column<T>& output_y,
1589  Column<Z>& output_z,
1590  Column<T>& output_w) {
1591  mgr.set_output_row_size(1);
1592  const std::string agg_type_str = agg_type.getString();
1593  const TFAggType min_or_max = agg_type_str == "MIN" ? TFAggType::MIN : TFAggType::MAX;
1594  output_row_count[0] = input1_id.size() + input2_id.size();
1595  output_id[0] = get_min_or_max_union(input1_id, input2_id, min_or_max);
1596  output_x[0] = get_min_or_max_union(input1_x, input2_x, min_or_max);
1597  output_y[0] = get_min_or_max_union(input1_y, input2_y, min_or_max);
1598  output_z[0] = get_min_or_max_union(input1_z, input2_z, min_or_max);
1599  if (input2_w.size() > 0) {
1600  const auto w_min_max = get_column_min_max(input2_w);
1601  output_w[0] = agg_type_str == "MIN" ? w_min_max.first : w_min_max.second;
1602  } else {
1603  output_w.setNull(0);
1604  }
1605  return 1;
1606 }
1607 
1608 #endif // #ifndef __CUDACC__
1609 
1610 // clang-format off
1611 /*
1612  UDTF: ct_union_pushdown_projection__cpu_template(TableFunctionManager, Cursor<Column<K> id, Column<T> x, Column<T> y, Column<Z> z>, Cursor<Column<K> id, Column<T> x, Column<T> y, Column<Z> z, Column<T> w>) | filter_table_function_transpose=on -> Column<K> id | input_id=args<0, 0>, Column<T> x, Column<T> y, Column<Z> z, Column<T> w, K=[int32_t, int64_t, TextEncodingDict], T=[int32_t, int64_t, float, double], Z=[int32_t, int64_t, float, double]
1613 */
1614 // clang-format on
1615 
1616 #ifndef __CUDACC__
1617 
1618 template <typename K, typename T, typename Z>
1619 NEVER_INLINE HOST int32_t
1621  const Column<K>& input1_id,
1622  const Column<T>& input1_x,
1623  const Column<T>& input1_y,
1624  const Column<Z>& input1_z,
1625  const Column<K>& input2_id,
1626  const Column<T>& input2_x,
1627  const Column<T>& input2_y,
1628  const Column<Z>& input2_z,
1629  const Column<T>& input2_w,
1630  Column<K>& output_id,
1631  Column<T>& output_x,
1632  Column<T>& output_y,
1633  Column<Z>& output_z,
1634  Column<T>& output_w) {
1635  const int64_t input1_size = input1_id.size();
1636  const int64_t input2_size = input2_id.size();
1637  int64_t output_size = input1_size + input2_size;
1638  mgr.set_output_row_size(output_size);
1639  for (int64_t input1_idx = 0; input1_idx < input1_size; ++input1_idx) {
1640  output_id[input1_idx] = input1_id[input1_idx];
1641  output_x[input1_idx] = input1_x[input1_idx];
1642  output_y[input1_idx] = input1_y[input1_idx];
1643  output_z[input1_idx] = input1_z[input1_idx];
1644  output_w.setNull(input1_idx);
1645  }
1646  for (int64_t input2_idx = 0; input2_idx < input2_size; ++input2_idx) {
1647  output_id[input1_size + input2_idx] = input2_id[input2_idx];
1648  output_x[input1_size + input2_idx] = input2_x[input2_idx];
1649  output_y[input1_size + input2_idx] = input2_y[input2_idx];
1650  output_z[input1_size + input2_idx] = input2_z[input2_idx];
1651  output_w[input1_size + input2_idx] = input2_w[input2_idx];
1652  }
1653  return output_size;
1654 }
1655 
1656 #endif // #ifndef __CUDACC__
1657 
1658 // clang-format off
1659 /*
1660  UDTF: ct_require__cpu_(Column<int32_t>, int | name=i | require="i > 0") -> Column<int32_t>
1661  UDTF: ct_require_mgr(TableFunctionManager, Column<int32_t>, int i | require="i > 1" | require="i < 5") -> Column<int32_t>
1662  UDTF: ct_require_str__cpu_(Column<int32_t>, TextEncodingNone s | require="s == \"hello\"") -> Column<int32_t>
1663  UDTF: ct_require_templating__cpu_template(Column<T>, int i | require="i > 0") -> Column<K>, T=[int, double], K=[int]
1664  UDTF: ct_require_and__cpu_(Column<int>, int i | require="i > 0 && i < 5") -> Column<int>
1665  UDTF: ct_require_or_str__cpu_(Column<int>, TextEncodingNone i | require="i == \"MAX\" || i == \"MIN\"") -> Column<int>
1666  UDTF: ct_require_str_diff__cpu_(Column<int>, TextEncodingNone i | require="i != \"MAX\"") -> Column<int>
1667  UDTF: ct_require_text_enc_dict__cpu_(Cursor<Column<TextEncodingDict>>, int64_t x | require="x >= 1") -> Column<int64_t>
1668 */
1669 // clang-format on
1670 
1671 #ifndef __CUDACC__
1672 
1674  const int32_t i,
1675  Column<int32_t>& out) {
1677  out[0] = 3;
1678  return 1;
1679 }
1680 
1682  const TextEncodingNone& s,
1683  Column<int32_t>& out) {
1685  out[0] = 3;
1686  return 1;
1687 }
1688 
1690  const Column<int32_t>& input1,
1691  const int32_t i,
1692  Column<int32_t>& out) {
1694  out[0] = 4;
1695  return 1;
1696 }
1697 
1698 template <typename T, typename K>
1700  const int32_t i,
1701  Column<K>& out) {
1703  if constexpr (std::is_same<T, int32_t>::value) {
1704  out[0] = 5;
1705  } else if constexpr (std::is_same<T, double>::value) {
1706  out[0] = 6.0;
1707  }
1708  return 1;
1709 }
1710 
1712  const int32_t i,
1713  Column<int32_t>& out) {
1715  out[0] = 7;
1716  return 1;
1717 }
1718 
1720  const TextEncodingNone& i,
1721  Column<int32_t>& out) {
1723  out[0] = 8;
1724  return 1;
1725 }
1726 
1728  const TextEncodingNone& i,
1729  Column<int32_t>& out) {
1731  out[0] = 9;
1732  return 1;
1733 }
1734 
1737  const int64_t x,
1738  Column<int64_t>& out) {
1740  out[0] = 10;
1741  return 1;
1742 }
1743 
1744 #endif // #ifndef __CUDACC__
1745 
1746 #ifdef __CUDACC__
1747 
1748 // clang-format off
1749 /*
1750  UDTF: ct_require_device_cuda__gpu_(Column<int32_t>, Constant<1>, int | name=i | require="i > 0") -> Column<int32_t>
1751 */
1752 // clang-format on
1753 
1754 EXTENSION_NOINLINE int32_t ct_require_device_cuda__gpu_(const Column<int32_t>& input1,
1755  const int32_t i,
1756  Column<int32_t>& out) {
1757  out[0] = (i > 0 ? 12345 : 54321);
1758  return 1;
1759 }
1760 
1761 // clang-format off
1762 /*
1763  UDTF: ct_cuda_enumerate_threads__gpu_(ConstantParameter output_size) -> Column<int32_t> local_thread_id, Column<int32_t> block_id, Column<int32_t> global_thread_id
1764 */
1765 // clang-format on
1766 
1767 EXTENSION_NOINLINE int32_t
1768 ct_cuda_enumerate_threads__gpu_(const int32_t output_size,
1769  Column<int32_t>& out_local_thread_id,
1770  Column<int32_t>& out_block_id,
1771  Column<int32_t>& out_global_thread_id) {
1772  int32_t local_thread_id = threadIdx.x;
1773  int32_t block_id = blockIdx.x;
1774  int32_t global_thread_id = threadIdx.x + blockDim.x * blockIdx.x;
1775  out_local_thread_id[global_thread_id] = local_thread_id;
1776  out_block_id[global_thread_id] = block_id;
1777  out_global_thread_id[global_thread_id] = global_thread_id;
1778  return output_size;
1779 }
1780 
1781 #endif //__CUDACC__
1782 
1783 // clang-format off
1784 /*
1785  UDTF: ct_test_nullable(Column<int32_t>, RowMultiplier) -> Column<int32_t>
1786 */
1787 // clang-format on
1788 
1790  const int32_t i,
1791  Column<int32_t>& out) {
1792  for (int i = 0; i < input.size(); i++) {
1793  if (i % 2 == 0) {
1794  out.setNull(i);
1795  } else {
1796  out[i] = input[i];
1797  }
1798  }
1799  return input.size();
1800 }
1801 
1802 // clang-format off
1803 /*
1804  UDTF: ct_test_preflight_sizer(Column<int32_t> col, int i, int j) -> Column<int32_t> | output_row_size="i + j"
1805  UDTF: ct_test_preflight_sizer_const(Column<int32_t> col) -> Column<int32_t> | output_row_size=2
1806 */
1807 // clang-format on
1808 
1810  const int32_t i,
1811  const int32_t j,
1812  Column<int32_t>& out) {
1813  out[0] = 123;
1814  out[1] = 456;
1815  return out.size();
1816 }
1817 
1819  Column<int32_t>& out) {
1820  out[0] = 789;
1821  out[1] = 321;
1822  return out.size();
1823 }
1824 
1825 #ifndef __CUDACC__
1826 
1827 // clang-format off
1828 /*
1829  UDTF: ct_test_preflight_singlecursor_qe227__cpu_(TableFunctionManager,
1830  Cursor<Column<int32_t> col, ColumnList<int32_t> lst>,
1831  int32_t x, int32_t y | require="x > 0" | require="y > 0") ->
1832  Column<int32_t> out
1833  */
1834 // clang-format on
1835 
1836 EXTENSION_NOINLINE int32_t
1838  const Column<int32_t>& col,
1839  const ColumnList<int32_t>& lst,
1840  const int x,
1841  const int y,
1842  Column<int32_t>& out) {
1843  mgr.set_output_row_size(lst.numCols() + 1);
1844  out[0] = col[0];
1845  for (int i = 0; i < lst.numCols(); i++) {
1846  out[i + 1] = lst[i][0];
1847  }
1848  return out.size();
1849 }
1850 
1851 // clang-format off
1852 /*
1853  UDTF: ct_test_preflight_multicursor_qe227__cpu_(TableFunctionManager,
1854  Column<int32_t> col, ColumnList<int32_t> lst,
1855  int32_t x, int32_t y | require="x > 0" | require="y > 0") ->
1856  Column<int32_t> out
1857  */
1858 // clang-format on
1859 
1860 EXTENSION_NOINLINE int32_t
1862  const Column<int32_t>& col,
1863  const ColumnList<int32_t>& lst,
1864  const int x,
1865  const int y,
1866  Column<int32_t>& out) {
1867  mgr.set_output_row_size(lst.numCols() + 1);
1868  out[0] = col[1];
1869  for (int i = 0; i < lst.numCols(); i++) {
1870  out[i + 1] = lst[i][1];
1871  }
1872  return out.size();
1873 }
1874 
1875 // clang-format off
1876 /*
1877  UDTF: ct_scalar_named_args__cpu_(TableFunctionManager, int32_t arg1, int32_t arg2) ->
1878  Column<int32_t> out1, Column<int32_t> out2
1879 */
1880 
1883  const int32_t arg2, Column<int32_t>& out1, Column<int32_t>& out2) {
1884  mgr.set_output_row_size(1);
1885  out1[0] = arg1;
1886  out2[0] = arg2;
1887  return 1;
1888  }
1889 
1890 // clang-format off
1891 /*
1892  UDTF: ct_cursor_named_args__cpu_(TableFunctionManager, Cursor<Column<int32_t> input_table_arg1,
1893  Column<int32_t> input_table_arg2> input_table, int32_t arg1, int32_t arg2) ->
1894  Column<int32_t> out1, Column<int32_t> out2
1895 */
1896 
1899 const Column<int32_t>& input_arg2, const int32_t arg1, const int32_t arg2,
1900  Column<int32_t>& out1, Column<int32_t>& out2) {
1901  const int32_t num_rows = input_arg1.size();
1902  mgr.set_output_row_size(num_rows);
1903  for (int32_t r = 0; r < num_rows; ++r) {
1904  out1[r] = input_arg1[r] + arg1;
1905  out2[r] = input_arg2[r] + arg2;
1906  }
1907  return num_rows;
1908 }
1909 
1910 #endif
1911 
1912 #ifndef __CUDACC__
1913 
1914 // clang-format off
1915 /*
1916  UDTF: ct_timestamp_extract(TableFunctionManager, Column<Timestamp>) -> Column<int64_t> ns, Column<int64_t> us, Column<int64_t> ms, Column<int64_t> s, Column<int64_t> m, Column<int64_t> h, Column<int64_t> d, Column<int64_t> mo, Column<int64_t> y
1917  UDTF: ct_timestamp_add_offset(TableFunctionManager, Column<Timestamp>, Timestamp) -> Column<Timestamp>
1918  UDTF: ct_timestamp_test_columns_and_scalars__cpu(Column<Timestamp>, int64_t, RowMultiplier, Column<Timestamp>) -> Column<Timestamp>
1919  UDTF: ct_timestamp_column_list_input(TableFunctionManager, ColumnList<int64_t>, Column<Timestamp>) -> Column<Timestamp>
1920  UDTF: ct_timestamp_truncate(TableFunctionManager, Column<Timestamp>) -> Column<Timestamp> y, Column<Timestamp> mo, Column<Timestamp> d, Column<Timestamp> h, Column<Timestamp> m, Column<Timestamp> s, Column<Timestamp> ms, Column<Timestamp> us
1921 */
1922 // clang-format on
1923 
1924 // Test table functions with Timestamp Column inputs
1925 // and Timestamp type helper functions
1927  const Column<Timestamp>& input,
1928  Column<int64_t>& ns,
1929  Column<int64_t>& us,
1930  Column<int64_t>& ms,
1931  Column<int64_t>& s,
1932  Column<int64_t>& m,
1933  Column<int64_t>& h,
1934  Column<int64_t>& d,
1935  Column<int64_t>& mo,
1936  Column<int64_t>& y) {
1937  int size = input.size();
1938  mgr.set_output_row_size(size);
1939  for (int i = 0; i < size; ++i) {
1940  if (input.isNull(i)) {
1941  ns.setNull(i);
1942  us.setNull(i);
1943  ms.setNull(i);
1944  s.setNull(i);
1945  m.setNull(i);
1946  h.setNull(i);
1947  d.setNull(i);
1948  mo.setNull(i);
1949  y.setNull(i);
1950  } else {
1951  ns[i] = input[i].getNanoseconds();
1952  us[i] = input[i].getMicroseconds();
1953  ms[i] = input[i].getMilliseconds();
1954  s[i] = input[i].getSeconds();
1955  m[i] = input[i].getMinutes();
1956  h[i] = input[i].getHours();
1957  d[i] = input[i].getDay();
1958  mo[i] = input[i].getMonth();
1959  y[i] = input[i].getYear();
1960  }
1961  }
1962  return size;
1963 }
1964 
1965 // Test table functions with scalar Timestamp inputs
1967  const Column<Timestamp>& input,
1968  const Timestamp offset,
1969  Column<Timestamp>& out) {
1970  int size = input.size();
1971  mgr.set_output_row_size(size);
1972  for (int i = 0; i < size; ++i) {
1973  if (input.isNull(i)) {
1974  out.setNull(i);
1975  } else {
1976  out[i] = input[i] + offset;
1977  }
1978  }
1979  return size;
1980 }
1981 
1982 // Test table function with sizer argument, and mix of scalar/column inputs.
1983 EXTENSION_NOINLINE int32_t
1985  const int64_t dummy,
1986  const int32_t multiplier,
1987  const Column<Timestamp>& input2,
1988  Column<Timestamp>& out) {
1989  int size = input.size();
1990  for (int i = 0; i < size; ++i) {
1991  if (input.isNull(i)) {
1992  out.setNull(i);
1993  } else {
1994  out[i] = input[i] + input2[i] + dummy;
1995  }
1996  }
1997  return size;
1998 }
1999 
2000 // Dummy test for ColumnList inputs + Column Timestamp input
2003  const ColumnList<int64_t>& input,
2004  const Column<Timestamp>& input2,
2005  Column<int64_t>& out) {
2006  mgr.set_output_row_size(1);
2007  out[0] = 1;
2008  return 1;
2009 }
2010 
2012  const Column<Timestamp>& input,
2013  Column<Timestamp>& y,
2014  Column<Timestamp>& mo,
2015  Column<Timestamp>& d,
2016  Column<Timestamp>& h,
2017  Column<Timestamp>& m,
2018  Column<Timestamp>& s,
2019  Column<Timestamp>& ms,
2020  Column<Timestamp>& us) {
2021  int size = input.size();
2022  mgr.set_output_row_size(size);
2023  for (int i = 0; i < size; ++i) {
2024  y[i] = input[i].truncateToYear();
2025  mo[i] = input[i].truncateToMonth();
2026  d[i] = input[i].truncateToDay();
2027  h[i] = input[i].truncateToHours();
2028  m[i] = input[i].truncateToMinutes();
2029  s[i] = input[i].truncateToSeconds();
2030  ms[i] = input[i].truncateToMilliseconds();
2031  us[i] = input[i].truncateToMicroseconds();
2032  }
2033 
2034  return size;
2035 }
2036 
2037 #endif // ifndef __CUDACC__
EXTENSION_NOINLINE_HOST int32_t ct_require_text_enc_dict__cpu_(const Column< TextEncodingDict > &input, const int64_t x, Column< int64_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer3a__cpu_1(const Column< int32_t > &input1, const int32_t multiplier, const int32_t x, Column< int32_t > &out)
DEVICE const std::string getString(int64_t index) const
Definition: heavydbTypes.h:506
void set_output_row_size(int64_t num_rows)
Definition: heavydbTypes.h:655
EXTENSION_NOINLINE_HOST int32_t ct_substr__cpu_(TableFunctionManager &mgr, const Column< TextEncodingDict > &input_str, const Column< int > &pos, const Column< int > &len, Column< TextEncodingDict > &output_substr)
EXTENSION_NOINLINE_HOST int32_t ct_binding_dict_encoded6__cpu_1(const ColumnList< TextEncodingDict > &input, Column< TextEncodingDict > &out0, Column< TextEncodingDict > &out1)
const T null_value_mapped_
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer3b__cpu_2(const Column< int32_t > &input1, const int32_t x, const Column< int32_t > &input2, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE int32_t ct_timestamp_test_columns_and_scalars__cpu(const Column< Timestamp > &input, const int64_t dummy, const int32_t multiplier, const Column< Timestamp > &input2, Column< Timestamp > &out)
NEVER_INLINE HOST int32_t ct_scalar_1_arg_runtime_sizing__cpu_template(const T num, Column< T > &answer)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf_constant__cpu_1(const Column< int32_t > &input1, Column< int32_t > &out)
EXTENSION_NOINLINE int32_t ct_test_preflight_sizer(const Column< int32_t > &input, const int32_t i, const int32_t j, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_string_concat__cpu_(TableFunctionManager &mgr, const ColumnList< TextEncodingDict > &input_strings, const TextEncodingNone &separator, Column< TextEncodingDict > &concatted_string)
NEVER_INLINE HOST int32_t ct_named_output__cpu_template(const Column< T > &input, Column< T > &out)
EXTENSION_NOINLINE_HOST void set_output_row_size(int64_t num_rows)
#define EXTENSION_NOINLINE
Definition: heavydbTypes.h:47
EXTENSION_NOINLINE_HOST int32_t ct_require__cpu_(const Column< int32_t > &input1, const int32_t i, Column< int32_t > &out)
static T map_null_value(const bool nulls_last)
T mapValue(const T &val)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf__cpu_15(const Column< int64_t > &input1, const Column< int64_t > &input2, const Column< int32_t > &input3, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf_constant__cpu_9(const ColumnList< int32_t > &input1, const ColumnList< int64_t > &input2, Column< int32_t > &out)
std::string getString() const
Definition: heavydbTypes.h:162
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf__cpu_11(const Column< int32_t > &input1, const int32_t multiplier, Column< int32_t > &out)
DEVICE int64_t size() const
Definition: heavydbTypes.h:445
NEVER_INLINE HOST int32_t sort_column_limit__cpu_template(const Column< T > &input, const int32_t limit, const bool sort_ascending, const bool nulls_last, Column< T > &output)
EXTENSION_NOINLINE_HOST int32_t ct_synthesize_new_dict__cpu_(TableFunctionManager &mgr, const int64_t num_strings, Column< TextEncodingDict > &new_dict_col)
EXTENSION_NOINLINE_HOST int32_t ct_cursor_named_args__cpu_(TableFunctionManager &mgr, const Column< int32_t > &input_arg1, const Column< int32_t > &input_arg2, const int32_t arg1, const int32_t arg2, Column< int32_t > &out1, Column< int32_t > &out2)
EXTENSION_NOINLINE_HOST int32_t ct_binding_str_equals__cpu_(const ColumnList< TextEncodingDict > &input_strings, Column< TextEncodingDict > &string_if_equal, Column< bool > &strings_are_equal)
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer2a__cpu_1(const Column< int32_t > &input1, const int32_t x, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_dict_encoded2__cpu_1(const Column< TextEncodingDict > &input1, const Column< TextEncodingDict > &input2, Column< TextEncodingDict > &out1, Column< TextEncodingDict > &out2)
DEVICE int64_t numCols() const
Definition: heavydbTypes.h:567
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf__cpu_20(const Column< int64_t > &input1, const ColumnList< int64_t > &input2, const Column< int64_t > &input3, const int32_t multiplier, Column< int64_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf5__cpu_24(const ColumnList< int32_t > &input1, const int32_t input2, const int32_t multiplier, Column< int32_t > &out)
DEVICE void sort(ARGS &&...args)
Definition: gpu_enabled.h:105
T * ptr_
Definition: heavydbTypes.h:430
EXTENSION_NOINLINE_HOST int32_t ct_sleep1__cpu_(int32_t seconds, int32_t mode, Column< int32_t > &output)
TEMPLATE_NOINLINE std::pair< T, T > get_column_min_max(const Column< T > &col)
NEVER_INLINE HOST int32_t ct_pushdown_projection__cpu_template(TableFunctionManager &mgr, const Column< K > &input_id, const Column< T > &input_x, const Column< T > &input_y, const Column< Z > &input_z, Column< K > &output_id, Column< T > &output_x, Column< T > &output_y, Column< Z > &output_z)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf_constant__cpu_3(const Column< int32_t > &input1, const Column< int32_t > &input2, const Column< int32_t > &input3, Column< int32_t > &out)
EXTENSION_NOINLINE int32_t ct_gpu_default_init__gpu_(Column< int32_t > &output_buffer)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf__cpu_12(const Column< int32_t > &input1, const Column< int32_t > &input2, const int32_t multiplier, Column< int32_t > &out)
DEVICE int64_t size() const
Definition: heavydbTypes.h:602
SortAsc(const bool nulls_last)
SortDesc(const bool nulls_last)
DEVICE void setNull(int64_t index)
Definition: heavydbTypes.h:502
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf_constant__cpu_2(const Column< int32_t > &input1, const Column< int32_t > &input2, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf4__cpu_23(const ColumnList< int32_t > &input1, const int32_t multiplier, const int32_t input2, Column< int32_t > &out)
NEVER_INLINE HOST int32_t ct_named_const_output__cpu_template(const Column< T > &input, Column< T > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf__cpu_16(const Column< int64_t > &input1, const Column< int32_t > &input2, const Column< int64_t > &input3, const int32_t multiplier, Column< int32_t > &out)
TEMPLATE_NOINLINE int32_t ct_get_string_chars__template(const Column< T > &indices, const TextEncodingNone &str, const int32_t multiplier, Column< int32_t > &idx, Column< int8_t > &char_bytes)
EXTENSION_NOINLINE_HOST int32_t ct_binding_dict_encoded1__cpu_1(const Column< TextEncodingDict > &input, const int32_t multiplier, Column< TextEncodingDict > &out)
std::string to_string(char const *&&v)
TEMPLATE_INLINE T get_min_or_max_union(const Column< T > &col1, const Column< T > &col2, const TFAggType min_or_max)
EXTENSION_NOINLINE_HOST int32_t ct_require_and__cpu_(const Column< int32_t > &input1, const int32_t i, Column< int32_t > &out)
DEVICE ALWAYS_INLINE int64_t size() const
Definition: heavydbTypes.h:184
EXTENSION_NOINLINE_HOST int32_t ct_sleep2(TableFunctionManager &mgr, int32_t seconds, int32_t mode, Column< int32_t > &output)
constexpr double a
Definition: Utm.h:32
#define CPU_DEVICE_CODE
NEVER_INLINE HOST int32_t ct_binding_template__cpu_template(const Column< T > &input, Column< T > &out)
#define HOST
T safe_addition(T x, T y)
EXTENSION_NOINLINE_HOST int32_t ct_no_cursor_user_constant_sizer__cpu_(const int32_t input_num, int32_t c, Column< int32_t > &output)
NEVER_INLINE HOST int32_t ct_templated_no_cursor_user_constant_sizer__cpu_template(const T input_num, int32_t c, Column< T > &output)
#define GPU_DEVICE_CODE
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer4b__cpu_2(const int32_t multiplier, const Column< int32_t > &input, const int32_t x, Column< int32_t > &out)
NEVER_INLINE HOST int32_t ct_named_user_const_output__cpu_template(const Column< T > &input, int32_t c, Column< T > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf__cpu_17(const Column< int32_t > &input1, const ColumnList< int32_t > &input2, const int32_t multiplier, Column< int32_t > &out)
NEVER_INLINE HOST int32_t ct_pushdown_stats__cpu_template(TableFunctionManager &mgr, const TextEncodingNone &agg_type, const Column< K > &input_id, const Column< T > &input_x, const Column< T > &input_y, const Column< Z > &input_z, Column< int32_t > &output_row_count, Column< K > &output_id, Column< T > &output_x, Column< T > &output_y, Column< Z > &output_z)
EXTENSION_NOINLINE int32_t ct_scalar_2_args_constant_sizing(const int64_t num1, const int64_t num2, Column< int64_t > &answer1, Column< int64_t > &answer2)
EXTENSION_NOINLINE_HOST int32_t ct_timestamp_column_list_input(TableFunctionManager &mgr, const ColumnList< int64_t > &input, const Column< Timestamp > &input2, Column< int64_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf__cpu_19(const ColumnList< int32_t > &input1, const ColumnList< int64_t > &input2, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf_constant__cpu_8(const ColumnList< int32_t > &input1, const Column< int64_t > &input2, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer1c__cpu_3(const Column< int32_t > &input1, const Column< int32_t > &input2, const Column< int32_t > &input3, const int32_t multiplier, const Column< int32_t > &input4, const int32_t x, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_timestamp_truncate(TableFunctionManager &mgr, const Column< Timestamp > &input, Column< Timestamp > &y, Column< Timestamp > &mo, Column< Timestamp > &d, Column< Timestamp > &h, Column< Timestamp > &m, Column< Timestamp > &s, Column< Timestamp > &ms, Column< Timestamp > &us)
#define EXTENSION_NOINLINE_HOST
Definition: heavydbTypes.h:44
DEVICE const TextEncodingDict getStringId(const std::string &str)
Definition: heavydbTypes.h:509
EXTENSION_NOINLINE_HOST int32_t ct_binding_dict_encoded5__cpu_1(const ColumnList< TextEncodingDict > &input, Column< TextEncodingDict > &out)
EXTENSION_NOINLINE int32_t ct_test_nullable(const Column< int32_t > &input, const int32_t i, Column< int32_t > &out)
#define TEMPLATE_INLINE
Definition: heavydbTypes.h:48
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf2__cpu_21(const int32_t multiplier, const Column< int32_t > &input1, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_timestamp_add_offset(TableFunctionManager &mgr, const Column< Timestamp > &input, const Timestamp offset, Column< Timestamp > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf_constant__cpu_7(const Column< int32_t > &input1, const ColumnList< int32_t > &input2, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer1a__cpu_1(const Column< int32_t > &input1, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer2b__cpu_2(const Column< int32_t > &input1, const int32_t multiplier, const Column< int32_t > &input2, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_dict_encoded3__cpu_1(const Column< TextEncodingDict > &input1, const Column< TextEncodingDict > &input2, Column< TextEncodingDict > &out1, Column< TextEncodingDict > &out2)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf__cpu_14(const Column< int64_t > &input1, const Column< int32_t > &input2, const Column< int32_t > &input3, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_require_str_diff__cpu_(const Column< int32_t > &input1, const TextEncodingNone &i, Column< int32_t > &out)
DEVICE int64_t numCols() const
Definition: heavydbTypes.h:603
T mapValue(const T &val)
NEVER_INLINE HOST int32_t column_list_safe_row_sum__cpu_template(const ColumnList< T > &input, Column< T > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf_constant__cpu_5(const Column< int64_t > &input1, const Column< int64_t > &input2, const Column< int32_t > &input3, Column< int32_t > &out)
EXTENSION_NOINLINE int32_t ct_no_arg_constant_sizing(Column< int32_t > &answer)
NEVER_INLINE HOST int32_t ct_union_pushdown_stats__cpu_template(TableFunctionManager &mgr, const TextEncodingNone &agg_type, const Column< K > &input1_id, const Column< T > &input1_x, const Column< T > &input1_y, const Column< Z > &input1_z, const Column< K > &input2_id, const Column< T > &input2_x, const Column< T > &input2_y, const Column< Z > &input2_z, const Column< T > &input2_w, Column< int32_t > &output_row_count, Column< K > &output_id, Column< T > &output_x, Column< T > &output_y, Column< Z > &output_z, Column< T > &output_w)
bool operator()(const T &a, const T &b)
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer4a__cpu_1(const Column< int32_t > &input1, const int32_t multiplier, const Column< int32_t > &input2, const int32_t x, Column< int32_t > &out)
DEVICE bool isNull(int64_t index) const
Definition: heavydbTypes.h:447
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf3__cpu_25(const Column< int32_t > &input1, const int32_t input2, const int32_t multiplier, Column< int32_t > &out)
DEVICE void setNull(int64_t index)
Definition: heavydbTypes.h:448
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer1d__cpu_4(const int32_t multiplier, const int32_t x, const Column< int32_t > &input1, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_add_size_and_mul_alpha(TableFunctionManager &mgr, const Column< int32_t > &input1, const Column< int32_t > &input2, int32_t alpha, Column< int32_t > &output1, Column< int32_t > &output2)
const T null_value_mapped_
EXTENSION_NOINLINE_HOST int32_t ct_require_str__cpu_(const Column< int32_t > &input1, const TextEncodingNone &s, Column< int32_t > &out)
NEVER_INLINE HOST int32_t ct_binding_column__cpu_template(const Column< T > &input, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_dict_encoded4__cpu_1(const ColumnList< TextEncodingDict > &input, Column< TextEncodingDict > &out)
EXTENSION_NOINLINE int32_t ct_hamming_distance(const TextEncodingNone &str1, const TextEncodingNone &str2, Column< int32_t > &hamming_distance)
EXTENSION_NOINLINE_HOST int32_t ct_copy_and_add_size(TableFunctionManager &mgr, const Column< int32_t > &input, Column< int32_t > &output)
EXTENSION_NOINLINE int32_t ct_sleep_worker(int32_t seconds, Column< int32_t > &output)
EXTENSION_NOINLINE_HOST int32_t ct_device_selection_udtf_both__cpu_(const Column< int32_t > &input, Column< int64_t > &out)
#define NEVER_INLINE
NEVER_INLINE HOST int32_t ct_throw_if_gt_100__cpu_template(TableFunctionManager &mgr, const Column< T > &input, Column< T > &output)
EXTENSION_NOINLINE_HOST int32_t ct_scalar_named_args__cpu_(TableFunctionManager &mgr, const int32_t arg1, const int32_t arg2, Column< int32_t > &out1, Column< int32_t > &out2)
static T map_null_value(const bool nulls_last)
bool operator()(const T &a, const T &b)
EXTENSION_NOINLINE int32_t ct_device_selection_udtf_any(const Column< int32_t > &input, Column< int64_t > &out)
TEMPLATE_INLINE T get_min_or_max(const Column< T > &col, const TFAggType min_or_max)
#define TABLE_FUNCTION_ERROR(MSG)
Definition: heavydbTypes.h:63
NEVER_INLINE HOST int32_t ct_named_rowmul_output__cpu_template(const Column< T > &input, int32_t m, Column< T > &out)
EXTENSION_NOINLINE int32_t ct_test_preflight_multicursor_qe227__cpu_(TableFunctionManager &mgr, const Column< int32_t > &col, const ColumnList< int32_t > &lst, const int x, const int y, Column< int32_t > &out)
NEVER_INLINE HOST int32_t ct_require_templating__cpu_template(const Column< T > &input1, const int32_t i, Column< K > &out)
EXTENSION_NOINLINE int32_t ct_device_selection_udtf_both__gpu_(const Column< int32_t > &input, Column< int64_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_timestamp_extract(TableFunctionManager &mgr, const Column< Timestamp > &input, Column< int64_t > &ns, Column< int64_t > &us, Column< int64_t > &ms, Column< int64_t > &s, Column< int64_t > &m, Column< int64_t > &h, Column< int64_t > &d, Column< int64_t > &mo, Column< int64_t > &y)
DEVICE int64_t size() const
Definition: heavydbTypes.h:498
EXTENSION_NOINLINE_HOST int32_t ct_require_or_str__cpu_(const Column< int32_t > &input1, const TextEncodingNone &i, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer2c__cpu_3(const int32_t x, const int32_t multiplier, const Column< int32_t > &input1, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_require_mgr(TableFunctionManager &mgr, const Column< int32_t > &input1, const int32_t i, Column< int32_t > &out)
NEVER_INLINE HOST int32_t ct_no_arg_runtime_sizing__cpu_template(Column< T > &answer)
EXTENSION_NOINLINE int32_t ct_device_selection_udtf_gpu__gpu_(const Column< int32_t > &input, Column< int64_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_device_selection_udtf_cpu__cpu_(const Column< int32_t > &input, Column< int64_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf6__cpu_22(const Column< int32_t > &input1, const int32_t multiplier, const int32_t input2, Column< int32_t > &out)
NEVER_INLINE HOST int32_t ct_union_pushdown_projection__cpu_template(TableFunctionManager &mgr, const Column< K > &input1_id, const Column< T > &input1_x, const Column< T > &input1_y, const Column< Z > &input1_z, const Column< K > &input2_id, const Column< T > &input2_x, const Column< T > &input2_y, const Column< Z > &input2_z, const Column< T > &input2_w, Column< K > &output_id, Column< T > &output_x, Column< T > &output_y, Column< Z > &output_z, Column< T > &output_w)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf_constant__cpu_6(const Column< int64_t > &input1, const Column< int32_t > &input2, const Column< int64_t > &input3, Column< int32_t > &out)
static TableFunctionManager * get_singleton()
Definition: heavydbTypes.h:651
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf_constant__cpu_10(const Column< int64_t > &input1, const ColumnList< int64_t > &input2, const Column< int64_t > &input3, Column< int64_t > &out)
EXTENSION_NOINLINE int32_t ct_test_preflight_singlecursor_qe227__cpu_(TableFunctionManager &mgr, const Column< int32_t > &col, const ColumnList< int32_t > &lst, const int x, const int y, Column< int32_t > &out)
NEVER_INLINE HOST int32_t ct_binding_scalar_multiply__cpu_template(const Column< T > &input, const T multiplier, Column< T > &out)
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer1b__cpu_2(const Column< int32_t > &input1, const Column< int32_t > &input2, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf_constant__cpu_4(const Column< int64_t > &input1, const Column< int32_t > &input2, const Column< int32_t > &input3, Column< int32_t > &out)
EXTENSION_NOINLINE int32_t ct_test_preflight_sizer_const(const Column< int32_t > &input, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf__cpu_13(const Column< int32_t > &input1, const Column< int32_t > &input2, const Column< int32_t > &input3, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_sparse_add(TableFunctionManager &mgr, const Column< int32_t > &x1, const Column< int32_t > &d1, int32_t f1, const Column< int32_t > &x2, const Column< int32_t > &d2, int32_t f2, Column< int32_t > &x, Column< int32_t > &d)
NEVER_INLINE HOST int32_t ct_binding_column2__cpu_template(const Column< T > &input1, const Column< U > &input2, Column< K > &out)
#define TEMPLATE_NOINLINE
Definition: heavydbTypes.h:49
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf__cpu_18(const ColumnList< int32_t > &input1, const Column< int64_t > &input2, const int32_t multiplier, Column< int32_t > &out)
std::pair< std::string_view, const char * > substring(const std::string &str, size_t substr_length)
return substring of str with postfix if str.size() &gt; substr_length
NEVER_INLINE HOST int32_t ct_binding_columnlist__cpu_template(const Column< T > &input1, const ColumnList< T > &input2, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_string_to_chars__cpu_(const TextEncodingNone &input, Column< int32_t > &char_idx, Column< int8_t > &char_bytes)
EXTENSION_NOINLINE_HOST int32_t ct_binding_str_length__cpu_(const Column< TextEncodingDict > &input_str, Column< TextEncodingDict > &out_str, Column< int64_t > &out_size)