forked from apache/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_scalar.h
More file actions
1694 lines (1530 loc) · 63.8 KB
/
Copy pathapi_scalar.h
File metadata and controls
1694 lines (1530 loc) · 63.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// Eager evaluation convenience APIs for invoking common functions, including
// necessary memory allocations
#pragma once
#include <optional>
#include <string>
#include <utility>
#include "arrow/compute/function.h"
#include "arrow/compute/type_fwd.h"
#include "arrow/datum.h"
#include "arrow/result.h"
#include "arrow/util/macros.h"
#include "arrow/util/visibility.h"
namespace arrow {
namespace compute {
/// \addtogroup compute-concrete-options
///
/// @{
class ARROW_EXPORT ArithmeticOptions : public FunctionOptions {
public:
explicit ArithmeticOptions(bool check_overflow = false);
static constexpr char const kTypeName[] = "ArithmeticOptions";
bool check_overflow;
};
class ARROW_EXPORT ElementWiseAggregateOptions : public FunctionOptions {
public:
explicit ElementWiseAggregateOptions(bool skip_nulls = true);
static constexpr char const kTypeName[] = "ElementWiseAggregateOptions";
static ElementWiseAggregateOptions Defaults() { return ElementWiseAggregateOptions{}; }
bool skip_nulls;
};
/// Rounding and tie-breaking modes for round compute functions.
/// Additional details and examples are provided in compute.rst.
enum class RoundMode : int8_t {
/// Round to nearest integer less than or equal in magnitude (aka "floor")
DOWN,
/// Round to nearest integer greater than or equal in magnitude (aka "ceil")
UP,
/// Get the integral part without fractional digits (aka "trunc")
TOWARDS_ZERO,
/// Round negative values with DOWN rule
/// and positive values with UP rule (aka "away from zero")
TOWARDS_INFINITY,
/// Round ties with DOWN rule (also called "round half towards negative infinity")
HALF_DOWN,
/// Round ties with UP rule (also called "round half towards positive infinity")
HALF_UP,
/// Round ties with TOWARDS_ZERO rule (also called "round half away from infinity")
HALF_TOWARDS_ZERO,
/// Round ties with TOWARDS_INFINITY rule (also called "round half away from zero")
HALF_TOWARDS_INFINITY,
/// Round ties to nearest even integer
HALF_TO_EVEN,
/// Round ties to nearest odd integer
HALF_TO_ODD,
};
class ARROW_EXPORT RoundOptions : public FunctionOptions {
public:
explicit RoundOptions(int64_t ndigits = 0,
RoundMode round_mode = RoundMode::HALF_TO_EVEN);
static constexpr char const kTypeName[] = "RoundOptions";
static RoundOptions Defaults() { return RoundOptions(); }
/// Rounding precision (number of digits to round to)
int64_t ndigits;
/// Rounding and tie-breaking mode
RoundMode round_mode;
};
class ARROW_EXPORT RoundBinaryOptions : public FunctionOptions {
public:
explicit RoundBinaryOptions(RoundMode round_mode = RoundMode::HALF_TO_EVEN);
static constexpr char const kTypeName[] = "RoundBinaryOptions";
static RoundBinaryOptions Defaults() { return RoundBinaryOptions(); }
/// Rounding and tie-breaking mode
RoundMode round_mode;
};
enum class CalendarUnit : int8_t {
NANOSECOND,
MICROSECOND,
MILLISECOND,
SECOND,
MINUTE,
HOUR,
DAY,
WEEK,
MONTH,
QUARTER,
YEAR
};
class ARROW_EXPORT RoundTemporalOptions : public FunctionOptions {
public:
explicit RoundTemporalOptions(int multiple = 1, CalendarUnit unit = CalendarUnit::DAY,
bool week_starts_monday = true,
bool ceil_is_strictly_greater = false,
bool calendar_based_origin = false);
static constexpr char const kTypeName[] = "RoundTemporalOptions";
static RoundTemporalOptions Defaults() { return RoundTemporalOptions(); }
/// Number of units to round to
int multiple;
/// The unit used for rounding of time
CalendarUnit unit;
/// What day does the week start with (Monday=true, Sunday=false)
bool week_starts_monday;
/// Enable this flag to return a rounded value that is strictly greater than the input.
/// For example: ceiling 1970-01-01T00:00:00 to 3 hours would yield 1970-01-01T03:00:00
/// if set to true and 1970-01-01T00:00:00 if set to false.
/// This applies for ceiling only.
bool ceil_is_strictly_greater;
/// By default time is rounded to a multiple of units since 1970-01-01T00:00:00.
/// By setting calendar_based_origin to true, time will be rounded to a number
/// of units since the last greater calendar unit.
/// For example: rounding to a multiple of days since the beginning of the month or
/// to hours since the beginning of the day.
/// Exceptions: week and quarter are not used as greater units, therefore days will
/// will be rounded to the beginning of the month not week. Greater unit of week
/// is year.
/// Note that ceiling and rounding might change sorting order of an array near greater
/// unit change. For example rounding YYYY-mm-dd 23:00:00 to 5 hours will ceil and
/// round to YYYY-mm-dd+1 01:00:00 and floor to YYYY-mm-dd 20:00:00. On the other hand
/// YYYY-mm-dd+1 00:00:00 will ceil, round and floor to YYYY-mm-dd+1 00:00:00. This
/// can break the order of an already ordered array.
bool calendar_based_origin;
};
class ARROW_EXPORT RoundToMultipleOptions : public FunctionOptions {
public:
explicit RoundToMultipleOptions(double multiple = 1.0,
RoundMode round_mode = RoundMode::HALF_TO_EVEN);
explicit RoundToMultipleOptions(std::shared_ptr<Scalar> multiple,
RoundMode round_mode = RoundMode::HALF_TO_EVEN);
static constexpr char const kTypeName[] = "RoundToMultipleOptions";
static RoundToMultipleOptions Defaults() { return RoundToMultipleOptions(); }
/// Rounding scale (multiple to round to).
///
/// Should be a positive numeric scalar of a type compatible with the
/// argument to be rounded. The cast kernel is used to convert the rounding
/// multiple to match the result type.
std::shared_ptr<Scalar> multiple;
/// Rounding and tie-breaking mode
RoundMode round_mode;
};
/// Options for var_args_join.
class ARROW_EXPORT JoinOptions : public FunctionOptions {
public:
/// How to handle null values. (A null separator always results in a null output.)
enum NullHandlingBehavior {
/// A null in any input results in a null in the output.
EMIT_NULL,
/// Nulls in inputs are skipped.
SKIP,
/// Nulls in inputs are replaced with the replacement string.
REPLACE,
};
explicit JoinOptions(NullHandlingBehavior null_handling = EMIT_NULL,
std::string null_replacement = "");
static constexpr char const kTypeName[] = "JoinOptions";
static JoinOptions Defaults() { return JoinOptions(); }
NullHandlingBehavior null_handling;
std::string null_replacement;
};
class ARROW_EXPORT MatchSubstringOptions : public FunctionOptions {
public:
explicit MatchSubstringOptions(std::string pattern, bool ignore_case = false);
MatchSubstringOptions();
static constexpr char const kTypeName[] = "MatchSubstringOptions";
/// The exact substring (or regex, depending on kernel) to look for inside input values.
std::string pattern;
/// Whether to perform a case-insensitive match.
bool ignore_case;
};
class ARROW_EXPORT SplitOptions : public FunctionOptions {
public:
explicit SplitOptions(int64_t max_splits = -1, bool reverse = false);
static constexpr char const kTypeName[] = "SplitOptions";
/// Maximum number of splits allowed, or unlimited when -1
int64_t max_splits;
/// Start splitting from the end of the string (only relevant when max_splits != -1)
bool reverse;
};
class ARROW_EXPORT SplitPatternOptions : public FunctionOptions {
public:
explicit SplitPatternOptions(std::string pattern, int64_t max_splits = -1,
bool reverse = false);
SplitPatternOptions();
static constexpr char const kTypeName[] = "SplitPatternOptions";
/// The exact substring to split on.
std::string pattern;
/// Maximum number of splits allowed, or unlimited when -1
int64_t max_splits;
/// Start splitting from the end of the string (only relevant when max_splits != -1)
bool reverse;
};
class ARROW_EXPORT ReplaceSliceOptions : public FunctionOptions {
public:
explicit ReplaceSliceOptions(int64_t start, int64_t stop, std::string replacement);
ReplaceSliceOptions();
static constexpr char const kTypeName[] = "ReplaceSliceOptions";
/// Index to start slicing at
int64_t start;
/// Index to stop slicing at
int64_t stop;
/// String to replace the slice with
std::string replacement;
};
class ARROW_EXPORT ReplaceSubstringOptions : public FunctionOptions {
public:
explicit ReplaceSubstringOptions(std::string pattern, std::string replacement,
int64_t max_replacements = -1);
ReplaceSubstringOptions();
static constexpr char const kTypeName[] = "ReplaceSubstringOptions";
/// Pattern to match, literal, or regular expression depending on which kernel is used
std::string pattern;
/// String to replace the pattern with
std::string replacement;
/// Max number of substrings to replace (-1 means unbounded)
int64_t max_replacements;
};
class ARROW_EXPORT ExtractRegexOptions : public FunctionOptions {
public:
explicit ExtractRegexOptions(std::string pattern);
ExtractRegexOptions();
static constexpr char const kTypeName[] = "ExtractRegexOptions";
/// Regular expression with named capture fields
std::string pattern;
};
/// Options for IsIn and IndexIn functions
class ARROW_EXPORT SetLookupOptions : public FunctionOptions {
public:
explicit SetLookupOptions(Datum value_set, bool skip_nulls = false);
SetLookupOptions();
static constexpr char const kTypeName[] = "SetLookupOptions";
/// The set of values to look up input values into.
Datum value_set;
/// Whether nulls in `value_set` count for lookup.
///
/// If true, any null in `value_set` is ignored and nulls in the input
/// produce null (IndexIn) or false (IsIn) values in the output.
/// If false, any null in `value_set` is successfully matched in
/// the input.
bool skip_nulls;
};
/// Options for struct_field function
class ARROW_EXPORT StructFieldOptions : public FunctionOptions {
public:
explicit StructFieldOptions(std::vector<int> indices);
explicit StructFieldOptions(std::initializer_list<int>);
explicit StructFieldOptions(FieldRef field_ref);
StructFieldOptions();
static constexpr char const kTypeName[] = "StructFieldOptions";
/// The FieldRef specifying what to extract from struct or union.
FieldRef field_ref;
};
class ARROW_EXPORT StrptimeOptions : public FunctionOptions {
public:
explicit StrptimeOptions(std::string format, TimeUnit::type unit,
bool error_is_null = false);
StrptimeOptions();
static constexpr char const kTypeName[] = "StrptimeOptions";
/// The desired format string.
std::string format;
/// The desired time resolution
TimeUnit::type unit;
/// Return null on parsing errors if true or raise if false
bool error_is_null;
};
class ARROW_EXPORT StrftimeOptions : public FunctionOptions {
public:
explicit StrftimeOptions(std::string format, std::string locale = "C");
StrftimeOptions();
static constexpr char const kTypeName[] = "StrftimeOptions";
static constexpr const char* kDefaultFormat = "%Y-%m-%dT%H:%M:%S";
/// The desired format string.
std::string format;
/// The desired output locale string.
std::string locale;
};
class ARROW_EXPORT PadOptions : public FunctionOptions {
public:
explicit PadOptions(int64_t width, std::string padding = " ");
PadOptions();
static constexpr char const kTypeName[] = "PadOptions";
/// The desired string length.
int64_t width;
/// What to pad the string with. Should be one codepoint (Unicode)/byte (ASCII).
std::string padding;
};
class ARROW_EXPORT TrimOptions : public FunctionOptions {
public:
explicit TrimOptions(std::string characters);
TrimOptions();
static constexpr char const kTypeName[] = "TrimOptions";
/// The individual characters to be trimmed from the string.
std::string characters;
};
class ARROW_EXPORT SliceOptions : public FunctionOptions {
public:
explicit SliceOptions(int64_t start, int64_t stop = std::numeric_limits<int64_t>::max(),
int64_t step = 1);
SliceOptions();
static constexpr char const kTypeName[] = "SliceOptions";
int64_t start, stop, step;
};
class ARROW_EXPORT ListSliceOptions : public FunctionOptions {
public:
explicit ListSliceOptions(int64_t start, std::optional<int64_t> stop = std::nullopt,
int64_t step = 1,
std::optional<bool> return_fixed_size_list = std::nullopt);
ListSliceOptions();
static constexpr char const kTypeName[] = "ListSliceOptions";
/// The start of list slicing.
int64_t start;
/// Optional stop of list slicing. If not set, then slice to end. (NotImplemented)
std::optional<int64_t> stop;
/// Slicing step
int64_t step;
// Whether to return a FixedSizeListArray. If true _and_ stop is after
// a list element's length, nulls will be appended to create the requested slice size.
// Default of `nullopt` will return whatever type it got in.
std::optional<bool> return_fixed_size_list;
};
class ARROW_EXPORT NullOptions : public FunctionOptions {
public:
explicit NullOptions(bool nan_is_null = false);
static constexpr char const kTypeName[] = "NullOptions";
static NullOptions Defaults() { return NullOptions{}; }
bool nan_is_null;
};
enum CompareOperator : int8_t {
EQUAL,
NOT_EQUAL,
GREATER,
GREATER_EQUAL,
LESS,
LESS_EQUAL,
};
struct ARROW_EXPORT CompareOptions {
explicit CompareOptions(CompareOperator op) : op(op) {}
CompareOptions() : CompareOptions(CompareOperator::EQUAL) {}
enum CompareOperator op;
};
class ARROW_EXPORT MakeStructOptions : public FunctionOptions {
public:
MakeStructOptions(std::vector<std::string> n, std::vector<bool> r,
std::vector<std::shared_ptr<const KeyValueMetadata>> m);
explicit MakeStructOptions(std::vector<std::string> n);
MakeStructOptions();
static constexpr char const kTypeName[] = "MakeStructOptions";
/// Names for wrapped columns
std::vector<std::string> field_names;
/// Nullability bits for wrapped columns
std::vector<bool> field_nullability;
/// Metadata attached to wrapped columns
std::vector<std::shared_ptr<const KeyValueMetadata>> field_metadata;
};
struct ARROW_EXPORT DayOfWeekOptions : public FunctionOptions {
public:
explicit DayOfWeekOptions(bool count_from_zero = true, uint32_t week_start = 1);
static constexpr char const kTypeName[] = "DayOfWeekOptions";
static DayOfWeekOptions Defaults() { return DayOfWeekOptions(); }
/// Number days from 0 if true and from 1 if false
bool count_from_zero;
/// What day does the week start with (Monday=1, Sunday=7).
/// The numbering is unaffected by the count_from_zero parameter.
uint32_t week_start;
};
/// Used to control timestamp timezone conversion and handling ambiguous/nonexistent
/// times.
struct ARROW_EXPORT AssumeTimezoneOptions : public FunctionOptions {
public:
/// \brief How to interpret ambiguous local times that can be interpreted as
/// multiple instants (normally two) due to DST shifts.
///
/// AMBIGUOUS_EARLIEST emits the earliest instant amongst possible interpretations.
/// AMBIGUOUS_LATEST emits the latest instant amongst possible interpretations.
enum Ambiguous { AMBIGUOUS_RAISE, AMBIGUOUS_EARLIEST, AMBIGUOUS_LATEST };
/// \brief How to handle local times that do not exist due to DST shifts.
///
/// NONEXISTENT_EARLIEST emits the instant "just before" the DST shift instant
/// in the given timestamp precision (for example, for a nanoseconds precision
/// timestamp, this is one nanosecond before the DST shift instant).
/// NONEXISTENT_LATEST emits the DST shift instant.
enum Nonexistent { NONEXISTENT_RAISE, NONEXISTENT_EARLIEST, NONEXISTENT_LATEST };
explicit AssumeTimezoneOptions(std::string timezone,
Ambiguous ambiguous = AMBIGUOUS_RAISE,
Nonexistent nonexistent = NONEXISTENT_RAISE);
AssumeTimezoneOptions();
static constexpr char const kTypeName[] = "AssumeTimezoneOptions";
/// Timezone to convert timestamps from
std::string timezone;
/// How to interpret ambiguous local times (due to DST shifts)
Ambiguous ambiguous;
/// How to interpret non-existent local times (due to DST shifts)
Nonexistent nonexistent;
};
struct ARROW_EXPORT WeekOptions : public FunctionOptions {
public:
explicit WeekOptions(bool week_starts_monday = true, bool count_from_zero = false,
bool first_week_is_fully_in_year = false);
static constexpr char const kTypeName[] = "WeekOptions";
static WeekOptions Defaults() { return WeekOptions{}; }
static WeekOptions ISODefaults() {
return WeekOptions{/*week_starts_monday*/ true,
/*count_from_zero=*/false,
/*first_week_is_fully_in_year=*/false};
}
static WeekOptions USDefaults() {
return WeekOptions{/*week_starts_monday*/ false,
/*count_from_zero=*/false,
/*first_week_is_fully_in_year=*/false};
}
/// What day does the week start with (Monday=true, Sunday=false)
bool week_starts_monday;
/// Dates from current year that fall into last ISO week of the previous year return
/// 0 if true and 52 or 53 if false.
bool count_from_zero;
/// Must the first week be fully in January (true), or is a week that begins on
/// December 29, 30, or 31 considered to be the first week of the new year (false)?
bool first_week_is_fully_in_year;
};
struct ARROW_EXPORT Utf8NormalizeOptions : public FunctionOptions {
public:
enum Form { NFC, NFKC, NFD, NFKD };
explicit Utf8NormalizeOptions(Form form = NFC);
static Utf8NormalizeOptions Defaults() { return Utf8NormalizeOptions(); }
static constexpr char const kTypeName[] = "Utf8NormalizeOptions";
/// The Unicode normalization form to apply
Form form;
};
class ARROW_EXPORT RandomOptions : public FunctionOptions {
public:
enum Initializer { SystemRandom, Seed };
static RandomOptions FromSystemRandom() { return RandomOptions{SystemRandom, 0}; }
static RandomOptions FromSeed(uint64_t seed) { return RandomOptions{Seed, seed}; }
RandomOptions(Initializer initializer, uint64_t seed);
RandomOptions();
static constexpr char const kTypeName[] = "RandomOptions";
static RandomOptions Defaults() { return RandomOptions(); }
/// The type of initialization for random number generation - system or provided seed.
Initializer initializer;
/// The seed value used to initialize the random number generation.
uint64_t seed;
};
/// Options for map_lookup function
class ARROW_EXPORT MapLookupOptions : public FunctionOptions {
public:
enum Occurrence {
/// Return the first matching value
FIRST,
/// Return the last matching value
LAST,
/// Return all matching values
ALL
};
explicit MapLookupOptions(std::shared_ptr<Scalar> query_key, Occurrence occurrence);
MapLookupOptions();
constexpr static char const kTypeName[] = "MapLookupOptions";
/// The key to lookup in the map
std::shared_ptr<Scalar> query_key;
/// Whether to return the first, last, or all matching values
Occurrence occurrence;
};
/// @}
/// \brief Get the absolute value of a value.
///
/// If argument is null the result will be null.
///
/// \param[in] arg the value transformed
/// \param[in] options arithmetic options (overflow handling), optional
/// \param[in] ctx the function execution context, optional
/// \return the elementwise absolute value
ARROW_EXPORT
Result<Datum> AbsoluteValue(const Datum& arg,
ArithmeticOptions options = ArithmeticOptions(),
ExecContext* ctx = NULLPTR);
/// \brief Add two values together. Array values must be the same length. If
/// either addend is null the result will be null.
///
/// \param[in] left the first addend
/// \param[in] right the second addend
/// \param[in] options arithmetic options (overflow handling), optional
/// \param[in] ctx the function execution context, optional
/// \return the elementwise sum
ARROW_EXPORT
Result<Datum> Add(const Datum& left, const Datum& right,
ArithmeticOptions options = ArithmeticOptions(),
ExecContext* ctx = NULLPTR);
/// \brief Subtract two values. Array values must be the same length. If the
/// minuend or subtrahend is null the result will be null.
///
/// \param[in] left the value subtracted from (minuend)
/// \param[in] right the value by which the minuend is reduced (subtrahend)
/// \param[in] options arithmetic options (overflow handling), optional
/// \param[in] ctx the function execution context, optional
/// \return the elementwise difference
ARROW_EXPORT
Result<Datum> Subtract(const Datum& left, const Datum& right,
ArithmeticOptions options = ArithmeticOptions(),
ExecContext* ctx = NULLPTR);
/// \brief Multiply two values. Array values must be the same length. If either
/// factor is null the result will be null.
///
/// \param[in] left the first factor
/// \param[in] right the second factor
/// \param[in] options arithmetic options (overflow handling), optional
/// \param[in] ctx the function execution context, optional
/// \return the elementwise product
ARROW_EXPORT
Result<Datum> Multiply(const Datum& left, const Datum& right,
ArithmeticOptions options = ArithmeticOptions(),
ExecContext* ctx = NULLPTR);
/// \brief Divide two values. Array values must be the same length. If either
/// argument is null the result will be null. For integer types, if there is
/// a zero divisor, an error will be raised.
///
/// \param[in] left the dividend
/// \param[in] right the divisor
/// \param[in] options arithmetic options (enable/disable overflow checking), optional
/// \param[in] ctx the function execution context, optional
/// \return the elementwise quotient
ARROW_EXPORT
Result<Datum> Divide(const Datum& left, const Datum& right,
ArithmeticOptions options = ArithmeticOptions(),
ExecContext* ctx = NULLPTR);
/// \brief Negate values.
///
/// If argument is null the result will be null.
///
/// \param[in] arg the value negated
/// \param[in] options arithmetic options (overflow handling), optional
/// \param[in] ctx the function execution context, optional
/// \return the elementwise negation
ARROW_EXPORT
Result<Datum> Negate(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(),
ExecContext* ctx = NULLPTR);
/// \brief Raise the values of base array to the power of the exponent array values.
/// Array values must be the same length. If either base or exponent is null the result
/// will be null.
///
/// \param[in] left the base
/// \param[in] right the exponent
/// \param[in] options arithmetic options (enable/disable overflow checking), optional
/// \param[in] ctx the function execution context, optional
/// \return the elementwise base value raised to the power of exponent
ARROW_EXPORT
Result<Datum> Power(const Datum& left, const Datum& right,
ArithmeticOptions options = ArithmeticOptions(),
ExecContext* ctx = NULLPTR);
/// \brief Raise Euler's number to the power of specified exponent, element-wise.
/// If the exponent value is null the result will be null.
///
/// \param[in] arg the exponent
/// \param[in] ctx the function execution context, optional
/// \return the element-wise Euler's number raised to the power of exponent
ARROW_EXPORT
Result<Datum> Exp(const Datum& arg, ExecContext* ctx = NULLPTR);
/// \brief Left shift the left array by the right array. Array values must be the
/// same length. If either operand is null, the result will be null.
///
/// \param[in] left the value to shift
/// \param[in] right the value to shift by
/// \param[in] options arithmetic options (enable/disable overflow checking), optional
/// \param[in] ctx the function execution context, optional
/// \return the elementwise left value shifted left by the right value
ARROW_EXPORT
Result<Datum> ShiftLeft(const Datum& left, const Datum& right,
ArithmeticOptions options = ArithmeticOptions(),
ExecContext* ctx = NULLPTR);
/// \brief Right shift the left array by the right array. Array values must be the
/// same length. If either operand is null, the result will be null. Performs a
/// logical shift for unsigned values, and an arithmetic shift for signed values.
///
/// \param[in] left the value to shift
/// \param[in] right the value to shift by
/// \param[in] options arithmetic options (enable/disable overflow checking), optional
/// \param[in] ctx the function execution context, optional
/// \return the elementwise left value shifted right by the right value
ARROW_EXPORT
Result<Datum> ShiftRight(const Datum& left, const Datum& right,
ArithmeticOptions options = ArithmeticOptions(),
ExecContext* ctx = NULLPTR);
/// \brief Compute the sine of the array values.
/// \param[in] arg The values to compute the sine for.
/// \param[in] options arithmetic options (enable/disable overflow checking), optional
/// \param[in] ctx the function execution context, optional
/// \return the elementwise sine of the values
ARROW_EXPORT
Result<Datum> Sin(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(),
ExecContext* ctx = NULLPTR);
/// \brief Compute the cosine of the array values.
/// \param[in] arg The values to compute the cosine for.
/// \param[in] options arithmetic options (enable/disable overflow checking), optional
/// \param[in] ctx the function execution context, optional
/// \return the elementwise cosine of the values
ARROW_EXPORT
Result<Datum> Cos(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(),
ExecContext* ctx = NULLPTR);
/// \brief Compute the inverse sine (arcsine) of the array values.
/// \param[in] arg The values to compute the inverse sine for.
/// \param[in] options arithmetic options (enable/disable overflow checking), optional
/// \param[in] ctx the function execution context, optional
/// \return the elementwise inverse sine of the values
ARROW_EXPORT
Result<Datum> Asin(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(),
ExecContext* ctx = NULLPTR);
/// \brief Compute the inverse cosine (arccosine) of the array values.
/// \param[in] arg The values to compute the inverse cosine for.
/// \param[in] options arithmetic options (enable/disable overflow checking), optional
/// \param[in] ctx the function execution context, optional
/// \return the elementwise inverse cosine of the values
ARROW_EXPORT
Result<Datum> Acos(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(),
ExecContext* ctx = NULLPTR);
/// \brief Compute the tangent of the array values.
/// \param[in] arg The values to compute the tangent for.
/// \param[in] options arithmetic options (enable/disable overflow checking), optional
/// \param[in] ctx the function execution context, optional
/// \return the elementwise tangent of the values
ARROW_EXPORT
Result<Datum> Tan(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(),
ExecContext* ctx = NULLPTR);
/// \brief Compute the inverse tangent (arctangent) of the array values.
/// \param[in] arg The values to compute the inverse tangent for.
/// \param[in] ctx the function execution context, optional
/// \return the elementwise inverse tangent of the values
ARROW_EXPORT
Result<Datum> Atan(const Datum& arg, ExecContext* ctx = NULLPTR);
/// \brief Compute the inverse tangent (arctangent) of y/x, using the
/// argument signs to determine the correct quadrant.
/// \param[in] y The y-values to compute the inverse tangent for.
/// \param[in] x The x-values to compute the inverse tangent for.
/// \param[in] ctx the function execution context, optional
/// \return the elementwise inverse tangent of the values
ARROW_EXPORT
Result<Datum> Atan2(const Datum& y, const Datum& x, ExecContext* ctx = NULLPTR);
/// \brief Get the natural log of a value.
///
/// If argument is null the result will be null.
///
/// \param[in] arg The values to compute the logarithm for.
/// \param[in] options arithmetic options (overflow handling), optional
/// \param[in] ctx the function execution context, optional
/// \return the elementwise natural log
ARROW_EXPORT
Result<Datum> Ln(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(),
ExecContext* ctx = NULLPTR);
/// \brief Get the log base 10 of a value.
///
/// If argument is null the result will be null.
///
/// \param[in] arg The values to compute the logarithm for.
/// \param[in] options arithmetic options (overflow handling), optional
/// \param[in] ctx the function execution context, optional
/// \return the elementwise log base 10
ARROW_EXPORT
Result<Datum> Log10(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(),
ExecContext* ctx = NULLPTR);
/// \brief Get the log base 2 of a value.
///
/// If argument is null the result will be null.
///
/// \param[in] arg The values to compute the logarithm for.
/// \param[in] options arithmetic options (overflow handling), optional
/// \param[in] ctx the function execution context, optional
/// \return the elementwise log base 2
ARROW_EXPORT
Result<Datum> Log2(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(),
ExecContext* ctx = NULLPTR);
/// \brief Get the natural log of (1 + value).
///
/// If argument is null the result will be null.
/// This function may be more accurate than Log(1 + value) for values close to zero.
///
/// \param[in] arg The values to compute the logarithm for.
/// \param[in] options arithmetic options (overflow handling), optional
/// \param[in] ctx the function execution context, optional
/// \return the elementwise natural log
ARROW_EXPORT
Result<Datum> Log1p(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(),
ExecContext* ctx = NULLPTR);
/// \brief Get the log of a value to the given base.
///
/// If argument is null the result will be null.
///
/// \param[in] arg The values to compute the logarithm for.
/// \param[in] base The given base.
/// \param[in] options arithmetic options (overflow handling), optional
/// \param[in] ctx the function execution context, optional
/// \return the elementwise log to the given base
ARROW_EXPORT
Result<Datum> Logb(const Datum& arg, const Datum& base,
ArithmeticOptions options = ArithmeticOptions(),
ExecContext* ctx = NULLPTR);
/// \brief Get the square-root of a value.
///
/// If argument is null the result will be null.
///
/// \param[in] arg The values to compute the square-root for.
/// \param[in] options arithmetic options (overflow handling), optional
/// \param[in] ctx the function execution context, optional
/// \return the elementwise square-root
ARROW_EXPORT
Result<Datum> Sqrt(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(),
ExecContext* ctx = NULLPTR);
/// \brief Round to the nearest integer less than or equal in magnitude to the
/// argument.
///
/// If argument is null the result will be null.
///
/// \param[in] arg the value to round
/// \param[in] ctx the function execution context, optional
/// \return the rounded value
ARROW_EXPORT
Result<Datum> Floor(const Datum& arg, ExecContext* ctx = NULLPTR);
/// \brief Round to the nearest integer greater than or equal in magnitude to the
/// argument.
///
/// If argument is null the result will be null.
///
/// \param[in] arg the value to round
/// \param[in] ctx the function execution context, optional
/// \return the rounded value
ARROW_EXPORT
Result<Datum> Ceil(const Datum& arg, ExecContext* ctx = NULLPTR);
/// \brief Get the integral part without fractional digits.
///
/// If argument is null the result will be null.
///
/// \param[in] arg the value to truncate
/// \param[in] ctx the function execution context, optional
/// \return the truncated value
ARROW_EXPORT
Result<Datum> Trunc(const Datum& arg, ExecContext* ctx = NULLPTR);
/// \brief Find the element-wise maximum of any number of arrays or scalars.
/// Array values must be the same length.
///
/// \param[in] args arrays or scalars to operate on.
/// \param[in] options options for handling nulls, optional
/// \param[in] ctx the function execution context, optional
/// \return the element-wise maximum
ARROW_EXPORT
Result<Datum> MaxElementWise(
const std::vector<Datum>& args,
ElementWiseAggregateOptions options = ElementWiseAggregateOptions::Defaults(),
ExecContext* ctx = NULLPTR);
/// \brief Find the element-wise minimum of any number of arrays or scalars.
/// Array values must be the same length.
///
/// \param[in] args arrays or scalars to operate on.
/// \param[in] options options for handling nulls, optional
/// \param[in] ctx the function execution context, optional
/// \return the element-wise minimum
ARROW_EXPORT
Result<Datum> MinElementWise(
const std::vector<Datum>& args,
ElementWiseAggregateOptions options = ElementWiseAggregateOptions::Defaults(),
ExecContext* ctx = NULLPTR);
/// \brief Get the sign of a value. Array values can be of arbitrary length. If argument
/// is null the result will be null.
///
/// \param[in] arg the value to extract sign from
/// \param[in] ctx the function execution context, optional
/// \return the element-wise sign function
ARROW_EXPORT
Result<Datum> Sign(const Datum& arg, ExecContext* ctx = NULLPTR);
/// \brief Round a value to a given precision.
///
/// If arg is null the result will be null.
///
/// \param[in] arg the value to be rounded
/// \param[in] options rounding options (rounding mode and number of digits), optional
/// \param[in] ctx the function execution context, optional
/// \return the element-wise rounded value
ARROW_EXPORT
Result<Datum> Round(const Datum& arg, RoundOptions options = RoundOptions::Defaults(),
ExecContext* ctx = NULLPTR);
/// \brief Round a value to a given precision.
///
/// If arg1 is null the result will be null.
/// If arg2 is null then the result will be null. If arg2 is negative, then the rounding
/// place will be shifted to the left (thus -1 would correspond to rounding to the nearest
/// ten). If positive, the rounding place will shift to the right (and +1 would
/// correspond to rounding to the nearest tenth).
///
/// \param[in] arg1 the value to be rounded
/// \param[in] arg2 the number of significant digits to round to
/// \param[in] options rounding options, optional
/// \param[in] ctx the function execution context, optional
/// \return the element-wise rounded value
ARROW_EXPORT
Result<Datum> RoundBinary(const Datum& arg1, const Datum& arg2,
RoundBinaryOptions options = RoundBinaryOptions::Defaults(),
ExecContext* ctx = NULLPTR);
/// \brief Round a value to a given multiple.
///
/// If argument is null the result will be null.
///
/// \param[in] arg the value to round
/// \param[in] options rounding options (rounding mode and multiple), optional
/// \param[in] ctx the function execution context, optional
/// \return the element-wise rounded value
ARROW_EXPORT
Result<Datum> RoundToMultiple(
const Datum& arg, RoundToMultipleOptions options = RoundToMultipleOptions::Defaults(),
ExecContext* ctx = NULLPTR);
/// \brief Ceil a temporal value to a given frequency
///
/// If argument is null the result will be null.
///
/// \param[in] arg the temporal value to ceil
/// \param[in] options temporal rounding options, optional
/// \param[in] ctx the function execution context, optional
/// \return the element-wise rounded value
///
/// \since 7.0.0
/// \note API not yet finalized
ARROW_EXPORT
Result<Datum> CeilTemporal(
const Datum& arg, RoundTemporalOptions options = RoundTemporalOptions::Defaults(),
ExecContext* ctx = NULLPTR);
/// \brief Floor a temporal value to a given frequency
///
/// If argument is null the result will be null.
///
/// \param[in] arg the temporal value to floor
/// \param[in] options temporal rounding options, optional
/// \param[in] ctx the function execution context, optional
/// \return the element-wise rounded value
///
/// \since 7.0.0
/// \note API not yet finalized
ARROW_EXPORT
Result<Datum> FloorTemporal(
const Datum& arg, RoundTemporalOptions options = RoundTemporalOptions::Defaults(),
ExecContext* ctx = NULLPTR);
/// \brief Round a temporal value to a given frequency
///
/// If argument is null the result will be null.
///
/// \param[in] arg the temporal value to round
/// \param[in] options temporal rounding options, optional
/// \param[in] ctx the function execution context, optional
/// \return the element-wise rounded value
///
/// \since 7.0.0
/// \note API not yet finalized
ARROW_EXPORT
Result<Datum> RoundTemporal(
const Datum& arg, RoundTemporalOptions options = RoundTemporalOptions::Defaults(),
ExecContext* ctx = NULLPTR);
/// \brief Compare a numeric array with a scalar.
///
/// \param[in] left datum to compare, must be an Array
/// \param[in] right datum to compare, must be a Scalar of the same type than
/// left Datum.
/// \param[in] options compare options
/// \param[in] ctx the function execution context, optional
/// \return resulting datum
///
/// Note on floating point arrays, this uses ieee-754 compare semantics.
///
/// \since 1.0.0
/// \note API not yet finalized
ARROW_DEPRECATED("Deprecated in 5.0.0. Use each compare function directly")
ARROW_EXPORT
Result<Datum> Compare(const Datum& left, const Datum& right, CompareOptions options,
ExecContext* ctx = NULLPTR);
/// \brief Invert the values of a boolean datum
/// \param[in] value datum to invert
/// \param[in] ctx the function execution context, optional
/// \return the resulting datum
///
/// \since 1.0.0
/// \note API not yet finalized
ARROW_EXPORT
Result<Datum> Invert(const Datum& value, ExecContext* ctx = NULLPTR);